diff --git a/doc/wiki b/doc/wiki index 19179c6f6..4feb6c921 160000 --- a/doc/wiki +++ b/doc/wiki @@ -1 +1 @@ -Subproject commit 19179c6f6afb422cf8376ed3b4a498a6396fc12f +Subproject commit 4feb6c9214d6adfab5c9fead5d8935589eea8dba diff --git a/include/AudioAlsa.h b/include/AudioAlsa.h index 4bfd0217e..c8452d003 100644 --- a/include/AudioAlsa.h +++ b/include/AudioAlsa.h @@ -66,7 +66,7 @@ public: typedef std::vector DeviceInfoCollection; public: - AudioAlsa( bool & _success_ful, Mixer* mixer ); + AudioAlsa( bool & _success_ful, AudioEngine* audioEngine ); virtual ~AudioAlsa(); inline static QString name() diff --git a/include/AudioDevice.h b/include/AudioDevice.h index c9ad7f4b3..d635efa09 100644 --- a/include/AudioDevice.h +++ b/include/AudioDevice.h @@ -1,5 +1,5 @@ /* - * AudioDevice.h - base-class for audio-devices, used by LMMS-mixer + * AudioDevice.h - base-class for audio-devices, used by LMMS audio engine * * Copyright (c) 2004-2014 Tobias Doerffel * @@ -31,15 +31,15 @@ #include "lmms_basics.h" +class AudioEngine; class AudioPort; -class Mixer; class QThread; class AudioDevice { public: - AudioDevice( const ch_cnt_t _channels, Mixer* mixer ); + AudioDevice( const ch_cnt_t _channels, AudioEngine* audioEngine ); virtual ~AudioDevice(); inline void lock() @@ -126,9 +126,9 @@ protected: m_sampleRate = _new_sr; } - Mixer* mixer() + AudioEngine* audioEngine() { - return m_mixer; + return m_audioEngine; } bool hqAudio() const; @@ -143,7 +143,7 @@ protected: private: sample_rate_t m_sampleRate; ch_cnt_t m_channels; - Mixer* m_mixer; + AudioEngine* m_audioEngine; bool m_inProcess; QMutex m_devMutex; diff --git a/include/AudioDummy.h b/include/AudioDummy.h index cf77491bc..a0f2c528e 100644 --- a/include/AudioDummy.h +++ b/include/AudioDummy.h @@ -27,16 +27,16 @@ #include "AudioDevice.h" #include "AudioDeviceSetupWidget.h" +#include "AudioEngine.h" #include "MicroTimer.h" -#include "Mixer.h" class AudioDummy : public QThread, public AudioDevice { Q_OBJECT public: - AudioDummy( bool & _success_ful, Mixer* mixer ) : - AudioDevice( DEFAULT_CHANNELS, mixer ) + AudioDummy( bool & _success_ful, AudioEngine* audioEngine ) : + AudioDevice( DEFAULT_CHANNELS, audioEngine ) { _success_ful = true; } @@ -94,17 +94,17 @@ private: while( true ) { timer.reset(); - const surroundSampleFrame* b = mixer()->nextBuffer(); + const surroundSampleFrame* b = audioEngine()->nextBuffer(); if( !b ) { break; } - if( mixer()->hasFifoWriter() ) + if( audioEngine()->hasFifoWriter() ) { delete[] b; } - const int microseconds = static_cast( mixer()->framesPerPeriod() * 1000000.0f / mixer()->processingSampleRate() - timer.elapsed() ); + const int microseconds = static_cast( audioEngine()->framesPerPeriod() * 1000000.0f / audioEngine()->processingSampleRate() - timer.elapsed() ); if( microseconds > 0 ) { usleep( microseconds ); diff --git a/include/Mixer.h b/include/AudioEngine.h similarity index 93% rename from include/Mixer.h rename to include/AudioEngine.h index ad712a416..3b15518a1 100644 --- a/include/Mixer.h +++ b/include/AudioEngine.h @@ -1,5 +1,5 @@ /* - * Mixer.h - audio-device-independent mixer for LMMS + * AudioEngine.h - device-independent audio engine for LMMS * * Copyright (c) 2004-2014 Tobias Doerffel * @@ -22,8 +22,8 @@ * */ -#ifndef MIXER_H -#define MIXER_H +#ifndef AUDIO_ENGINE_H +#define AUDIO_ENGINE_H #include #include @@ -36,7 +36,7 @@ #include "LocklessList.h" #include "Note.h" #include "FifoBuffer.h" -#include "MixerProfiler.h" +#include "AudioEngineProfiler.h" class AudioDevice; @@ -58,10 +58,10 @@ const float OUTPUT_SAMPLE_MULTIPLIER = 32767.0f; #include "PlayHandle.h" -class MixerWorkerThread; +class AudioEngineWorkerThread; -class LMMS_EXPORT Mixer : public QObject +class LMMS_EXPORT AudioEngine : public QObject { Q_OBJECT public: @@ -223,7 +223,7 @@ public: } - MixerProfiler& profiler() + AudioEngineProfiler& profiler() { return m_profiler; } @@ -328,25 +328,24 @@ private: class fifoWriter : public QThread { public: - fifoWriter( Mixer * mixer, Fifo * fifo ); + fifoWriter( AudioEngine * audioEngine, Fifo * fifo ); void finish(); private: - Mixer * m_mixer; + AudioEngine * m_audioEngine; Fifo * m_fifo; volatile bool m_writing; void run() override; void write( surroundSampleFrame * buffer ); - } ; - Mixer( bool renderOnly ); - virtual ~Mixer(); + AudioEngine( bool renderOnly ); + virtual ~AudioEngine(); void startProcessing(bool needsFifo = true); void stopProcessing(); @@ -384,7 +383,7 @@ private: surroundSampleFrame * m_outputBufferWrite; // worker thread stuff - QVector m_workers; + QVector m_workers; int m_numWorkers; // playhandle stuff @@ -414,7 +413,7 @@ private: Fifo * m_fifo; fifoWriter * m_fifoWriter; - MixerProfiler m_profiler; + AudioEngineProfiler m_profiler; bool m_metronomeActive; @@ -425,16 +424,14 @@ private: QMutex m_changesMutex; QMutex m_doChangesMutex; QMutex m_waitChangesMutex; - QWaitCondition m_changesMixerCondition; + QWaitCondition m_changesAudioEngineCondition; QWaitCondition m_changesRequestCondition; bool m_waitingForWrite; friend class LmmsCore; - friend class MixerWorkerThread; + friend class AudioEngineWorkerThread; friend class ProjectRenderer; - } ; - #endif diff --git a/include/MixerProfiler.h b/include/AudioEngineProfiler.h similarity index 85% rename from include/MixerProfiler.h rename to include/AudioEngineProfiler.h index 0c46c34cb..19f0b612b 100644 --- a/include/MixerProfiler.h +++ b/include/AudioEngineProfiler.h @@ -1,5 +1,5 @@ /* - * MixerProfiler.h - class for profiling performance of Mixer + * AudioEngineProfiler.h - class for profiling performance of AudioEngine * * Copyright (c) 2014 Tobias Doerffel * @@ -22,19 +22,19 @@ * */ -#ifndef MIXER_PROFILER_H -#define MIXER_PROFILER_H +#ifndef AUDIO_ENGINE_PROFILER_H +#define AUDIO_ENGINE_PROFILER_H #include #include "lmms_basics.h" #include "MicroTimer.h" -class MixerProfiler +class AudioEngineProfiler { public: - MixerProfiler(); - ~MixerProfiler(); + AudioEngineProfiler(); + ~AudioEngineProfiler(); void startPeriod() { @@ -55,7 +55,6 @@ private: MicroTimer m_periodTimer; int m_cpuLoad; QFile m_outputFile; - }; #endif diff --git a/include/MixerWorkerThread.h b/include/AudioEngineWorkerThread.h similarity index 87% rename from include/MixerWorkerThread.h rename to include/AudioEngineWorkerThread.h index 2d49dce09..7b4a83630 100644 --- a/include/MixerWorkerThread.h +++ b/include/AudioEngineWorkerThread.h @@ -1,5 +1,5 @@ /* - * MixerWorkerThread.h - declaration of class MixerWorkerThread + * AudioEngineWorkerThread.h - declaration of class AudioEngineWorkerThread * * Copyright (c) 2009-2014 Tobias Doerffel * @@ -22,18 +22,18 @@ * */ -#ifndef MIXER_WORKER_THREAD_H -#define MIXER_WORKER_THREAD_H +#ifndef AUDIO_ENGINE_WORKER_THREAD_H +#define AUDIO_ENGINE_WORKER_THREAD_H #include #include +class AudioEngine; class QWaitCondition; -class Mixer; class ThreadableJob; -class MixerWorkerThread : public QThread +class AudioEngineWorkerThread : public QThread { Q_OBJECT public: @@ -69,12 +69,11 @@ public: std::atomic_int m_writeIndex; std::atomic_int m_itemsDone; OperationMode m_opMode; - } ; - MixerWorkerThread( Mixer* mixer ); - virtual ~MixerWorkerThread(); + AudioEngineWorkerThread( AudioEngine* audioEngine ); + virtual ~AudioEngineWorkerThread(); virtual void quit(); @@ -110,10 +109,9 @@ private: static JobQueue globalJobQueue; static QWaitCondition * queueReadyWaitCond; - static QList workerThreads; + static QList workerThreads; volatile bool m_quit; - } ; diff --git a/include/AudioFileDevice.h b/include/AudioFileDevice.h index e7177b30f..cdcd407e1 100644 --- a/include/AudioFileDevice.h +++ b/include/AudioFileDevice.h @@ -37,7 +37,7 @@ class AudioFileDevice : public AudioDevice public: AudioFileDevice(OutputSettings const & outputSettings, const ch_cnt_t _channels, const QString & _file, - Mixer* mixer ); + AudioEngine* audioEngine ); virtual ~AudioFileDevice(); QString outputFile() const @@ -71,7 +71,7 @@ typedef AudioFileDevice * ( * AudioFileDeviceInstantiaton ) ( const QString & outputFilename, OutputSettings const & outputSettings, const ch_cnt_t channels, - Mixer* mixer, + AudioEngine* audioEngine, bool & successful ); diff --git a/include/AudioFileFlac.h b/include/AudioFileFlac.h index b421654c2..75e86d368 100644 --- a/include/AudioFileFlac.h +++ b/include/AudioFileFlac.h @@ -37,7 +37,7 @@ public: ch_cnt_t const channels, bool& successful, QString const& file, - Mixer* mixer + AudioEngine* audioEngine ); virtual ~AudioFileFlac(); @@ -45,7 +45,7 @@ public: static AudioFileDevice* getInst(QString const& outputFilename, OutputSettings const& outputSettings, ch_cnt_t const channels, - Mixer* mixer, + AudioEngine* audioEngine, bool& successful) { return new AudioFileFlac( @@ -53,7 +53,7 @@ public: channels, successful, outputFilename, - mixer + audioEngine ); } diff --git a/include/AudioFileMP3.h b/include/AudioFileMP3.h index 057fd13a4..ab72ed689 100644 --- a/include/AudioFileMP3.h +++ b/include/AudioFileMP3.h @@ -42,17 +42,17 @@ public: const ch_cnt_t _channels, bool & successful, const QString & _file, - Mixer* mixer ); + AudioEngine* audioEngine ); virtual ~AudioFileMP3(); static AudioFileDevice * getInst( const QString & outputFilename, OutputSettings const & outputSettings, const ch_cnt_t channels, - Mixer* mixer, + AudioEngine* audioEngine, bool & successful ) { return new AudioFileMP3( outputSettings, channels, successful, - outputFilename, mixer ); + outputFilename, audioEngine ); } protected: diff --git a/include/AudioFileOgg.h b/include/AudioFileOgg.h index 8082f3767..9c7337e9c 100644 --- a/include/AudioFileOgg.h +++ b/include/AudioFileOgg.h @@ -42,17 +42,16 @@ public: const ch_cnt_t _channels, bool & _success_ful, const QString & _file, - Mixer* mixer ); + AudioEngine* audioEngine ); virtual ~AudioFileOgg(); static AudioFileDevice * getInst( const QString & outputFilename, OutputSettings const & outputSettings, const ch_cnt_t channels, - Mixer* mixer, + AudioEngine* audioEngine, bool & successful ) { - return new AudioFileOgg( outputSettings, channels, successful, - outputFilename, mixer ); + return new AudioFileOgg( outputSettings, channels, successful, outputFilename, audioEngine ); } diff --git a/include/AudioFileWave.h b/include/AudioFileWave.h index 7c8d54964..d8e537859 100644 --- a/include/AudioFileWave.h +++ b/include/AudioFileWave.h @@ -39,17 +39,17 @@ public: const ch_cnt_t channels, bool & successful, const QString & file, - Mixer* mixer ); + AudioEngine* audioEngine ); virtual ~AudioFileWave(); static AudioFileDevice * getInst( const QString & outputFilename, OutputSettings const & outputSettings, const ch_cnt_t channels, - Mixer* mixer, + AudioEngine* audioEngine, bool & successful ) { return new AudioFileWave( outputSettings, channels, successful, - outputFilename, mixer ); + outputFilename, audioEngine ); } diff --git a/include/AudioJack.h b/include/AudioJack.h index 844aa886d..ca65b0f96 100644 --- a/include/AudioJack.h +++ b/include/AudioJack.h @@ -51,7 +51,7 @@ class AudioJack : public QObject, public AudioDevice { Q_OBJECT public: - AudioJack( bool & _success_ful, Mixer* mixer ); + AudioJack( bool & _success_ful, AudioEngine* audioEngine ); virtual ~AudioJack(); // this is to allow the jack midi connection to use the same jack client connection diff --git a/include/AudioOss.h b/include/AudioOss.h index c631bcedd..b1b5d839c 100644 --- a/include/AudioOss.h +++ b/include/AudioOss.h @@ -43,7 +43,7 @@ class AudioOss : public QThread, public AudioDevice { Q_OBJECT public: - AudioOss( bool & _success_ful, Mixer* mixer ); + AudioOss( bool & _success_ful, AudioEngine* audioEngine ); virtual ~AudioOss(); inline static QString name() diff --git a/include/AudioPort.h b/include/AudioPort.h index 146bbd192..0e48d90ed 100644 --- a/include/AudioPort.h +++ b/include/AudioPort.h @@ -129,8 +129,8 @@ private: FloatModel * m_panningModel; BoolModel * m_mutedModel; - friend class Mixer; - friend class MixerWorkerThread; + friend class AudioEngine; + friend class AudioEngineWorkerThread; } ; diff --git a/include/AudioPortAudio.h b/include/AudioPortAudio.h index 5279492ce..763703c33 100644 --- a/include/AudioPortAudio.h +++ b/include/AudioPortAudio.h @@ -67,7 +67,7 @@ class LcdSpinBox; class AudioPortAudio : public AudioDevice { public: - AudioPortAudio( bool & _success_ful, Mixer* mixer ); + AudioPortAudio( bool & _success_ful, AudioEngine* audioEngine ); virtual ~AudioPortAudio(); inline static QString name() diff --git a/include/AudioPulseAudio.h b/include/AudioPulseAudio.h index b92a386b9..3fe098d68 100644 --- a/include/AudioPulseAudio.h +++ b/include/AudioPulseAudio.h @@ -45,7 +45,7 @@ class AudioPulseAudio : public QThread, public AudioDevice { Q_OBJECT public: - AudioPulseAudio( bool & _success_ful, Mixer* mixer ); + AudioPulseAudio( bool & _success_ful, AudioEngine* audioEngine ); virtual ~AudioPulseAudio(); inline static QString name() diff --git a/include/AudioSampleRecorder.h b/include/AudioSampleRecorder.h index 0a82d2d96..76cb7e1a4 100644 --- a/include/AudioSampleRecorder.h +++ b/include/AudioSampleRecorder.h @@ -37,8 +37,7 @@ class SampleBuffer; class AudioSampleRecorder : public AudioDevice { public: - AudioSampleRecorder( const ch_cnt_t _channels, bool & _success_ful, - Mixer* mixer ); + AudioSampleRecorder( const ch_cnt_t _channels, bool & _success_ful, AudioEngine* audioEngine ); virtual ~AudioSampleRecorder(); f_cnt_t framesRecorded() const; diff --git a/include/AudioSdl.h b/include/AudioSdl.h index 1bda446b2..1e6c03358 100644 --- a/include/AudioSdl.h +++ b/include/AudioSdl.h @@ -46,7 +46,7 @@ class QLineEdit; class AudioSdl : public AudioDevice { public: - AudioSdl( bool & _success_ful, Mixer* mixer ); + AudioSdl( bool & _success_ful, AudioEngine* audioEngine ); virtual ~AudioSdl(); inline static QString name() diff --git a/include/AudioSndio.h b/include/AudioSndio.h index 0cc88facf..94fcfa93b 100644 --- a/include/AudioSndio.h +++ b/include/AudioSndio.h @@ -44,7 +44,7 @@ class AudioSndio : public QThread, public AudioDevice { Q_OBJECT public: - AudioSndio( bool & _success_ful, Mixer * _mixer ); + AudioSndio( bool & _success_ful, AudioEngine * _audioEngine ); virtual ~AudioSndio(); inline static QString name( void ) diff --git a/include/AudioSoundIo.h b/include/AudioSoundIo.h index 6a740a024..171022032 100644 --- a/include/AudioSoundIo.h +++ b/include/AudioSoundIo.h @@ -56,7 +56,7 @@ public slots: class AudioSoundIo : public AudioDevice { public: - AudioSoundIo( bool & _success_ful, Mixer* mixer ); + AudioSoundIo( bool & _success_ful, AudioEngine* audioEngine ); virtual ~AudioSoundIo(); inline static QString name() diff --git a/include/BandLimitedWave.h b/include/BandLimitedWave.h index 386713328..c05963ec4 100644 --- a/include/BandLimitedWave.h +++ b/include/BandLimitedWave.h @@ -34,7 +34,7 @@ class QString; #include "lmms_basics.h" #include "lmms_math.h" #include "Engine.h" -#include "Mixer.h" +#include "AudioEngine.h" #define MAXLEN 11 #define MIPMAPSIZE 2 << ( MAXLEN + 1 ) @@ -102,7 +102,7 @@ public: */ static inline float freqToLen( float f ) { - return freqToLen( f, Engine::mixer()->processingSampleRate() ); + return freqToLen( f, Engine::audioEngine()->processingSampleRate() ); } /*! \brief This method converts frequency to wavelength, but you can use any custom sample rate with it. diff --git a/include/Controller.h b/include/Controller.h index b60349463..092c684e0 100644 --- a/include/Controller.h +++ b/include/Controller.h @@ -166,7 +166,7 @@ protected: signals: - // The value changed while the mixer isn't running (i.e: MIDI CC) + // The value changed while the audio engine isn't running (i.e: MIDI CC) void valueChanged(); friend class ControllerDialog; diff --git a/include/ControllerConnection.h b/include/ControllerConnection.h index 6b44e6723..4c5673c8d 100644 --- a/include/ControllerConnection.h +++ b/include/ControllerConnection.h @@ -112,7 +112,7 @@ protected: static ControllerConnectionVector s_connections; signals: - // The value changed while the mixer isn't running (i.e: MIDI CC) + // The value changed while the audio engine isn't running (i.e: MIDI CC) void valueChanged(); friend class ControllerConnectionDialog; diff --git a/include/DummyInstrument.h b/include/DummyInstrument.h index a37b089ae..4dd341894 100644 --- a/include/DummyInstrument.h +++ b/include/DummyInstrument.h @@ -32,7 +32,7 @@ #include -#include "Mixer.h" +#include "AudioEngine.h" class DummyInstrument : public Instrument @@ -50,7 +50,7 @@ public: void playNote( NotePlayHandle *, sampleFrame * buffer ) override { memset( buffer, 0, sizeof( sampleFrame ) * - Engine::mixer()->framesPerPeriod() ); + Engine::audioEngine()->framesPerPeriod() ); } void saveSettings( QDomDocument &, QDomElement & ) override diff --git a/include/Effect.h b/include/Effect.h index 3874aa602..6d1fea6bf 100644 --- a/include/Effect.h +++ b/include/Effect.h @@ -28,7 +28,7 @@ #include "Plugin.h" #include "Engine.h" -#include "Mixer.h" +#include "AudioEngine.h" #include "AutomatableModel.h" #include "TempoSyncKnobModel.h" #include "MemoryManager.h" @@ -103,8 +103,8 @@ public: inline f_cnt_t timeout() const { - const float samples = Engine::mixer()->processingSampleRate() * m_autoQuitModel.value() / 1000.0f; - return 1 + ( static_cast( samples ) / Engine::mixer()->framesPerPeriod() ); + const float samples = Engine::audioEngine()->processingSampleRate() * m_autoQuitModel.value() / 1000.0f; + return 1 + ( static_cast( samples ) / Engine::audioEngine()->framesPerPeriod() ); } inline float wetLevel() const @@ -179,9 +179,9 @@ protected: sample_rate_t _dst_sr ) { resample( 0, _src_buf, - Engine::mixer()->processingSampleRate(), + Engine::audioEngine()->processingSampleRate(), _dst_buf, _dst_sr, - Engine::mixer()->framesPerPeriod() ); + Engine::audioEngine()->framesPerPeriod() ); } inline void sampleBack( const sampleFrame * _src_buf, @@ -189,9 +189,9 @@ protected: sample_rate_t _src_sr ) { resample( 1, _src_buf, _src_sr, _dst_buf, - Engine::mixer()->processingSampleRate(), - Engine::mixer()->framesPerPeriod() * _src_sr / - Engine::mixer()->processingSampleRate() ); + Engine::audioEngine()->processingSampleRate(), + Engine::audioEngine()->framesPerPeriod() * _src_sr / + Engine::audioEngine()->processingSampleRate() ); } void reinitSRC(); diff --git a/include/Engine.h b/include/Engine.h index 4ec146b2b..08a1f7ca3 100644 --- a/include/Engine.h +++ b/include/Engine.h @@ -34,10 +34,10 @@ #include "lmms_export.h" #include "lmms_basics.h" +class AudioEngine; class BBTrackContainer; class FxMixer; class ProjectJournal; -class Mixer; class Song; class Ladspa2LMMS; @@ -62,9 +62,9 @@ public: static void destroy(); // core - static Mixer *mixer() + static AudioEngine *audioEngine() { - return s_mixer; + return s_audioEngine; } static FxMixer * fxMixer() @@ -140,7 +140,7 @@ private: static float s_framesPerTick; // core - static Mixer *s_mixer; + static AudioEngine *s_audioEngine; static FxMixer * s_fxMixer; static Song * s_song; static BBTrackContainer * s_bbTrackContainer; diff --git a/include/Instrument.h b/include/Instrument.h index eab218081..c3cd56272 100644 --- a/include/Instrument.h +++ b/include/Instrument.h @@ -68,7 +68,7 @@ public: // if the plugin doesn't play each note, it can create an instrument- // play-handle and re-implement this method, so that it mixes its - // output buffer only once per mixer-period + // output buffer only once per audio engine period virtual void play( sampleFrame * _working_buffer ); // to be implemented by actual plugin diff --git a/include/Oscillator.h b/include/Oscillator.h index 5a7b412a6..4b1db9787 100644 --- a/include/Oscillator.h +++ b/include/Oscillator.h @@ -37,7 +37,7 @@ #include "Engine.h" #include "lmms_constants.h" #include "lmmsconfig.h" -#include "Mixer.h" +#include "AudioEngine.h" #include "OscillatorConstants.h" #include "SampleBuffer.h" @@ -185,7 +185,8 @@ public: control.f2 = control.f1 < OscillatorConstants::WAVETABLE_LENGTH - 1 ? control.f1 + 1 : 0; - control.band = waveTableBandFromFreq(m_freq * m_detuning_div_samplerate * Engine::mixer()->processingSampleRate()); + control.band = waveTableBandFromFreq( + m_freq * m_detuning_div_samplerate * Engine::audioEngine()->processingSampleRate()); return control; } diff --git a/include/ProjectRenderer.h b/include/ProjectRenderer.h index 1af9d422d..729abcc91 100644 --- a/include/ProjectRenderer.h +++ b/include/ProjectRenderer.h @@ -27,7 +27,7 @@ #include "AudioFileDevice.h" #include "lmmsconfig.h" -#include "Mixer.h" +#include "AudioEngine.h" #include "OutputSettings.h" #include "lmms_export.h" @@ -56,7 +56,7 @@ public: } ; - ProjectRenderer( const Mixer::qualitySettings & _qs, + ProjectRenderer( const AudioEngine::qualitySettings & _qs, const OutputSettings & _os, ExportFileFormats _file_format, const QString & _out_file ); @@ -89,7 +89,7 @@ private: void run() override; AudioFileDevice * m_fileDev; - Mixer::qualitySettings m_qualitySettings; + AudioEngine::qualitySettings m_qualitySettings; volatile int m_progress; volatile bool m_abort; diff --git a/include/RenderManager.h b/include/RenderManager.h index 01236d747..935983702 100644 --- a/include/RenderManager.h +++ b/include/RenderManager.h @@ -37,7 +37,7 @@ class RenderManager : public QObject Q_OBJECT public: RenderManager( - const Mixer::qualitySettings & qualitySettings, + const AudioEngine::qualitySettings & qualitySettings, const OutputSettings & outputSettings, ProjectRenderer::ExportFileFormats fmt, QString outputPath); @@ -66,8 +66,8 @@ private: void render( QString outputPath ); - const Mixer::qualitySettings m_qualitySettings; - const Mixer::qualitySettings m_oldQualitySettings; + const AudioEngine::qualitySettings m_qualitySettings; + const AudioEngine::qualitySettings m_oldQualitySettings; const OutputSettings m_outputSettings; ProjectRenderer::ExportFileFormats m_format; QString m_outputPath; diff --git a/include/SampleBuffer.h b/include/SampleBuffer.h index a70251a25..d1e594b2c 100644 --- a/include/SampleBuffer.h +++ b/include/SampleBuffer.h @@ -288,7 +288,7 @@ public slots: void sampleRateChanged(); private: - static sample_rate_t mixerSampleRate(); + static sample_rate_t audioEngineSampleRate(); void update(bool keepSettings = false); diff --git a/include/Song.h b/include/Song.h index a297a488f..6bc19c6d4 100644 --- a/include/Song.h +++ b/include/Song.h @@ -34,11 +34,11 @@ #include #include "TrackContainer.h" +#include "AudioEngine.h" #include "Controller.h" #include "Keymap.h" #include "lmms_constants.h" #include "MeterModel.h" -#include "Mixer.h" #include "Scale.h" #include "VstSyncController.h" @@ -307,7 +307,7 @@ public: void loadingCancelled() { m_isCancelled = true; - Engine::mixer()->clearNewPlayHandles(); + Engine::audioEngine()->clearNewPlayHandles(); } bool isCancelled() diff --git a/plugins/BassBooster/BassBooster.cpp b/plugins/BassBooster/BassBooster.cpp index 1ed1f2467..f60694995 100644 --- a/plugins/BassBooster/BassBooster.cpp +++ b/plugins/BassBooster/BassBooster.cpp @@ -117,7 +117,7 @@ bool BassBoosterEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames inline void BassBoosterEffect::changeFrequency() { - const sample_t fac = Engine::mixer()->processingSampleRate() / 44100.0f; + const sample_t fac = Engine::audioEngine()->processingSampleRate() / 44100.0f; m_bbFX.leftFX().setFrequency( m_bbControls.m_freqModel.value() * fac ); m_bbFX.rightFX().setFrequency( m_bbControls.m_freqModel.value() * fac ); diff --git a/plugins/BassBooster/BassBoosterControls.cpp b/plugins/BassBooster/BassBoosterControls.cpp index 1de0f918a..195f00801 100644 --- a/plugins/BassBooster/BassBoosterControls.cpp +++ b/plugins/BassBooster/BassBoosterControls.cpp @@ -37,7 +37,7 @@ BassBoosterControls::BassBoosterControls( BassBoosterEffect* effect ) : m_gainModel( 1.0f, 0.1f, 5.0f, 0.05f, this, tr( "Gain" ) ), m_ratioModel( 2.0f, 0.1f, 10.0f, 0.1f, this, tr( "Ratio" ) ) { - connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( changeFrequency() ) ); + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( changeFrequency() ) ); } diff --git a/plugins/Bitcrush/Bitcrush.cpp b/plugins/Bitcrush/Bitcrush.cpp index fa19b195f..f9bb17614 100644 --- a/plugins/Bitcrush/Bitcrush.cpp +++ b/plugins/Bitcrush/Bitcrush.cpp @@ -55,10 +55,10 @@ Plugin::Descriptor PLUGIN_EXPORT bitcrush_plugin_descriptor = BitcrushEffect::BitcrushEffect( Model * parent, const Descriptor::SubPluginFeatures::Key * key ) : Effect( &bitcrush_plugin_descriptor, parent, key ), m_controls( this ), - m_sampleRate( Engine::mixer()->processingSampleRate() ), + m_sampleRate( Engine::audioEngine()->processingSampleRate() ), m_filter( m_sampleRate ) { - m_buffer = MM_ALLOC( sampleFrame, Engine::mixer()->framesPerPeriod() * OS_RATE ); + m_buffer = MM_ALLOC( sampleFrame, Engine::audioEngine()->framesPerPeriod() * OS_RATE ); m_filter.setLowpass( m_sampleRate * ( CUTOFF_RATIO * OS_RATIO ) ); m_needsUpdate = true; @@ -79,7 +79,7 @@ BitcrushEffect::~BitcrushEffect() void BitcrushEffect::sampleRateChanged() { - m_sampleRate = Engine::mixer()->processingSampleRate(); + m_sampleRate = Engine::audioEngine()->processingSampleRate(); m_filter.setSampleRate( m_sampleRate ); m_filter.setLowpass( m_sampleRate * ( CUTOFF_RATIO * OS_RATIO ) ); m_needsUpdate = true; diff --git a/plugins/Bitcrush/BitcrushControls.cpp b/plugins/Bitcrush/BitcrushControls.cpp index f768be4b8..f572b83eb 100644 --- a/plugins/Bitcrush/BitcrushControls.cpp +++ b/plugins/Bitcrush/BitcrushControls.cpp @@ -47,7 +47,7 @@ BitcrushControls::BitcrushControls( BitcrushEffect * eff ) : m_rate.setStrictStepSize( true ); m_levels.setStrictStepSize( true ); - connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( sampleRateChanged() ) ); + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( sampleRateChanged() ) ); } BitcrushControls::~BitcrushControls() diff --git a/plugins/Compressor/Compressor.cpp b/plugins/Compressor/Compressor.cpp index c009b91b6..b7550b13d 100755 --- a/plugins/Compressor/Compressor.cpp +++ b/plugins/Compressor/Compressor.cpp @@ -52,7 +52,7 @@ CompressorEffect::CompressorEffect(Model* parent, const Descriptor::SubPluginFea Effect(&compressor_plugin_descriptor, parent, key), m_compressorControls(this) { - m_sampleRate = Engine::mixer()->processingSampleRate(); + m_sampleRate = Engine::audioEngine()->processingSampleRate(); m_yL[0] = m_yL[1] = COMP_NOISE_FLOOR; @@ -86,7 +86,7 @@ CompressorEffect::CompressorEffect(Model* parent, const Descriptor::SubPluginFea connect(&m_compressorControls.m_kneeModel, SIGNAL(dataChanged()), this, SLOT(calcAutoMakeup()), Qt::DirectConnection); connect(&m_compressorControls.m_autoMakeupModel, SIGNAL(dataChanged()), this, SLOT(calcAutoMakeup()), Qt::DirectConnection); - connect(Engine::mixer(), SIGNAL(sampleRateChanged()), this, SLOT(changeSampleRate())); + connect(Engine::audioEngine(), SIGNAL(sampleRateChanged()), this, SLOT(changeSampleRate())); changeSampleRate(); } @@ -614,7 +614,7 @@ inline void CompressorEffect::calcTiltFilter(sample_t inputSample, sample_t &out void CompressorEffect::changeSampleRate() { - m_sampleRate = Engine::mixer()->processingSampleRate(); + m_sampleRate = Engine::audioEngine()->processingSampleRate(); m_coeffPrecalc = COMP_LOG / (m_sampleRate * 0.001f); diff --git a/plugins/CrossoverEQ/CrossoverEQ.cpp b/plugins/CrossoverEQ/CrossoverEQ.cpp index 78029134e..930860dd5 100644 --- a/plugins/CrossoverEQ/CrossoverEQ.cpp +++ b/plugins/CrossoverEQ/CrossoverEQ.cpp @@ -51,7 +51,7 @@ Plugin::Descriptor PLUGIN_EXPORT crossovereq_plugin_descriptor = CrossoverEQEffect::CrossoverEQEffect( Model* parent, const Descriptor::SubPluginFeatures::Key* key ) : Effect( &crossovereq_plugin_descriptor, parent, key ), m_controls( this ), - m_sampleRate( Engine::mixer()->processingSampleRate() ), + m_sampleRate( Engine::audioEngine()->processingSampleRate() ), m_lp1( m_sampleRate ), m_lp2( m_sampleRate ), m_lp3( m_sampleRate ), @@ -60,9 +60,9 @@ CrossoverEQEffect::CrossoverEQEffect( Model* parent, const Descriptor::SubPlugin m_hp4( m_sampleRate ), m_needsUpdate( true ) { - m_tmp1 = MM_ALLOC( sampleFrame, Engine::mixer()->framesPerPeriod() ); - m_tmp2 = MM_ALLOC( sampleFrame, Engine::mixer()->framesPerPeriod() ); - m_work = MM_ALLOC( sampleFrame, Engine::mixer()->framesPerPeriod() ); + m_tmp1 = MM_ALLOC( sampleFrame, Engine::audioEngine()->framesPerPeriod() ); + m_tmp2 = MM_ALLOC( sampleFrame, Engine::audioEngine()->framesPerPeriod() ); + m_work = MM_ALLOC( sampleFrame, Engine::audioEngine()->framesPerPeriod() ); } CrossoverEQEffect::~CrossoverEQEffect() @@ -74,7 +74,7 @@ CrossoverEQEffect::~CrossoverEQEffect() void CrossoverEQEffect::sampleRateChanged() { - m_sampleRate = Engine::mixer()->processingSampleRate(); + m_sampleRate = Engine::audioEngine()->processingSampleRate(); m_lp1.setSampleRate( m_sampleRate ); m_lp2.setSampleRate( m_sampleRate ); m_lp3.setSampleRate( m_sampleRate ); diff --git a/plugins/CrossoverEQ/CrossoverEQControls.cpp b/plugins/CrossoverEQ/CrossoverEQControls.cpp index e8a1634f0..19c1163a3 100644 --- a/plugins/CrossoverEQ/CrossoverEQControls.cpp +++ b/plugins/CrossoverEQ/CrossoverEQControls.cpp @@ -42,7 +42,7 @@ CrossoverEQControls::CrossoverEQControls( CrossoverEQEffect * eff ) : m_mute3( true, this, "Mute Band 3" ), m_mute4( true, this, "Mute Band 4" ) { - connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( sampleRateChanged() ) ); + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( sampleRateChanged() ) ); connect( &m_xover12, SIGNAL( dataChanged() ), this, SLOT( xover12Changed() ) ); connect( &m_xover23, SIGNAL( dataChanged() ), this, SLOT( xover23Changed() ) ); connect( &m_xover34, SIGNAL( dataChanged() ), this, SLOT( xover34Changed() ) ); diff --git a/plugins/Delay/DelayControls.cpp b/plugins/Delay/DelayControls.cpp index 1b1c8f2a2..35e8f869e 100644 --- a/plugins/Delay/DelayControls.cpp +++ b/plugins/Delay/DelayControls.cpp @@ -38,7 +38,7 @@ DelayControls::DelayControls( DelayEffect* effect ): m_lfoAmountModel(0.0, 0.0, 0.5, 0.0001, 2000.0, this, tr ( "LFO amount" ) ), m_outGainModel( 0.0, -60.0, 20.0, 0.01, this, tr( "Output gain" ) ) { - connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( changeSampleRate() ) ); + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( changeSampleRate() ) ); m_outPeakL = 0.0; m_outPeakR = 0.0; } diff --git a/plugins/Delay/DelayEffect.cpp b/plugins/Delay/DelayEffect.cpp index 69ee924e8..8cf0439eb 100644 --- a/plugins/Delay/DelayEffect.cpp +++ b/plugins/Delay/DelayEffect.cpp @@ -52,8 +52,8 @@ DelayEffect::DelayEffect( Model* parent, const Plugin::Descriptor::SubPluginFeat m_delayControls( this ) { m_delay = 0; - m_delay = new StereoDelay( 20, Engine::mixer()->processingSampleRate() ); - m_lfo = new Lfo( Engine::mixer()->processingSampleRate() ); + m_delay = new StereoDelay( 20, Engine::audioEngine()->processingSampleRate() ); + m_lfo = new Lfo( Engine::audioEngine()->processingSampleRate() ); m_outGain = 1.0; } @@ -82,7 +82,7 @@ bool DelayEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) return( false ); } double outSum = 0.0; - const float sr = Engine::mixer()->processingSampleRate(); + const float sr = Engine::audioEngine()->processingSampleRate(); const float d = dryLevel(); const float w = wetLevel(); sample_t dryS[2]; @@ -117,7 +117,7 @@ bool DelayEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) m_delay->setFeedback( *feedbackPtr ); m_lfo->setFrequency( *lfoTimePtr ); - sampleLength = *lengthPtr * Engine::mixer()->processingSampleRate(); + sampleLength = *lengthPtr * Engine::audioEngine()->processingSampleRate(); m_currentLength = sampleLength; m_delay->setLength( m_currentLength + ( *amplitudePtr * ( float )m_lfo->tick() ) ); m_delay->tick( buf[f] ); @@ -146,8 +146,8 @@ bool DelayEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) void DelayEffect::changeSampleRate() { - m_lfo->setSampleRate( Engine::mixer()->processingSampleRate() ); - m_delay->setSampleRate( Engine::mixer()->processingSampleRate() ); + m_lfo->setSampleRate( Engine::audioEngine()->processingSampleRate() ); + m_delay->setSampleRate( Engine::audioEngine()->processingSampleRate() ); } diff --git a/plugins/DualFilter/DualFilter.cpp b/plugins/DualFilter/DualFilter.cpp index d4e5d4b5e..86c280c3d 100644 --- a/plugins/DualFilter/DualFilter.cpp +++ b/plugins/DualFilter/DualFilter.cpp @@ -53,8 +53,8 @@ DualFilterEffect::DualFilterEffect( Model* parent, const Descriptor::SubPluginFe Effect( &dualfilter_plugin_descriptor, parent, key ), m_dfControls( this ) { - m_filter1 = new BasicFilters<2>( Engine::mixer()->processingSampleRate() ); - m_filter2 = new BasicFilters<2>( Engine::mixer()->processingSampleRate() ); + m_filter1 = new BasicFilters<2>( Engine::audioEngine()->processingSampleRate() ); + m_filter2 = new BasicFilters<2>( Engine::audioEngine()->processingSampleRate() ); // ensure filters get updated m_filter1changed = true; diff --git a/plugins/DualFilter/DualFilterControls.cpp b/plugins/DualFilter/DualFilterControls.cpp index 35cbaab3a..575a62152 100644 --- a/plugins/DualFilter/DualFilterControls.cpp +++ b/plugins/DualFilter/DualFilterControls.cpp @@ -97,7 +97,7 @@ DualFilterControls::DualFilterControls( DualFilterEffect* effect ) : m_filter2Model.addItem( tr( "Fast Formant" ), std::make_unique( "filter_hp" ) ); m_filter2Model.addItem( tr( "Tripole" ), std::make_unique( "filter_lp" ) ); - connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( updateFilters() ) ); + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( updateFilters() ) ); } @@ -108,8 +108,8 @@ void DualFilterControls::updateFilters() delete m_effect->m_filter1; delete m_effect->m_filter2; - m_effect->m_filter1 = new BasicFilters<2>( Engine::mixer()->processingSampleRate() ); - m_effect->m_filter2 = new BasicFilters<2>( Engine::mixer()->processingSampleRate() ); + m_effect->m_filter1 = new BasicFilters<2>( Engine::audioEngine()->processingSampleRate() ); + m_effect->m_filter2 = new BasicFilters<2>( Engine::audioEngine()->processingSampleRate() ); // flag filters as needing recalculation diff --git a/plugins/Eq/EqCurve.cpp b/plugins/Eq/EqCurve.cpp index 5d669b04a..b066871fa 100644 --- a/plugins/Eq/EqCurve.cpp +++ b/plugins/Eq/EqCurve.cpp @@ -190,7 +190,7 @@ bool EqHandle::mousePressed() const float EqHandle::getPeakCurve( float x ) { double freqZ = xPixelToFreq( EqHandle::x(), m_width ); - const int SR = Engine::mixer()->processingSampleRate(); + const int SR = Engine::audioEngine()->processingSampleRate(); double w0 = 2 * LD_PI * freqZ / SR ; double c = cosf( w0 ); double s = sinf( w0 ); @@ -228,7 +228,7 @@ float EqHandle::getPeakCurve( float x ) float EqHandle::getHighShelfCurve( float x ) { double freqZ = xPixelToFreq( EqHandle::x(), m_width ); - const int SR = Engine::mixer()->processingSampleRate(); + const int SR = Engine::audioEngine()->processingSampleRate(); double w0 = 2 * LD_PI * freqZ / SR; double c = cosf( w0 ); double s = sinf( w0 ); @@ -264,7 +264,7 @@ float EqHandle::getHighShelfCurve( float x ) float EqHandle::getLowShelfCurve( float x ) { double freqZ = xPixelToFreq( EqHandle::x(), m_width ); - const int SR = Engine::mixer()->processingSampleRate(); + const int SR = Engine::audioEngine()->processingSampleRate(); double w0 = 2 * LD_PI * freqZ / SR ; double c = cosf( w0 ); double s = sinf( w0 ); @@ -301,7 +301,7 @@ float EqHandle::getLowShelfCurve( float x ) float EqHandle::getLowCutCurve( float x ) { double freqZ = xPixelToFreq( EqHandle::x(), m_width ); - const int SR = Engine::mixer()->processingSampleRate(); + const int SR = Engine::audioEngine()->processingSampleRate(); double w0 = 2 * LD_PI * freqZ / SR ; double c = cosf( w0 ); double s = sinf( w0 ); @@ -345,7 +345,7 @@ float EqHandle::getLowCutCurve( float x ) float EqHandle::getHighCutCurve( float x ) { double freqZ = xPixelToFreq( EqHandle::x(), m_width ); - const int SR = Engine::mixer()->processingSampleRate(); + const int SR = Engine::audioEngine()->processingSampleRate(); double w0 = 2 * LD_PI * freqZ / SR ; double c = cosf( w0 ); double s = sinf( w0 ); @@ -520,7 +520,7 @@ void EqHandle::setlp48() double EqHandle::calculateGain(const double freq, const double a1, const double a2, const double b0, const double b1, const double b2 ) { - const int SR = Engine::mixer()->processingSampleRate(); + const int SR = Engine::audioEngine()->processingSampleRate(); const double w = 2 * LD_PI * freq / SR ; const double PHI = pow( sin( w / 2 ), 2 ) * 4; diff --git a/plugins/Eq/EqEffect.cpp b/plugins/Eq/EqEffect.cpp index a29537493..820525eec 100644 --- a/plugins/Eq/EqEffect.cpp +++ b/plugins/Eq/EqEffect.cpp @@ -71,7 +71,7 @@ EqEffect::~EqEffect() bool EqEffect::processAudioBuffer( sampleFrame *buf, const fpp_t frames ) { - const int sampleRate = Engine::mixer()->processingSampleRate(); + const int sampleRate = Engine::audioEngine()->processingSampleRate(); //wet/dry controls const float dry = dryLevel(); diff --git a/plugins/Eq/EqSpectrumView.cpp b/plugins/Eq/EqSpectrumView.cpp index e9e0043de..cda23b123 100644 --- a/plugins/Eq/EqSpectrumView.cpp +++ b/plugins/Eq/EqSpectrumView.cpp @@ -22,11 +22,11 @@ #include "EqSpectrumView.h" +#include "AudioEngine.h" #include "Engine.h" #include "EqCurve.h" #include "GuiApplication.h" #include "MainWindow.h" -#include "Mixer.h" EqAnalyser::EqAnalyser() : m_framesFilledUp ( 0 ), @@ -93,7 +93,7 @@ void EqAnalyser::analyze( sampleFrame *buf, const fpp_t frames ) return; } - m_sampleRate = Engine::mixer()->processingSampleRate(); + m_sampleRate = Engine::audioEngine()->processingSampleRate(); const int LOWEST_FREQ = 0; const int HIGHEST_FREQ = m_sampleRate / 2; diff --git a/plugins/Flanger/FlangerControls.cpp b/plugins/Flanger/FlangerControls.cpp index c5ac1ab86..81e9268c7 100644 --- a/plugins/Flanger/FlangerControls.cpp +++ b/plugins/Flanger/FlangerControls.cpp @@ -43,7 +43,7 @@ FlangerControls::FlangerControls( FlangerEffect *effect ) : m_invertFeedbackModel ( false, this, tr( "Invert" ) ) { - connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( changedSampleRate() ) ); + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( changedSampleRate() ) ); connect( Engine::getSong(), SIGNAL( playbackStateChanged() ), this, SLOT( changedPlaybackState() ) ); } diff --git a/plugins/Flanger/FlangerEffect.cpp b/plugins/Flanger/FlangerEffect.cpp index a8bd4d2c8..beccdf02b 100644 --- a/plugins/Flanger/FlangerEffect.cpp +++ b/plugins/Flanger/FlangerEffect.cpp @@ -51,9 +51,9 @@ FlangerEffect::FlangerEffect( Model *parent, const Plugin::Descriptor::SubPlugin Effect( &flanger_plugin_descriptor, parent, key ), m_flangerControls( this ) { - m_lfo = new QuadratureLfo( Engine::mixer()->processingSampleRate() ); - m_lDelay = new MonoDelay( 1, Engine::mixer()->processingSampleRate() ); - m_rDelay = new MonoDelay( 1, Engine::mixer()->processingSampleRate() ); + m_lfo = new QuadratureLfo( Engine::audioEngine()->processingSampleRate() ); + m_lDelay = new MonoDelay( 1, Engine::audioEngine()->processingSampleRate() ); + m_rDelay = new MonoDelay( 1, Engine::audioEngine()->processingSampleRate() ); m_noise = new Noise; } @@ -92,9 +92,9 @@ bool FlangerEffect::processAudioBuffer( sampleFrame *buf, const fpp_t frames ) double outSum = 0.0; const float d = dryLevel(); const float w = wetLevel(); - const float length = m_flangerControls.m_delayTimeModel.value() * Engine::mixer()->processingSampleRate(); + const float length = m_flangerControls.m_delayTimeModel.value() * Engine::audioEngine()->processingSampleRate(); const float noise = m_flangerControls.m_whiteNoiseAmountModel.value(); - float amplitude = m_flangerControls.m_lfoAmountModel.value() * Engine::mixer()->processingSampleRate(); + float amplitude = m_flangerControls.m_lfoAmountModel.value() * Engine::audioEngine()->processingSampleRate(); bool invertFeedback = m_flangerControls.m_invertFeedbackModel.value(); m_lfo->setFrequency( 1.0/m_flangerControls.m_lfoFrequencyModel.value() ); m_lfo->setOffset( m_flangerControls.m_lfoPhaseModel.value() / 180 * D_PI ); @@ -135,9 +135,9 @@ bool FlangerEffect::processAudioBuffer( sampleFrame *buf, const fpp_t frames ) void FlangerEffect::changeSampleRate() { - m_lfo->setSampleRate( Engine::mixer()->processingSampleRate() ); - m_lDelay->setSampleRate( Engine::mixer()->processingSampleRate() ); - m_rDelay->setSampleRate( Engine::mixer()->processingSampleRate() ); + m_lfo->setSampleRate( Engine::audioEngine()->processingSampleRate() ); + m_lDelay->setSampleRate( Engine::audioEngine()->processingSampleRate() ); + m_rDelay->setSampleRate( Engine::audioEngine()->processingSampleRate() ); } diff --git a/plugins/FreeBoy/FreeBoy.cpp b/plugins/FreeBoy/FreeBoy.cpp index 95ba5a215..5004d392d 100644 --- a/plugins/FreeBoy/FreeBoy.cpp +++ b/plugins/FreeBoy/FreeBoy.cpp @@ -33,7 +33,7 @@ #include "base64.h" #include "InstrumentTrack.h" #include "Knob.h" -#include "Mixer.h" +#include "AudioEngine.h" #include "NotePlayHandle.h" #include "PixmapButton.h" #include "ToolTip.h" @@ -224,7 +224,7 @@ QString FreeBoyInstrument::nodeName() const /*f_cnt_t FreeBoyInstrument::desiredReleaseFrames() const { - const float samplerate = Engine::mixer()->processingSampleRate(); + const float samplerate = Engine::audioEngine()->processingSampleRate(); int maxrel = 0; for( int i = 0 ; i < 3 ; ++i ) { @@ -246,7 +246,7 @@ void FreeBoyInstrument::playNote( NotePlayHandle * _n, sampleFrame * _working_buffer ) { const f_cnt_t tfp = _n->totalFramesPlayed(); - const int samplerate = Engine::mixer()->processingSampleRate(); + const int samplerate = Engine::audioEngine()->processingSampleRate(); const fpp_t frames = _n->framesLeftForCurrentPeriod(); const f_cnt_t offset = _n->noteOffset(); diff --git a/plugins/GigPlayer/GigPlayer.cpp b/plugins/GigPlayer/GigPlayer.cpp index 4ecbd3500..323580224 100644 --- a/plugins/GigPlayer/GigPlayer.cpp +++ b/plugins/GigPlayer/GigPlayer.cpp @@ -36,6 +36,7 @@ #include #include +#include "AudioEngine.h" #include "ConfigManager.h" #include "endian_handling.h" #include "Engine.h" @@ -43,7 +44,6 @@ #include "InstrumentTrack.h" #include "InstrumentPlayHandle.h" #include "Knob.h" -#include "Mixer.h" #include "NotePlayHandle.h" #include "PathUtil.h" #include "SampleBuffer.h" @@ -90,13 +90,13 @@ GigInstrument::GigInstrument( InstrumentTrack * _instrument_track ) : m_currentKeyDimension( 0 ) { InstrumentPlayHandle * iph = new InstrumentPlayHandle( this, _instrument_track ); - Engine::mixer()->addPlayHandle( iph ); + Engine::audioEngine()->addPlayHandle( iph ); updateSampleRate(); connect( &m_bankNum, SIGNAL( dataChanged() ), this, SLOT( updatePatch() ) ); connect( &m_patchNum, SIGNAL( dataChanged() ), this, SLOT( updatePatch() ) ); - connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( updateSampleRate() ) ); + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( updateSampleRate() ) ); } @@ -104,7 +104,7 @@ GigInstrument::GigInstrument( InstrumentTrack * _instrument_track ) : GigInstrument::~GigInstrument() { - Engine::mixer()->removePlayHandlesOfTypes( instrumentTrack(), + Engine::audioEngine()->removePlayHandlesOfTypes( instrumentTrack(), PlayHandle::TypeNotePlayHandle | PlayHandle::TypeInstrumentPlayHandle ); freeInstance(); @@ -321,8 +321,8 @@ void GigInstrument::playNote( NotePlayHandle * _n, sampleFrame * ) // the preferences) void GigInstrument::play( sampleFrame * _working_buffer ) { - const fpp_t frames = Engine::mixer()->framesPerPeriod(); - const int rate = Engine::mixer()->processingSampleRate(); + const fpp_t frames = Engine::audioEngine()->framesPerPeriod(); + const int rate = Engine::audioEngine()->processingSampleRate(); // Initialize to zeros std::memset( &_working_buffer[0][0], 0, DEFAULT_CHANNELS * frames * sizeof( float ) ); @@ -758,7 +758,7 @@ void GigInstrument::addSamples( GigNote & gignote, bool wantReleaseSample ) if( gignote.midiNote >= keyLow && gignote.midiNote <= keyHigh ) { float attenuation = pDimRegion->GetVelocityAttenuation( gignote.velocity ); - float length = (float) pSample->SamplesTotal / Engine::mixer()->processingSampleRate(); + float length = (float) pSample->SamplesTotal / Engine::audioEngine()->processingSampleRate(); // TODO: sample panning? crossfade different layers? diff --git a/plugins/LadspaEffect/LadspaEffect.cpp b/plugins/LadspaEffect/LadspaEffect.cpp index 117e1e0e1..fd1257f41 100644 --- a/plugins/LadspaEffect/LadspaEffect.cpp +++ b/plugins/LadspaEffect/LadspaEffect.cpp @@ -30,11 +30,11 @@ #include "LadspaEffect.h" #include "DataFile.h" #include "AudioDevice.h" +#include "AudioEngine.h" #include "ConfigManager.h" #include "Ladspa2LMMS.h" #include "LadspaControl.h" #include "LadspaSubPluginFeatures.h" -#include "Mixer.h" #include "EffectChain.h" #include "AutomationPattern.h" #include "ControllerConnection.h" @@ -87,7 +87,7 @@ LadspaEffect::LadspaEffect( Model * _parent, pluginInstantiation(); - connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( changeSampleRate() ) ); } @@ -142,13 +142,13 @@ bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, sampleFrame * o_buf = NULL; QVarLengthArray sBuf(_frames * DEFAULT_CHANNELS); - if( m_maxSampleRate < Engine::mixer()->processingSampleRate() ) + if( m_maxSampleRate < Engine::audioEngine()->processingSampleRate() ) { o_buf = _buf; _buf = reinterpret_cast(sBuf.data()); sampleDown( o_buf, _buf, m_maxSampleRate ); frames = _frames * m_maxSampleRate / - Engine::mixer()->processingSampleRate(); + Engine::audioEngine()->processingSampleRate(); } // Copy the LMMS audio buffer to the LADSPA input buffer and initialize @@ -289,7 +289,7 @@ void LadspaEffect::pluginInstantiation() Ladspa2LMMS * manager = Engine::getLADSPAManager(); // Calculate how many processing units are needed. - const ch_cnt_t lmms_chnls = Engine::mixer()->audioDev()->channels(); + const ch_cnt_t lmms_chnls = Engine::audioEngine()->audioDev()->channels(); int effect_channels = manager->getDescription( m_key )->inputChannels; setProcessorCount( lmms_chnls / effect_channels ); @@ -324,7 +324,7 @@ void LadspaEffect::pluginInstantiation() manager->isPortInput( m_key, port ) ) { p->rate = CHANNEL_IN; - p->buffer = MM_ALLOC( LADSPA_Data, Engine::mixer()->framesPerPeriod() ); + p->buffer = MM_ALLOC( LADSPA_Data, Engine::audioEngine()->framesPerPeriod() ); inbuf[ inputch ] = p->buffer; inputch++; } @@ -339,19 +339,19 @@ void LadspaEffect::pluginInstantiation() } else { - p->buffer = MM_ALLOC( LADSPA_Data, Engine::mixer()->framesPerPeriod() ); + p->buffer = MM_ALLOC( LADSPA_Data, Engine::audioEngine()->framesPerPeriod() ); m_inPlaceBroken = true; } } else if( manager->isPortInput( m_key, port ) ) { p->rate = AUDIO_RATE_INPUT; - p->buffer = MM_ALLOC( LADSPA_Data, Engine::mixer()->framesPerPeriod() ); + p->buffer = MM_ALLOC( LADSPA_Data, Engine::audioEngine()->framesPerPeriod() ); } else { p->rate = AUDIO_RATE_OUTPUT; - p->buffer = MM_ALLOC( LADSPA_Data, Engine::mixer()->framesPerPeriod() ); + p->buffer = MM_ALLOC( LADSPA_Data, Engine::audioEngine()->framesPerPeriod() ); } } else @@ -586,7 +586,7 @@ sample_rate_t LadspaEffect::maxSamplerate( const QString & _name ) { return( __buggy_plugins[_name] ); } - return( Engine::mixer()->processingSampleRate() ); + return( Engine::audioEngine()->processingSampleRate() ); } diff --git a/plugins/LadspaEffect/LadspaSubPluginFeatures.cpp b/plugins/LadspaEffect/LadspaSubPluginFeatures.cpp index 4cefa90b5..dfd302d6c 100644 --- a/plugins/LadspaEffect/LadspaSubPluginFeatures.cpp +++ b/plugins/LadspaEffect/LadspaSubPluginFeatures.cpp @@ -30,10 +30,10 @@ #include "LadspaSubPluginFeatures.h" #include "AudioDevice.h" +#include "AudioEngine.h" #include "Engine.h" #include "Ladspa2LMMS.h" #include "LadspaBase.h" -#include "Mixer.h" LadspaSubPluginFeatures::LadspaSubPluginFeatures( Plugin::PluginTypes _type ) : @@ -154,8 +154,7 @@ void LadspaSubPluginFeatures::listSubPluginKeys( for( l_sortable_plugin_t::const_iterator it = plugins.begin(); it != plugins.end(); ++it ) { - if( lm->getDescription( ( *it ).second )->inputChannels <= - Engine::mixer()->audioDev()->channels() ) + if( lm->getDescription( ( *it ).second )->inputChannels <= Engine::audioEngine()->audioDev()->channels() ) { _kl.push_back( ladspaKeyToSubPluginKey( _desc, ( *it ).first, ( *it ).second ) ); } diff --git a/plugins/Lv2Effect/Lv2Effect.cpp b/plugins/Lv2Effect/Lv2Effect.cpp index dd0c4c44f..ddec187bb 100644 --- a/plugins/Lv2Effect/Lv2Effect.cpp +++ b/plugins/Lv2Effect/Lv2Effect.cpp @@ -60,7 +60,7 @@ Plugin::Descriptor PLUGIN_EXPORT lv2effect_plugin_descriptor = Lv2Effect::Lv2Effect(Model* parent, const Descriptor::SubPluginFeatures::Key *key) : Effect(&lv2effect_plugin_descriptor, parent, key), m_controls(this, key->attributes["uri"]), - m_tmpOutputSmps(Engine::mixer()->framesPerPeriod()) + m_tmpOutputSmps(Engine::audioEngine()->framesPerPeriod()) { } diff --git a/plugins/Lv2Effect/Lv2FxControls.cpp b/plugins/Lv2Effect/Lv2FxControls.cpp index a5733fec6..56469d3cc 100644 --- a/plugins/Lv2Effect/Lv2FxControls.cpp +++ b/plugins/Lv2Effect/Lv2FxControls.cpp @@ -40,7 +40,7 @@ Lv2FxControls::Lv2FxControls(class Lv2Effect *effect, const QString& uri) : { if (isValid()) { - connect(Engine::mixer(), &Mixer::sampleRateChanged, + connect(Engine::audioEngine(), &AudioEngine::sampleRateChanged, this, [this](){Lv2ControlBase::reloadPlugin();}); } } diff --git a/plugins/Lv2Instrument/Lv2Instrument.cpp b/plugins/Lv2Instrument/Lv2Instrument.cpp index 3eba7cdcc..30dfd80c5 100644 --- a/plugins/Lv2Instrument/Lv2Instrument.cpp +++ b/plugins/Lv2Instrument/Lv2Instrument.cpp @@ -27,11 +27,11 @@ #include #include +#include "AudioEngine.h" #include "Engine.h" #include "InstrumentPlayHandle.h" #include "InstrumentTrack.h" #include "Lv2SubPluginFeatures.h" -#include "Mixer.h" #include "StringPairDrag.h" #include "Clipboard.h" @@ -80,13 +80,13 @@ Lv2Instrument::Lv2Instrument(InstrumentTrack *instrumentTrackArg, #endif connect(instrumentTrack()->pitchRangeModel(), SIGNAL(dataChanged()), this, SLOT(updatePitchRange()), Qt::DirectConnection); - connect(Engine::mixer(), &Mixer::sampleRateChanged, + connect(Engine::audioEngine(), &AudioEngine::sampleRateChanged, this, [this](){Lv2ControlBase::reloadPlugin();}); // now we need a play-handle which cares for calling play() InstrumentPlayHandle *iph = new InstrumentPlayHandle(this, instrumentTrackArg); - Engine::mixer()->addPlayHandle(iph); + Engine::audioEngine()->addPlayHandle(iph); } } @@ -95,9 +95,8 @@ Lv2Instrument::Lv2Instrument(InstrumentTrack *instrumentTrackArg, Lv2Instrument::~Lv2Instrument() { - Engine::mixer()->removePlayHandlesOfTypes(instrumentTrack(), - PlayHandle::TypeNotePlayHandle | - PlayHandle::TypeInstrumentPlayHandle); + Engine::audioEngine()->removePlayHandlesOfTypes(instrumentTrack(), + PlayHandle::TypeNotePlayHandle | PlayHandle::TypeInstrumentPlayHandle); } @@ -160,7 +159,7 @@ void Lv2Instrument::play(sampleFrame *buf) { copyModelsFromLmms(); - fpp_t fpp = Engine::mixer()->framesPerPeriod(); + fpp_t fpp = Engine::audioEngine()->framesPerPeriod(); run(fpp); diff --git a/plugins/MultitapEcho/MultitapEcho.cpp b/plugins/MultitapEcho/MultitapEcho.cpp index eb6c51cba..2ee322905 100644 --- a/plugins/MultitapEcho/MultitapEcho.cpp +++ b/plugins/MultitapEcho/MultitapEcho.cpp @@ -51,10 +51,10 @@ MultitapEchoEffect::MultitapEchoEffect( Model* parent, const Descriptor::SubPlug m_stages( 1 ), m_controls( this ), m_buffer( 16100.0f ), - m_sampleRate( Engine::mixer()->processingSampleRate() ), + m_sampleRate( Engine::audioEngine()->processingSampleRate() ), m_sampleRatio( 1.0f / m_sampleRate ) { - m_work = MM_ALLOC( sampleFrame, Engine::mixer()->framesPerPeriod() ); + m_work = MM_ALLOC( sampleFrame, Engine::audioEngine()->framesPerPeriod() ); m_buffer.reset(); m_stages = static_cast( m_controls.m_stages.value() ); updateFilters( 0, 19 ); diff --git a/plugins/MultitapEcho/MultitapEchoControls.cpp b/plugins/MultitapEcho/MultitapEchoControls.cpp index 533f5c30e..54dd309c2 100644 --- a/plugins/MultitapEcho/MultitapEchoControls.cpp +++ b/plugins/MultitapEcho/MultitapEchoControls.cpp @@ -48,7 +48,7 @@ MultitapEchoControls::MultitapEchoControls( MultitapEchoEffect * eff ) : connect( &m_lpGraph, SIGNAL( samplesChanged( int, int ) ), this, SLOT( lpSamplesChanged( int, int ) ) ); connect( &m_steps, SIGNAL( dataChanged() ), this, SLOT( lengthChanged() ) ); - connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( sampleRateChanged() ) ); + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( sampleRateChanged() ) ); setDefaultAmpShape(); setDefaultLpShape(); @@ -174,7 +174,7 @@ void MultitapEchoControls::lengthChanged() void MultitapEchoControls::sampleRateChanged() { - m_effect->m_sampleRate = Engine::mixer()->processingSampleRate(); + m_effect->m_sampleRate = Engine::audioEngine()->processingSampleRate(); m_effect->m_sampleRatio = 1.0f / m_effect->m_sampleRate; m_effect->updateFilters( 0, 19 ); } diff --git a/plugins/OpulenZ/OpulenZ.cpp b/plugins/OpulenZ/OpulenZ.cpp index 422f635f8..760138702 100644 --- a/plugins/OpulenZ/OpulenZ.cpp +++ b/plugins/OpulenZ/OpulenZ.cpp @@ -35,10 +35,10 @@ #include "OpulenZ.h" #include "Instrument.h" +#include "AudioEngine.h" #include "Engine.h" #include "InstrumentPlayHandle.h" #include "InstrumentTrack.h" -#include "Mixer.h" #include #include @@ -139,7 +139,7 @@ OpulenzInstrument::OpulenzInstrument( InstrumentTrack * _instrument_track ) : // Create an emulator - samplerate, 16 bit, mono emulatorMutex.lock(); - theEmulator = new CTemuopl(Engine::mixer()->processingSampleRate(), true, false); + theEmulator = new CTemuopl(Engine::audioEngine()->processingSampleRate(), true, false); theEmulator->init(); // Enable waveform selection theEmulator->write(0x01,0x20); @@ -158,7 +158,7 @@ OpulenzInstrument::OpulenzInstrument( InstrumentTrack * _instrument_track ) : updatePatch(); // Can the buffer size change suddenly? I bet that would break lots of stuff - frameCount = Engine::mixer()->framesPerPeriod(); + frameCount = Engine::audioEngine()->framesPerPeriod(); renderbuffer = new short[frameCount]; // Some kind of sane defaults @@ -168,7 +168,7 @@ OpulenzInstrument::OpulenzInstrument( InstrumentTrack * _instrument_track ) : tuneEqual(69, 440); - connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( reloadEmulator() ) ); // Connect knobs // This one's for testing... @@ -213,14 +213,14 @@ OpulenzInstrument::OpulenzInstrument( InstrumentTrack * _instrument_track ) : MOD_CON( vib_depth_mdl ); MOD_CON( trem_depth_mdl ); - // Connect the plugin to the mixer... + // Connect the plugin to the audio engine... InstrumentPlayHandle * iph = new InstrumentPlayHandle( this, _instrument_track ); - Engine::mixer()->addPlayHandle( iph ); + Engine::audioEngine()->addPlayHandle( iph ); } OpulenzInstrument::~OpulenzInstrument() { delete theEmulator; - Engine::mixer()->removePlayHandlesOfTypes( instrumentTrack(), + Engine::audioEngine()->removePlayHandlesOfTypes( instrumentTrack(), PlayHandle::TypeNotePlayHandle | PlayHandle::TypeInstrumentPlayHandle ); delete [] renderbuffer; @@ -230,7 +230,7 @@ OpulenzInstrument::~OpulenzInstrument() { void OpulenzInstrument::reloadEmulator() { delete theEmulator; emulatorMutex.lock(); - theEmulator = new CTemuopl(Engine::mixer()->processingSampleRate(), true, false); + theEmulator = new CTemuopl(Engine::audioEngine()->processingSampleRate(), true, false); theEmulator->init(); theEmulator->write(0x01,0x20); emulatorMutex.unlock(); diff --git a/plugins/ReverbSC/ReverbSC.cpp b/plugins/ReverbSC/ReverbSC.cpp index f54002199..f544511b1 100644 --- a/plugins/ReverbSC/ReverbSC.cpp +++ b/plugins/ReverbSC/ReverbSC.cpp @@ -51,7 +51,7 @@ ReverbSCEffect::ReverbSCEffect( Model* parent, const Descriptor::SubPluginFeatur m_reverbSCControls( this ) { sp_create(&sp); - sp->sr = Engine::mixer()->processingSampleRate(); + sp->sr = Engine::audioEngine()->processingSampleRate(); sp_revsc_create(&revsc); sp_revsc_init(sp, revsc); @@ -59,8 +59,8 @@ ReverbSCEffect::ReverbSCEffect( Model* parent, const Descriptor::SubPluginFeatur sp_dcblock_create(&dcblk[0]); sp_dcblock_create(&dcblk[1]); - sp_dcblock_init(sp, dcblk[0], Engine::mixer()->currentQualitySettings().sampleRateMultiplier() ); - sp_dcblock_init(sp, dcblk[1], Engine::mixer()->currentQualitySettings().sampleRateMultiplier() ); + sp_dcblock_init(sp, dcblk[0], Engine::audioEngine()->currentQualitySettings().sampleRateMultiplier() ); + sp_dcblock_init(sp, dcblk[1], Engine::audioEngine()->currentQualitySettings().sampleRateMultiplier() ); } ReverbSCEffect::~ReverbSCEffect() @@ -130,7 +130,7 @@ bool ReverbSCEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) void ReverbSCEffect::changeSampleRate() { // Change sr variable in Soundpipe. does not need to be destroyed - sp->sr = Engine::mixer()->processingSampleRate(); + sp->sr = Engine::audioEngine()->processingSampleRate(); mutex.lock(); sp_revsc_destroy(&revsc); @@ -143,8 +143,8 @@ void ReverbSCEffect::changeSampleRate() sp_dcblock_create(&dcblk[0]); sp_dcblock_create(&dcblk[1]); - sp_dcblock_init(sp, dcblk[0], Engine::mixer()->currentQualitySettings().sampleRateMultiplier() ); - sp_dcblock_init(sp, dcblk[1], Engine::mixer()->currentQualitySettings().sampleRateMultiplier() ); + sp_dcblock_init(sp, dcblk[0], Engine::audioEngine()->currentQualitySettings().sampleRateMultiplier() ); + sp_dcblock_init(sp, dcblk[1], Engine::audioEngine()->currentQualitySettings().sampleRateMultiplier() ); mutex.unlock(); } diff --git a/plugins/ReverbSC/ReverbSCControls.cpp b/plugins/ReverbSC/ReverbSCControls.cpp index 0b9e337b4..165e784f6 100644 --- a/plugins/ReverbSC/ReverbSCControls.cpp +++ b/plugins/ReverbSC/ReverbSCControls.cpp @@ -38,7 +38,7 @@ ReverbSCControls::ReverbSCControls( ReverbSCEffect* effect ) : m_colorModel( 10000.0f, 100.0f, 15000.0f, 0.1f, this, tr( "Color" ) ), m_outputGainModel( 0.0f, -60.0f, 15, 0.1f, this, tr( "Output gain" ) ) { - connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( changeSampleRate() )); + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( changeSampleRate() )); } void ReverbSCControls::changeControl() diff --git a/plugins/Sid/SidInstrument.cpp b/plugins/Sid/SidInstrument.cpp index c26200214..d8498c55a 100644 --- a/plugins/Sid/SidInstrument.cpp +++ b/plugins/Sid/SidInstrument.cpp @@ -33,10 +33,10 @@ #include "sid.h" #include "SidInstrument.h" +#include "AudioEngine.h" #include "Engine.h" #include "InstrumentTrack.h" #include "Knob.h" -#include "Mixer.h" #include "NotePlayHandle.h" #include "PixmapButton.h" #include "ToolTip.h" @@ -233,7 +233,7 @@ QString SidInstrument::nodeName() const f_cnt_t SidInstrument::desiredReleaseFrames() const { - const float samplerate = Engine::mixer()->processingSampleRate(); + const float samplerate = Engine::audioEngine()->processingSampleRate(); int maxrel = 0; for( int i = 0 ; i < 3 ; ++i ) { @@ -308,7 +308,7 @@ void SidInstrument::playNote( NotePlayHandle * _n, const f_cnt_t tfp = _n->totalFramesPlayed(); const int clockrate = C64_PAL_CYCLES_PER_SEC; - const int samplerate = Engine::mixer()->processingSampleRate(); + const int samplerate = Engine::audioEngine()->processingSampleRate(); if ( tfp == 0 ) { diff --git a/plugins/SpectrumAnalyzer/SaProcessor.cpp b/plugins/SpectrumAnalyzer/SaProcessor.cpp index 9d83f2916..dba09b39c 100644 --- a/plugins/SpectrumAnalyzer/SaProcessor.cpp +++ b/plugins/SpectrumAnalyzer/SaProcessor.cpp @@ -45,7 +45,7 @@ SaProcessor::SaProcessor(const SaControls *controls) : m_terminate(false), m_inBlockSize(FFT_BLOCK_SIZES[0]), m_fftBlockSize(FFT_BLOCK_SIZES[0]), - m_sampleRate(Engine::mixer()->processingSampleRate()), + m_sampleRate(Engine::audioEngine()->processingSampleRate()), m_framesFilledUp(0), m_spectrumActive(false), m_waterfallActive(false), @@ -158,7 +158,7 @@ void SaProcessor::analyze(LocklessRingBuffer &ring_buffer) #endif // update sample rate - m_sampleRate = Engine::mixer()->processingSampleRate(); + m_sampleRate = Engine::audioEngine()->processingSampleRate(); // apply FFT window for (unsigned int i = 0; i < m_inBlockSize; i++) diff --git a/plugins/Xpressive/Xpressive.cpp b/plugins/Xpressive/Xpressive.cpp index b83c2686e..f16322b1f 100644 --- a/plugins/Xpressive/Xpressive.cpp +++ b/plugins/Xpressive/Xpressive.cpp @@ -26,6 +26,7 @@ #include +#include "AudioEngine.h" #include "Engine.h" #include "Graph.h" #include "GuiApplication.h" @@ -33,7 +34,6 @@ #include "Knob.h" #include "LedCheckbox.h" #include "MainWindow.h" -#include "Mixer.h" #include "NotePlayHandle.h" #include "Oscillator.h" #include "PixmapButton.h" @@ -204,14 +204,14 @@ void Xpressive::playNote(NotePlayHandle* nph, sampleFrame* working_buffer) { if (nph->totalFramesPlayed() == 0 || nph->m_pluginData == NULL) { - ExprFront *exprO1 = new ExprFront(m_outputExpression[0].constData(),Engine::mixer()->processingSampleRate());//give the "last" function a whole second - ExprFront *exprO2 = new ExprFront(m_outputExpression[1].constData(),Engine::mixer()->processingSampleRate()); + ExprFront *exprO1 = new ExprFront(m_outputExpression[0].constData(),Engine::audioEngine()->processingSampleRate());//give the "last" function a whole second + ExprFront *exprO2 = new ExprFront(m_outputExpression[1].constData(),Engine::audioEngine()->processingSampleRate()); auto init_expression_step1 = [this, nph](ExprFront* e) { //lambda function to init exprO1 and exprO2 //add the constants and the variables to the expression. e->add_constant("key", nph->key());//the key that was pressed. e->add_constant("bnote", nph->instrumentTrack()->baseNote()); // the base note - e->add_constant("srate", Engine::mixer()->processingSampleRate());// sample rate of the mixer + e->add_constant("srate", Engine::audioEngine()->processingSampleRate());// sample rate of the audio engine e->add_constant("v", nph->getVolume() / 255.0); //volume of the note. e->add_constant("tempo", Engine::getSong()->getTempo());//tempo of the song. e->add_variable("A1", m_A1);//A1,A2,A3: general purpose input controls. @@ -225,7 +225,7 @@ void Xpressive::playNote(NotePlayHandle* nph, sampleFrame* working_buffer) { m_W2.setInterpolate(m_interpolateW2.value()); m_W3.setInterpolate(m_interpolateW3.value()); nph->m_pluginData = new ExprSynth(&m_W1, &m_W2, &m_W3, exprO1, exprO2, nph, - Engine::mixer()->processingSampleRate(), &m_panning1, &m_panning2, m_relTransition.value()); + Engine::audioEngine()->processingSampleRate(), &m_panning1, &m_panning2, m_relTransition.value()); } diff --git a/plugins/audio_file_processor/audio_file_processor.cpp b/plugins/audio_file_processor/audio_file_processor.cpp index b5276f51d..bff0fd0f1 100644 --- a/plugins/audio_file_processor/audio_file_processor.cpp +++ b/plugins/audio_file_processor/audio_file_processor.cpp @@ -32,13 +32,13 @@ #include +#include "AudioEngine.h" #include "ConfigManager.h" #include "DataFile.h" #include "Engine.h" #include "gui_templates.h" #include "InstrumentTrack.h" #include "interpolation.h" -#include "Mixer.h" #include "NotePlayHandle.h" #include "PathUtil.h" #include "Song.h" @@ -305,7 +305,7 @@ int audioFileProcessor::getBeatLen( NotePlayHandle * _n ) const { const auto baseFreq = instrumentTrack()->baseFreq(); const float freq_factor = baseFreq / _n->frequency() * - Engine::mixer()->processingSampleRate() / Engine::mixer()->baseSampleRate(); + Engine::audioEngine()->processingSampleRate() / Engine::audioEngine()->baseSampleRate(); return static_cast( floorf( ( m_sampleBuffer.endFrame() - m_sampleBuffer.startFrame() ) * freq_factor ) ); } diff --git a/plugins/bit_invader/bit_invader.cpp b/plugins/bit_invader/bit_invader.cpp index 2b3a2c3c6..dd0ca20d5 100644 --- a/plugins/bit_invader/bit_invader.cpp +++ b/plugins/bit_invader/bit_invader.cpp @@ -26,13 +26,13 @@ #include #include "bit_invader.h" +#include "AudioEngine.h" #include "base64.h" #include "Engine.h" #include "Graph.h" #include "InstrumentTrack.h" #include "Knob.h" #include "LedCheckbox.h" -#include "Mixer.h" #include "NotePlayHandle.h" #include "Oscillator.h" #include "PixmapButton.h" @@ -295,7 +295,7 @@ void bitInvader::playNote( NotePlayHandle * _n, const_cast( m_graph.samples() ), _n, m_interpolation.value(), factor, - Engine::mixer()->processingSampleRate() ); + Engine::audioEngine()->processingSampleRate() ); } const fpp_t frames = _n->framesLeftForCurrentPeriod(); diff --git a/plugins/carlabase/carla.cpp b/plugins/carlabase/carla.cpp index ce651d86e..0bb2c5d5f 100644 --- a/plugins/carlabase/carla.cpp +++ b/plugins/carlabase/carla.cpp @@ -24,6 +24,7 @@ #include "carla.h" +#include "AudioEngine.h" #include "Engine.h" #include "Song.h" #include "GuiApplication.h" @@ -31,7 +32,6 @@ #include "InstrumentTrack.h" #include "MidiEventToByteSeq.h" #include "MainWindow.h" -#include "Mixer.h" #include "Song.h" #include "gui_templates.h" @@ -189,7 +189,7 @@ CarlaInstrument::CarlaInstrument(InstrumentTrack* const instrumentTrack, const D // we need a play-handle which cares for calling play() InstrumentPlayHandle * iph = new InstrumentPlayHandle( this, instrumentTrack ); - Engine::mixer()->addPlayHandle( iph ); + Engine::audioEngine()->addPlayHandle( iph ); #if CARLA_VERSION_HEX >= CARLA_MIN_PARAM_VERSION // text filter completion @@ -209,12 +209,12 @@ CarlaInstrument::CarlaInstrument(InstrumentTrack* const instrumentTrack, const D } #endif - connect(Engine::mixer(), SIGNAL(sampleRateChanged()), this, SLOT(sampleRateChanged())); + connect(Engine::audioEngine(), SIGNAL(sampleRateChanged()), this, SLOT(sampleRateChanged())); } CarlaInstrument::~CarlaInstrument() { - Engine::mixer()->removePlayHandlesOfTypes(instrumentTrack(), PlayHandle::TypeNotePlayHandle | PlayHandle::TypeInstrumentPlayHandle); + Engine::audioEngine()->removePlayHandlesOfTypes(instrumentTrack(), PlayHandle::TypeNotePlayHandle | PlayHandle::TypeInstrumentPlayHandle); if (fHost.resourceDir != NULL) { @@ -248,12 +248,12 @@ CarlaInstrument::~CarlaInstrument() uint32_t CarlaInstrument::handleGetBufferSize() const { - return Engine::mixer()->framesPerPeriod(); + return Engine::audioEngine()->framesPerPeriod(); } double CarlaInstrument::handleGetSampleRate() const { - return Engine::mixer()->processingSampleRate(); + return Engine::audioEngine()->processingSampleRate(); } bool CarlaInstrument::handleIsOffline() const @@ -496,7 +496,7 @@ void CarlaInstrument::loadSettings(const QDomElement& elem) void CarlaInstrument::play(sampleFrame* workingBuffer) { - const uint bufsize = Engine::mixer()->framesPerPeriod(); + const uint bufsize = Engine::audioEngine()->framesPerPeriod(); std::memset(workingBuffer, 0, sizeof(sample_t)*bufsize*DEFAULT_CHANNELS); diff --git a/plugins/dynamics_processor/dynamics_processor.cpp b/plugins/dynamics_processor/dynamics_processor.cpp index 38c74cf19..954864a4f 100644 --- a/plugins/dynamics_processor/dynamics_processor.cpp +++ b/plugins/dynamics_processor/dynamics_processor.cpp @@ -59,8 +59,8 @@ dynProcEffect::dynProcEffect( Model * _parent, m_dpControls( this ) { m_currentPeak[0] = m_currentPeak[1] = DYN_NOISE_FLOOR; - m_rms[0] = new RmsHelper( 64 * Engine::mixer()->processingSampleRate() / 44100 ); - m_rms[1] = new RmsHelper( 64 * Engine::mixer()->processingSampleRate() / 44100 ); + m_rms[0] = new RmsHelper( 64 * Engine::audioEngine()->processingSampleRate() / 44100 ); + m_rms[1] = new RmsHelper( 64 * Engine::audioEngine()->processingSampleRate() / 44100 ); calcAttack(); calcRelease(); } @@ -77,12 +77,12 @@ dynProcEffect::~dynProcEffect() inline void dynProcEffect::calcAttack() { - m_attCoeff = exp10( ( DNF_LOG / ( m_dpControls.m_attackModel.value() * 0.001 ) ) / Engine::mixer()->processingSampleRate() ); + m_attCoeff = exp10( ( DNF_LOG / ( m_dpControls.m_attackModel.value() * 0.001 ) ) / Engine::audioEngine()->processingSampleRate() ); } inline void dynProcEffect::calcRelease() { - m_relCoeff = exp10( ( -DNF_LOG / ( m_dpControls.m_releaseModel.value() * 0.001 ) ) / Engine::mixer()->processingSampleRate() ); + m_relCoeff = exp10( ( -DNF_LOG / ( m_dpControls.m_releaseModel.value() * 0.001 ) ) / Engine::audioEngine()->processingSampleRate() ); } @@ -118,8 +118,8 @@ bool dynProcEffect::processAudioBuffer( sampleFrame * _buf, if( m_needsUpdate ) { - m_rms[0]->setSize( 64 * Engine::mixer()->processingSampleRate() / 44100 ); - m_rms[1]->setSize( 64 * Engine::mixer()->processingSampleRate() / 44100 ); + m_rms[0]->setSize( 64 * Engine::audioEngine()->processingSampleRate() / 44100 ); + m_rms[1]->setSize( 64 * Engine::audioEngine()->processingSampleRate() / 44100 ); calcAttack(); calcRelease(); m_needsUpdate = false; diff --git a/plugins/dynamics_processor/dynamics_processor_controls.cpp b/plugins/dynamics_processor/dynamics_processor_controls.cpp index 55b0d569a..87db60894 100644 --- a/plugins/dynamics_processor/dynamics_processor_controls.cpp +++ b/plugins/dynamics_processor/dynamics_processor_controls.cpp @@ -48,7 +48,7 @@ dynProcControls::dynProcControls( dynProcEffect * _eff ) : { connect( &m_wavegraphModel, SIGNAL( samplesChanged( int, int ) ), this, SLOT( samplesChanged( int, int ) ) ); - connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( sampleRateChanged() ) ); + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( sampleRateChanged() ) ); setDefaultShape(); diff --git a/plugins/kicker/kicker.cpp b/plugins/kicker/kicker.cpp index fe770c1ac..b1a77d509 100644 --- a/plugins/kicker/kicker.cpp +++ b/plugins/kicker/kicker.cpp @@ -28,10 +28,10 @@ #include #include "kicker.h" +#include "AudioEngine.h" #include "Engine.h" #include "InstrumentTrack.h" #include "Knob.h" -#include "Mixer.h" #include "NotePlayHandle.h" #include "KickerOsc.h" @@ -166,8 +166,7 @@ void kickerInstrument::playNote( NotePlayHandle * _n, { const fpp_t frames = _n->framesLeftForCurrentPeriod(); const f_cnt_t offset = _n->noteOffset(); - const float decfr = m_decayModel.value() * - Engine::mixer()->processingSampleRate() / 1000.0f; + const float decfr = m_decayModel.value() * Engine::audioEngine()->processingSampleRate() / 1000.0f; const f_cnt_t tfp = _n->totalFramesPlayed(); if ( tfp == 0 ) @@ -191,7 +190,7 @@ void kickerInstrument::playNote( NotePlayHandle * _n, } SweepOsc * so = static_cast( _n->m_pluginData ); - so->update( _working_buffer + offset, frames, Engine::mixer()->processingSampleRate() ); + so->update( _working_buffer + offset, frames, Engine::audioEngine()->processingSampleRate() ); if( _n->isReleased() ) { diff --git a/plugins/ladspa_browser/ladspa_description.cpp b/plugins/ladspa_browser/ladspa_description.cpp index 600f64b6e..da195546c 100644 --- a/plugins/ladspa_browser/ladspa_description.cpp +++ b/plugins/ladspa_browser/ladspa_description.cpp @@ -31,9 +31,9 @@ #include #include "AudioDevice.h" +#include "AudioEngine.h" #include "Engine.h" #include "Ladspa2LMMS.h" -#include "Mixer.h" @@ -74,7 +74,7 @@ ladspaDescription::ladspaDescription( QWidget * _parent, { if( _type != VALID || manager->getDescription( ( *it ).second )->inputChannels - <= Engine::mixer()->audioDev()->channels() ) + <= Engine::audioEngine()->audioDev()->channels() ) { pluginNames.push_back( ( *it ).first ); m_pluginKeys.push_back( ( *it ).second ); diff --git a/plugins/ladspa_browser/ladspa_port_dialog.cpp b/plugins/ladspa_browser/ladspa_port_dialog.cpp index c213c6f02..f1301f744 100644 --- a/plugins/ladspa_browser/ladspa_port_dialog.cpp +++ b/plugins/ladspa_browser/ladspa_port_dialog.cpp @@ -28,10 +28,10 @@ #include #include +#include "AudioEngine.h" #include "embed.h" #include "Engine.h" #include "Ladspa2LMMS.h" -#include "Mixer.h" ladspaPortDialog::ladspaPortDialog( const ladspa_key_t & _key ) @@ -87,11 +87,11 @@ ladspaPortDialog::ladspaPortDialog( const ladspa_key_t & _key ) { if( min != NOHINT ) { - min *= Engine::mixer()->processingSampleRate(); + min *= Engine::audioEngine()->processingSampleRate(); } if( max != NOHINT ) { - max *= Engine::mixer()->processingSampleRate(); + max *= Engine::audioEngine()->processingSampleRate(); } } diff --git a/plugins/lb302/README b/plugins/lb302/README index b556d80d4..7ed09a0c1 100644 --- a/plugins/lb302/README +++ b/plugins/lb302/README @@ -27,8 +27,8 @@ BUG: without also using LB302, so I do not know if the problem is actually in the Bass Synth. I have gotten the backtraces a few times: ... - mixer::renderNextBuffer() - mixer::nextAudioBuffer() + audioEngine::renderNextBuffer() + audioEngine::nextAudioBuffer() QOBject::activate_signal() ??() diff --git a/plugins/lb302/lb302.cpp b/plugins/lb302/lb302.cpp index e9a518e3d..de26402aa 100644 --- a/plugins/lb302/lb302.cpp +++ b/plugins/lb302/lb302.cpp @@ -73,7 +73,7 @@ // -//#define engine::mixer()->processingSampleRate() 44100.0f +//#define engine::audioEngine()->processingSampleRate() 44100.0f const float sampleRateCutoff = 44100.0f; extern "C" @@ -112,8 +112,8 @@ void lb302Filter::recalc() { vcf_e1 = exp(6.109 + 1.5876*(fs->envmod) + 2.1553*(fs->cutoff) - 1.2*(1.0-(fs->reso))); vcf_e0 = exp(5.613 - 0.8*(fs->envmod) + 2.1553*(fs->cutoff) - 0.7696*(1.0-(fs->reso))); - vcf_e0*=M_PI/Engine::mixer()->processingSampleRate(); - vcf_e1*=M_PI/Engine::mixer()->processingSampleRate(); + vcf_e0*=M_PI/Engine::audioEngine()->processingSampleRate(); + vcf_e1*=M_PI/Engine::audioEngine()->processingSampleRate(); vcf_e1 -= vcf_e0; vcf_rescoeff = exp(-1.20 + 3.455*(fs->reso)); @@ -229,7 +229,7 @@ void lb302Filter3Pole::envRecalc() w = vcf_e0 + vcf_c0; k = (fs->cutoff > 0.975)?0.975:fs->cutoff; // sampleRateCutoff should not be changed to anything dynamic that is outside the - // scope of lb302 (like e.g. the mixers sample rate) as this changes the filters cutoff + // scope of lb302 (like e.g. the audio engine's sample rate) as this changes the filter's cutoff // behavior without any modification to its controls. kfco = 50.f + (k)*((2300.f-1600.f*(fs->envmod))+(w) * (700.f+1500.f*(k)+(1500.f+(k)*(sampleRateCutoff/2.f-6000.f)) * @@ -239,7 +239,7 @@ void lb302Filter3Pole::envRecalc() #ifdef LB_24_IGNORE_ENVELOPE // kfcn = fs->cutoff; - kfcn = 2.0 * kfco / Engine::mixer()->processingSampleRate(); + kfcn = 2.0 * kfco / Engine::audioEngine()->processingSampleRate(); #else kfcn = w; #endif @@ -294,7 +294,7 @@ lb302Synth::lb302Synth( InstrumentTrack * _instrumentTrack ) : vca_mode(never_played) { - connect( Engine::mixer(), SIGNAL( sampleRateChanged( ) ), + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged( ) ), this, SLOT ( filterChanged( ) ) ); connect( &vcf_cut_knob, SIGNAL( dataChanged( ) ), @@ -351,7 +351,7 @@ lb302Synth::lb302Synth( InstrumentTrack * _instrumentTrack ) : filterChanged(); InstrumentPlayHandle * iph = new InstrumentPlayHandle( this, _instrumentTrack ); - Engine::mixer()->addPlayHandle( iph ); + Engine::audioEngine()->addPlayHandle( iph ); } @@ -410,7 +410,7 @@ void lb302Synth::filterChanged() float d = 0.2 + (2.3*vcf_dec_knob.value()); - d *= Engine::mixer()->processingSampleRate(); // d *= smpl rate + d *= Engine::audioEngine()->processingSampleRate(); // d *= smpl rate fs.envdecay = pow(0.1, 1.0/d * ENVINC); // decay is 0.1 to the 1/d * ENVINC // vcf_envdecay is now adjusted for both // sampling rate and ENVINC @@ -444,7 +444,7 @@ void lb302Synth::recalcFilter() // THIS IS OLD 3pole/24dB code, I may reintegrate it. Don't need it // right now. Should be toggled by LB_24_RES_TRICK at the moment. - /*kfcn = 2.0 * (((vcf_cutoff*3000))) / engine::mixer()->processingSampleRate(); + /*kfcn = 2.0 * (((vcf_cutoff*3000))) / engine::audioEngine()->processingSampleRate(); kp = ((-2.7528*kfcn + 3.0429)*kfcn + 1.718)*kfcn - 0.9984; kp1 = kp+1.0; kp1h = 0.5*kp1; @@ -455,12 +455,12 @@ void lb302Synth::recalcFilter() } inline float GET_INC(float freq) { - return freq/Engine::mixer()->processingSampleRate(); // TODO: Use actual sampling rate. + return freq/Engine::audioEngine()->processingSampleRate(); // TODO: Use actual sampling rate. } int lb302Synth::process(sampleFrame *outbuf, const int size) { - const float sampleRatio = 44100.f / Engine::mixer()->processingSampleRate(); + const float sampleRatio = 44100.f / Engine::audioEngine()->processingSampleRate(); float w; float samp; @@ -635,7 +635,7 @@ int lb302Synth::process(sampleFrame *outbuf, const int size) // Handle Envelope if(vca_mode==attack) { vca_a+=(vca_a0-vca_a)*vca_attack; - if(sample_cnt>=0.5*Engine::mixer()->processingSampleRate()) + if(sample_cnt>=0.5*Engine::audioEngine()->processingSampleRate()) vca_mode = idle; } else if(vca_mode == decay) { @@ -787,7 +787,7 @@ void lb302Synth::play( sampleFrame * _working_buffer ) }; m_notesMutex.unlock(); - const fpp_t frames = Engine::mixer()->framesPerPeriod(); + const fpp_t frames = Engine::audioEngine()->framesPerPeriod(); process( _working_buffer, frames ); instrumentTrack()->processAudioBuffer( _working_buffer, frames, NULL ); diff --git a/plugins/monstro/Monstro.cpp b/plugins/monstro/Monstro.cpp index 816cfe550..e2d543db1 100644 --- a/plugins/monstro/Monstro.cpp +++ b/plugins/monstro/Monstro.cpp @@ -1006,9 +1006,9 @@ MonstroInstrument::MonstroInstrument( InstrumentTrack * _instrument_track ) : // updateSampleRate - connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( updateSamplerate() ) ); + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( updateSamplerate() ) ); - m_fpp = Engine::mixer()->framesPerPeriod(); + m_fpp = Engine::audioEngine()->framesPerPeriod(); updateSamplerate(); updateVolume1(); @@ -1419,7 +1419,7 @@ void MonstroInstrument::updateLFOAtts() void MonstroInstrument::updateSamplerate() { - m_samplerate = Engine::mixer()->processingSampleRate(); + m_samplerate = Engine::audioEngine()->processingSampleRate(); m_integrator = 0.5f - ( 0.5f - INTEGRATOR ) * 44100.0f / m_samplerate; m_fmCorrection = 44100.f / m_samplerate * FM_AMOUNT; diff --git a/plugins/nes/Nes.cpp b/plugins/nes/Nes.cpp index 802986304..40f39638e 100644 --- a/plugins/nes/Nes.cpp +++ b/plugins/nes/Nes.cpp @@ -25,13 +25,13 @@ #include #include "Nes.h" +#include "AudioEngine.h" #include "Engine.h" #include "InstrumentTrack.h" #include "ToolTip.h" #include "Song.h" #include "lmms_math.h" #include "interpolation.h" -#include "Mixer.h" #include "Oscillator.h" #include "embed.h" @@ -560,7 +560,7 @@ void NesInstrument::playNote( NotePlayHandle * n, sampleFrame * workingBuffer ) if ( n->totalFramesPlayed() == 0 || n->m_pluginData == NULL ) { - NesObject * nes = new NesObject( this, Engine::mixer()->processingSampleRate(), n ); + NesObject * nes = new NesObject( this, Engine::audioEngine()->processingSampleRate(), n ); n->m_pluginData = nes; } diff --git a/plugins/organic/organic.cpp b/plugins/organic/organic.cpp index c78d5c056..bc1e3e671 100644 --- a/plugins/organic/organic.cpp +++ b/plugins/organic/organic.cpp @@ -31,9 +31,9 @@ #include "Engine.h" +#include "AudioEngine.h" #include "InstrumentTrack.h" #include "Knob.h" -#include "Mixer.h" #include "NotePlayHandle.h" #include "Oscillator.h" #include "PixmapButton.h" @@ -143,7 +143,7 @@ organicInstrument::organicInstrument( InstrumentTrack * _instrument_track ) : } - connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( updateAllDetuning() ) ); } @@ -622,10 +622,10 @@ void OscillatorObject::updateDetuning() { m_detuningLeft = powf( 2.0f, organicInstrument::s_harmonics[ static_cast( m_harmModel.value() ) ] + (float)m_detuneModel.value() * CENT ) / - Engine::mixer()->processingSampleRate(); + Engine::audioEngine()->processingSampleRate(); m_detuningRight = powf( 2.0f, organicInstrument::s_harmonics[ static_cast( m_harmModel.value() ) ] - (float)m_detuneModel.value() * CENT ) / - Engine::mixer()->processingSampleRate(); + Engine::audioEngine()->processingSampleRate(); } diff --git a/plugins/sf2_player/sf2_player.cpp b/plugins/sf2_player/sf2_player.cpp index 7a07b0ec6..1eb669053 100644 --- a/plugins/sf2_player/sf2_player.cpp +++ b/plugins/sf2_player/sf2_player.cpp @@ -30,6 +30,7 @@ #include #include +#include "AudioEngine.h" #include "ConfigManager.h" #include "FileDialog.h" #include "ConfigManager.h" @@ -37,7 +38,6 @@ #include "InstrumentTrack.h" #include "InstrumentPlayHandle.h" #include "Knob.h" -#include "Mixer.h" #include "NotePlayHandle.h" #include "PathUtil.h" #include "SampleBuffer.h" @@ -124,7 +124,7 @@ sf2Instrument::sf2Instrument( InstrumentTrack * _instrument_track ) : #endif m_settings = new_fluid_settings(); - //fluid_settings_setint( m_settings, (char *) "audio.period-size", engine::mixer()->framesPerPeriod() ); + //fluid_settings_setint( m_settings, (char *) "audio.period-size", engine::audioEngine()->framesPerPeriod() ); // This is just our starting instance of synth. It is recreated // everytime we load a new soundfont. @@ -165,7 +165,7 @@ sf2Instrument::sf2Instrument( InstrumentTrack * _instrument_track ) : connect( &m_bankNum, SIGNAL( dataChanged() ), this, SLOT( updatePatch() ) ); connect( &m_patchNum, SIGNAL( dataChanged() ), this, SLOT( updatePatch() ) ); - connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( updateSampleRate() ) ); + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( updateSampleRate() ) ); // Gain connect( &m_gain, SIGNAL( dataChanged() ), this, SLOT( updateGain() ) ); @@ -185,14 +185,14 @@ sf2Instrument::sf2Instrument( InstrumentTrack * _instrument_track ) : connect( &m_chorusDepth, SIGNAL( dataChanged() ), this, SLOT( updateChorus() ) ); InstrumentPlayHandle * iph = new InstrumentPlayHandle( this, _instrument_track ); - Engine::mixer()->addPlayHandle( iph ); + Engine::audioEngine()->addPlayHandle( iph ); } sf2Instrument::~sf2Instrument() { - Engine::mixer()->removePlayHandlesOfTypes( instrumentTrack(), + Engine::audioEngine()->removePlayHandlesOfTypes( instrumentTrack(), PlayHandle::TypeNotePlayHandle | PlayHandle::TypeInstrumentPlayHandle ); freeFont(); @@ -549,7 +549,7 @@ void sf2Instrument::updateSampleRate() double tempRate; // Set & get, returns the true sample rate - fluid_settings_setnum( m_settings, (char *) "synth.sample-rate", Engine::mixer()->processingSampleRate() ); + fluid_settings_setnum( m_settings, (char *) "synth.sample-rate", Engine::audioEngine()->processingSampleRate() ); fluid_settings_getnum( m_settings, (char *) "synth.sample-rate", &tempRate ); m_internalSampleRate = static_cast( tempRate ); @@ -578,8 +578,8 @@ void sf2Instrument::updateSampleRate() } m_synthMutex.lock(); - if( Engine::mixer()->currentQualitySettings().interpolation >= - Mixer::qualitySettings::Interpolation_SincFastest ) + if( Engine::audioEngine()->currentQualitySettings().interpolation >= + AudioEngine::qualitySettings::Interpolation_SincFastest ) { fluid_synth_set_interp_method( m_synth, -1, FLUID_INTERP_7THORDER ); } @@ -588,7 +588,7 @@ void sf2Instrument::updateSampleRate() fluid_synth_set_interp_method( m_synth, -1, FLUID_INTERP_DEFAULT ); } m_synthMutex.unlock(); - if( m_internalSampleRate < Engine::mixer()->processingSampleRate() ) + if( m_internalSampleRate < Engine::audioEngine()->processingSampleRate() ) { m_synthMutex.lock(); if( m_srcState != NULL ) @@ -596,7 +596,7 @@ void sf2Instrument::updateSampleRate() src_delete( m_srcState ); } int error; - m_srcState = src_new( Engine::mixer()->currentQualitySettings().libsrcInterpolation(), DEFAULT_CHANNELS, &error ); + m_srcState = src_new( Engine::audioEngine()->currentQualitySettings().libsrcInterpolation(), DEFAULT_CHANNELS, &error ); if( m_srcState == NULL || error ) { qCritical( "error while creating libsamplerate data structure in Sf2Instrument::updateSampleRate()" ); @@ -728,7 +728,7 @@ void sf2Instrument::noteOff( SF2PluginData * n ) void sf2Instrument::play( sampleFrame * _working_buffer ) { - const fpp_t frames = Engine::mixer()->framesPerPeriod(); + const fpp_t frames = Engine::audioEngine()->framesPerPeriod(); // set midi pitch for this period const int currentMidiPitch = instrumentTrack()->midiPitch(); @@ -817,10 +817,10 @@ void sf2Instrument::play( sampleFrame * _working_buffer ) void sf2Instrument::renderFrames( f_cnt_t frames, sampleFrame * buf ) { m_synthMutex.lock(); - if( m_internalSampleRate < Engine::mixer()->processingSampleRate() && + if( m_internalSampleRate < Engine::audioEngine()->processingSampleRate() && m_srcState != NULL ) { - const fpp_t f = frames * m_internalSampleRate / Engine::mixer()->processingSampleRate(); + const fpp_t f = frames * m_internalSampleRate / Engine::audioEngine()->processingSampleRate(); #ifdef __GNUC__ sampleFrame tmp[f]; #else diff --git a/plugins/sfxr/sfxr.cpp b/plugins/sfxr/sfxr.cpp index ef801e0f5..6011aabc1 100644 --- a/plugins/sfxr/sfxr.cpp +++ b/plugins/sfxr/sfxr.cpp @@ -40,6 +40,7 @@ float frnd(float range) #include #include "sfxr.h" +#include "AudioEngine.h" #include "Engine.h" #include "InstrumentTrack.h" #include "Knob.h" @@ -49,7 +50,6 @@ float frnd(float range) #include "ToolTip.h" #include "Song.h" #include "MidiEvent.h" -#include "Mixer.h" #include "embed.h" @@ -455,7 +455,7 @@ QString sfxrInstrument::nodeName() const void sfxrInstrument::playNote( NotePlayHandle * _n, sampleFrame * _working_buffer ) { - float currentSampleRate = Engine::mixer()->processingSampleRate(); + float currentSampleRate = Engine::audioEngine()->processingSampleRate(); fpp_t frameNum = _n->framesLeftForCurrentPeriod(); const f_cnt_t offset = _n->noteOffset(); diff --git a/plugins/stk/mallets/mallets.cpp b/plugins/stk/mallets/mallets.cpp index 6f968985c..05836edeb 100644 --- a/plugins/stk/mallets/mallets.cpp +++ b/plugins/stk/mallets/mallets.cpp @@ -33,12 +33,12 @@ #include "ModalBar.h" #include "TubeBell.h" +#include "AudioEngine.h" #include "ConfigManager.h" #include "Engine.h" #include "gui_templates.h" #include "GuiApplication.h" #include "InstrumentTrack.h" -#include "Mixer.h" #include "embed.h" #include "plugin_export.h" @@ -309,7 +309,7 @@ void malletsInstrument::playNote( NotePlayHandle * _n, m_vibratoFreqModel.value(), p, (uint8_t) m_spreadModel.value(), - Engine::mixer()->processingSampleRate() ); + Engine::audioEngine()->processingSampleRate() ); } else if( p == 9 ) { @@ -322,7 +322,7 @@ void malletsInstrument::playNote( NotePlayHandle * _n, m_lfoSpeedModel.value(), m_adsrModel.value(), (uint8_t) m_spreadModel.value(), - Engine::mixer()->processingSampleRate() ); + Engine::audioEngine()->processingSampleRate() ); } else { @@ -335,7 +335,7 @@ void malletsInstrument::playNote( NotePlayHandle * _n, m_strikeModel.value() * 128.0, m_velocityModel.value(), (uint8_t) m_spreadModel.value(), - Engine::mixer()->processingSampleRate() ); + Engine::audioEngine()->processingSampleRate() ); } m.unlock(); static_cast(_n->m_pluginData)->setPresetIndex(p); diff --git a/plugins/triple_oscillator/TripleOscillator.cpp b/plugins/triple_oscillator/TripleOscillator.cpp index a6d5a0570..6d8a00d46 100644 --- a/plugins/triple_oscillator/TripleOscillator.cpp +++ b/plugins/triple_oscillator/TripleOscillator.cpp @@ -28,12 +28,12 @@ #include #include "TripleOscillator.h" +#include "AudioEngine.h" #include "AutomatableButton.h" #include "debug.h" #include "Engine.h" #include "InstrumentTrack.h" #include "Knob.h" -#include "Mixer.h" #include "NotePlayHandle.h" #include "PixmapButton.h" #include "SampleBuffer.h" @@ -181,7 +181,7 @@ void OscillatorObject::updateDetuningLeft() { m_detuningLeft = powf( 2.0f, ( (float)m_coarseModel.value() * 100.0f + (float)m_fineLeftModel.value() ) / 1200.0f ) - / Engine::mixer()->processingSampleRate(); + / Engine::audioEngine()->processingSampleRate(); } @@ -191,7 +191,7 @@ void OscillatorObject::updateDetuningRight() { m_detuningRight = powf( 2.0f, ( (float)m_coarseModel.value() * 100.0f + (float)m_fineRightModel.value() ) / 1200.0f ) - / Engine::mixer()->processingSampleRate(); + / Engine::audioEngine()->processingSampleRate(); } @@ -228,7 +228,7 @@ TripleOscillator::TripleOscillator( InstrumentTrack * _instrument_track ) : } - connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( updateAllDetuning() ) ); } diff --git a/plugins/vestige/vestige.cpp b/plugins/vestige/vestige.cpp index 421cc7240..f5918b3de 100644 --- a/plugins/vestige/vestige.cpp +++ b/plugins/vestige/vestige.cpp @@ -40,6 +40,7 @@ #include +#include "AudioEngine.h" #include "BufferManager.h" #include "ConfigManager.h" #include "Engine.h" @@ -50,7 +51,6 @@ #include "InstrumentTrack.h" #include "LocaleHelper.h" #include "MainWindow.h" -#include "Mixer.h" #include "PathUtil.h" #include "PixmapButton.h" #include "SampleBuffer.h" @@ -156,7 +156,7 @@ vestigeInstrument::vestigeInstrument( InstrumentTrack * _instrument_track ) : { // now we need a play-handle which cares for calling play() InstrumentPlayHandle * iph = new InstrumentPlayHandle( this, _instrument_track ); - Engine::mixer()->addPlayHandle( iph ); + Engine::audioEngine()->addPlayHandle( iph ); connect( ConfigManager::inst(), SIGNAL( valueChanged(QString,QString,QString) ), this, SLOT( handleConfigChange(QString, QString, QString) ), @@ -178,7 +178,7 @@ vestigeInstrument::~vestigeInstrument() knobFModel = NULL; } - Engine::mixer()->removePlayHandlesOfTypes( instrumentTrack(), + Engine::audioEngine()->removePlayHandlesOfTypes( instrumentTrack(), PlayHandle::TypeNotePlayHandle | PlayHandle::TypeInstrumentPlayHandle ); closePlugin(); @@ -393,7 +393,7 @@ void vestigeInstrument::play( sampleFrame * _buf ) { if (!m_pluginMutex.tryLock(Engine::getSong()->isExporting() ? -1 : 0)) {return;} - const fpp_t frames = Engine::mixer()->framesPerPeriod(); + const fpp_t frames = Engine::audioEngine()->framesPerPeriod(); if( m_plugin == NULL ) { @@ -702,7 +702,7 @@ void VestigeInstrumentView::openPlugin() { return; } - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); if (m_vi->p_subWindow != NULL) { delete m_vi->p_subWindow; @@ -710,7 +710,7 @@ void VestigeInstrumentView::openPlugin() } m_vi->loadFile( ofd.selectedFiles()[0] ); - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); if( m_vi->m_plugin && m_vi->m_plugin->pluginWidget() ) { m_vi->m_plugin->pluginWidget()->setWindowIcon( diff --git a/plugins/vibed/vibed.cpp b/plugins/vibed/vibed.cpp index 6610bab0e..746995d42 100644 --- a/plugins/vibed/vibed.cpp +++ b/plugins/vibed/vibed.cpp @@ -26,9 +26,9 @@ #include #include "vibed.h" +#include "AudioEngine.h" #include "Engine.h" #include "InstrumentTrack.h" -#include "Mixer.h" #include "NotePlayHandle.h" #include "ToolTip.h" #include "base64.h" @@ -276,7 +276,7 @@ void vibed::playNote( NotePlayHandle * _n, sampleFrame * _working_buffer ) if ( _n->totalFramesPlayed() == 0 || _n->m_pluginData == NULL ) { _n->m_pluginData = new stringContainer( _n->frequency(), - Engine::mixer()->processingSampleRate(), + Engine::audioEngine()->processingSampleRate(), __sampleLength ); for( int i = 0; i < 9; ++i ) diff --git a/plugins/vibed/vibrating_string.cpp b/plugins/vibed/vibrating_string.cpp index 14a666bbd..117d878e7 100644 --- a/plugins/vibed/vibrating_string.cpp +++ b/plugins/vibed/vibrating_string.cpp @@ -25,7 +25,7 @@ #include "vibrating_string.h" #include "interpolation.h" -#include "Mixer.h" +#include "AudioEngine.h" #include "Engine.h" @@ -41,7 +41,7 @@ vibratingString::vibratingString( float _pitch, float _detune, bool _state ) : m_oversample( 2 * _oversample / (int)( _sample_rate / - Engine::mixer()->baseSampleRate() ) ), + Engine::audioEngine()->baseSampleRate() ) ), m_randomize( _randomize ), m_stringLoss( 1.0f - _string_loss ), m_state( 0.1f ) diff --git a/plugins/vst_base/VstPlugin.cpp b/plugins/vst_base/VstPlugin.cpp index a08ef072d..53d8cd315 100644 --- a/plugins/vst_base/VstPlugin.cpp +++ b/plugins/vst_base/VstPlugin.cpp @@ -50,11 +50,11 @@ # include #endif +#include "AudioEngine.h" #include "ConfigManager.h" #include "GuiApplication.h" #include "LocaleHelper.h" #include "MainWindow.h" -#include "Mixer.h" #include "PathUtil.h" #include "Song.h" #include "FileDialog.h" @@ -154,7 +154,7 @@ VstPlugin::VstPlugin( const QString & _plugin ) : connect( Engine::getSong(), SIGNAL( tempoChanged( bpm_t ) ), this, SLOT( setTempo( bpm_t ) ), Qt::DirectConnection ); - connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( updateSampleRate() ) ); // update once per second @@ -308,7 +308,7 @@ void VstPlugin::updateSampleRate() { lock(); sendMessage( message( IdSampleRateInformation ). - addInt( Engine::mixer()->processingSampleRate() ) ); + addInt( Engine::audioEngine()->processingSampleRate() ) ); waitForMessage( IdInformationUpdated, true ); unlock(); } diff --git a/plugins/watsyn/Watsyn.cpp b/plugins/watsyn/Watsyn.cpp index b60dd5a99..6736cbf4e 100644 --- a/plugins/watsyn/Watsyn.cpp +++ b/plugins/watsyn/Watsyn.cpp @@ -26,12 +26,12 @@ #include "Watsyn.h" #include "base64.h" +#include "AudioEngine.h" #include "Engine.h" #include "InstrumentTrack.h" #include "ToolTip.h" #include "Song.h" #include "lmms_math.h" -#include "Mixer.h" #include "interpolation.h" #include "embed.h" @@ -338,8 +338,8 @@ void WatsynInstrument::playNote( NotePlayHandle * _n, &B1_wave[0], &B2_wave[0], m_amod.value(), m_bmod.value(), - Engine::mixer()->processingSampleRate(), _n, - Engine::mixer()->framesPerPeriod(), this ); + Engine::audioEngine()->processingSampleRate(), _n, + Engine::audioEngine()->framesPerPeriod(), this ); _n->m_pluginData = w; } @@ -365,7 +365,7 @@ void WatsynInstrument::playNote( NotePlayHandle * _n, // if sample-exact is enabled, use sample-exact calculations... // disabled pending proper implementation of sample-exactness -/* if( engine::mixer()->currentQualitySettings().sampleExactControllers ) +/* if( engine::audioEngine()->currentQualitySettings().sampleExactControllers ) { for( fpp_t f=0; f < frames; f++ ) { diff --git a/plugins/zynaddsubfx/ZynAddSubFx.cpp b/plugins/zynaddsubfx/ZynAddSubFx.cpp index 94f480ce0..02dbb7519 100644 --- a/plugins/zynaddsubfx/ZynAddSubFx.cpp +++ b/plugins/zynaddsubfx/ZynAddSubFx.cpp @@ -45,7 +45,7 @@ #include "StringPairDrag.h" #include "RemoteZynAddSubFx.h" #include "LocalZynAddSubFx.h" -#include "Mixer.h" +#include "AudioEngine.h" #include "ControllerConnection.h" #include "Clipboard.h" @@ -140,9 +140,9 @@ ZynAddSubFxInstrument::ZynAddSubFxInstrument( // now we need a play-handle which cares for calling play() InstrumentPlayHandle * iph = new InstrumentPlayHandle( this, _instrumentTrack ); - Engine::mixer()->addPlayHandle( iph ); + Engine::audioEngine()->addPlayHandle( iph ); - connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( reloadPlugin() ) ); connect( instrumentTrack()->pitchRangeModel(), SIGNAL( dataChanged() ), @@ -154,7 +154,7 @@ ZynAddSubFxInstrument::ZynAddSubFxInstrument( ZynAddSubFxInstrument::~ZynAddSubFxInstrument() { - Engine::mixer()->removePlayHandlesOfTypes( instrumentTrack(), + Engine::audioEngine()->removePlayHandlesOfTypes( instrumentTrack(), PlayHandle::TypeNotePlayHandle | PlayHandle::TypeInstrumentPlayHandle ); @@ -345,7 +345,7 @@ void ZynAddSubFxInstrument::play( sampleFrame * _buf ) m_plugin->processAudio( _buf ); } m_pluginMutex.unlock(); - instrumentTrack()->processAudioBuffer( _buf, Engine::mixer()->framesPerPeriod(), NULL ); + instrumentTrack()->processAudioBuffer( _buf, Engine::audioEngine()->framesPerPeriod(), NULL ); } @@ -457,11 +457,11 @@ void ZynAddSubFxInstrument::initPlugin() QDir( ConfigManager::inst()->factoryPresetsDir() + "/ZynAddSubFX" ).absolutePath() ) ) ); - m_remotePlugin->updateSampleRate( Engine::mixer()->processingSampleRate() ); + m_remotePlugin->updateSampleRate( Engine::audioEngine()->processingSampleRate() ); // temporary workaround until the VST synchronization feature gets stripped out of the RemotePluginClient class // causing not to send buffer size information requests - m_remotePlugin->sendMessage( RemotePlugin::message( IdBufferSizeInformation ).addInt( Engine::mixer()->framesPerPeriod() ) ); + m_remotePlugin->sendMessage( RemotePlugin::message( IdBufferSizeInformation ).addInt( Engine::audioEngine()->framesPerPeriod() ) ); m_remotePlugin->showUI(); m_remotePlugin->unlock(); @@ -469,8 +469,8 @@ void ZynAddSubFxInstrument::initPlugin() else { m_plugin = new LocalZynAddSubFx; - m_plugin->setSampleRate( Engine::mixer()->processingSampleRate() ); - m_plugin->setBufferSize( Engine::mixer()->framesPerPeriod() ); + m_plugin->setSampleRate( Engine::audioEngine()->processingSampleRate() ); + m_plugin->setBufferSize( Engine::audioEngine()->framesPerPeriod() ); } m_pluginMutex.unlock(); diff --git a/src/core/Mixer.cpp b/src/core/AudioEngine.cpp similarity index 87% rename from src/core/Mixer.cpp rename to src/core/AudioEngine.cpp index 1690b0d91..8a5778522 100644 --- a/src/core/Mixer.cpp +++ b/src/core/AudioEngine.cpp @@ -1,5 +1,5 @@ /* - * Mixer.cpp - audio-device-independent mixer for LMMS + * AudioEngine.cpp - device-independent audio engine for LMMS * * Copyright (c) 2004-2014 Tobias Doerffel * @@ -22,15 +22,15 @@ * */ -#include "Mixer.h" +#include "AudioEngine.h" #include "denormals.h" #include "lmmsconfig.h" +#include "AudioEngineWorkerThread.h" #include "AudioPort.h" #include "FxMixer.h" -#include "MixerWorkerThread.h" #include "Song.h" #include "EnvelopeAndLfoParameters.h" #include "NotePlayHandle.h" @@ -69,7 +69,7 @@ static thread_local bool s_renderingThread; -Mixer::Mixer( bool renderOnly ) : +AudioEngine::AudioEngine( bool renderOnly ) : m_renderOnly( renderOnly ), m_framesPerPeriod( DEFAULT_BUFFER_SIZE ), m_inputBufferRead( 0 ), @@ -145,7 +145,7 @@ Mixer::Mixer( bool renderOnly ) : for( int i = 0; i < m_numWorkers+1; ++i ) { - MixerWorkerThread * wt = new MixerWorkerThread( this ); + AudioEngineWorkerThread * wt = new AudioEngineWorkerThread( this ); if( i < m_numWorkers ) { wt->start( QThread::TimeCriticalPriority ); @@ -157,7 +157,7 @@ Mixer::Mixer( bool renderOnly ) : -Mixer::~Mixer() +AudioEngine::~AudioEngine() { runChangesInModel(); @@ -166,7 +166,7 @@ Mixer::~Mixer() m_workers[w]->quit(); } - MixerWorkerThread::startAndWaitForJobs(); + AudioEngineWorkerThread::startAndWaitForJobs(); for( int w = 0; w < m_numWorkers; ++w ) { @@ -194,7 +194,7 @@ Mixer::~Mixer() -void Mixer::initDevices() +void AudioEngine::initDevices() { bool success_ful = false; if( m_renderOnly ) { @@ -213,7 +213,7 @@ void Mixer::initDevices() -void Mixer::startProcessing(bool needsFifo) +void AudioEngine::startProcessing(bool needsFifo) { if (needsFifo) { @@ -233,7 +233,7 @@ void Mixer::startProcessing(bool needsFifo) -void Mixer::stopProcessing() +void AudioEngine::stopProcessing() { m_isProcessing = false; @@ -254,7 +254,7 @@ void Mixer::stopProcessing() -sample_rate_t Mixer::baseSampleRate() const +sample_rate_t AudioEngine::baseSampleRate() const { sample_rate_t sr = ConfigManager::inst()->value( "mixer", "samplerate" ).toInt(); @@ -268,7 +268,7 @@ sample_rate_t Mixer::baseSampleRate() const -sample_rate_t Mixer::outputSampleRate() const +sample_rate_t AudioEngine::outputSampleRate() const { return m_audioDev != NULL ? m_audioDev->sampleRate() : baseSampleRate(); @@ -277,7 +277,7 @@ sample_rate_t Mixer::outputSampleRate() const -sample_rate_t Mixer::inputSampleRate() const +sample_rate_t AudioEngine::inputSampleRate() const { return m_audioDev != NULL ? m_audioDev->sampleRate() : baseSampleRate(); @@ -286,7 +286,7 @@ sample_rate_t Mixer::inputSampleRate() const -sample_rate_t Mixer::processingSampleRate() const +sample_rate_t AudioEngine::processingSampleRate() const { return outputSampleRate() * m_qualitySettings.sampleRateMultiplier(); } @@ -294,7 +294,7 @@ sample_rate_t Mixer::processingSampleRate() const -bool Mixer::criticalXRuns() const +bool AudioEngine::criticalXRuns() const { return cpuLoad() >= 99 && Engine::getSong()->isExporting() == false; } @@ -302,7 +302,7 @@ bool Mixer::criticalXRuns() const -void Mixer::pushInputFrames( sampleFrame * _ab, const f_cnt_t _frames ) +void AudioEngine::pushInputFrames( sampleFrame * _ab, const f_cnt_t _frames ) { requestChangeInModel(); @@ -332,7 +332,7 @@ void Mixer::pushInputFrames( sampleFrame * _ab, const f_cnt_t _frames ) -const surroundSampleFrame * Mixer::renderNextBuffer() +const surroundSampleFrame * AudioEngine::renderNextBuffer() { m_profiler.startPeriod(); @@ -387,8 +387,8 @@ const surroundSampleFrame * Mixer::renderNextBuffer() } // STAGE 1: run and render all play handles - MixerWorkerThread::fillJobQueue( m_playHandles ); - MixerWorkerThread::startAndWaitForJobs(); + AudioEngineWorkerThread::fillJobQueue( m_playHandles ); + AudioEngineWorkerThread::startAndWaitForJobs(); // removed all play handles which are done for( PlayHandleList::Iterator it = m_playHandles.begin(); @@ -417,8 +417,8 @@ const surroundSampleFrame * Mixer::renderNextBuffer() } // STAGE 2: process effects of all instrument- and sampletracks - MixerWorkerThread::fillJobQueue >( m_audioPorts ); - MixerWorkerThread::startAndWaitForJobs(); + AudioEngineWorkerThread::fillJobQueue >( m_audioPorts ); + AudioEngineWorkerThread::startAndWaitForJobs(); // STAGE 3: do master mix in FX mixer @@ -444,7 +444,7 @@ const surroundSampleFrame * Mixer::renderNextBuffer() -void Mixer::swapBuffers() +void AudioEngine::swapBuffers() { m_inputBufferWrite = (m_inputBufferWrite + 1) % 2; m_inputBufferRead = (m_inputBufferRead + 1) % 2; @@ -457,7 +457,7 @@ void Mixer::swapBuffers() -void Mixer::handleMetronome() +void AudioEngine::handleMetronome() { static tick_t lastMetroTicks = -1; @@ -503,7 +503,7 @@ void Mixer::handleMetronome() -void Mixer::clear() +void AudioEngine::clear() { m_clearSignal = true; } @@ -511,7 +511,7 @@ void Mixer::clear() -void Mixer::clearNewPlayHandles() +void AudioEngine::clearNewPlayHandles() { requestChangeInModel(); for( LocklessListElement * e = m_newPlayHandles.popList(); e; ) @@ -527,7 +527,7 @@ void Mixer::clearNewPlayHandles() // removes all play-handles. this is necessary, when the song is stopped -> // all remaining notes etc. would be played until their end -void Mixer::clearInternal() +void AudioEngine::clearInternal() { // TODO: m_midiClient->noteOffAll(); for (auto ph : m_playHandles) @@ -536,14 +536,13 @@ void Mixer::clearInternal() { m_playHandlesToRemove.push_back(ph); } - } } -Mixer::StereoSample Mixer::getPeakValues(sampleFrame * ab, const f_cnt_t frames) const +AudioEngine::StereoSample AudioEngine::getPeakValues(sampleFrame * ab, const f_cnt_t frames) const { sample_t peakLeft = 0.0f; sample_t peakRight = 0.0f; @@ -569,7 +568,7 @@ Mixer::StereoSample Mixer::getPeakValues(sampleFrame * ab, const f_cnt_t frames) -void Mixer::changeQuality(const struct qualitySettings & qs) +void AudioEngine::changeQuality(const struct qualitySettings & qs) { // don't delete the audio-device stopProcessing(); @@ -586,7 +585,7 @@ void Mixer::changeQuality(const struct qualitySettings & qs) -void Mixer::doSetAudioDevice( AudioDevice * _dev ) +void AudioEngine::doSetAudioDevice( AudioDevice * _dev ) { // TODO: Use shared_ptr here in the future. // Currently, this is safe, because this is only called by @@ -600,7 +599,7 @@ void Mixer::doSetAudioDevice( AudioDevice * _dev ) } else { - printf( "param _dev == NULL in Mixer::setAudioDevice(...). " + printf( "param _dev == NULL in AudioEngine::setAudioDevice(...). " "Trying any working audio-device\n" ); m_audioDev = tryAudioDevices(); } @@ -609,7 +608,7 @@ void Mixer::doSetAudioDevice( AudioDevice * _dev ) -void Mixer::setAudioDevice(AudioDevice * _dev, +void AudioEngine::setAudioDevice(AudioDevice * _dev, const struct qualitySettings & _qs, bool _needs_fifo, bool startNow) @@ -629,7 +628,7 @@ void Mixer::setAudioDevice(AudioDevice * _dev, -void Mixer::storeAudioDevice() +void AudioEngine::storeAudioDevice() { if( !m_oldAudioDev ) { @@ -640,7 +639,7 @@ void Mixer::storeAudioDevice() -void Mixer::restoreAudioDevice() +void AudioEngine::restoreAudioDevice() { if( m_oldAudioDev && m_audioDev != m_oldAudioDev ) { @@ -658,7 +657,7 @@ void Mixer::restoreAudioDevice() -void Mixer::removeAudioPort(AudioPort * port) +void AudioEngine::removeAudioPort(AudioPort * port) { requestChangeInModel(); @@ -671,7 +670,7 @@ void Mixer::removeAudioPort(AudioPort * port) } -bool Mixer::addPlayHandle( PlayHandle* handle ) +bool AudioEngine::addPlayHandle( PlayHandle* handle ) { if( criticalXRuns() == false ) { @@ -690,11 +689,11 @@ bool Mixer::addPlayHandle( PlayHandle* handle ) } -void Mixer::removePlayHandle(PlayHandle * ph) +void AudioEngine::removePlayHandle(PlayHandle * ph) { requestChangeInModel(); // check thread affinity as we must not delete play-handles - // which were created in a thread different than mixer thread + // which were created in a thread different than the audio engine thread if (ph->affinityMatters() && ph->affinity() == QThread::currentThread()) { ph->audioPort()->removePlayHandle(ph); @@ -748,7 +747,7 @@ void Mixer::removePlayHandle(PlayHandle * ph) -void Mixer::removePlayHandlesOfTypes(Track * track, const quint8 types) +void AudioEngine::removePlayHandlesOfTypes(Track * track, const quint8 types) { requestChangeInModel(); PlayHandleList::Iterator it = m_playHandles.begin(); @@ -775,7 +774,7 @@ void Mixer::removePlayHandlesOfTypes(Track * track, const quint8 types) -void Mixer::requestChangeInModel() +void AudioEngine::requestChangeInModel() { if( s_renderingThread ) return; @@ -797,7 +796,7 @@ void Mixer::requestChangeInModel() -void Mixer::doneChangeInModel() +void AudioEngine::doneChangeInModel() { if( s_renderingThread ) return; @@ -809,7 +808,7 @@ void Mixer::doneChangeInModel() if( !moreChanges ) { m_changesSignal = false; - m_changesMixerCondition.wakeOne(); + m_changesAudioEngineCondition.wakeOne(); } m_doChangesMutex.unlock(); } @@ -817,7 +816,7 @@ void Mixer::doneChangeInModel() -void Mixer::runChangesInModel() +void AudioEngine::runChangesInModel() { if( m_changesSignal ) { @@ -825,12 +824,12 @@ void Mixer::runChangesInModel() // allow changes in the model from other threads ... m_changesRequestCondition.wakeOne(); // ... and wait until they are done - m_changesMixerCondition.wait( &m_waitChangesMutex ); + m_changesAudioEngineCondition.wait( &m_waitChangesMutex ); m_waitChangesMutex.unlock(); } } -bool Mixer::isAudioDevNameValid(QString name) +bool AudioEngine::isAudioDevNameValid(QString name) { #ifdef LMMS_HAVE_SDL if (name == AudioSdl::name()) @@ -901,7 +900,7 @@ bool Mixer::isAudioDevNameValid(QString name) return false; } -bool Mixer::isMidiDevNameValid(QString name) +bool AudioEngine::isMidiDevNameValid(QString name) { #ifdef LMMS_HAVE_ALSA if (name == MidiAlsaSeq::name() || name == MidiAlsaRaw::name()) @@ -953,7 +952,7 @@ bool Mixer::isMidiDevNameValid(QString name) return false; } -AudioDevice * Mixer::tryAudioDevices() +AudioDevice * AudioEngine::tryAudioDevices() { bool success_ful = false; AudioDevice * dev = NULL; @@ -1101,7 +1100,7 @@ AudioDevice * Mixer::tryAudioDevices() -MidiClient * Mixer::tryMidiClients() +MidiClient * AudioEngine::tryMidiClients() { QString client_name = ConfigManager::inst()->value( "mixer", "mididev" ); @@ -1224,18 +1223,18 @@ MidiClient * Mixer::tryMidiClients() -Mixer::fifoWriter::fifoWriter( Mixer* mixer, Fifo * fifo ) : - m_mixer( mixer ), +AudioEngine::fifoWriter::fifoWriter( AudioEngine* audioEngine, Fifo * fifo ) : + m_audioEngine( audioEngine ), m_fifo( fifo ), m_writing( true ) { - setObjectName("Mixer::fifoWriter"); + setObjectName("AudioEngine::fifoWriter"); } -void Mixer::fifoWriter::finish() +void AudioEngine::fifoWriter::finish() { m_writing = false; } @@ -1243,7 +1242,7 @@ void Mixer::fifoWriter::finish() -void Mixer::fifoWriter::run() +void AudioEngine::fifoWriter::run() { disable_denormals(); @@ -1258,11 +1257,11 @@ void Mixer::fifoWriter::run() #endif #endif - const fpp_t frames = m_mixer->framesPerPeriod(); + const fpp_t frames = m_audioEngine->framesPerPeriod(); while( m_writing ) { surroundSampleFrame * buffer = new surroundSampleFrame[frames]; - const surroundSampleFrame * b = m_mixer->renderNextBuffer(); + const surroundSampleFrame * b = m_audioEngine->renderNextBuffer(); memcpy( buffer, b, frames * sizeof( surroundSampleFrame ) ); write( buffer ); } @@ -1275,16 +1274,16 @@ void Mixer::fifoWriter::run() -void Mixer::fifoWriter::write( surroundSampleFrame * buffer ) +void AudioEngine::fifoWriter::write( surroundSampleFrame * buffer ) { - m_mixer->m_waitChangesMutex.lock(); - m_mixer->m_waitingForWrite = true; - m_mixer->m_waitChangesMutex.unlock(); - m_mixer->runChangesInModel(); + m_audioEngine->m_waitChangesMutex.lock(); + m_audioEngine->m_waitingForWrite = true; + m_audioEngine->m_waitChangesMutex.unlock(); + m_audioEngine->runChangesInModel(); m_fifo->write( buffer ); - m_mixer->m_doChangesMutex.lock(); - m_mixer->m_waitingForWrite = false; - m_mixer->m_doChangesMutex.unlock(); + m_audioEngine->m_doChangesMutex.lock(); + m_audioEngine->m_waitingForWrite = false; + m_audioEngine->m_doChangesMutex.unlock(); } diff --git a/src/core/MixerProfiler.cpp b/src/core/AudioEngineProfiler.cpp similarity index 79% rename from src/core/MixerProfiler.cpp rename to src/core/AudioEngineProfiler.cpp index 3ea95c084..837894c79 100644 --- a/src/core/MixerProfiler.cpp +++ b/src/core/AudioEngineProfiler.cpp @@ -1,5 +1,5 @@ /* - * MixerProfiler.cpp - class for profiling performance of Mixer + * AudioEngineProfiler.cpp - class for profiling performance of AudioEngine * * Copyright (c) 2014 Tobias Doerffel * @@ -22,10 +22,10 @@ * */ -#include "MixerProfiler.h" +#include "AudioEngineProfiler.h" -MixerProfiler::MixerProfiler() : +AudioEngineProfiler::AudioEngineProfiler() : m_periodTimer(), m_cpuLoad( 0 ), m_outputFile() @@ -34,12 +34,12 @@ MixerProfiler::MixerProfiler() : -MixerProfiler::~MixerProfiler() +AudioEngineProfiler::~AudioEngineProfiler() { } -void MixerProfiler::finishPeriod( sample_rate_t sampleRate, fpp_t framesPerPeriod ) +void AudioEngineProfiler::finishPeriod( sample_rate_t sampleRate, fpp_t framesPerPeriod ) { int periodElapsed = m_periodTimer.elapsed(); @@ -54,7 +54,7 @@ void MixerProfiler::finishPeriod( sample_rate_t sampleRate, fpp_t framesPerPerio -void MixerProfiler::setOutputFile( const QString& outputFile ) +void AudioEngineProfiler::setOutputFile( const QString& outputFile ) { m_outputFile.close(); m_outputFile.setFileName( outputFile ); diff --git a/src/core/MixerWorkerThread.cpp b/src/core/AudioEngineWorkerThread.cpp similarity index 74% rename from src/core/MixerWorkerThread.cpp rename to src/core/AudioEngineWorkerThread.cpp index 52041d76e..0746583d2 100644 --- a/src/core/MixerWorkerThread.cpp +++ b/src/core/AudioEngineWorkerThread.cpp @@ -1,5 +1,5 @@ /* - * MixerWorkerThread.cpp - implementation of MixerWorkerThread + * AudioEngineWorkerThread.cpp - implementation of AudioEngineWorkerThread * * Copyright (c) 2009-2014 Tobias Doerffel * @@ -22,26 +22,26 @@ * */ -#include "MixerWorkerThread.h" +#include "AudioEngineWorkerThread.h" #include #include #include #include "denormals.h" +#include "AudioEngine.h" #include "ThreadableJob.h" -#include "Mixer.h" #if defined(LMMS_HOST_X86) || defined(LMMS_HOST_X86_64) #include #endif -MixerWorkerThread::JobQueue MixerWorkerThread::globalJobQueue; -QWaitCondition * MixerWorkerThread::queueReadyWaitCond = NULL; -QList MixerWorkerThread::workerThreads; +AudioEngineWorkerThread::JobQueue AudioEngineWorkerThread::globalJobQueue; +QWaitCondition * AudioEngineWorkerThread::queueReadyWaitCond = NULL; +QList AudioEngineWorkerThread::workerThreads; // implementation of internal JobQueue -void MixerWorkerThread::JobQueue::reset( OperationMode _opMode ) +void AudioEngineWorkerThread::JobQueue::reset( OperationMode _opMode ) { m_writeIndex = 0; m_itemsDone = 0; @@ -51,7 +51,7 @@ void MixerWorkerThread::JobQueue::reset( OperationMode _opMode ) -void MixerWorkerThread::JobQueue::addJob( ThreadableJob * _job ) +void AudioEngineWorkerThread::JobQueue::addJob( ThreadableJob * _job ) { if( _job->requiresProcessing() ) { @@ -70,7 +70,7 @@ void MixerWorkerThread::JobQueue::addJob( ThreadableJob * _job ) -void MixerWorkerThread::JobQueue::run() +void AudioEngineWorkerThread::JobQueue::run() { bool processedJob = true; while (processedJob && m_itemsDone < m_writeIndex) @@ -94,7 +94,7 @@ void MixerWorkerThread::JobQueue::run() -void MixerWorkerThread::JobQueue::wait() +void AudioEngineWorkerThread::JobQueue::wait() { while (m_itemsDone < m_writeIndex) { @@ -110,8 +110,8 @@ void MixerWorkerThread::JobQueue::wait() // implementation of worker threads -MixerWorkerThread::MixerWorkerThread( Mixer* mixer ) : - QThread( mixer ), +AudioEngineWorkerThread::AudioEngineWorkerThread( AudioEngine* audioEngine ) : + QThread( audioEngine ), m_quit( false ) { // initialize global static data @@ -122,7 +122,7 @@ MixerWorkerThread::MixerWorkerThread( Mixer* mixer ) : // keep track of all instantiated worker threads - this is used for // processing the last worker thread "inline", see comments in - // MixerWorkerThread::startAndWaitForJobs() for details + // AudioEngineWorkerThread::startAndWaitForJobs() for details workerThreads << this; resetJobQueue(); @@ -131,7 +131,7 @@ MixerWorkerThread::MixerWorkerThread( Mixer* mixer ) : -MixerWorkerThread::~MixerWorkerThread() +AudioEngineWorkerThread::~AudioEngineWorkerThread() { workerThreads.removeAll( this ); } @@ -139,7 +139,7 @@ MixerWorkerThread::~MixerWorkerThread() -void MixerWorkerThread::quit() +void AudioEngineWorkerThread::quit() { m_quit = true; resetJobQueue(); @@ -148,11 +148,11 @@ void MixerWorkerThread::quit() -void MixerWorkerThread::startAndWaitForJobs() +void AudioEngineWorkerThread::startAndWaitForJobs() { queueReadyWaitCond->wakeAll(); // The last worker-thread is never started. Instead it's processed "inline" - // i.e. within the global Mixer thread. This way we can reduce latencies + // i.e. within the global AudioEngine thread. This way we can reduce latencies // that otherwise would be caused by synchronizing with another thread. globalJobQueue.run(); globalJobQueue.wait(); @@ -161,7 +161,7 @@ void MixerWorkerThread::startAndWaitForJobs() -void MixerWorkerThread::run() +void AudioEngineWorkerThread::run() { MemoryManager::ThreadGuard mmThreadGuard; Q_UNUSED(mmThreadGuard); disable_denormals(); diff --git a/src/core/AutomatableModel.cpp b/src/core/AutomatableModel.cpp index 2c1162e0d..84d033cb6 100644 --- a/src/core/AutomatableModel.cpp +++ b/src/core/AutomatableModel.cpp @@ -26,10 +26,10 @@ #include "lmms_math.h" +#include "AudioEngine.h" #include "AutomationPattern.h" #include "ControllerConnection.h" #include "LocaleHelper.h" -#include "Mixer.h" #include "ProjectJournal.h" #include "Song.h" @@ -51,7 +51,7 @@ AutomatableModel::AutomatableModel( m_setValueDepth( 0 ), m_hasStrictStepSize( false ), m_controllerConnection( NULL ), - m_valueBuffer( static_cast( Engine::mixer()->framesPerPeriod() ) ), + m_valueBuffer( static_cast( Engine::audioEngine()->framesPerPeriod() ) ), m_lastUpdatedPeriod( -1 ), m_hasSampleExactData(false), m_useControllerValue(true) diff --git a/src/core/BufferManager.cpp b/src/core/BufferManager.cpp index 2df7bcaa9..79a0734f7 100644 --- a/src/core/BufferManager.cpp +++ b/src/core/BufferManager.cpp @@ -27,7 +27,6 @@ #include "BufferManager.h" #include "Engine.h" -#include "Mixer.h" #include "MemoryManager.h" static fpp_t framesPerPeriod; diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index c4807ebcf..103c4c062 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -1,6 +1,9 @@ set(LMMS_SRCS ${LMMS_SRCS} + core/AudioEngine.cpp + core/AudioEngineProfiler.cpp + core/AudioEngineWorkerThread.cpp core/AutomatableModel.cpp core/AutomationPattern.cpp core/AutomationNode.cpp @@ -41,9 +44,6 @@ set(LMMS_SRCS core/MeterModel.cpp core/MicroTimer.cpp core/Microtuner.cpp - core/Mixer.cpp - core/MixerProfiler.cpp - core/MixerWorkerThread.cpp core/MixHelpers.cpp core/Model.cpp core/ModelVisitor.cpp diff --git a/src/core/Controller.cpp b/src/core/Controller.cpp index affb68d5f..da1af20a5 100644 --- a/src/core/Controller.cpp +++ b/src/core/Controller.cpp @@ -30,7 +30,7 @@ #include "Song.h" -#include "Mixer.h" +#include "AudioEngine.h" #include "ControllerConnection.h" #include "ControllerDialog.h" #include "LfoController.h" @@ -47,7 +47,7 @@ Controller::Controller( ControllerTypes _type, Model * _parent, const QString & _display_name ) : Model( _parent, _display_name ), JournallingObject(), - m_valueBuffer( Engine::mixer()->framesPerPeriod() ), + m_valueBuffer( Engine::audioEngine()->framesPerPeriod() ), m_bufferLastUpdated( -1 ), m_connectionCount( 0 ), m_type( _type ) @@ -140,7 +140,7 @@ void Controller::updateValueBuffer() // Get position in frames unsigned int Controller::runningFrames() { - return s_periods * Engine::mixer()->framesPerPeriod(); + return s_periods * Engine::audioEngine()->framesPerPeriod(); } @@ -148,7 +148,7 @@ unsigned int Controller::runningFrames() // Get position in seconds float Controller::runningTime() { - return runningFrames() / Engine::mixer()->processingSampleRate(); + return runningFrames() / Engine::audioEngine()->processingSampleRate(); } diff --git a/src/core/Effect.cpp b/src/core/Effect.cpp index f1e32669e..ce305d1ab 100644 --- a/src/core/Effect.cpp +++ b/src/core/Effect.cpp @@ -180,7 +180,7 @@ void Effect::reinitSRC() } int error; if( ( m_srcState[i] = src_new( - Engine::mixer()->currentQualitySettings(). + Engine::audioEngine()->currentQualitySettings(). libsrcInterpolation(), DEFAULT_CHANNELS, &error ) ) == NULL ) { @@ -202,7 +202,7 @@ void Effect::resample( int _i, const sampleFrame * _src_buf, return; } m_srcData[_i].input_frames = _frames; - m_srcData[_i].output_frames = Engine::mixer()->framesPerPeriod(); + m_srcData[_i].output_frames = Engine::audioEngine()->framesPerPeriod(); m_srcData[_i].data_in = const_cast(_src_buf[0].data()); m_srcData[_i].data_out = _dst_buf[0].data (); m_srcData[_i].src_ratio = (double) _dst_sr / _src_sr; diff --git a/src/core/EffectChain.cpp b/src/core/EffectChain.cpp index 21b85917b..9c233bc41 100644 --- a/src/core/EffectChain.cpp +++ b/src/core/EffectChain.cpp @@ -78,7 +78,7 @@ void EffectChain::loadSettings( const QDomElement & _this ) { clear(); - // TODO This method should probably also lock the mixer + // TODO This method should probably also lock the audio engine m_enabledModel.loadSettings( _this, "enabled" ); @@ -121,9 +121,9 @@ void EffectChain::loadSettings( const QDomElement & _this ) void EffectChain::appendEffect( Effect * _effect ) { - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); m_effects.append( _effect ); - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); m_enabledModel.setValue( true ); @@ -135,17 +135,17 @@ void EffectChain::appendEffect( Effect * _effect ) void EffectChain::removeEffect( Effect * _effect ) { - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); Effect ** found = std::find( m_effects.begin(), m_effects.end(), _effect ); if( found == m_effects.end() ) { - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); return; } m_effects.erase( found ); - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); if( m_effects.isEmpty() ) { @@ -228,7 +228,7 @@ void EffectChain::clear() { emit aboutToClear(); - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); while( m_effects.count() ) { @@ -237,7 +237,7 @@ void EffectChain::clear() delete e; } - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); m_enabledModel.setValue( false ); } diff --git a/src/core/Engine.cpp b/src/core/Engine.cpp index 867260c22..b3c2b67a3 100644 --- a/src/core/Engine.cpp +++ b/src/core/Engine.cpp @@ -24,12 +24,12 @@ #include "Engine.h" +#include "AudioEngine.h" #include "BBTrackContainer.h" #include "ConfigManager.h" #include "FxMixer.h" #include "Ladspa2LMMS.h" #include "Lv2Manager.h" -#include "Mixer.h" #include "Plugin.h" #include "PresetPreviewPlayHandle.h" #include "ProjectJournal.h" @@ -38,7 +38,7 @@ #include "Oscillator.h" float LmmsCore::s_framesPerTick; -Mixer* LmmsCore::s_mixer = NULL; +AudioEngine* LmmsCore::s_audioEngine = NULL; FxMixer * LmmsCore::s_fxMixer = NULL; BBTrackContainer * LmmsCore::s_bbTrackContainer = NULL; Song * LmmsCore::s_song = NULL; @@ -64,7 +64,7 @@ void LmmsCore::init( bool renderOnly ) emit engine->initProgress(tr("Initializing data structures")); s_projectJournal = new ProjectJournal; - s_mixer = new Mixer( renderOnly ); + s_audioEngine = new AudioEngine( renderOnly ); s_song = new Song; s_fxMixer = new FxMixer; s_bbTrackContainer = new BBTrackContainer; @@ -78,12 +78,12 @@ void LmmsCore::init( bool renderOnly ) s_projectJournal->setJournalling( true ); emit engine->initProgress(tr("Opening audio and midi devices")); - s_mixer->initDevices(); + s_audioEngine->initDevices(); PresetPreviewPlayHandle::init(); - emit engine->initProgress(tr("Launching mixer threads")); - s_mixer->startProcessing(); + emit engine->initProgress(tr("Launching audio engine threads")); + s_audioEngine->startProcessing(); } @@ -92,7 +92,7 @@ void LmmsCore::init( bool renderOnly ) void LmmsCore::destroy() { s_projectJournal->stopAllJournalling(); - s_mixer->stopProcessing(); + s_audioEngine->stopProcessing(); PresetPreviewPlayHandle::cleanup(); @@ -101,7 +101,7 @@ void LmmsCore::destroy() deleteHelper( &s_bbTrackContainer ); deleteHelper( &s_fxMixer ); - deleteHelper( &s_mixer ); + deleteHelper( &s_audioEngine ); #ifdef LMMS_HAVE_LV2 deleteHelper( &s_lv2Manager ); @@ -143,8 +143,7 @@ float LmmsCore::framesPerTick(sample_rate_t sampleRate) void LmmsCore::updateFramesPerTick() { - s_framesPerTick = s_mixer->processingSampleRate() * 60.0f * 4 / - DefaultTicksPerBar / s_song->getTempo(); + s_framesPerTick = s_audioEngine->processingSampleRate() * 60.0f * 4 / DefaultTicksPerBar / s_song->getTempo(); } diff --git a/src/core/EnvelopeAndLfoParameters.cpp b/src/core/EnvelopeAndLfoParameters.cpp index 27a73b2c1..613f4d446 100644 --- a/src/core/EnvelopeAndLfoParameters.cpp +++ b/src/core/EnvelopeAndLfoParameters.cpp @@ -25,8 +25,8 @@ #include #include "EnvelopeAndLfoParameters.h" +#include "AudioEngine.h" #include "Engine.h" -#include "Mixer.h" #include "Oscillator.h" @@ -47,8 +47,7 @@ void EnvelopeAndLfoParameters::LfoInstances::trigger() for( LfoList::Iterator it = m_lfos.begin(); it != m_lfos.end(); ++it ) { - ( *it )->m_lfoFrame += - Engine::mixer()->framesPerPeriod(); + ( *it )->m_lfoFrame += Engine::audioEngine()->framesPerPeriod(); ( *it )->m_bad_lfoShapeData = true; } } @@ -158,12 +157,12 @@ EnvelopeAndLfoParameters::EnvelopeAndLfoParameters( connect( &m_x100Model, SIGNAL( dataChanged() ), this, SLOT( updateSampleVars() ), Qt::DirectConnection ); - connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( updateSampleVars() ) ); m_lfoShapeData = - new sample_t[Engine::mixer()->framesPerPeriod()]; + new sample_t[Engine::audioEngine()->framesPerPeriod()]; updateSampleVars(); } @@ -243,7 +242,7 @@ inline sample_t EnvelopeAndLfoParameters::lfoShapeSample( fpp_t _frame_offset ) void EnvelopeAndLfoParameters::updateLfoShapeData() { - const fpp_t frames = Engine::mixer()->framesPerPeriod(); + const fpp_t frames = Engine::audioEngine()->framesPerPeriod(); for( fpp_t offset = 0; offset < frames; ++offset ) { m_lfoShapeData[offset] = lfoShapeSample( offset ); @@ -399,7 +398,7 @@ void EnvelopeAndLfoParameters::updateSampleVars() QMutexLocker m(&m_paramMutex); const float frames_per_env_seg = SECS_PER_ENV_SEGMENT * - Engine::mixer()->processingSampleRate(); + Engine::audioEngine()->processingSampleRate(); // TODO: Remove the expKnobVals, time should be linear const f_cnt_t predelay_frames = static_cast( @@ -501,7 +500,7 @@ void EnvelopeAndLfoParameters::updateSampleVars() const float frames_per_lfo_oscillation = SECS_PER_LFO_OSCILLATION * - Engine::mixer()->processingSampleRate(); + Engine::audioEngine()->processingSampleRate(); m_lfoPredelayFrames = static_cast( frames_per_lfo_oscillation * expKnobVal( m_lfoPredelayModel.value() ) ); m_lfoAttackFrames = static_cast( frames_per_lfo_oscillation * diff --git a/src/core/FxMixer.cpp b/src/core/FxMixer.cpp index 7ddcbea62..e360c1f85 100644 --- a/src/core/FxMixer.cpp +++ b/src/core/FxMixer.cpp @@ -24,10 +24,10 @@ #include +#include "AudioEngine.h" +#include "AudioEngineWorkerThread.h" #include "BufferManager.h" #include "FxMixer.h" -#include "Mixer.h" -#include "MixerWorkerThread.h" #include "MixHelpers.h" #include "Song.h" @@ -65,7 +65,7 @@ FxChannel::FxChannel( int idx, Model * _parent ) : m_stillRunning( false ), m_peakLeft( 0.0f ), m_peakRight( 0.0f ), - m_buffer( new sampleFrame[Engine::mixer()->framesPerPeriod()] ), + m_buffer( new sampleFrame[Engine::audioEngine()->framesPerPeriod()] ), m_muteModel( false, _parent ), m_soloModel( false, _parent ), m_volumeModel( 1.0, 0.0, 2.0, 0.001, _parent ), @@ -76,7 +76,7 @@ FxChannel::FxChannel( int idx, Model * _parent ) : m_hasColor( false ), m_dependenciesMet(0) { - BufferManager::clear( m_buffer, Engine::mixer()->framesPerPeriod() ); + BufferManager::clear( m_buffer, Engine::audioEngine()->framesPerPeriod() ); } @@ -105,7 +105,7 @@ void FxChannel::incrementDeps() if( i >= m_receives.size() && ! m_queued ) { m_queued = true; - MixerWorkerThread::addJob( this ); + AudioEngineWorkerThread::addJob( this ); } } @@ -119,7 +119,7 @@ void FxChannel::unmuteForSolo() void FxChannel::doProcessing() { - const fpp_t fpp = Engine::mixer()->framesPerPeriod(); + const fpp_t fpp = Engine::audioEngine()->framesPerPeriod(); if( m_muted == false ) { @@ -173,7 +173,7 @@ void FxChannel::doProcessing() m_stillRunning = m_fxChain.processAudioBuffer( m_buffer, fpp, m_hasInput ); - Mixer::StereoSample peakSamples = Engine::mixer()->getPeakValues(m_buffer, fpp); + AudioEngine::StereoSample peakSamples = Engine::audioEngine()->getPeakValues(m_buffer, fpp); m_peakLeft = qMax( m_peakLeft, peakSamples.left * v ); m_peakRight = qMax( m_peakRight, peakSamples.right * v ); } @@ -283,7 +283,7 @@ void FxMixer::toggledSolo() void FxMixer::deleteChannel( int index ) { // channel deletion is performed between mixer rounds - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); // go through every instrument and adjust for the channel index change TrackContainer::TrackList tracks; @@ -365,7 +365,7 @@ void FxMixer::deleteChannel( int index ) } } - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); } @@ -469,7 +469,7 @@ FxRoute * FxMixer::createRoute( FxChannel * from, FxChannel * to, float amount ) { return NULL; } - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); FxRoute * route = new FxRoute( from, to, amount ); // add us to from's sends @@ -480,7 +480,7 @@ FxRoute * FxMixer::createRoute( FxChannel * from, FxChannel * to, float amount ) // add us to fxmixer's list Engine::fxMixer()->m_fxRoutes.append( route ); - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); return route; } @@ -507,7 +507,7 @@ void FxMixer::deleteChannelSend( fx_ch_t fromChannel, fx_ch_t toChannel ) void FxMixer::deleteChannelSend( FxRoute * route ) { - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); // remove us from from's sends route->sender()->m_sends.remove( route->sender()->m_sends.indexOf( route ) ); // remove us from to's receives @@ -515,7 +515,7 @@ void FxMixer::deleteChannelSend( FxRoute * route ) // remove us from fxmixer's list Engine::fxMixer()->m_fxRoutes.remove( Engine::fxMixer()->m_fxRoutes.indexOf( route ) ); delete route; - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); } @@ -585,7 +585,7 @@ void FxMixer::mixToChannel( const sampleFrame * _buf, fx_ch_t _ch ) if( m_fxChannels[_ch]->m_muteModel.value() == false ) { m_fxChannels[_ch]->m_lock.lock(); - MixHelpers::add( m_fxChannels[_ch]->m_buffer, _buf, Engine::mixer()->framesPerPeriod() ); + MixHelpers::add( m_fxChannels[_ch]->m_buffer, _buf, Engine::audioEngine()->framesPerPeriod() ); m_fxChannels[_ch]->m_hasInput = true; m_fxChannels[_ch]->m_lock.unlock(); } @@ -597,14 +597,14 @@ void FxMixer::mixToChannel( const sampleFrame * _buf, fx_ch_t _ch ) void FxMixer::prepareMasterMix() { BufferManager::clear( m_fxChannels[0]->m_buffer, - Engine::mixer()->framesPerPeriod() ); + Engine::audioEngine()->framesPerPeriod() ); } void FxMixer::masterMix( sampleFrame * _buf ) { - const int fpp = Engine::mixer()->framesPerPeriod(); + const int fpp = Engine::audioEngine()->framesPerPeriod(); // add the channels that have no dependencies (no incoming senders, ie. // no receives) to the jobqueue. The channels that have receives get @@ -613,7 +613,7 @@ void FxMixer::masterMix( sampleFrame * _buf ) // also instantly add all muted channels as they don't need to care // about their senders, and can just increment the deps of their // recipients right away. - MixerWorkerThread::resetJobQueue( MixerWorkerThread::JobQueue::Dynamic ); + AudioEngineWorkerThread::resetJobQueue( AudioEngineWorkerThread::JobQueue::Dynamic ); for( FxChannel * ch : m_fxChannels ) { ch->m_muted = ch->m_muteModel.value(); @@ -625,7 +625,7 @@ void FxMixer::masterMix( sampleFrame * _buf ) else if( ch->m_receives.size() == 0 ) { ch->m_queued = true; - MixerWorkerThread::addJob( ch ); + AudioEngineWorkerThread::addJob( ch ); } } while (m_fxChannels[0]->state() != ThreadableJob::ProcessingState::Done) @@ -645,7 +645,7 @@ void FxMixer::masterMix( sampleFrame * _buf ) { break; } - MixerWorkerThread::startAndWaitForJobs(); + AudioEngineWorkerThread::startAndWaitForJobs(); } // handle sample-exact data in master volume fader @@ -670,7 +670,7 @@ void FxMixer::masterMix( sampleFrame * _buf ) for( int i = 0; i < numChannels(); ++i) { BufferManager::clear( m_fxChannels[i]->m_buffer, - Engine::mixer()->framesPerPeriod() ); + Engine::audioEngine()->framesPerPeriod() ); m_fxChannels[i]->reset(); m_fxChannels[i]->m_queued = false; // also reset hasInput diff --git a/src/core/Instrument.cpp b/src/core/Instrument.cpp index 3e8dc8074..7ef95c81e 100644 --- a/src/core/Instrument.cpp +++ b/src/core/Instrument.cpp @@ -176,7 +176,7 @@ void Instrument::applyFadeIn(sampleFrame * buf, NotePlayHandle * n) void Instrument::applyRelease( sampleFrame * buf, const NotePlayHandle * _n ) { const fpp_t frames = _n->framesLeftForCurrentPeriod(); - const fpp_t fpp = Engine::mixer()->framesPerPeriod(); + const fpp_t fpp = Engine::audioEngine()->framesPerPeriod(); const f_cnt_t fl = _n->framesLeft(); if( fl <= desiredReleaseFrames()+fpp ) { diff --git a/src/core/InstrumentFunctions.cpp b/src/core/InstrumentFunctions.cpp index 0b3f2a9bf..1295ed6d2 100644 --- a/src/core/InstrumentFunctions.cpp +++ b/src/core/InstrumentFunctions.cpp @@ -25,10 +25,10 @@ #include #include "InstrumentFunctions.h" +#include "AudioEngine.h" #include "embed.h" #include "Engine.h" #include "InstrumentTrack.h" -#include "Mixer.h" #include "PresetPreviewPlayHandle.h" @@ -261,7 +261,7 @@ void InstrumentFunctionNoteStacking::processNote( NotePlayHandle * _n ) // create sub-note-play-handle, only note is // different - Engine::mixer()->addPlayHandle( + Engine::audioEngine()->addPlayHandle( NotePlayHandleManager::acquire( _n->instrumentTrack(), _n->offset(), _n->frames(), note_copy, _n, -1, NotePlayHandle::OriginNoteStacking ) ); @@ -374,7 +374,7 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n ) const int total_range = range * cnphv.size(); // number of frames that every note should be played - const f_cnt_t arp_frames = (f_cnt_t)( m_arpTimeModel.value() / 1000.0f * Engine::mixer()->processingSampleRate() ); + const f_cnt_t arp_frames = (f_cnt_t)( m_arpTimeModel.value() / 1000.0f * Engine::audioEngine()->processingSampleRate() ); const f_cnt_t gated_frames = (f_cnt_t)( m_arpGateModel.value() * arp_frames / 100.0f ); // used for calculating remaining frames for arp-note, we have to add @@ -386,12 +386,12 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n ) // used for loop f_cnt_t frames_processed = ( m_arpModeModel.value() != FreeMode ) ? cnphv.first()->noteOffset() : _n->noteOffset(); - while( frames_processed < Engine::mixer()->framesPerPeriod() ) + while( frames_processed < Engine::audioEngine()->framesPerPeriod() ) { const f_cnt_t remaining_frames_for_cur_arp = arp_frames - ( cur_frame % arp_frames ); // does current arp-note fill whole audio-buffer or is the remaining time just // a short bit that we can discard? - if( remaining_frames_for_cur_arp > Engine::mixer()->framesPerPeriod() || + if( remaining_frames_for_cur_arp > Engine::audioEngine()->framesPerPeriod() || _n->frames() - _n->totalFramesPlayed() < arp_frames / 5 ) { // then we don't have to do something! @@ -497,7 +497,7 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n ) // range-checking if( sub_note_key >= NumKeys || sub_note_key < 0 || - Engine::mixer()->criticalXRuns() ) + Engine::audioEngine()->criticalXRuns() ) { continue; } @@ -506,7 +506,7 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n ) // create sub-note-play-handle, only ptr to note is different // and is_arp_note=true - Engine::mixer()->addPlayHandle( + Engine::audioEngine()->addPlayHandle( NotePlayHandleManager::acquire( _n->instrumentTrack(), frames_processed, gated_frames, diff --git a/src/core/InstrumentSoundShaping.cpp b/src/core/InstrumentSoundShaping.cpp index b9e32427a..59141f5e4 100644 --- a/src/core/InstrumentSoundShaping.cpp +++ b/src/core/InstrumentSoundShaping.cpp @@ -26,13 +26,13 @@ #include #include "InstrumentSoundShaping.h" +#include "AudioEngine.h" #include "BasicFilters.h" #include "embed.h" #include "Engine.h" #include "EnvelopeAndLfoParameters.h" #include "Instrument.h" #include "InstrumentTrack.h" -#include "Mixer.h" const float CUT_FREQ_MULTIPLIER = 6000.0f; @@ -117,7 +117,7 @@ float InstrumentSoundShaping::volumeLevel( NotePlayHandle* n, const f_cnt_t fram if( n->isReleased() == false ) { - envReleaseBegin += Engine::mixer()->framesPerPeriod(); + envReleaseBegin += Engine::audioEngine()->framesPerPeriod(); } float level; @@ -160,7 +160,7 @@ void InstrumentSoundShaping::processAudioBuffer( sampleFrame* buffer, if( n->m_filter == nullptr ) { - n->m_filter = std::make_unique>( Engine::mixer()->processingSampleRate() ); + n->m_filter = std::make_unique>( Engine::audioEngine()->processingSampleRate() ); } n->m_filter->setFilterType( m_filterModel.value() ); diff --git a/src/core/LfoController.cpp b/src/core/LfoController.cpp index 2b2db2f14..38fc8b43c 100644 --- a/src/core/LfoController.cpp +++ b/src/core/LfoController.cpp @@ -27,9 +27,9 @@ #include -#include "Song.h" -#include "Mixer.h" #include "LfoController.h" +#include "AudioEngine.h" +#include "Song.h" LfoController::LfoController( Model * _parent ) : @@ -55,7 +55,7 @@ LfoController::LfoController( Model * _parent ) : this, SLOT( updateDuration() ), Qt::DirectConnection ); connect( &m_multiplierModel, SIGNAL( dataChanged() ), this, SLOT( updateDuration() ), Qt::DirectConnection ); - connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( updateDuration() ) ); connect( Engine::getSong(), SIGNAL( playbackStateChanged() ), @@ -91,7 +91,7 @@ void LfoController::updateValueBuffer() if( m_bufferLastUpdated < s_periods ) { int diff = s_periods - m_bufferLastUpdated; - phase += static_cast( Engine::mixer()->framesPerPeriod() * diff ) / m_duration; + phase += static_cast( Engine::audioEngine()->framesPerPeriod() * diff ) / m_duration; m_bufferLastUpdated += diff; } @@ -125,7 +125,7 @@ void LfoController::updatePhase() void LfoController::updateDuration() { - float newDurationF = Engine::mixer()->processingSampleRate() * m_speedModel.value(); + float newDurationF = Engine::audioEngine()->processingSampleRate() * m_speedModel.value(); switch(m_multiplierModel.value() ) { diff --git a/src/core/NotePlayHandle.cpp b/src/core/NotePlayHandle.cpp index dd2e23ece..f13df6d9a 100644 --- a/src/core/NotePlayHandle.cpp +++ b/src/core/NotePlayHandle.cpp @@ -26,6 +26,7 @@ #include "NotePlayHandle.h" #include "lmms_constants.h" +#include "AudioEngine.h" #include "BasicFilters.h" #include "DetuningHelper.h" #include "InstrumentSoundShaping.h" @@ -188,9 +189,9 @@ void NotePlayHandle::play( sampleFrame * _working_buffer ) } // if the note offset falls over to next period, then don't start playback yet - if( offset() >= Engine::mixer()->framesPerPeriod() ) + if( offset() >= Engine::audioEngine()->framesPerPeriod() ) { - setOffset( offset() - Engine::mixer()->framesPerPeriod() ); + setOffset( offset() - Engine::audioEngine()->framesPerPeriod() ); return; } @@ -238,8 +239,8 @@ void NotePlayHandle::play( sampleFrame * _working_buffer ) // number of frames that can be played this period f_cnt_t framesThisPeriod = m_totalFramesPlayed == 0 - ? Engine::mixer()->framesPerPeriod() - offset() - : Engine::mixer()->framesPerPeriod(); + ? Engine::audioEngine()->framesPerPeriod() - offset() + : Engine::audioEngine()->framesPerPeriod(); // check if we start release during this period if( m_released == false && @@ -274,7 +275,7 @@ void NotePlayHandle::play( sampleFrame * _working_buffer ) // are inserted by arpAndChordsTabWidget::processNote() if( ! m_subNotes.isEmpty() ) { - m_releaseFramesToDo = m_releaseFramesDone + 2 * Engine::mixer()->framesPerPeriod(); + m_releaseFramesToDo = m_releaseFramesDone + 2 * Engine::audioEngine()->framesPerPeriod(); } // look whether we have frames left to be done before release if( m_framesBeforeRelease ) @@ -327,7 +328,7 @@ f_cnt_t NotePlayHandle::framesLeft() const { if( instrumentTrack()->isSustainPedalPressed() ) { - return 4*Engine::mixer()->framesPerPeriod(); + return 4 * Engine::audioEngine()->framesPerPeriod(); } else if( m_released && actualReleaseFramesToDo() == 0 ) { @@ -347,9 +348,9 @@ fpp_t NotePlayHandle::framesLeftForCurrentPeriod() const { if( m_totalFramesPlayed == 0 ) { - return (fpp_t) qMin( framesLeft(), Engine::mixer()->framesPerPeriod() - offset() ); + return (fpp_t) qMin( framesLeft(), Engine::audioEngine()->framesPerPeriod() - offset() ); } - return (fpp_t) qMin( framesLeft(), Engine::mixer()->framesPerPeriod() ); + return (fpp_t) qMin( framesLeft(), Engine::audioEngine()->framesPerPeriod() ); } @@ -452,7 +453,7 @@ void NotePlayHandle::mute() int NotePlayHandle::index() const { - const PlayHandleList & playHandles = Engine::mixer()->playHandles(); + const PlayHandleList & playHandles = Engine::audioEngine()->playHandles(); int idx = 0; for( PlayHandleList::ConstIterator it = playHandles.begin(); it != playHandles.end(); ++it ) { @@ -475,7 +476,7 @@ int NotePlayHandle::index() const ConstNotePlayHandleList NotePlayHandle::nphsOfInstrumentTrack( const InstrumentTrack * _it, bool _all_ph ) { - const PlayHandleList & playHandles = Engine::mixer()->playHandles(); + const PlayHandleList & playHandles = Engine::audioEngine()->playHandles(); ConstNotePlayHandleList cnphv; for( PlayHandleList::ConstIterator it = playHandles.begin(); it != playHandles.end(); ++it ) diff --git a/src/core/Oscillator.cpp b/src/core/Oscillator.cpp index 8999b9d4b..dcf64a144 100644 --- a/src/core/Oscillator.cpp +++ b/src/core/Oscillator.cpp @@ -32,7 +32,7 @@ #include "BufferManager.h" #include "Engine.h" -#include "Mixer.h" +#include "AudioEngine.h" #include "AutomatableModel.h" #include "fftw3.h" #include "fft_helpers.h" @@ -76,7 +76,7 @@ Oscillator::Oscillator(const IntModel *wave_shape_model, void Oscillator::update(sampleFrame* ab, const fpp_t frames, const ch_cnt_t chnl, bool modulator) { - if (m_freq >= Engine::mixer()->processingSampleRate() / 2) + if (m_freq >= Engine::audioEngine()->processingSampleRate() / 2) { BufferManager::clear(ab, frames); return; @@ -673,8 +673,7 @@ void Oscillator::updateFM( sampleFrame * _ab, const fpp_t _frames, m_subOsc->update( _ab, _frames, _chnl, true ); recalcPhase(); const float osc_coeff = m_freq * m_detuning_div_samplerate; - const float sampleRateCorrection = 44100.0f / - Engine::mixer()->processingSampleRate(); + const float sampleRateCorrection = 44100.0f / Engine::audioEngine()->processingSampleRate(); for( fpp_t frame = 0; frame < _frames; ++frame ) { @@ -690,7 +689,7 @@ void Oscillator::updateFM( sampleFrame * _ab, const fpp_t _frames, template<> inline sample_t Oscillator::getSample(const float sample) { - const float current_freq = m_freq * m_detuning_div_samplerate * Engine::mixer()->processingSampleRate(); + const float current_freq = m_freq * m_detuning_div_samplerate * Engine::audioEngine()->processingSampleRate(); if (!m_useWaveTable || current_freq < OscillatorConstants::MAX_FREQ) { diff --git a/src/core/PeakController.cpp b/src/core/PeakController.cpp index b2e3bc921..6e2cf0be6 100644 --- a/src/core/PeakController.cpp +++ b/src/core/PeakController.cpp @@ -30,7 +30,7 @@ #include #include -#include "Mixer.h" +#include "AudioEngine.h" #include "EffectChain.h" #include "plugins/peak_controller_effect/peak_controller_effect.h" @@ -52,7 +52,7 @@ PeakController::PeakController( Model * _parent, connect( m_peakEffect, SIGNAL( destroyed( ) ), this, SLOT( handleDestroyedEffect( ) ) ); } - connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( updateCoeffs() ) ); + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( updateCoeffs() ) ); connect( m_peakEffect->attackModel(), SIGNAL( dataChanged() ), this, SLOT( updateCoeffs() ), Qt::DirectConnection ); connect( m_peakEffect->decayModel(), SIGNAL( dataChanged() ), @@ -76,7 +76,7 @@ void PeakController::updateValueBuffer() { if( m_coeffNeedsUpdate ) { - const float ratio = 44100.0f / Engine::mixer()->processingSampleRate(); + const float ratio = 44100.0f / Engine::audioEngine()->processingSampleRate(); m_attackCoeff = 1.0f - powf( 2.0f, -0.3f * ( 1.0f - m_peakEffect->attackModel()->value() ) * ratio ); m_decayCoeff = 1.0f - powf( 2.0f, -0.3f * ( 1.0f - m_peakEffect->decayModel()->value() ) * ratio ); m_coeffNeedsUpdate = false; @@ -87,7 +87,7 @@ void PeakController::updateValueBuffer() float targetSample = m_peakEffect->lastSample(); if( m_currentSample != targetSample ) { - const f_cnt_t frames = Engine::mixer()->framesPerPeriod(); + const f_cnt_t frames = Engine::audioEngine()->framesPerPeriod(); float * values = m_valueBuffer.values(); for( f_cnt_t f = 0; f < frames; ++f ) diff --git a/src/core/PlayHandle.cpp b/src/core/PlayHandle.cpp index 9e92019a6..a553ab66f 100644 --- a/src/core/PlayHandle.cpp +++ b/src/core/PlayHandle.cpp @@ -23,9 +23,9 @@ */ #include "PlayHandle.h" +#include "AudioEngine.h" #include "BufferManager.h" #include "Engine.h" -#include "Mixer.h" #include #include @@ -54,7 +54,7 @@ void PlayHandle::doProcessing() if( m_usesBuffer ) { m_bufferReleased = false; - BufferManager::clear(m_playHandleBuffer, Engine::mixer()->framesPerPeriod()); + BufferManager::clear(m_playHandleBuffer, Engine::audioEngine()->framesPerPeriod()); play( buffer() ); } else diff --git a/src/core/PresetPreviewPlayHandle.cpp b/src/core/PresetPreviewPlayHandle.cpp index d7a0260ef..f2ed35c78 100644 --- a/src/core/PresetPreviewPlayHandle.cpp +++ b/src/core/PresetPreviewPlayHandle.cpp @@ -25,10 +25,10 @@ #include #include "PresetPreviewPlayHandle.h" +#include "AudioEngine.h" #include "Engine.h" #include "Instrument.h" #include "InstrumentTrack.h" -#include "Mixer.h" #include "PluginFactory.h" #include "ProjectJournal.h" #include "TrackContainer.h" @@ -122,10 +122,10 @@ PresetPreviewPlayHandle::PresetPreviewPlayHandle( const QString & _preset_file, s_previewTC->lockData(); - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); s_previewTC->setPreviewNote( nullptr ); s_previewTC->previewInstrumentTrack()->silenceAllNotes(); - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); const bool j = Engine::projectJournal()->isJournalling(); Engine::projectJournal()->setJournalling( false ); @@ -170,7 +170,7 @@ PresetPreviewPlayHandle::PresetPreviewPlayHandle( const QString & _preset_file, s_previewTC->previewInstrumentTrack()-> midiPort()->setMode( MidiPort::Disabled ); - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); // create note-play-handle for it m_previewNote = NotePlayHandleManager::acquire( s_previewTC->previewInstrumentTrack(), 0, @@ -181,9 +181,9 @@ PresetPreviewPlayHandle::PresetPreviewPlayHandle( const QString & _preset_file, s_previewTC->setPreviewNote( m_previewNote ); - Engine::mixer()->addPlayHandle( m_previewNote ); + Engine::audioEngine()->addPlayHandle( m_previewNote ); - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); s_previewTC->unlockData(); Engine::projectJournal()->setJournalling( j ); } @@ -193,13 +193,13 @@ PresetPreviewPlayHandle::PresetPreviewPlayHandle( const QString & _preset_file, PresetPreviewPlayHandle::~PresetPreviewPlayHandle() { - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); // not muted by other preset-preview-handle? if (s_previewTC->testAndSetPreviewNote(m_previewNote, nullptr)) { m_previewNote->noteOff(); } - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); } @@ -208,7 +208,7 @@ PresetPreviewPlayHandle::~PresetPreviewPlayHandle() void PresetPreviewPlayHandle::play( sampleFrame * _working_buffer ) { // Do nothing; the preview instrument is played by m_previewNote, which - // has been added to the mixer + // has been added to the audio engine } diff --git a/src/core/ProjectRenderer.cpp b/src/core/ProjectRenderer.cpp index 0616a9252..1013a96c7 100644 --- a/src/core/ProjectRenderer.cpp +++ b/src/core/ProjectRenderer.cpp @@ -77,11 +77,11 @@ const ProjectRenderer::FileEncodeDevice ProjectRenderer::fileEncodeDevices[] = -ProjectRenderer::ProjectRenderer( const Mixer::qualitySettings & qualitySettings, +ProjectRenderer::ProjectRenderer( const AudioEngine::qualitySettings & qualitySettings, const OutputSettings & outputSettings, ExportFileFormats exportFileFormat, const QString & outputFilename ) : - QThread( Engine::mixer() ), + QThread( Engine::audioEngine() ), m_fileDev( NULL ), m_qualitySettings( qualitySettings ), m_progress( 0 ), @@ -95,7 +95,7 @@ ProjectRenderer::ProjectRenderer( const Mixer::qualitySettings & qualitySettings m_fileDev = audioEncoderFactory( outputFilename, outputSettings, DEFAULT_CHANNELS, - Engine::mixer(), successful ); + Engine::audioEngine(), successful ); if( !successful ) { delete m_fileDev; @@ -149,10 +149,9 @@ void ProjectRenderer::startProcessing() if( isReady() ) { - // Have to do mixer stuff with GUI-thread affinity in order to + // Have to do audio engine stuff with GUI-thread affinity in order to // make slots connected to sampleRateChanged()-signals being called immediately. - Engine::mixer()->setAudioDevice( m_fileDev, - m_qualitySettings, false, false ); + Engine::audioEngine()->setAudioDevice( m_fileDev, m_qualitySettings, false, false ); start( #ifndef LMMS_BUILD_WIN32 @@ -182,12 +181,12 @@ void ProjectRenderer::run() Engine::getSong()->startExport(); // Skip first empty buffer. - Engine::mixer()->nextBuffer(); + Engine::audioEngine()->nextBuffer(); m_progress = 0; // Now start processing - Engine::mixer()->startProcessing(false); + Engine::audioEngine()->startProcessing(false); // Continually track and emit progress percentage to listeners. while (!Engine::getSong()->isExportDone() && !m_abort) @@ -201,8 +200,8 @@ void ProjectRenderer::run() } } - // Notify mixer of the end of processing. - Engine::mixer()->stopProcessing(); + // Notify the audio engine of the end of processing. + Engine::audioEngine()->stopProcessing(); Engine::getSong()->stopExport(); diff --git a/src/core/RemotePlugin.cpp b/src/core/RemotePlugin.cpp index 45678139f..904d7940e 100644 --- a/src/core/RemotePlugin.cpp +++ b/src/core/RemotePlugin.cpp @@ -30,7 +30,7 @@ #include "BufferManager.h" #include "RemotePlugin.h" -#include "Mixer.h" +#include "AudioEngine.h" #include "Engine.h" #include @@ -278,10 +278,9 @@ bool RemotePlugin::init(const QString &pluginExecutable, -bool RemotePlugin::process( const sampleFrame * _in_buf, - sampleFrame * _out_buf ) +bool RemotePlugin::process( const sampleFrame * _in_buf, sampleFrame * _out_buf ) { - const fpp_t frames = Engine::mixer()->framesPerPeriod(); + const fpp_t frames = Engine::audioEngine()->framesPerPeriod(); if( m_failed || !isRunning() ) { @@ -431,9 +430,7 @@ void RemotePlugin::hideUI() void RemotePlugin::resizeSharedProcessingMemory() { - const size_t s = ( m_inputCount+m_outputCount ) * - Engine::mixer()->framesPerPeriod() * - sizeof( float ); + const size_t s = ( m_inputCount+m_outputCount ) * Engine::audioEngine()->framesPerPeriod() * sizeof( float ); if( m_shm != NULL ) { #ifdef USE_QT_SHMEM @@ -510,12 +507,12 @@ bool RemotePlugin::processMessage( const message & _m ) case IdSampleRateInformation: reply = true; - reply_message.addInt( Engine::mixer()->processingSampleRate() ); + reply_message.addInt( Engine::audioEngine()->processingSampleRate() ); break; case IdBufferSizeInformation: reply = true; - reply_message.addInt( Engine::mixer()->framesPerPeriod() ); + reply_message.addInt( Engine::audioEngine()->framesPerPeriod() ); break; case IdChangeInputCount: diff --git a/src/core/RenderManager.cpp b/src/core/RenderManager.cpp index 62b278888..4d64f3a14 100644 --- a/src/core/RenderManager.cpp +++ b/src/core/RenderManager.cpp @@ -32,23 +32,23 @@ RenderManager::RenderManager( - const Mixer::qualitySettings & qualitySettings, + const AudioEngine::qualitySettings & qualitySettings, const OutputSettings & outputSettings, ProjectRenderer::ExportFileFormats fmt, QString outputPath) : m_qualitySettings(qualitySettings), - m_oldQualitySettings( Engine::mixer()->currentQualitySettings() ), + m_oldQualitySettings( Engine::audioEngine()->currentQualitySettings() ), m_outputSettings(outputSettings), m_format(fmt), m_outputPath(outputPath) { - Engine::mixer()->storeAudioDevice(); + Engine::audioEngine()->storeAudioDevice(); } RenderManager::~RenderManager() { - Engine::mixer()->restoreAudioDevice(); // Also deletes audio dev. - Engine::mixer()->changeQuality( m_oldQualitySettings ); + Engine::audioEngine()->restoreAudioDevice(); // Also deletes audio dev. + Engine::audioEngine()->changeQuality( m_oldQualitySettings ); } void RenderManager::abortProcessing() diff --git a/src/core/RingBuffer.cpp b/src/core/RingBuffer.cpp index dd51ab605..3fe1feeb7 100644 --- a/src/core/RingBuffer.cpp +++ b/src/core/RingBuffer.cpp @@ -24,14 +24,14 @@ */ #include "RingBuffer.h" +#include "AudioEngine.h" #include "Engine.h" -#include "Mixer.h" #include "MixHelpers.h" RingBuffer::RingBuffer( f_cnt_t size ) : - m_fpp( Engine::mixer()->framesPerPeriod() ), - m_samplerate( Engine::mixer()->processingSampleRate() ), + m_fpp( Engine::audioEngine()->framesPerPeriod() ), + m_samplerate( Engine::audioEngine()->processingSampleRate() ), m_size( size + m_fpp ) { m_buffer = new sampleFrame[ m_size ]; @@ -41,8 +41,8 @@ RingBuffer::RingBuffer( f_cnt_t size ) : RingBuffer::RingBuffer( float size ) : - m_fpp( Engine::mixer()->framesPerPeriod() ), - m_samplerate( Engine::mixer()->processingSampleRate() ) + m_fpp( Engine::audioEngine()->framesPerPeriod() ), + m_samplerate( Engine::audioEngine()->processingSampleRate() ) { m_size = msToFrames( size ) + m_fpp; m_buffer = new sampleFrame[ m_size ]; @@ -88,11 +88,11 @@ void RingBuffer::setSamplerateAware( bool b ) { if( b ) { - connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( updateSamplerate() ), Qt::UniqueConnection ); + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( updateSamplerate() ), Qt::UniqueConnection ); } else { - disconnect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( updateSamplerate() ) ); + disconnect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( updateSamplerate() ) ); } } @@ -304,9 +304,9 @@ void RingBuffer::writeSwappedAddingMultiplied( sampleFrame * src, float offset, void RingBuffer::updateSamplerate() { - float newsize = static_cast( ( m_size - m_fpp ) * Engine::mixer()->processingSampleRate() ) / m_samplerate; + float newsize = static_cast( ( m_size - m_fpp ) * Engine::audioEngine()->processingSampleRate() ) / m_samplerate; m_size = static_cast( ceilf( newsize ) ) + m_fpp; - m_samplerate = Engine::mixer()->processingSampleRate(); + m_samplerate = Engine::audioEngine()->processingSampleRate(); delete[] m_buffer; m_buffer = new sampleFrame[ m_size ]; memset( m_buffer, 0, m_size * sizeof( sampleFrame ) ); diff --git a/src/core/SampleBuffer.cpp b/src/core/SampleBuffer.cpp index 13e9df948..392a69364 100644 --- a/src/core/SampleBuffer.cpp +++ b/src/core/SampleBuffer.cpp @@ -50,6 +50,7 @@ #endif +#include "AudioEngine.h" #include "base64.h" #include "ConfigManager.h" #include "DrumSynth.h" @@ -57,7 +58,6 @@ #include "Engine.h" #include "GuiApplication.h" #include "lmms_constants.h" -#include "Mixer.h" #include "PathUtil.h" #include "FileDialog.h" @@ -77,10 +77,10 @@ SampleBuffer::SampleBuffer() : m_amplification(1.0f), m_reversed(false), m_frequency(DefaultBaseFreq), - m_sampleRate(mixerSampleRate()) + m_sampleRate(audioEngineSampleRate()) { - connect(Engine::mixer(), SIGNAL(sampleRateChanged()), this, SLOT(sampleRateChanged())); + connect(Engine::audioEngine(), SIGNAL(sampleRateChanged()), this, SLOT(sampleRateChanged())); update(); } @@ -226,9 +226,9 @@ void SampleBuffer::sampleRateChanged() update(true); } -sample_rate_t SampleBuffer::mixerSampleRate() +sample_rate_t SampleBuffer::audioEngineSampleRate() { - return Engine::mixer()->processingSampleRate(); + return Engine::audioEngine()->processingSampleRate(); } @@ -237,7 +237,7 @@ void SampleBuffer::update(bool keepSettings) const bool lock = (m_data != nullptr); if (lock) { - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); m_varLock.lockForWrite(); MM_FREE(m_data); } @@ -266,7 +266,7 @@ void SampleBuffer::update(bool keepSettings) int_sample_t * buf = nullptr; sample_t * fbuf = nullptr; ch_cnt_t channels = DEFAULT_CHANNELS; - sample_rate_t samplerate = mixerSampleRate(); + sample_rate_t samplerate = audioEngineSampleRate(); m_frames = 0; const QFileInfo fileInfo(file); @@ -350,7 +350,7 @@ void SampleBuffer::update(bool keepSettings) if (lock) { m_varLock.unlock(); - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); } emit sampleUpdated(); @@ -433,11 +433,11 @@ void SampleBuffer::normalizeSampleRate(const sample_rate_t srcSR, bool keepSetti { const sample_rate_t oldRate = m_sampleRate; // do samplerate-conversion to our default-samplerate - if (srcSR != mixerSampleRate()) + if (srcSR != audioEngineSampleRate()) { - SampleBuffer * resampled = resample(srcSR, mixerSampleRate()); + SampleBuffer * resampled = resample(srcSR, audioEngineSampleRate()); - m_sampleRate = mixerSampleRate(); + m_sampleRate = audioEngineSampleRate(); MM_FREE(m_data); m_frames = resampled->frames(); m_data = MM_ALLOC(sampleFrame, m_frames); @@ -451,15 +451,15 @@ void SampleBuffer::normalizeSampleRate(const sample_rate_t srcSR, bool keepSetti m_loopStartFrame = m_startFrame = 0; m_loopEndFrame = m_endFrame = m_frames; } - else if (oldRate != mixerSampleRate()) + else if (oldRate != audioEngineSampleRate()) { - auto oldRateToNewRateRatio = static_cast(mixerSampleRate()) / oldRate; + auto oldRateToNewRateRatio = static_cast(audioEngineSampleRate()) / oldRate; m_startFrame = qBound(0, f_cnt_t(m_startFrame * oldRateToNewRateRatio), m_frames); m_endFrame = qBound(m_startFrame, f_cnt_t(m_endFrame * oldRateToNewRateRatio), m_frames); m_loopStartFrame = qBound(0, f_cnt_t(m_loopStartFrame * oldRateToNewRateRatio), m_frames); m_loopEndFrame = qBound(m_loopStartFrame, f_cnt_t(m_loopEndFrame * oldRateToNewRateRatio), m_frames); - m_sampleRate = mixerSampleRate(); + m_sampleRate = audioEngineSampleRate(); } } @@ -723,7 +723,7 @@ bool SampleBuffer::play( // samples that contain a tone that matches the default base note frequency of 440 Hz will // produce the exact requested pitch in [Hz]. const double freqFactor = (double) freq / (double) m_frequency * - m_sampleRate / Engine::mixer()->processingSampleRate(); + m_sampleRate / Engine::audioEngine()->processingSampleRate(); // calculate how many frames we have in requested pitch const f_cnt_t totalFramesForCurrentPitch = static_cast( @@ -1272,7 +1272,7 @@ QString & SampleBuffer::toBase64(QString & dst) const /* FLAC__stream_encoder_set_do_exhaustive_model_search(flacEnc, true); FLAC__stream_encoder_set_do_mid_side_stereo(flacEnc, true);*/ FLAC__stream_encoder_set_sample_rate(flacEnc, - Engine::mixer()->sampleRate()); + Engine::audioEngine()->sampleRate()); QBuffer baWriter; baWriter.open(QBuffer::WriteOnly); @@ -1299,7 +1299,7 @@ QString & SampleBuffer::toBase64(QString & dst) const for (ch_cnt_t ch = 0; ch < DEFAULT_CHANNELS; ++ch) { buf[f*DEFAULT_CHANNELS+ch] = (FLAC__int32)( - Mixer::clip(m_data[f+frameCnt][ch]) * + AudioEngine::clip(m_data[f+frameCnt][ch]) * OUTPUT_SAMPLE_MULTIPLIER); } } @@ -1554,12 +1554,12 @@ void SampleBuffer::setAmplification(float a) void SampleBuffer::setReversed(bool on) { - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); m_varLock.lockForWrite(); if (m_reversed != on) { std::reverse(m_data, m_data + m_frames); } m_reversed = on; m_varLock.unlock(); - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); emit sampleUpdated(); } diff --git a/src/core/SamplePlayHandle.cpp b/src/core/SamplePlayHandle.cpp index 2b19d56fc..b46607f05 100644 --- a/src/core/SamplePlayHandle.cpp +++ b/src/core/SamplePlayHandle.cpp @@ -23,12 +23,12 @@ */ #include "SamplePlayHandle.h" +#include "AudioEngine.h" #include "AudioPort.h" #include "BBTrack.h" #include "Engine.h" #include "InstrumentTrack.h" #include "lmms_constants.h" -#include "Mixer.h" #include "SampleTCO.h" @@ -86,7 +86,7 @@ SamplePlayHandle::~SamplePlayHandle() void SamplePlayHandle::play( sampleFrame * buffer ) { - const fpp_t fpp = Engine::mixer()->framesPerPeriod(); + const fpp_t fpp = Engine::audioEngine()->framesPerPeriod(); //play( 0, _try_parallelizing ); if( framesDone() >= totalFrames() ) { @@ -143,7 +143,8 @@ bool SamplePlayHandle::isFromTrack( const Track * _track ) const f_cnt_t SamplePlayHandle::totalFrames() const { - return ( m_sampleBuffer->endFrame() - m_sampleBuffer->startFrame() ) * ( Engine::mixer()->processingSampleRate() / m_sampleBuffer->sampleRate() ); + return ( m_sampleBuffer->endFrame() - m_sampleBuffer->startFrame() ) * + ( Engine::audioEngine()->processingSampleRate() / m_sampleBuffer->sampleRate() ); } diff --git a/src/core/SampleRecordHandle.cpp b/src/core/SampleRecordHandle.cpp index c8f688a96..9da1163bf 100644 --- a/src/core/SampleRecordHandle.cpp +++ b/src/core/SampleRecordHandle.cpp @@ -24,10 +24,10 @@ #include "SampleRecordHandle.h" +#include "AudioEngine.h" #include "BBTrack.h" #include "Engine.h" #include "InstrumentTrack.h" -#include "Mixer.h" #include "SampleBuffer.h" #include "SampleTrack.h" #include "debug.h" @@ -68,8 +68,8 @@ SampleRecordHandle::~SampleRecordHandle() void SampleRecordHandle::play( sampleFrame * /*_working_buffer*/ ) { - const sampleFrame * recbuf = Engine::mixer()->inputBuffer(); - const f_cnt_t frames = Engine::mixer()->inputBufferFrames(); + const sampleFrame * recbuf = Engine::audioEngine()->inputBuffer(); + const f_cnt_t frames = Engine::audioEngine()->inputBufferFrames(); writeBuffer( recbuf, frames ); m_framesRecorded += frames; @@ -120,8 +120,7 @@ void SampleRecordHandle::createSampleBuffer( SampleBuffer** sampleBuf ) assert( data != NULL ); // now copy all buffers into big buffer - for( bufferList::const_iterator it = m_buffers.begin(); - it != m_buffers.end(); ++it ) + for( bufferList::const_iterator it = m_buffers.begin(); it != m_buffers.end(); ++it ) { memcpy( data_ptr, ( *it ).first, ( *it ).second * sizeof( sampleFrame ) ); @@ -129,15 +128,14 @@ void SampleRecordHandle::createSampleBuffer( SampleBuffer** sampleBuf ) } // create according sample-buffer out of big buffer *sampleBuf = new SampleBuffer( data, frames ); - ( *sampleBuf)->setSampleRate( Engine::mixer()->inputSampleRate() ); + ( *sampleBuf)->setSampleRate( Engine::audioEngine()->inputSampleRate() ); delete[] data; } -void SampleRecordHandle::writeBuffer( const sampleFrame * _ab, - const f_cnt_t _frames ) +void SampleRecordHandle::writeBuffer( const sampleFrame * _ab, const f_cnt_t _frames ) { sampleFrame * buf = new sampleFrame[_frames]; for( f_cnt_t frame = 0; frame < _frames; ++frame ) diff --git a/src/core/SampleTCO.cpp b/src/core/SampleTCO.cpp index 888fb3cb9..5c4ac44d0 100644 --- a/src/core/SampleTCO.cpp +++ b/src/core/SampleTCO.cpp @@ -100,9 +100,9 @@ SampleTCO::~SampleTCO() { sampletrack->updateTcos(); } - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); sharedObject::unref( m_sampleBuffer ); - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); } @@ -125,9 +125,9 @@ const QString & SampleTCO::sampleFile() const void SampleTCO::setSampleBuffer( SampleBuffer* sb ) { - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); sharedObject::unref( m_sampleBuffer ); - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); m_sampleBuffer = sb; updateLength(); @@ -172,7 +172,7 @@ void SampleTCO::toggleRecord() void SampleTCO::playbackPositionChanged() { - Engine::mixer()->removePlayHandlesOfTypes( getTrack(), PlayHandle::TypeSamplePlayHandle ); + Engine::audioEngine()->removePlayHandlesOfTypes( getTrack(), PlayHandle::TypeSamplePlayHandle ); SampleTrack * st = dynamic_cast( getTrack() ); st->setPlayingTcos( false ); } diff --git a/src/core/Song.cpp b/src/core/Song.cpp index 64773e654..e09a89ef1 100644 --- a/src/core/Song.cpp +++ b/src/core/Song.cpp @@ -106,7 +106,7 @@ Song::Song() : this, SLOT( setTimeSignature() ), Qt::DirectConnection ); - connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( updateFramesPerTick() ) ); connect( &m_masterVolumeModel, SIGNAL( dataChanged() ), @@ -135,8 +135,7 @@ Song::~Song() void Song::masterVolumeChanged() { - Engine::mixer()->setMasterGain( m_masterVolumeModel.value() / - 100.0f ); + Engine::audioEngine()->setMasterGain( m_masterVolumeModel.value() / 100.0f ); } @@ -144,9 +143,9 @@ void Song::masterVolumeChanged() void Song::setTempo() { - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); const bpm_t tempo = ( bpm_t ) m_tempoModel.value(); - PlayHandleList & playHandles = Engine::mixer()->playHandles(); + PlayHandleList & playHandles = Engine::audioEngine()->playHandles(); for( PlayHandleList::Iterator it = playHandles.begin(); it != playHandles.end(); ++it ) { @@ -158,7 +157,7 @@ void Song::setTempo() nph->unlock(); } } - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); Engine::updateFramesPerTick(); @@ -272,7 +271,7 @@ void Song::processNextBuffer() } const auto framesPerTick = Engine::framesPerTick(); - const auto framesPerPeriod = Engine::mixer()->framesPerPeriod(); + const auto framesPerPeriod = Engine::audioEngine()->framesPerPeriod(); f_cnt_t frameOffsetInPeriod = 0; @@ -640,7 +639,7 @@ void Song::stop() } // To avoid race conditions with the processing threads - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); TimeLineWidget * tl = m_playPos[m_playMode].m_timeLine; m_paused = false; @@ -688,7 +687,7 @@ void Song::stop() / (double) Engine::framesPerTick() ); // remove all note-play-handles that are active - Engine::mixer()->clear(); + Engine::audioEngine()->clear(); // Moves the control of the models that were processed on the last frame // back to their controllers. @@ -701,7 +700,7 @@ void Song::stop() m_playMode = Mode_None; - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); emit stopped(); emit playbackStateChanged(); @@ -865,7 +864,7 @@ void Song::clearProject() } - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); if( gui && gui->getBBEditor() ) { @@ -909,7 +908,7 @@ void Song::clearProject() AutomationPattern::globalAutomationPattern( &m_masterPitchModel )-> clear(); - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); if( gui && gui->getProjectNotes() ) { @@ -1066,7 +1065,7 @@ void Song::loadProject( const QString & fileName ) clearErrors(); - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); // get the header information from the DOM m_tempoModel.loadSettings( dataFile.head(), "bpm" ); @@ -1187,7 +1186,7 @@ void Song::loadProject( const QString & fileName ) AutomationPattern::resolveAllIDs(); - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); ConfigManager::inst()->addRecentlyOpenedProject( fileName ); @@ -1538,10 +1537,10 @@ void Song::setScale(unsigned int index, std::shared_ptr newScale) { if (index >= MaxScaleCount) {index = 0;} - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); std::atomic_store(&m_scales[index], newScale); emit scaleListChanged(index); - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); } @@ -1549,8 +1548,8 @@ void Song::setKeymap(unsigned int index, std::shared_ptr newMap) { if (index >= MaxKeymapCount) {index = 0;} - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); std::atomic_store(&m_keymaps[index], newMap); emit keymapListChanged(index); - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); } diff --git a/src/core/Track.cpp b/src/core/Track.cpp index a6111c06e..513dac0b7 100644 --- a/src/core/Track.cpp +++ b/src/core/Track.cpp @@ -105,7 +105,7 @@ Track::~Track() */ Track * Track::create( TrackTypes tt, TrackContainer * tc ) { - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); Track * t = NULL; @@ -130,7 +130,7 @@ Track * Track::create( TrackTypes tt, TrackContainer * tc ) tc->updateAfterTrackAdd(); - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); return t; } @@ -145,7 +145,7 @@ Track * Track::create( TrackTypes tt, TrackContainer * tc ) */ Track * Track::create( const QDomElement & element, TrackContainer * tc ) { - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); Track * t = create( static_cast( element.attribute( "type" ).toInt() ), @@ -155,7 +155,7 @@ Track * Track::create( const QDomElement & element, TrackContainer * tc ) t->restoreState( element ); } - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); return t; } diff --git a/src/core/TrackContentObject.cpp b/src/core/TrackContentObject.cpp index ad41fd110..52c02b7aa 100644 --- a/src/core/TrackContentObject.cpp +++ b/src/core/TrackContentObject.cpp @@ -92,9 +92,9 @@ void TrackContentObject::movePosition( const TimePos & pos ) TimePos newPos = qMax(0, pos.getTicks()); if (m_startPosition != newPos) { - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); m_startPosition = newPos; - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); Engine::getSong()->updateLength(); emit positionChanged(); } diff --git a/src/core/VstSyncController.cpp b/src/core/VstSyncController.cpp index dd9660cb5..215c59788 100644 --- a/src/core/VstSyncController.cpp +++ b/src/core/VstSyncController.cpp @@ -25,9 +25,9 @@ #include +#include "AudioEngine.h" #include "ConfigManager.h" #include "Engine.h" -#include "Mixer.h" #include "VstSyncController.h" #include "RemotePlugin.h" @@ -48,7 +48,7 @@ VstSyncController::VstSyncController() : { if( ConfigManager::inst()->value( "ui", "syncvstplugins" ).toInt() ) { - connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( updateSampleRate() ) ); + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( updateSampleRate() ) ); #ifdef USE_QT_SHMEM if ( m_shm.create( sizeof( VstSyncData ) ) ) @@ -98,7 +98,7 @@ VstSyncController::VstSyncController() : } m_syncData->isPlaying = false; - m_syncData->m_bufferSize = Engine::mixer()->framesPerPeriod(); + m_syncData->m_bufferSize = Engine::audioEngine()->framesPerPeriod(); m_syncData->timeSigNumer = 4; m_syncData->timeSigDenom = 4; @@ -170,7 +170,7 @@ void VstSyncController::startCycle( int startTick, int endTick ) void VstSyncController::update() { - m_syncData->m_bufferSize = Engine::mixer()->framesPerPeriod(); + m_syncData->m_bufferSize = Engine::audioEngine()->framesPerPeriod(); #ifdef VST_SNC_LATENCY m_syncData->m_latency = m_syncData->m_bufferSize * m_syncData->m_bpm / ( (float) m_syncData->m_sampleRate * 60 ); @@ -181,7 +181,7 @@ void VstSyncController::update() void VstSyncController::updateSampleRate() { - m_syncData->m_sampleRate = Engine::mixer()->processingSampleRate(); + m_syncData->m_sampleRate = Engine::audioEngine()->processingSampleRate(); #ifdef VST_SNC_LATENCY m_syncData->m_latency = m_syncData->m_bufferSize * m_syncData->m_bpm / ( (float) m_syncData->m_sampleRate * 60 ); diff --git a/src/core/audio/AudioAlsa.cpp b/src/core/audio/AudioAlsa.cpp index b86675706..549c05d55 100644 --- a/src/core/audio/AudioAlsa.cpp +++ b/src/core/audio/AudioAlsa.cpp @@ -30,17 +30,17 @@ #ifdef LMMS_HAVE_ALSA #include "endian_handling.h" +#include "AudioEngine.h" #include "ConfigManager.h" #include "Engine.h" -#include "Mixer.h" #include "gui_templates.h" -AudioAlsa::AudioAlsa( bool & _success_ful, Mixer* _mixer ) : +AudioAlsa::AudioAlsa( bool & _success_ful, AudioEngine* _audioEngine ) : AudioDevice( qBound( DEFAULT_CHANNELS, ConfigManager::inst()->value( "audioalsa", "channels" ).toInt(), - SURROUND_CHANNELS ), _mixer ), + SURROUND_CHANNELS ), _audioEngine ), m_handle( NULL ), m_hwParams( NULL ), m_swParams( NULL ), @@ -255,7 +255,7 @@ void AudioAlsa::applyQualitySettings() { if( hqAudio() ) { - setSampleRate( Engine::mixer()->processingSampleRate() ); + setSampleRate( Engine::audioEngine()->processingSampleRate() ); if( m_handle != NULL ) { @@ -296,14 +296,11 @@ void AudioAlsa::applyQualitySettings() void AudioAlsa::run() { - surroundSampleFrame * temp = - new surroundSampleFrame[mixer()->framesPerPeriod()]; - int_sample_t * outbuf = - new int_sample_t[mixer()->framesPerPeriod() * - channels()]; + surroundSampleFrame * temp = new surroundSampleFrame[audioEngine()->framesPerPeriod()]; + int_sample_t * outbuf = new int_sample_t[audioEngine()->framesPerPeriod() * channels()]; int_sample_t * pcmbuf = new int_sample_t[m_periodSize * channels()]; - int outbuf_size = mixer()->framesPerPeriod() * channels(); + int outbuf_size = audioEngine()->framesPerPeriod() * channels(); int outbuf_pos = 0; int pcmbuf_size = m_periodSize * channels(); @@ -328,7 +325,7 @@ void AudioAlsa::run() outbuf_size = frames * channels(); convertToS16( temp, frames, - mixer()->masterGain(), + audioEngine()->masterGain(), outbuf, m_convertEndian ); } @@ -429,7 +426,7 @@ int AudioAlsa::setHWParams( const ch_cnt_t _channels, snd_pcm_access_t _access ) sampleRate(), 0 ) ) < 0 ) { if( ( err = snd_pcm_hw_params_set_rate( m_handle, m_hwParams, - mixer()->baseSampleRate(), 0 ) ) < 0 ) + audioEngine()->baseSampleRate(), 0 ) ) < 0 ) { printf( "Could not set sample rate: %s\n", snd_strerror( err ) ); @@ -437,7 +434,7 @@ int AudioAlsa::setHWParams( const ch_cnt_t _channels, snd_pcm_access_t _access ) } } - m_periodSize = mixer()->framesPerPeriod(); + m_periodSize = audioEngine()->framesPerPeriod(); m_bufferSize = m_periodSize * 8; dir = 0; err = snd_pcm_hw_params_set_period_size_near( m_handle, m_hwParams, diff --git a/src/core/audio/AudioDevice.cpp b/src/core/audio/AudioDevice.cpp index a57fa2bd6..c0d3688a9 100644 --- a/src/core/audio/AudioDevice.cpp +++ b/src/core/audio/AudioDevice.cpp @@ -1,5 +1,5 @@ /* - * AudioDevice.cpp - base-class for audio-devices used by LMMS-mixer + * AudioDevice.cpp - base-class for audio-devices used by LMMS audio engine * * Copyright (c) 2004-2014 Tobias Doerffel * @@ -25,22 +25,22 @@ #include #include "AudioDevice.h" +#include "AudioEngine.h" #include "ConfigManager.h" #include "debug.h" -#include "Mixer.h" -AudioDevice::AudioDevice( const ch_cnt_t _channels, Mixer* _mixer ) : +AudioDevice::AudioDevice( const ch_cnt_t _channels, AudioEngine* _audioEngine ) : m_supportsCapture( false ), - m_sampleRate( _mixer->processingSampleRate() ), + m_sampleRate( _audioEngine->processingSampleRate() ), m_channels( _channels ), - m_mixer( _mixer ), - m_buffer( new surroundSampleFrame[mixer()->framesPerPeriod()] ) + m_audioEngine( _audioEngine ), + m_buffer( new surroundSampleFrame[audioEngine()->framesPerPeriod()] ) { int error; if( ( m_srcState = src_new( - mixer()->currentQualitySettings().libsrcInterpolation(), + audioEngine()->currentQualitySettings().libsrcInterpolation(), SURROUND_CHANNELS, &error ) ) == NULL ) { printf( "Error: src_new() failed in audio_device.cpp!\n" ); @@ -67,7 +67,7 @@ void AudioDevice::processNextBuffer() const fpp_t frames = getNextBuffer( m_buffer ); if( frames ) { - writeBuffer( m_buffer, frames, mixer()->masterGain() ); + writeBuffer( m_buffer, frames, audioEngine()->masterGain() ); } else { @@ -80,8 +80,8 @@ void AudioDevice::processNextBuffer() fpp_t AudioDevice::getNextBuffer( surroundSampleFrame * _ab ) { - fpp_t frames = mixer()->framesPerPeriod(); - const surroundSampleFrame * b = mixer()->nextBuffer(); + fpp_t frames = audioEngine()->framesPerPeriod(); + const surroundSampleFrame * b = audioEngine()->nextBuffer(); if( !b ) { return 0; @@ -91,10 +91,9 @@ fpp_t AudioDevice::getNextBuffer( surroundSampleFrame * _ab ) lock(); // resample if necessary - if( mixer()->processingSampleRate() != m_sampleRate ) + if( audioEngine()->processingSampleRate() != m_sampleRate ) { - frames = resample( b, frames, _ab, mixer()->processingSampleRate(), - m_sampleRate ); + frames = resample( b, frames, _ab, audioEngine()->processingSampleRate(), m_sampleRate ); } else { @@ -104,7 +103,7 @@ fpp_t AudioDevice::getNextBuffer( surroundSampleFrame * _ab ) // release lock unlock(); - if( mixer()->hasFifoWriter() ) + if( audioEngine()->hasFifoWriter() ) { delete[] b; } @@ -117,7 +116,7 @@ fpp_t AudioDevice::getNextBuffer( surroundSampleFrame * _ab ) void AudioDevice::stopProcessing() { - if( mixer()->hasFifoWriter() ) + if( audioEngine()->hasFifoWriter() ) { while( m_inProcess ) { @@ -151,7 +150,7 @@ void AudioDevice::applyQualitySettings() int error; if( ( m_srcState = src_new( - mixer()->currentQualitySettings().libsrcInterpolation(), + audioEngine()->currentQualitySettings().libsrcInterpolation(), SURROUND_CHANNELS, &error ) ) == NULL ) { printf( "Error: src_new() failed in audio_device.cpp!\n" ); @@ -222,7 +221,7 @@ int AudioDevice::convertToS16( const surroundSampleFrame * _ab, { for( ch_cnt_t chnl = 0; chnl < channels(); ++chnl ) { - temp = static_cast( Mixer::clip( _ab[frame][chnl] * _master_gain ) * OUTPUT_SAMPLE_MULTIPLIER ); + temp = static_cast( AudioEngine::clip( _ab[frame][chnl] * _master_gain ) * OUTPUT_SAMPLE_MULTIPLIER ); ( _output_buffer + frame * channels() )[chnl] = ( temp & 0x00ff ) << 8 | @@ -238,7 +237,7 @@ int AudioDevice::convertToS16( const surroundSampleFrame * _ab, { ( _output_buffer + frame * channels() )[chnl] = static_cast( - Mixer::clip( _ab[frame][chnl] * + AudioEngine::clip( _ab[frame][chnl] * _master_gain ) * OUTPUT_SAMPLE_MULTIPLIER ); } diff --git a/src/core/audio/AudioFileDevice.cpp b/src/core/audio/AudioFileDevice.cpp index 2c340861c..62f5871e7 100644 --- a/src/core/audio/AudioFileDevice.cpp +++ b/src/core/audio/AudioFileDevice.cpp @@ -33,8 +33,8 @@ AudioFileDevice::AudioFileDevice( OutputSettings const & outputSettings, const ch_cnt_t _channels, const QString & _file, - Mixer* _mixer ) : - AudioDevice( _channels, _mixer ), + AudioEngine* _audioEngine ) : + AudioDevice( _channels, _audioEngine ), m_outputFile( _file ), m_outputSettings(outputSettings) { diff --git a/src/core/audio/AudioFileFlac.cpp b/src/core/audio/AudioFileFlac.cpp index cb159e46d..aa6d8e214 100644 --- a/src/core/audio/AudioFileFlac.cpp +++ b/src/core/audio/AudioFileFlac.cpp @@ -29,10 +29,10 @@ #include "AudioFileFlac.h" #include "endian_handling.h" -#include "Mixer.h" +#include "AudioEngine.h" -AudioFileFlac::AudioFileFlac(OutputSettings const& outputSettings, ch_cnt_t const channels, bool& successful, QString const& file, Mixer* mixer): - AudioFileDevice(outputSettings,channels,file,mixer), +AudioFileFlac::AudioFileFlac(OutputSettings const& outputSettings, ch_cnt_t const channels, bool& successful, QString const& file, AudioEngine* audioEngine): + AudioFileDevice(outputSettings,channels,file,audioEngine), m_sf(nullptr) { successful = outputFileOpened() && startEncoding(); @@ -47,7 +47,7 @@ bool AudioFileFlac::startEncoding() { m_sfinfo.samplerate=sampleRate(); m_sfinfo.channels=channels(); - m_sfinfo.frames = mixer()->framesPerPeriod(); + m_sfinfo.frames = audioEngine()->framesPerPeriod(); m_sfinfo.sections=1; m_sfinfo.seekable=0; diff --git a/src/core/audio/AudioFileMP3.cpp b/src/core/audio/AudioFileMP3.cpp index a00cdf611..0a0045a9c 100644 --- a/src/core/audio/AudioFileMP3.cpp +++ b/src/core/audio/AudioFileMP3.cpp @@ -27,7 +27,7 @@ #ifdef LMMS_HAVE_MP3LAME -#include "Mixer.h" +#include "AudioEngine.h" #include @@ -36,8 +36,8 @@ AudioFileMP3::AudioFileMP3( OutputSettings const & outputSettings, const ch_cnt_t channels, bool & successful, const QString & file, - Mixer* mixer ) : - AudioFileDevice( outputSettings, channels, file, mixer ) + AudioEngine* audioEngine ) : + AudioFileDevice( outputSettings, channels, file, audioEngine ) { successful = true; // For now only accept stereo sources diff --git a/src/core/audio/AudioFileOgg.cpp b/src/core/audio/AudioFileOgg.cpp index 7e1cb48b4..3024789b2 100644 --- a/src/core/audio/AudioFileOgg.cpp +++ b/src/core/audio/AudioFileOgg.cpp @@ -36,15 +36,15 @@ #include #include -#include "Mixer.h" +#include "AudioEngine.h" AudioFileOgg::AudioFileOgg( OutputSettings const & outputSettings, const ch_cnt_t channels, bool & successful, const QString & file, - Mixer* mixer ) : - AudioFileDevice( outputSettings, channels, file, mixer ) + AudioEngine* audioEngine ) : + AudioFileDevice( outputSettings, channels, file, audioEngine ) { m_ok = successful = outputFileOpened() && startEncoding(); } diff --git a/src/core/audio/AudioFileWave.cpp b/src/core/audio/AudioFileWave.cpp index 8a590a8b8..6d2f7f771 100644 --- a/src/core/audio/AudioFileWave.cpp +++ b/src/core/audio/AudioFileWave.cpp @@ -25,7 +25,7 @@ #include "AudioFileWave.h" #include "endian_handling.h" -#include "Mixer.h" +#include "AudioEngine.h" #include #include @@ -34,8 +34,8 @@ AudioFileWave::AudioFileWave( OutputSettings const & outputSettings, const ch_cnt_t channels, bool & successful, const QString & file, - Mixer* mixer ) : - AudioFileDevice( outputSettings, channels, file, mixer ), + AudioEngine* audioEngine ) : + AudioFileDevice( outputSettings, channels, file, audioEngine ), m_sf( NULL ) { successful = outputFileOpened() && startEncoding(); @@ -56,7 +56,7 @@ bool AudioFileWave::startEncoding() { m_si.samplerate = sampleRate(); m_si.channels = channels(); - m_si.frames = mixer()->framesPerPeriod(); + m_si.frames = audioEngine()->framesPerPeriod(); m_si.sections = 1; m_si.seekable = 0; diff --git a/src/core/audio/AudioJack.cpp b/src/core/audio/AudioJack.cpp index 8c03b328d..50053c7f6 100644 --- a/src/core/audio/AudioJack.cpp +++ b/src/core/audio/AudioJack.cpp @@ -37,21 +37,21 @@ #include "LcdSpinBox.h" #include "AudioPort.h" #include "MainWindow.h" -#include "Mixer.h" +#include "AudioEngine.h" #include "MidiJack.h" -AudioJack::AudioJack( bool & _success_ful, Mixer* _mixer ) : +AudioJack::AudioJack( bool & _success_ful, AudioEngine* _audioEngine ) : AudioDevice( qBound( DEFAULT_CHANNELS, ConfigManager::inst()->value( "audiojack", "channels" ).toInt(), - SURROUND_CHANNELS ), _mixer ), + SURROUND_CHANNELS ), _audioEngine ), m_client( NULL ), m_active( false ), m_midiClient( NULL ), m_tempOutBufs( new jack_default_audio_sample_t *[channels()] ), - m_outBuf( new surroundSampleFrame[mixer()->framesPerPeriod()] ), + m_outBuf( new surroundSampleFrame[audioEngine()->framesPerPeriod()] ), m_framesDoneInCurBuf( 0 ), m_framesToDoInCurBuf( 0 ) { @@ -218,7 +218,7 @@ void AudioJack::startProcessing() // try to sync JACK's and LMMS's buffer-size -// jack_set_buffer_size( m_client, mixer()->framesPerPeriod() ); +// jack_set_buffer_size( m_client, audioEngine()->framesPerPeriod() ); @@ -264,7 +264,7 @@ void AudioJack::applyQualitySettings() { if( hqAudio() ) { - setSampleRate( Engine::mixer()->processingSampleRate() ); + setSampleRate( Engine::audioEngine()->processingSampleRate() ); if( jack_get_sample_rate( m_client ) != sampleRate() ) { @@ -363,7 +363,7 @@ int AudioJack::processCallback( jack_nframes_t _nframes, void * _udata ) } #ifdef AUDIO_PORT_SUPPORT - const int frames = qMin( _nframes, mixer()->framesPerPeriod() ); + const int frames = qMin( _nframes, audioEngine()->framesPerPeriod() ); for( JackPortMap::iterator it = m_portMap.begin(); it != m_portMap.end(); ++it ) { @@ -392,7 +392,7 @@ int AudioJack::processCallback( jack_nframes_t _nframes, void * _udata ) _nframes, m_framesToDoInCurBuf - m_framesDoneInCurBuf ); - const float gain = mixer()->masterGain(); + const float gain = audioEngine()->masterGain(); for( int c = 0; c < channels(); ++c ) { jack_default_audio_sample_t * o = m_tempOutBufs[c]; diff --git a/src/core/audio/AudioOss.cpp b/src/core/audio/AudioOss.cpp index cbf9278a7..7de9d259f 100644 --- a/src/core/audio/AudioOss.cpp +++ b/src/core/audio/AudioOss.cpp @@ -32,7 +32,7 @@ #include "endian_handling.h" #include "LcdSpinBox.h" -#include "Mixer.h" +#include "AudioEngine.h" #include "Engine.h" #include "gui_templates.h" @@ -68,11 +68,11 @@ -AudioOss::AudioOss( bool & _success_ful, Mixer* _mixer ) : +AudioOss::AudioOss( bool & _success_ful, AudioEngine* _audioEngine ) : AudioDevice( qBound( DEFAULT_CHANNELS, ConfigManager::inst()->value( "audiooss", "channels" ).toInt(), - SURROUND_CHANNELS ), _mixer ), + SURROUND_CHANNELS ), _audioEngine ), m_convertEndian( false ) { _success_ful = false; @@ -100,7 +100,7 @@ AudioOss::AudioOss( bool & _success_ful, Mixer* _mixer ) : int frag_spec; for( frag_spec = 0; static_cast( 0x01 << frag_spec ) < - mixer()->framesPerPeriod() * channels() * + audioEngine()->framesPerPeriod() * channels() * BYTES_PER_INT_SAMPLE; ++frag_spec ) { @@ -172,7 +172,7 @@ AudioOss::AudioOss( bool & _success_ful, Mixer* _mixer ) : } if( value != sampleRate() ) { - value = mixer()->baseSampleRate(); + value = audioEngine()->baseSampleRate(); if ( ioctl( m_audioFD, SNDCTL_DSP_SPEED, &value ) < 0 ) { perror( "SNDCTL_DSP_SPEED" ); @@ -261,7 +261,7 @@ void AudioOss::applyQualitySettings() { if( hqAudio() ) { - setSampleRate( Engine::mixer()->processingSampleRate() ); + setSampleRate( Engine::audioEngine()->processingSampleRate() ); unsigned int value = sampleRate(); if ( ioctl( m_audioFD, SNDCTL_DSP_SPEED, &value ) < 0 ) @@ -272,7 +272,7 @@ void AudioOss::applyQualitySettings() } if( value != sampleRate() ) { - value = mixer()->baseSampleRate(); + value = audioEngine()->baseSampleRate(); if ( ioctl( m_audioFD, SNDCTL_DSP_SPEED, &value ) < 0 ) { perror( "SNDCTL_DSP_SPEED" ); @@ -291,11 +291,8 @@ void AudioOss::applyQualitySettings() void AudioOss::run() { - surroundSampleFrame * temp = - new surroundSampleFrame[mixer()->framesPerPeriod()]; - int_sample_t * outbuf = - new int_sample_t[mixer()->framesPerPeriod() * - channels()]; + surroundSampleFrame * temp = new surroundSampleFrame[audioEngine()->framesPerPeriod()]; + int_sample_t * outbuf = new int_sample_t[audioEngine()->framesPerPeriod() * channels()]; while( true ) { @@ -305,9 +302,7 @@ void AudioOss::run() break; } - int bytes = convertToS16( temp, frames, - mixer()->masterGain(), outbuf, - m_convertEndian ); + int bytes = convertToS16( temp, frames, audioEngine()->masterGain(), outbuf, m_convertEndian ); if( write( m_audioFD, outbuf, bytes ) != bytes ) { break; diff --git a/src/core/audio/AudioPort.cpp b/src/core/audio/AudioPort.cpp index 71544dde2..969f4b9f0 100644 --- a/src/core/audio/AudioPort.cpp +++ b/src/core/audio/AudioPort.cpp @@ -24,10 +24,10 @@ #include "AudioPort.h" #include "AudioDevice.h" +#include "AudioEngine.h" #include "EffectChain.h" #include "FxMixer.h" #include "Engine.h" -#include "Mixer.h" #include "MixHelpers.h" #include "BufferManager.h" @@ -45,7 +45,7 @@ AudioPort::AudioPort( const QString & _name, bool _has_effect_chain, m_panningModel( panningModel ), m_mutedModel( mutedModel ) { - Engine::mixer()->addAudioPort( this ); + Engine::audioEngine()->addAudioPort( this ); setExtOutputEnabled( true ); } @@ -55,7 +55,7 @@ AudioPort::AudioPort( const QString & _name, bool _has_effect_chain, AudioPort::~AudioPort() { setExtOutputEnabled( false ); - Engine::mixer()->removeAudioPort( this ); + Engine::audioEngine()->removeAudioPort( this ); BufferManager::release( m_portBuffer ); } @@ -69,11 +69,11 @@ void AudioPort::setExtOutputEnabled( bool _enabled ) m_extOutputEnabled = _enabled; if( m_extOutputEnabled ) { - Engine::mixer()->audioDev()->registerPort( this ); + Engine::audioEngine()->audioDev()->registerPort( this ); } else { - Engine::mixer()->audioDev()->unregisterPort( this ); + Engine::audioEngine()->audioDev()->unregisterPort( this ); } } } @@ -84,7 +84,7 @@ void AudioPort::setExtOutputEnabled( bool _enabled ) void AudioPort::setName( const QString & _name ) { m_name = _name; - Engine::mixer()->audioDev()->renamePort( this ); + Engine::audioEngine()->audioDev()->renamePort( this ); } @@ -94,7 +94,7 @@ bool AudioPort::processEffects() { if( m_effects ) { - bool more = m_effects->processAudioBuffer( m_portBuffer, Engine::mixer()->framesPerPeriod(), m_bufferUsage ); + bool more = m_effects->processAudioBuffer( m_portBuffer, Engine::audioEngine()->framesPerPeriod(), m_bufferUsage ); return more; } return false; @@ -108,7 +108,7 @@ void AudioPort::doProcessing() return; } - const fpp_t fpp = Engine::mixer()->framesPerPeriod(); + const fpp_t fpp = Engine::audioEngine()->framesPerPeriod(); // clear the buffer BufferManager::clear( m_portBuffer, fpp ); diff --git a/src/core/audio/AudioPortAudio.cpp b/src/core/audio/AudioPortAudio.cpp index 865eeca8d..4a73173ec 100644 --- a/src/core/audio/AudioPortAudio.cpp +++ b/src/core/audio/AudioPortAudio.cpp @@ -49,22 +49,22 @@ void AudioPortAudioSetupUtil::updateChannels() #include "ConfigManager.h" #include "gui_templates.h" #include "ComboBox.h" -#include "Mixer.h" +#include "AudioEngine.h" -AudioPortAudio::AudioPortAudio( bool & _success_ful, Mixer * _mixer ) : +AudioPortAudio::AudioPortAudio( bool & _success_ful, AudioEngine * _audioEngine ) : AudioDevice( qBound( DEFAULT_CHANNELS, ConfigManager::inst()->value( "audioportaudio", "channels" ).toInt(), - SURROUND_CHANNELS ), _mixer ), + SURROUND_CHANNELS ), _audioEngine ), m_paStream( NULL ), m_wasPAInitError( false ), - m_outBuf( new surroundSampleFrame[mixer()->framesPerPeriod()] ), + m_outBuf( new surroundSampleFrame[audioEngine()->framesPerPeriod()] ), m_outBufPos( 0 ) { _success_ful = false; - m_outBufSize = mixer()->framesPerPeriod(); + m_outBufSize = audioEngine()->framesPerPeriod(); PaError err = Pa_Initialize(); @@ -111,12 +111,12 @@ AudioPortAudio::AudioPortAudio( bool & _success_ful, Mixer * _mixer ) : return; } - double inLatency = 0;//(double)mixer()->framesPerPeriod() / (double)sampleRate(); - double outLatency = 0;//(double)mixer()->framesPerPeriod() / (double)sampleRate(); + double inLatency = 0;//(double)audioEngine()->framesPerPeriod() / (double)sampleRate(); + double outLatency = 0;//(double)audioEngine()->framesPerPeriod() / (double)sampleRate(); //inLatency = Pa_GetDeviceInfo( inDevIdx )->defaultLowInputLatency; //outLatency = Pa_GetDeviceInfo( outDevIdx )->defaultLowOutputLatency; - const int samples = mixer()->framesPerPeriod(); + const int samples = audioEngine()->framesPerPeriod(); // Configure output parameters. m_outputParameters.device = outDevIdx; @@ -169,7 +169,7 @@ AudioPortAudio::AudioPortAudio( bool & _success_ful, Mixer * _mixer ) : printf( "Input device: '%s' backend: '%s'\n", Pa_GetDeviceInfo( inDevIdx )->name, Pa_GetHostApiInfo( Pa_GetDeviceInfo( inDevIdx )->hostApi )->name ); printf( "Output device: '%s' backend: '%s'\n", Pa_GetDeviceInfo( outDevIdx )->name, Pa_GetHostApiInfo( Pa_GetDeviceInfo( outDevIdx )->hostApi )->name ); - // TODO: debug Mixer::pushInputFrames() + // TODO: debug AudioEngine::pushInputFrames() //m_supportsCapture = true; _success_ful = true; @@ -229,8 +229,8 @@ void AudioPortAudio::applyQualitySettings() if( hqAudio() ) { - setSampleRate( Engine::mixer()->processingSampleRate() ); - int samples = mixer()->framesPerPeriod(); + setSampleRate( Engine::audioEngine()->processingSampleRate() ); + int samples = audioEngine()->framesPerPeriod(); PaError err = Pa_OpenStream( &m_paStream, @@ -261,8 +261,7 @@ int AudioPortAudio::process_callback( { if( supportsCapture() ) { - mixer()->pushInputFrames( (sampleFrame*)_inputBuffer, - _framesPerBuffer ); + audioEngine()->pushInputFrames( (sampleFrame*)_inputBuffer, _framesPerBuffer ); } if( m_stopped ) @@ -290,14 +289,14 @@ int AudioPortAudio::process_callback( const int min_len = qMin( (int)_framesPerBuffer, m_outBufSize - m_outBufPos ); - float master_gain = mixer()->masterGain(); + float master_gain = audioEngine()->masterGain(); for( fpp_t frame = 0; frame < min_len; ++frame ) { for( ch_cnt_t chnl = 0; chnl < channels(); ++chnl ) { ( _outputBuffer + frame * channels() )[chnl] = - Mixer::clip( m_outBuf[frame][chnl] * + AudioEngine::clip( m_outBuf[frame][chnl] * master_gain ); } } diff --git a/src/core/audio/AudioPulseAudio.cpp b/src/core/audio/AudioPulseAudio.cpp index af14960a7..a384c46e5 100644 --- a/src/core/audio/AudioPulseAudio.cpp +++ b/src/core/audio/AudioPulseAudio.cpp @@ -31,7 +31,7 @@ #include "ConfigManager.h" #include "LcdSpinBox.h" -#include "Mixer.h" +#include "AudioEngine.h" #include "gui_templates.h" #include "Engine.h" @@ -44,11 +44,11 @@ static void stream_write_callback(pa_stream *s, size_t length, void *userdata) -AudioPulseAudio::AudioPulseAudio( bool & _success_ful, Mixer* _mixer ) : +AudioPulseAudio::AudioPulseAudio( bool & _success_ful, AudioEngine* _audioEngine ) : AudioDevice( qBound( DEFAULT_CHANNELS, ConfigManager::inst()->value( "audiopa", "channels" ).toInt(), - SURROUND_CHANNELS ), _mixer ), + SURROUND_CHANNELS ), _audioEngine ), m_s( NULL ), m_quit( false ), m_convertEndian( false ) @@ -114,7 +114,7 @@ void AudioPulseAudio::applyQualitySettings() { if( hqAudio() ) { -// setSampleRate( engine::mixer()->processingSampleRate() ); +// setSampleRate( engine::audioEngine()->processingSampleRate() ); } @@ -175,8 +175,7 @@ static void context_state_callback(pa_context *c, void *userdata) buffer_attr.minreq = (uint32_t)(-1); buffer_attr.fragsize = (uint32_t)(-1); - double latency = (double)( Engine::mixer()->framesPerPeriod() ) / - (double)_this->sampleRate(); + double latency = (double)( Engine::audioEngine()->framesPerPeriod() ) / (double)_this->sampleRate(); // ask PulseAudio for the desired latency (which might not be approved) buffer_attr.tlength = pa_usec_to_bytes( latency * PA_USEC_PER_MSEC, @@ -245,7 +244,7 @@ void AudioPulseAudio::run() } else { - const fpp_t fpp = mixer()->framesPerPeriod(); + const fpp_t fpp = audioEngine()->framesPerPeriod(); surroundSampleFrame * temp = new surroundSampleFrame[fpp]; while( getNextBuffer( temp ) ) { @@ -264,7 +263,7 @@ void AudioPulseAudio::run() void AudioPulseAudio::streamWriteCallback( pa_stream *s, size_t length ) { - const fpp_t fpp = mixer()->framesPerPeriod(); + const fpp_t fpp = audioEngine()->framesPerPeriod(); surroundSampleFrame * temp = new surroundSampleFrame[fpp]; int_sample_t* pcmbuf = (int_sample_t *)pa_xmalloc( fpp * channels() * sizeof(int_sample_t) ); @@ -278,7 +277,7 @@ void AudioPulseAudio::streamWriteCallback( pa_stream *s, size_t length ) break; } int bytes = convertToS16( temp, frames, - mixer()->masterGain(), + audioEngine()->masterGain(), pcmbuf, m_convertEndian ); if( bytes > 0 ) diff --git a/src/core/audio/AudioSampleRecorder.cpp b/src/core/audio/AudioSampleRecorder.cpp index a36e0e9da..1e7090694 100644 --- a/src/core/audio/AudioSampleRecorder.cpp +++ b/src/core/audio/AudioSampleRecorder.cpp @@ -32,8 +32,8 @@ AudioSampleRecorder::AudioSampleRecorder( const ch_cnt_t _channels, bool & _success_ful, - Mixer * _mixer ) : - AudioDevice( _channels, _mixer ), + AudioEngine * _audioEngine ) : + AudioDevice( _channels, _audioEngine ), m_buffers() { _success_ful = true; diff --git a/src/core/audio/AudioSdl.cpp b/src/core/audio/AudioSdl.cpp index 833db1b03..ffea3cb66 100644 --- a/src/core/audio/AudioSdl.cpp +++ b/src/core/audio/AudioSdl.cpp @@ -29,14 +29,14 @@ #include #include +#include "AudioEngine.h" #include "Engine.h" #include "ConfigManager.h" #include "gui_templates.h" -#include "Mixer.h" -AudioSdl::AudioSdl( bool & _success_ful, Mixer* _mixer ) : - AudioDevice( DEFAULT_CHANNELS, _mixer ), - m_outBuf( new surroundSampleFrame[mixer()->framesPerPeriod()] ) +AudioSdl::AudioSdl( bool & _success_ful, AudioEngine* _audioEngine ) : + AudioDevice( DEFAULT_CHANNELS, _audioEngine ), + m_outBuf( new surroundSampleFrame[audioEngine()->framesPerPeriod()] ) { _success_ful = false; @@ -44,7 +44,7 @@ AudioSdl::AudioSdl( bool & _success_ful, Mixer* _mixer ) : m_currentBufferFramesCount = 0; m_currentBufferFramePos = 0; #else - m_convertedBufSize = mixer()->framesPerPeriod() * channels() + m_convertedBufSize = audioEngine()->framesPerPeriod() * channels() * sizeof( int_sample_t ); m_convertedBufPos = 0; m_convertedBuf = new Uint8[m_convertedBufSize]; @@ -67,7 +67,7 @@ AudioSdl::AudioSdl( bool & _success_ful, Mixer* _mixer ) : // to convert the buffers #endif m_audioHandle.channels = channels(); - m_audioHandle.samples = qMax( 1024, mixer()->framesPerPeriod()*2 ); + m_audioHandle.samples = qMax( 1024, audioEngine()->framesPerPeriod()*2 ); m_audioHandle.callback = sdlAudioCallback; m_audioHandle.userdata = this; @@ -200,7 +200,7 @@ void AudioSdl::applyQualitySettings() { SDL_CloseAudio(); - setSampleRate( Engine::mixer()->processingSampleRate() ); + setSampleRate( Engine::audioEngine()->processingSampleRate() ); m_audioHandle.freq = sampleRate(); @@ -258,7 +258,7 @@ void AudioSdl::sdlAudioCallback( Uint8 * _buf, int _len ) m_currentBufferFramesCount - m_currentBufferFramePos ); - const float gain = mixer()->masterGain(); + const float gain = audioEngine()->masterGain(); for (uint f = 0; f < min_frames_count; f++) { (m_outBuf + m_currentBufferFramePos)[f][0] *= gain; @@ -289,7 +289,7 @@ void AudioSdl::sdlAudioCallback( Uint8 * _buf, int _len ) * sizeof( int_sample_t ); convertToS16( m_outBuf, frames, - mixer()->masterGain(), + audioEngine()->masterGain(), (int_sample_t *)m_convertedBuf, m_outConvertEndian ); } @@ -316,7 +316,7 @@ void AudioSdl::sdlInputAudioCallback(Uint8 *_buf, int _len) { sampleFrame *samples_buffer = (sampleFrame *) _buf; fpp_t frames = _len / sizeof ( sampleFrame ); - mixer()->pushInputFrames (samples_buffer, frames); + audioEngine()->pushInputFrames (samples_buffer, frames); } #endif diff --git a/src/core/audio/AudioSndio.cpp b/src/core/audio/AudioSndio.cpp index 24bef9246..7d9098734 100644 --- a/src/core/audio/AudioSndio.cpp +++ b/src/core/audio/AudioSndio.cpp @@ -33,7 +33,7 @@ #include "endian_handling.h" #include "LcdSpinBox.h" -#include "Mixer.h" +#include "AudioEngine.h" #include "Engine.h" #include "gui_templates.h" @@ -48,11 +48,11 @@ -AudioSndio::AudioSndio(bool & _success_ful, Mixer * _mixer) : +AudioSndio::AudioSndio(bool & _success_ful, AudioEngine * _audioEngine) : AudioDevice( qBound( DEFAULT_CHANNELS, ConfigManager::inst()->value( "audiosndio", "channels" ).toInt(), - SURROUND_CHANNELS ), _mixer ), + SURROUND_CHANNELS ), _audioEngine ), m_convertEndian ( false ) { _success_ful = false; @@ -80,7 +80,7 @@ AudioSndio::AudioSndio(bool & _success_ful, Mixer * _mixer) : m_par.bits = 16; m_par.le = SIO_LE_NATIVE; m_par.rate = sampleRate(); - m_par.round = mixer()->framesPerPeriod(); + m_par.round = audioEngine()->framesPerPeriod(); m_par.appbufsz = m_par.round * 2; if ( (isLittleEndian() && (m_par.le == 0)) || @@ -150,7 +150,7 @@ void AudioSndio::applyQualitySettings( void ) { if( hqAudio() ) { - setSampleRate( Engine::mixer()->processingSampleRate() ); + setSampleRate( Engine::audioEngine()->processingSampleRate() ); /* change sample rate to sampleRate() */ } @@ -161,10 +161,8 @@ void AudioSndio::applyQualitySettings( void ) void AudioSndio::run( void ) { - surroundSampleFrame * temp = - new surroundSampleFrame[mixer()->framesPerPeriod()]; - int_sample_t * outbuf = - new int_sample_t[mixer()->framesPerPeriod() * channels()]; + surroundSampleFrame * temp = new surroundSampleFrame[audioEngine()->framesPerPeriod()]; + int_sample_t * outbuf = new int_sample_t[audioEngine()->framesPerPeriod() * channels()]; while( true ) { @@ -175,7 +173,7 @@ void AudioSndio::run( void ) } uint bytes = convertToS16( temp, frames, - mixer()->masterGain(), outbuf, m_convertEndian ); + audioEngine()->masterGain(), outbuf, m_convertEndian ); if( sio_write( m_hdl, outbuf, bytes ) != bytes ) { break; diff --git a/src/core/audio/AudioSoundIo.cpp b/src/core/audio/AudioSoundIo.cpp index 34deec1d0..80dd03cb0 100644 --- a/src/core/audio/AudioSoundIo.cpp +++ b/src/core/audio/AudioSoundIo.cpp @@ -34,13 +34,13 @@ #include "ConfigManager.h" #include "gui_templates.h" #include "ComboBox.h" -#include "Mixer.h" +#include "AudioEngine.h" -AudioSoundIo::AudioSoundIo( bool & outSuccessful, Mixer * _mixer ) : +AudioSoundIo::AudioSoundIo( bool & outSuccessful, AudioEngine * _audioEngine ) : AudioDevice( qBound( DEFAULT_CHANNELS, ConfigManager::inst()->value( "audiosoundio", "channels" ).toInt(), - SURROUND_CHANNELS ), _mixer ) + SURROUND_CHANNELS ), _audioEngine ) { outSuccessful = false; m_soundio = NULL; @@ -168,7 +168,7 @@ AudioSoundIo::AudioSoundIo( bool & outSuccessful, Mixer * _mixer ) : } m_outstream->name = "LMMS"; - m_outstream->software_latency = (double)mixer()->framesPerPeriod() / (double)currentSampleRate; + m_outstream->software_latency = (double)audioEngine()->framesPerPeriod() / (double)currentSampleRate; m_outstream->userdata = this; m_outstream->write_callback = staticWriteCallback; m_outstream->error_callback = staticErrorCallback; @@ -216,7 +216,7 @@ void AudioSoundIo::startProcessing() m_outBufFrameIndex = 0; m_outBufFramesTotal = 0; - m_outBufSize = mixer()->framesPerPeriod(); + m_outBufSize = audioEngine()->framesPerPeriod(); m_outBuf = new surroundSampleFrame[m_outBufSize]; @@ -283,7 +283,7 @@ void AudioSoundIo::writeCallback(int frameCountMin, int frameCountMax) int bytesPerSample = m_outstream->bytes_per_sample; int err; - const float gain = mixer()->masterGain(); + const float gain = audioEngine()->masterGain(); int framesLeft = frameCountMax; diff --git a/src/core/lv2/Lv2Proc.cpp b/src/core/lv2/Lv2Proc.cpp index 1ae522150..3ea734f91 100644 --- a/src/core/lv2/Lv2Proc.cpp +++ b/src/core/lv2/Lv2Proc.cpp @@ -33,6 +33,7 @@ #include #include +#include "AudioEngine.h" #include "AutomatableModel.h" #include "ComboBoxModel.h" #include "Engine.h" @@ -41,7 +42,6 @@ #include "Lv2Ports.h" #include "Lv2Evbuf.h" #include "MidiEventToByteSeq.h" -#include "Mixer.h" @@ -391,7 +391,7 @@ void Lv2Proc::initPlugin() createPorts(); m_instance = lilv_plugin_instantiate(m_plugin, - Engine::mixer()->processingSampleRate(), + Engine::audioEngine()->processingSampleRate(), m_features.featurePointers()); if (m_instance) @@ -451,8 +451,8 @@ void Lv2Proc::initMOptions() re-initialize, and this code section will be executed again, creating a new option vector. */ - float sampleRate = Engine::mixer()->processingSampleRate(); - int32_t blockLength = Engine::mixer()->framesPerPeriod(); + float sampleRate = Engine::audioEngine()->processingSampleRate(); + int32_t blockLength = Engine::audioEngine()->framesPerPeriod(); int32_t sequenceSize = defaultEvbufSize(); using Id = Lv2UridCache::Id; @@ -502,7 +502,7 @@ void Lv2Proc::createPort(std::size_t portNum) { AutoLilvNode node(lilv_port_get_name(m_plugin, lilvPort)); QString dispName = lilv_node_as_string(node.get()); - sample_rate_t sr = Engine::mixer()->processingSampleRate(); + sample_rate_t sr = Engine::audioEngine()->processingSampleRate(); if(meta.def() < meta.min(sr) || meta.def() > meta.max(sr)) { qWarning() << "Warning: Plugin" @@ -578,7 +578,7 @@ void Lv2Proc::createPort(std::size_t portNum) Lv2Ports::Audio* audio = new Lv2Ports::Audio( static_cast( - Engine::mixer()->framesPerPeriod()), + Engine::audioEngine()->framesPerPeriod()), portIsSideChain(m_plugin, lilvPort) ); port = audio; @@ -799,7 +799,7 @@ void Lv2Proc::dumpPort(std::size_t num) qDebug() << " visualization: " << Lv2Ports::toStr(port.m_vis); if (port.m_type == Lv2Ports::Type::Control || port.m_type == Lv2Ports::Type::Cv) { - sample_rate_t sr = Engine::mixer()->processingSampleRate(); + sample_rate_t sr = Engine::audioEngine()->processingSampleRate(); qDebug() << " default:" << port.def(); qDebug() << " min:" << port.min(sr); qDebug() << " max:" << port.max(sr); diff --git a/src/core/main.cpp b/src/core/main.cpp index 7b9dc5479..e9171505d 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -362,7 +362,7 @@ int main( int argc, char * * argv ) new QCoreApplication( argc, argv ) : new MainApplication( argc, argv ); - Mixer::qualitySettings qs( Mixer::qualitySettings::Mode_HighQuality ); + AudioEngine::qualitySettings qs( AudioEngine::qualitySettings::Mode_HighQuality ); OutputSettings os( 44100, OutputSettings::BitRateSettings(160, false), OutputSettings::Depth_16Bit, OutputSettings::StereoMode_JointStereo ); ProjectRenderer::ExportFileFormats eff = ProjectRenderer::WaveFile; @@ -628,19 +628,19 @@ int main( int argc, char * * argv ) if( ip == "linear" ) { - qs.interpolation = Mixer::qualitySettings::Interpolation_Linear; + qs.interpolation = AudioEngine::qualitySettings::Interpolation_Linear; } else if( ip == "sincfastest" ) { - qs.interpolation = Mixer::qualitySettings::Interpolation_SincFastest; + qs.interpolation = AudioEngine::qualitySettings::Interpolation_SincFastest; } else if( ip == "sincmedium" ) { - qs.interpolation = Mixer::qualitySettings::Interpolation_SincMedium; + qs.interpolation = AudioEngine::qualitySettings::Interpolation_SincMedium; } else if( ip == "sincbest" ) { - qs.interpolation = Mixer::qualitySettings::Interpolation_SincBest; + qs.interpolation = AudioEngine::qualitySettings::Interpolation_SincBest; } else { @@ -662,16 +662,16 @@ int main( int argc, char * * argv ) switch( o ) { case 1: - qs.oversampling = Mixer::qualitySettings::Oversampling_None; + qs.oversampling = AudioEngine::qualitySettings::Oversampling_None; break; case 2: - qs.oversampling = Mixer::qualitySettings::Oversampling_2x; + qs.oversampling = AudioEngine::qualitySettings::Oversampling_2x; break; case 4: - qs.oversampling = Mixer::qualitySettings::Oversampling_4x; + qs.oversampling = AudioEngine::qualitySettings::Oversampling_4x; break; case 8: - qs.oversampling = Mixer::qualitySettings::Oversampling_8x; + qs.oversampling = AudioEngine::qualitySettings::Oversampling_8x; break; default: return usageError( QString( "Invalid oversampling %1" ).arg( argv[i] ) ); @@ -840,7 +840,7 @@ int main( int argc, char * * argv ) if( profilerOutputFile.isEmpty() == false ) { - Engine::mixer()->profiler().setOutputFile( profilerOutputFile ); + Engine::audioEngine()->profiler().setOutputFile( profilerOutputFile ); } // start now! diff --git a/src/core/midi/MidiController.cpp b/src/core/midi/MidiController.cpp index 93cea4a00..43e30a077 100644 --- a/src/core/midi/MidiController.cpp +++ b/src/core/midi/MidiController.cpp @@ -27,7 +27,7 @@ #include #include "Song.h" -#include "Mixer.h" +#include "AudioEngine.h" #include "MidiClient.h" #include "MidiController.h" @@ -35,8 +35,7 @@ MidiController::MidiController( Model * _parent ) : Controller( Controller::MidiController, _parent, tr( "MIDI Controller" ) ), MidiEventProcessor(), - m_midiPort( tr( "unnamed_midi_controller" ), - Engine::mixer()->midiClient(), this, this, MidiPort::Input ), + m_midiPort( tr( "unnamed_midi_controller" ), Engine::audioEngine()->midiClient(), this, this, MidiPort::Input ), m_lastValue( 0.0f ), m_previousValue( 0.0f ) { diff --git a/src/core/midi/MidiJack.cpp b/src/core/midi/MidiJack.cpp index cd7cfa1a4..55cbbbece 100644 --- a/src/core/midi/MidiJack.cpp +++ b/src/core/midi/MidiJack.cpp @@ -29,11 +29,11 @@ #include #include +#include "AudioEngine.h" #include "ConfigManager.h" #include "gui_templates.h" #include "GuiApplication.h" #include "Engine.h" -#include "Mixer.h" #include "MainWindow.h" /* callback functions for jack */ @@ -71,7 +71,7 @@ MidiJack::MidiJack() : // and also handles the callback, we pass it our address // so that we can also process during the callback - m_jackAudio = dynamic_cast(Engine::mixer()->audioDev()); + m_jackAudio = dynamic_cast(Engine::audioEngine()->audioDev()); if( m_jackAudio ) { // if a jack connection has been created for audio we use that diff --git a/src/gui/ControllerConnectionDialog.cpp b/src/gui/ControllerConnectionDialog.cpp index e15b5aead..7d9a769af 100644 --- a/src/gui/ControllerConnectionDialog.cpp +++ b/src/gui/ControllerConnectionDialog.cpp @@ -29,12 +29,12 @@ #include #include +#include "AudioEngine.h" #include "ControllerConnectionDialog.h" #include "ControllerConnection.h" #include "MidiController.h" #include "MidiClient.h" #include "MidiPortMenu.h" -#include "Mixer.h" #include "LcdSpinBox.h" #include "LedCheckbox.h" #include "ComboBox.h" @@ -70,7 +70,7 @@ public: { m_detectedMidiChannel = event.channel() + 1; m_detectedMidiController = event.controllerNumber() + 1; - m_detectedMidiPort = Engine::mixer()->midiClient()->sourcePortName( event ); + m_detectedMidiPort = Engine::audioEngine()->midiClient()->sourcePortName( event ); emit valueChanged(); } @@ -165,7 +165,7 @@ ControllerConnectionDialog::ControllerConnectionDialog( QWidget * _parent, // when using with non-raw-clients we can provide buttons showing // our port-menus when being clicked - if( !Engine::mixer()->midiClient()->isRaw() ) + if( !Engine::audioEngine()->midiClient()->isRaw() ) { m_readablePorts = new MidiPortMenu( MidiPort::Input ); connect( m_readablePorts, SIGNAL( triggered( QAction * ) ), diff --git a/src/gui/ExportProjectDialog.cpp b/src/gui/ExportProjectDialog.cpp index d6b44dff9..89586ef17 100644 --- a/src/gui/ExportProjectDialog.cpp +++ b/src/gui/ExportProjectDialog.cpp @@ -154,10 +154,10 @@ OutputSettings::StereoMode mapToStereoMode(int index) void ExportProjectDialog::startExport() { - Mixer::qualitySettings qs = - Mixer::qualitySettings( - static_cast(interpolationCB->currentIndex()), - static_cast(oversamplingCB->currentIndex()) ); + AudioEngine::qualitySettings qs = + AudioEngine::qualitySettings( + static_cast(interpolationCB->currentIndex()), + static_cast(oversamplingCB->currentIndex()) ); const int samplerates[5] = { 44100, 48000, 88200, 96000, 192000 }; const bitrate_t bitrates[6] = { 64, 128, 160, 192, 256, 320 }; diff --git a/src/gui/FileBrowser.cpp b/src/gui/FileBrowser.cpp index 8b08ffa59..c91f09630 100644 --- a/src/gui/FileBrowser.cpp +++ b/src/gui/FileBrowser.cpp @@ -37,6 +37,7 @@ #include #include "FileBrowser.h" +#include "AudioEngine.h" #include "BBTrackContainer.h" #include "ConfigManager.h" #include "DataFile.h" @@ -48,7 +49,6 @@ #include "Instrument.h" #include "InstrumentTrack.h" #include "MainWindow.h" -#include "Mixer.h" #include "PluginFactory.h" #include "PresetPreviewPlayHandle.h" #include "SamplePlayHandle.h" @@ -650,7 +650,7 @@ void FileBrowserTreeWidget::previewFileItem(FileItem* file) if (newPPH != nullptr) { - if (Engine::mixer()->addPlayHandle(newPPH)) + if (Engine::audioEngine()->addPlayHandle(newPPH)) { m_previewPlayHandle = newPPH; } @@ -666,7 +666,7 @@ void FileBrowserTreeWidget::stopPreview() QMutexLocker previewLocker(&m_pphMutex); if (m_previewPlayHandle != nullptr) { - Engine::mixer()->removePlayHandle(m_previewPlayHandle); + Engine::audioEngine()->removePlayHandle(m_previewPlayHandle); m_previewPlayHandle = nullptr; } } @@ -751,7 +751,7 @@ void FileBrowserTreeWidget::mouseReleaseEvent(QMouseEvent * me ) void FileBrowserTreeWidget::handleFile(FileItem * f, InstrumentTrack * it) { - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); switch( f->handling() ) { case FileItem::LoadAsProject: @@ -791,7 +791,7 @@ void FileBrowserTreeWidget::handleFile(FileItem * f, InstrumentTrack * it) break; } - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); } @@ -857,10 +857,10 @@ bool FileBrowserTreeWidget::openInNewSampleTrack(FileItem* item) Track::create(Track::SampleTrack, Engine::getSong())); // Add the sample clip to the track - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); SampleTCO* clip = static_cast(sampleTrack->createTCO(0)); clip->setSampleFile(item->fullName()); - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); return true; } diff --git a/src/gui/FxMixerView.cpp b/src/gui/FxMixerView.cpp index 149e132e2..08832c22b 100644 --- a/src/gui/FxMixerView.cpp +++ b/src/gui/FxMixerView.cpp @@ -44,7 +44,7 @@ #include "FxMixer.h" #include "GuiApplication.h" #include "MainWindow.h" -#include "Mixer.h" +#include "AudioEngine.h" #include "gui_templates.h" #include "InstrumentTrack.h" #include "SampleTrack.h" @@ -593,8 +593,8 @@ void FxMixerView::updateFaders() FxMixer * m = Engine::fxMixer(); // apply master gain - m->effectChannel(0)->m_peakLeft *= Engine::mixer()->masterGain(); - m->effectChannel(0)->m_peakRight *= Engine::mixer()->masterGain(); + m->effectChannel(0)->m_peakLeft *= Engine::audioEngine()->masterGain(); + m->effectChannel(0)->m_peakRight *= Engine::audioEngine()->masterGain(); for( int i = 0; i < m_fxChannelViews.size(); ++i ) { diff --git a/src/gui/Lv2ViewBase.cpp b/src/gui/Lv2ViewBase.cpp index 767adea5a..24bb4fbe0 100644 --- a/src/gui/Lv2ViewBase.cpp +++ b/src/gui/Lv2ViewBase.cpp @@ -33,6 +33,7 @@ #include #include +#include "AudioEngine.h" #include "Controls.h" #include "Engine.h" #include "GuiApplication.h" @@ -44,7 +45,6 @@ #include "Lv2Proc.h" #include "Lv2Ports.h" #include "MainWindow.h" -#include "Mixer.h" #include "SubWindow.h" @@ -72,7 +72,7 @@ Lv2ViewProc::Lv2ViewProc(QWidget* parent, Lv2Proc* ctrlBase, int colNum) : break; case PortVis::Integer: { - sample_rate_t sr = Engine::mixer()->processingSampleRate(); + sample_rate_t sr = Engine::audioEngine()->processingSampleRate(); m_control = new LcdControl((port.max(sr) <= 9.0f) ? 1 : 2, m_par); break; diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 73c7065e2..cc20c2bc8 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -477,7 +477,7 @@ void MainWindow::finalize() this, SLOT( onToggleMetronome() ), m_toolBar ); m_metronomeToggle->setCheckable(true); - m_metronomeToggle->setChecked(Engine::mixer()->isMetronomeActive()); + m_metronomeToggle->setChecked(Engine::audioEngine()->isMetronomeActive()); m_toolBarLayout->setColumnMinimumWidth( 0, 5 ); m_toolBarLayout->addWidget( project_new, 0, 1 ); @@ -573,10 +573,10 @@ void MainWindow::finalize() SetupDialog sd; sd.exec(); } - // look whether mixer failed to start the audio device selected by the + // look whether the audio engine failed to start the audio device selected by the // user and is using AudioDummy as a fallback // or the audio device is set to invalid one - else if( Engine::mixer()->audioDevStartFailed() || !Mixer::isAudioDevNameValid( + else if( Engine::audioEngine()->audioDevStartFailed() || !AudioEngine::isAudioDevNameValid( ConfigManager::inst()->value( "mixer", "audiodev" ) ) ) { // if so, offer the audio settings section of the setup dialog @@ -1257,9 +1257,7 @@ void MainWindow::updateConfig( QAction * _who ) void MainWindow::onToggleMetronome() { - Mixer * mixer = Engine::mixer(); - - mixer->setMetronomeActive( m_metronomeToggle->isChecked() ); + Engine::audioEngine()->setMetronomeActive( m_metronomeToggle->isChecked() ); } diff --git a/src/gui/SetupDialog.cpp b/src/gui/SetupDialog.cpp index fd306e682..1ca89140f 100644 --- a/src/gui/SetupDialog.cpp +++ b/src/gui/SetupDialog.cpp @@ -32,6 +32,7 @@ #include #include "AudioDeviceSetupWidget.h" +#include "AudioEngine.h" #include "debug.h" #include "embed.h" #include "Engine.h" @@ -39,7 +40,6 @@ #include "gui_templates.h" #include "MainWindow.h" #include "MidiSetupWidget.h" -#include "Mixer.h" #include "ProjectJournal.h" #include "SetupDialog.h" #include "TabBar.h" @@ -536,7 +536,7 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : QString audioDevName = ConfigManager::inst()->value("mixer", "audiodev"); if (m_audioInterfaces->findText(audioDevName) < 0) { - audioDevName = Engine::mixer()->audioDevName(); + audioDevName = Engine::audioEngine()->audioDevName(); ConfigManager::inst()->setValue("mixer", "audiodev", audioDevName); } m_audioInterfaces-> @@ -681,7 +681,7 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : QString midiDevName = ConfigManager::inst()->value("mixer", "mididev"); if (m_midiInterfaces->findText(midiDevName) < 0) { - midiDevName = Engine::mixer()->midiClientName(); + midiDevName = Engine::audioEngine()->midiClientName(); ConfigManager::inst()->setValue("mixer", "mididev", midiDevName); } m_midiInterfaces->setCurrentIndex(m_midiInterfaces->findText(midiDevName)); @@ -699,9 +699,9 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : m_assignableMidiDevices = new QComboBox(midiAutoAssign_tw); m_assignableMidiDevices->setGeometry(10, 20, 240, 28); m_assignableMidiDevices->addItem("none"); - if ( !Engine::mixer()->midiClient()->isRaw() ) + if ( !Engine::audioEngine()->midiClient()->isRaw() ) { - m_assignableMidiDevices->addItems(Engine::mixer()->midiClient()->readablePorts()); + m_assignableMidiDevices->addItems(Engine::audioEngine()->midiClient()->readablePorts()); } else { @@ -1199,7 +1199,7 @@ void SetupDialog::setBufferSize(int value) m_bufferSize = value * BUFFERSIZE_RESOLUTION; m_bufferSizeLbl->setText(tr("Frames: %1\nLatency: %2 ms").arg(m_bufferSize).arg( - 1000.0f * m_bufferSize / Engine::mixer()->processingSampleRate(), 0, 'f', 1)); + 1000.0f * m_bufferSize / Engine::audioEngine()->processingSampleRate(), 0, 'f', 1)); } diff --git a/src/gui/TrackContainerView.cpp b/src/gui/TrackContainerView.cpp index ffd9d5502..c70bbe265 100644 --- a/src/gui/TrackContainerView.cpp +++ b/src/gui/TrackContainerView.cpp @@ -33,10 +33,10 @@ #include #include "TrackContainer.h" +#include "AudioEngine.h" #include "BBTrack.h" #include "DataFile.h" #include "MainWindow.h" -#include "Mixer.h" #include "FileBrowser.h" #include "ImportFilter.h" #include "Instrument.h" @@ -268,9 +268,9 @@ void TrackContainerView::deleteTrackView( TrackView * _tv ) removeTrackView( _tv ); delete _tv; - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); delete t; - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); } diff --git a/src/gui/TrackView.cpp b/src/gui/TrackView.cpp index a9387ea0d..58fd13493 100644 --- a/src/gui/TrackView.cpp +++ b/src/gui/TrackView.cpp @@ -34,11 +34,11 @@ #include +#include "AudioEngine.h" #include "ConfigManager.h" #include "DataFile.h" #include "Engine.h" #include "FadeButton.h" -#include "Mixer.h" #include "PixmapButton.h" #include "StringPairDrag.h" #include "ToolTip.h" @@ -243,9 +243,9 @@ void TrackView::dropEvent( QDropEvent * de ) // value contains our XML-data so simply create a // DataFile which does the rest for us... DataFile dataFile( value.toUtf8() ); - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); m_track->restoreState( dataFile.content().firstChild().toElement() ); - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); de->accept(); } } diff --git a/src/gui/editors/SongEditor.cpp b/src/gui/editors/SongEditor.cpp index 17bac9498..2105282fc 100644 --- a/src/gui/editors/SongEditor.cpp +++ b/src/gui/editors/SongEditor.cpp @@ -35,6 +35,7 @@ #include #include "AudioDevice.h" +#include "AudioEngine.h" #include "AutomatableSlider.h" #include "ComboBox.h" #include "ConfigManager.h" @@ -45,7 +46,6 @@ #include "LcdSpinBox.h" #include "MainWindow.h" #include "MeterDialog.h" -#include "Mixer.h" #include "Oscilloscope.h" #include "PianoRoll.h" #include "TextFloat.h" @@ -329,9 +329,9 @@ QString SongEditor::getSnapSizeString() const void SongEditor::setHighQuality( bool hq ) { - Engine::mixer()->changeQuality( Mixer::qualitySettings( - hq ? Mixer::qualitySettings::Mode_HighQuality : - Mixer::qualitySettings::Mode_Draft ) ); + Engine::audioEngine()->changeQuality( AudioEngine::qualitySettings( + hq ? AudioEngine::qualitySettings::Mode_HighQuality : + AudioEngine::qualitySettings::Mode_Draft ) ); } @@ -657,7 +657,7 @@ void SongEditor::setMasterVolume( int new_val ) QPoint( m_masterVolumeSlider->width() + 2, -2 ) ); m_mvsStatus->setVisibilityTimeOut( 1000 ); } - Engine::mixer()->setMasterGain( new_val / 100.0f ); + Engine::audioEngine()->setMasterGain( new_val / 100.0f ); } @@ -910,7 +910,7 @@ ComboBoxModel *SongEditor::snappingModel() const SongEditorWindow::SongEditorWindow(Song* song) : - Editor(Engine::mixer()->audioDev()->supportsCapture(), false), + Editor(Engine::audioEngine()->audioDev()->supportsCapture(), false), m_editor(new SongEditor(song)), m_crtlAction( NULL ), m_snapSizeLabel( new QLabel( m_toolBar ) ) diff --git a/src/gui/widgets/CPULoadWidget.cpp b/src/gui/widgets/CPULoadWidget.cpp index 74bb5b975..4cc6bca9f 100644 --- a/src/gui/widgets/CPULoadWidget.cpp +++ b/src/gui/widgets/CPULoadWidget.cpp @@ -26,10 +26,10 @@ #include +#include "AudioEngine.h" #include "CPULoadWidget.h" #include "embed.h" #include "Engine.h" -#include "Mixer.h" CPULoadWidget::CPULoadWidget( QWidget * _parent ) : @@ -92,7 +92,7 @@ void CPULoadWidget::paintEvent( QPaintEvent * ) void CPULoadWidget::updateCpuLoad() { // smooth load-values a bit - int new_load = ( m_currentLoad + Engine::mixer()->cpuLoad() ) / 2; + int new_load = ( m_currentLoad + Engine::audioEngine()->cpuLoad() ) / 2; if( new_load != m_currentLoad ) { m_currentLoad = new_load; diff --git a/src/gui/widgets/EnvelopeAndLfoView.cpp b/src/gui/widgets/EnvelopeAndLfoView.cpp index 4635dc831..0df232819 100644 --- a/src/gui/widgets/EnvelopeAndLfoView.cpp +++ b/src/gui/widgets/EnvelopeAndLfoView.cpp @@ -33,7 +33,7 @@ #include "gui_templates.h" #include "Knob.h" #include "LedCheckbox.h" -#include "Mixer.h" +#include "AudioEngine.h" #include "DataFile.h" #include "Oscillator.h" #include "PixmapButton.h" @@ -425,7 +425,7 @@ void EnvelopeAndLfoView::paintEvent( QPaintEvent * ) int graph_y_base = LFO_GRAPH_Y + 3 + LFO_GRAPH_H / 2; const float frames_for_graph = SECS_PER_LFO_OSCILLATION * - Engine::mixer()->baseSampleRate() / 10; + Engine::audioEngine()->baseSampleRate() / 10; const float lfo_gray_amount = 1.0f - fabsf( m_lfoAmountKnob->value() ); p.setPen( QPen( QColor( static_cast( 96 * lfo_gray_amount ), diff --git a/src/gui/widgets/InstrumentMidiIOView.cpp b/src/gui/widgets/InstrumentMidiIOView.cpp index 63f9a9532..1c49c066a 100644 --- a/src/gui/widgets/InstrumentMidiIOView.cpp +++ b/src/gui/widgets/InstrumentMidiIOView.cpp @@ -29,13 +29,13 @@ #include "InstrumentMidiIOView.h" #include "MidiPortMenu.h" +#include "AudioEngine.h" #include "Engine.h" #include "embed.h" #include "GroupBox.h" #include "gui_templates.h" #include "LcdSpinBox.h" #include "MidiClient.h" -#include "Mixer.h" #include "InstrumentTrack.h" #include "LedCheckbox.h" @@ -127,7 +127,7 @@ InstrumentMidiIOView::InstrumentMidiIOView( QWidget* parent ) : connect( m_midiOutputGroupBox->ledButton(), SIGNAL( toggled( bool ) ), m_fixedOutputNoteSpinBox, SLOT( setEnabled( bool ) ) ); - if( !Engine::mixer()->midiClient()->isRaw() ) + if( !Engine::audioEngine()->midiClient()->isRaw() ) { m_rpBtn = new QToolButton; m_rpBtn->setMinimumSize( 32, 32 ); diff --git a/src/gui/widgets/Oscilloscope.cpp b/src/gui/widgets/Oscilloscope.cpp index 81432bcd4..a18a4a490 100644 --- a/src/gui/widgets/Oscilloscope.cpp +++ b/src/gui/widgets/Oscilloscope.cpp @@ -30,7 +30,7 @@ #include "GuiApplication.h" #include "gui_templates.h" #include "MainWindow.h" -#include "Mixer.h" +#include "AudioEngine.h" #include "Engine.h" #include "ToolTip.h" #include "Song.h" @@ -41,7 +41,7 @@ Oscilloscope::Oscilloscope( QWidget * _p ) : QWidget( _p ), m_background( embed::getIconPixmap( "output_graph" ) ), - m_points( new QPointF[Engine::mixer()->framesPerPeriod()] ), + m_points( new QPointF[Engine::audioEngine()->framesPerPeriod()] ), m_active( false ), m_normalColor(71, 253, 133), m_clippingColor(255, 64, 64) @@ -50,7 +50,7 @@ Oscilloscope::Oscilloscope( QWidget * _p ) : setAttribute( Qt::WA_OpaquePaintEvent, true ); setActive( ConfigManager::inst()->value( "ui", "displaywaveform").toInt() ); - const fpp_t frames = Engine::mixer()->framesPerPeriod(); + const fpp_t frames = Engine::audioEngine()->framesPerPeriod(); m_buffer = new sampleFrame[frames]; BufferManager::clear( m_buffer, frames ); @@ -75,7 +75,7 @@ void Oscilloscope::updateAudioBuffer( const surroundSampleFrame * buffer ) { if( !Engine::getSong()->isExporting() ) { - const fpp_t fpp = Engine::mixer()->framesPerPeriod(); + const fpp_t fpp = Engine::audioEngine()->framesPerPeriod(); memcpy( m_buffer, buffer, sizeof( surroundSampleFrame ) * fpp ); } } @@ -91,7 +91,7 @@ void Oscilloscope::setActive( bool _active ) connect( gui->mainWindow(), SIGNAL( periodicUpdate() ), this, SLOT( update() ) ); - connect( Engine::mixer(), + connect( Engine::audioEngine(), SIGNAL( nextAudioBuffer( const surroundSampleFrame* ) ), this, SLOT( updateAudioBuffer( const surroundSampleFrame* ) ) ); } @@ -100,7 +100,7 @@ void Oscilloscope::setActive( bool _active ) disconnect( gui->mainWindow(), SIGNAL( periodicUpdate() ), this, SLOT( update() ) ); - disconnect( Engine::mixer(), + disconnect( Engine::audioEngine(), SIGNAL( nextAudioBuffer( const surroundSampleFrame* ) ), this, SLOT( updateAudioBuffer( const surroundSampleFrame* ) ) ); // we have to update (remove last waves), @@ -139,12 +139,12 @@ void Oscilloscope::paintEvent( QPaintEvent * ) if( m_active && !Engine::getSong()->isExporting() ) { - Mixer const * mixer = Engine::mixer(); + AudioEngine const * audioEngine = Engine::audioEngine(); - float master_output = mixer->masterGain(); + float master_output = audioEngine->masterGain(); - const fpp_t frames = mixer->framesPerPeriod(); - Mixer::StereoSample peakValues = mixer->getPeakValues(m_buffer, frames); + const fpp_t frames = audioEngine->framesPerPeriod(); + AudioEngine::StereoSample peakValues = audioEngine->getPeakValues(m_buffer, frames); const float max_level = qMax( peakValues.left, peakValues.right ); // Set the color of the line according to the maximum level @@ -164,7 +164,7 @@ void Oscilloscope::paintEvent( QPaintEvent * ) { for( int frame = 0; frame < frames; ++frame ) { - sample_t const clippedSample = Mixer::clip(m_buffer[frame][ch]); + sample_t const clippedSample = AudioEngine::clip(m_buffer[frame][ch]); m_points[frame] = QPointF( x_base + static_cast(frame) * xd, y_base + ( static_cast(clippedSample) * half_h ) ); diff --git a/src/tracks/BBTrack.cpp b/src/tracks/BBTrack.cpp index 354412e02..8d5345697 100644 --- a/src/tracks/BBTrack.cpp +++ b/src/tracks/BBTrack.cpp @@ -56,7 +56,7 @@ BBTrack::BBTrack( TrackContainer* tc ) : BBTrack::~BBTrack() { - Engine::mixer()->removePlayHandlesOfTypes( this, + Engine::audioEngine()->removePlayHandlesOfTypes( this, PlayHandle::TypeNotePlayHandle | PlayHandle::TypeInstrumentPlayHandle | PlayHandle::TypeSamplePlayHandle ); diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index cb6f39da1..9290c01d5 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -37,6 +37,7 @@ #include #include "FileDialog.h" +#include "AudioEngine.h" #include "AutomationPattern.h" #include "BBTrack.h" #include "CaptionMenu.h" @@ -67,7 +68,6 @@ #include "MainWindow.h" #include "MidiClient.h" #include "MidiPortMenu.h" -#include "Mixer.h" #include "MixHelpers.h" #include "Pattern.h" #include "PluginFactory.h" @@ -89,7 +89,7 @@ const int PIANO_HEIGHT = 80; InstrumentTrack::InstrumentTrack( TrackContainer* tc ) : Track( Track::InstrumentTrack, tc ), MidiEventProcessor(), - m_midiPort( tr( "unnamed_track" ), Engine::mixer()->midiClient(), + m_midiPort( tr( "unnamed_track" ), Engine::audioEngine()->midiClient(), this, this ), m_notes(), m_sustainPedalPressed( false ), @@ -387,7 +387,7 @@ void InstrumentTrack::processInEvent( const MidiEvent& event, const TimePos& tim NULL, event.channel(), NotePlayHandle::OriginMidiInput ); m_notes[event.key()] = nph; - if( ! Engine::mixer()->addPlayHandle( nph ) ) + if( ! Engine::audioEngine()->addPlayHandle( nph ) ) { m_notes[event.key()] = NULL; } @@ -401,7 +401,7 @@ void InstrumentTrack::processInEvent( const MidiEvent& event, const TimePos& tim { // do actual note off and remove internal reference to NotePlayHandle (which itself will // be deleted later automatically) - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); m_notes[event.key()]->noteOff( offset ); if (isSustainPedalPressed() && m_notes[event.key()]->origin() == @@ -410,7 +410,7 @@ void InstrumentTrack::processInEvent( const MidiEvent& event, const TimePos& tim m_sustainedNotes << m_notes[event.key()]; } m_notes[event.key()] = NULL; - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); } eventHandled = true; break; @@ -574,7 +574,7 @@ void InstrumentTrack::silenceAllNotes( bool removeIPH ) } m_midiNotesMutex.unlock(); - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); // invalidate all NotePlayHandles and PresetPreviewHandles linked to this track m_processHandles.clear(); @@ -583,8 +583,8 @@ void InstrumentTrack::silenceAllNotes( bool removeIPH ) { flags |= PlayHandle::TypeInstrumentPlayHandle; } - Engine::mixer()->removePlayHandlesOfTypes( this, flags ); - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->removePlayHandlesOfTypes( this, flags ); + Engine::audioEngine()->doneChangeInModel(); } @@ -662,13 +662,13 @@ void InstrumentTrack::setName( const QString & _new_name ) void InstrumentTrack::updateBaseNote() { - Engine::mixer()->requestChangeInModel(); + Engine::audioEngine()->requestChangeInModel(); for( NotePlayHandleList::Iterator it = m_processHandles.begin(); it != m_processHandles.end(); ++it ) { ( *it )->setFrequencyUpdate(); } - Engine::mixer()->doneChangeInModel(); + Engine::audioEngine()->doneChangeInModel(); } @@ -819,7 +819,7 @@ bool InstrumentTrack::play( const TimePos & _start, const fpp_t _frames, notePlayHandle->setSongGlobalParentOffset( p->startPosition() ); } - Engine::mixer()->addPlayHandle( notePlayHandle ); + Engine::audioEngine()->addPlayHandle( notePlayHandle ); played_a_note = true; ++nit; } @@ -1096,14 +1096,14 @@ void InstrumentTrack::autoAssignMidiDevice(bool assign) } const QString &device = ConfigManager::inst()->value("midi", "midiautoassign"); - if ( Engine::mixer()->midiClient()->isRaw() && device != "none" ) + if ( Engine::audioEngine()->midiClient()->isRaw() && device != "none" ) { m_midiPort.setReadable( assign ); return; } // Check if the device exists - if ( Engine::mixer()->midiClient()->readablePorts().indexOf(device) >= 0 ) + if ( Engine::audioEngine()->midiClient()->readablePorts().indexOf(device) >= 0 ) { m_midiPort.subscribeReadablePort(device, assign); m_hasAutoMidiDev = assign; @@ -1170,7 +1170,7 @@ InstrumentTrackView::InstrumentTrackView( InstrumentTrack * _it, TrackContainerV m_midiMenu = new QMenu( tr( "MIDI" ), this ); // sequenced MIDI? - if( !Engine::mixer()->midiClient()->isRaw() ) + if( !Engine::audioEngine()->midiClient()->isRaw() ) { _it->m_midiPort.m_readablePortsMenu = new MidiPortMenu( MidiPort::Input ); diff --git a/src/tracks/SampleTrack.cpp b/src/tracks/SampleTrack.cpp index d035e747c..5f380b806 100644 --- a/src/tracks/SampleTrack.cpp +++ b/src/tracks/SampleTrack.cpp @@ -54,7 +54,7 @@ SampleTrack::SampleTrack(TrackContainer* tc) : SampleTrack::~SampleTrack() { - Engine::mixer()->removePlayHandlesOfTypes( this, PlayHandle::TypeSamplePlayHandle ); + Engine::audioEngine()->removePlayHandlesOfTypes( this, PlayHandle::TypeSamplePlayHandle ); } @@ -147,8 +147,8 @@ bool SampleTrack::play( const TimePos & _start, const fpp_t _frames, handle = smpHandle; } handle->setOffset( _offset ); - // send it to the mixer - Engine::mixer()->addPlayHandle( handle ); + // send it to the audio engine + Engine::audioEngine()->addPlayHandle( handle ); played_a_note = true; } } @@ -218,7 +218,7 @@ void SampleTrack::loadTrackSpecificSettings( const QDomElement & _this ) void SampleTrack::updateTcos() { - Engine::mixer()->removePlayHandlesOfTypes( this, PlayHandle::TypeSamplePlayHandle ); + Engine::audioEngine()->removePlayHandlesOfTypes( this, PlayHandle::TypeSamplePlayHandle ); setPlayingTcos( false ); }