From 286e62adf5561f0cb221b01fcb0608fa0f6db35b Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Sun, 30 Jun 2024 20:21:19 +0200 Subject: [PATCH] Simplify sample frame operations (make it a class) (#7156) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Remove the struct StereoSample Remove the struct `StereoSample`. Let `AudioEngine::getPeakValues` return a `sampleFrame` instead. Adjust the calls in `Mixer` and `Oscilloscope`. * Simplify AudioEngine::getPeakValues * Remove surroundSampleFrame Some code assumes that `surroundSampleFrame` is interchangeable with `sampleFrame`. Thus, if the line `#define LMMS_DISABLE_SURROUND` is commented out in `lmms_basics.h` then the code does not compile anymore because `surroundSampleFrame` now is defined to be an array with four values instead of two. There also does not seem to be any support for surround sound (four channels instead of two) in the application. The faders and mixers do not seem to support more that two channels and the instruments and effects all expect a `sampleFrame`, i.e. stereo channels. It therefore makes sense to remove the "feature" because it also hinders the improvement of `sampleFrame`, e.g. by making it a class with some convenience methods that act on `sampleFrame` instances. All occurrences of `surroundSampleFrame` are replaced with `sampleFrame`. The version of `BufferManager::clear` that takes a `surroundSampleFrame` is removed completely. The define `SURROUND_CHANNELS` is removed. All its occurrences are replaced with `DEFAULT_CHANNELS`. Most of the audio devices classes, i.e. classes that inherit from `AudioDevice`, now clamp the configuration parameter between two values of `DEFAULT_CHANNELS`. This can be improved/streamlined later. `BYTES_PER_SURROUND_FRAME` has been removed as it was not used anywhere anyway. * Make sampleFrame a class Make `sampleFrame` a class with several convenience methods. As a first step and demonstration adjust the follow methods to make use of the new functionality: * `AudioEngine::getPeakValues`: Much more concise now. * `lmms::MixHelpers::sanitize`: Better structure, better readable, less dereferencing and juggling with indices. * `AddOp`, `AddMultipliedOp`, `multiply`: Make use of operators. Might become superfluous in the future. * More operators and methods for sampleFrame Add some more operators and methods to `sampleFrame`: * Constructor which initializes both channels from a single sample value * Assignment operator from a single sample value * Addition/multiplication operators * Scalar product Adjust some more plugins to the new functionality of `sampleFrame`. * Adjust DelayEffect to methods in sampleFrame * Use composition instead of inheritance Using inheritance was the quickest way to enable adding methods to `sampleFrame` without having to reimpement much of `std::array`s interface. This is changed with this commit. The array is now a member of `sampleFrame` and the interface is extended with the necessary methods `data` and the index operator. An `average` method was added so that no iterators need to be implemented (see changes in `SampleWaveform.cpp`). * Apply suggestions from code review Apply Veratil's suggestions from the code review Co-authored-by: Kevin Zander * Fix warnings: zeroing non-trivial type Fix several warnings of the following form: Warnung: »void* memset(void*, int, size_t)« Säubern eines Objekts von nichttrivialem Typ »class lmms::sampleFrame«; use assignment or value-initialization instead [-Wclass-memaccess] * Remove unnecessary reinterpret_casts Remove some unnecessary reinterpret_casts with regards to `sampleFrame` buffers. `PlayHandle::m_playHandleBuffer` already is a `sampleFrame*` and does not need a reinterpret_cast anymore. In `LadspaEffect::processAudioBuffer` the `QVarLengthArray` is now directly initialized as an array of `sampleFrame` instances. I guess in both places the `sampleFrame` previously was a `surroundSampleFrame` which has been removed. * Clean up zeroSampleFrames code * Fix warnings in RemotePlugin Fix some warnings related to calls to `memcpy` in conjunction with`sampleFrame` which is now a class. Add the helper functions `copyToSampleFrames` and `copyFromSampleFrames` and use them. The first function copies data from a `float` buffer into a `sampleFrame` buffer and the second copies vice versa. * Rename "sampleFrame" to "SampleFrame" Uppercase the name of `sampleFrame` so that it uses UpperCamelCase convention. * Move SampleFrame into its own file Move the class `SampleFrame` into its own class and remove it from `lmms_basics.h`. Add forward includes to all headers where possible or include the `SampleFrame` header if it's not just referenced but used. Add include to all cpp files where necessary. It's a bit surprising that the `SampleFrame` header does not need to be included much more often in the implementation/cpp files. This is an indicator that it seems to be included via an include chain that at one point includes one of the headers where an include instead of a forward declaration had to be added in this commit. * Return reference for += and *= Return a reference for the compound assignment operators `+=` and `-=`. * Explicit float constructor Make the constructor that takes a `float` explicit. Remove the assignment operator that takes a `float`. Clients must use the explicit `float` constructor and assign the result. Adjust the code in "BitInvader" accordingly. * Use std::fill in zeroSampleFrames * Use zeroSampleFrames in sanitize * Replace max with absMax Replace `SampleFrame::max` with `SampleFrame::absMax`. Use `absMax` in `DelayEffect::processAudioBuffer`. This should also fix a buggy implementation of the peak computation. Add the function `getAbsPeakValues`. It computes the absolute peak values for a buffer. Remove `AudioEngine::getPeakValues`. It's not really the business of the audio engine. Let `Mixer` and `Oscilloscope` use `getAbsPeakValues`. * Replace scalarProduct Replace the rather mathematical method `scalarProduct` with `sumOfSquaredAmplitudes`. It was always called on itself anyway. * Remove comment/TODO * Simplify sanitize Simplify the `sanitize` function by getting rid of the `bool found` and by zeroing the buffer as soon as a problem is found. * Put pointer symbols next to type * Code review adjustments * Remove "#pragme once" * Adjust name of include guard * Remove superfluous includes (leftovers from previous code changes) --------- Co-authored-by: Kevin Zander --- include/AudioDevice.h | 9 +- include/AudioDummy.h | 2 +- include/AudioEngine.h | 33 +-- include/AudioFileFlac.h | 2 +- include/AudioFileMP3.h | 2 +- include/AudioFileOgg.h | 2 +- include/AudioFileWave.h | 2 +- include/AudioJack.h | 2 +- include/AudioPort.h | 4 +- include/AudioPortAudio.h | 2 +- include/AudioSampleRecorder.h | 4 +- include/AudioSdl.h | 2 +- include/AudioSoundIo.h | 2 +- include/BufferManager.h | 12 +- include/DspEffectLibrary.h | 13 +- include/DummyEffect.h | 2 +- include/DummyInstrument.h | 5 +- include/Effect.h | 14 +- include/EffectChain.h | 3 +- include/Instrument.h | 9 +- include/InstrumentPlayHandle.h | 2 +- include/InstrumentSoundShaping.h | 3 +- include/InstrumentTrack.h | 4 +- include/Lv2ControlBase.h | 5 +- include/Lv2Ports.h | 7 +- include/Lv2Proc.h | 5 +- include/MixHelpers.h | 30 +-- include/Mixer.h | 6 +- include/NotePlayHandle.h | 2 +- include/Oscillator.h | 28 +-- include/Oscilloscope.h | 11 +- include/PlayHandle.h | 7 +- include/PresetPreviewPlayHandle.h | 2 +- include/RemotePlugin.h | 3 +- include/RemotePluginClient.h | 10 +- include/RingBuffer.h | 29 +-- include/Sample.h | 8 +- include/SampleBuffer.h | 26 +- include/SampleDecoder.h | 3 +- include/SampleFrame.h | 229 ++++++++++++++++++ include/SamplePlayHandle.h | 2 +- include/SampleRecordHandle.h | 6 +- include/SampleWaveform.h | 2 +- include/SweepOscillator.h | 2 +- include/lmms_basics.h | 17 +- plugins/Amplifier/Amplifier.cpp | 14 +- plugins/Amplifier/Amplifier.h | 2 +- .../AudioFileProcessor/AudioFileProcessor.cpp | 4 +- .../AudioFileProcessor/AudioFileProcessor.h | 2 +- plugins/BassBooster/BassBooster.cpp | 26 +- plugins/BassBooster/BassBooster.h | 2 +- plugins/BitInvader/BitInvader.cpp | 8 +- plugins/BitInvader/BitInvader.h | 2 +- plugins/Bitcrush/Bitcrush.cpp | 4 +- plugins/Bitcrush/Bitcrush.h | 4 +- plugins/CarlaBase/Carla.cpp | 4 +- plugins/CarlaBase/Carla.h | 2 +- plugins/Compressor/Compressor.cpp | 2 +- plugins/Compressor/Compressor.h | 4 +- plugins/CrossoverEQ/CrossoverEQ.cpp | 10 +- plugins/CrossoverEQ/CrossoverEQ.h | 8 +- plugins/Delay/DelayEffect.cpp | 35 +-- plugins/Delay/DelayEffect.h | 2 +- plugins/Delay/StereoDelay.cpp | 6 +- plugins/Delay/StereoDelay.h | 6 +- plugins/Dispersion/Dispersion.cpp | 2 +- plugins/Dispersion/Dispersion.h | 2 +- plugins/DualFilter/DualFilter.cpp | 2 +- plugins/DualFilter/DualFilter.h | 2 +- .../DynamicsProcessor/DynamicsProcessor.cpp | 2 +- plugins/DynamicsProcessor/DynamicsProcessor.h | 2 +- plugins/Eq/EqEffect.cpp | 6 +- plugins/Eq/EqEffect.h | 4 +- plugins/Eq/EqFilter.h | 2 +- plugins/Eq/EqSpectrumView.cpp | 2 +- plugins/Eq/EqSpectrumView.h | 3 +- plugins/Flanger/FlangerEffect.cpp | 2 +- plugins/Flanger/FlangerEffect.h | 2 +- plugins/FreeBoy/FreeBoy.cpp | 2 +- plugins/FreeBoy/FreeBoy.h | 2 +- plugins/GigPlayer/GigPlayer.cpp | 12 +- plugins/GigPlayer/GigPlayer.h | 8 +- .../GranularPitchShifterEffect.cpp | 2 +- .../GranularPitchShifterEffect.h | 2 +- plugins/Kicker/Kicker.cpp | 2 +- plugins/Kicker/Kicker.h | 2 +- plugins/Kicker/KickerOsc.h | 2 +- plugins/LOMM/LOMM.cpp | 2 +- plugins/LOMM/LOMM.h | 2 +- plugins/LadspaEffect/LadspaEffect.cpp | 8 +- plugins/LadspaEffect/LadspaEffect.h | 2 +- plugins/Lb302/Lb302.cpp | 6 +- plugins/Lb302/Lb302.h | 6 +- plugins/Lv2Effect/Lv2Effect.cpp | 2 +- plugins/Lv2Effect/Lv2Effect.h | 4 +- plugins/Lv2Instrument/Lv2Instrument.cpp | 4 +- plugins/Lv2Instrument/Lv2Instrument.h | 4 +- plugins/Monstro/Monstro.cpp | 4 +- plugins/Monstro/Monstro.h | 4 +- plugins/MultitapEcho/MultitapEcho.cpp | 6 +- plugins/MultitapEcho/MultitapEcho.h | 6 +- plugins/Nes/Nes.cpp | 4 +- plugins/Nes/Nes.h | 4 +- plugins/OpulenZ/OpulenZ.cpp | 2 +- plugins/OpulenZ/OpulenZ.h | 2 +- plugins/Organic/Organic.cpp | 2 +- plugins/Organic/Organic.h | 2 +- plugins/Patman/Patman.cpp | 6 +- plugins/Patman/Patman.h | 2 +- .../PeakControllerEffect.cpp | 2 +- .../PeakControllerEffect.h | 2 +- plugins/ReverbSC/ReverbSC.cpp | 2 +- plugins/ReverbSC/ReverbSC.h | 2 +- plugins/Sf2Player/Sf2Player.cpp | 10 +- plugins/Sf2Player/Sf2Player.h | 6 +- plugins/Sfxr/Sfxr.cpp | 8 +- plugins/Sfxr/Sfxr.h | 4 +- plugins/Sid/SidInstrument.cpp | 2 +- plugins/Sid/SidInstrument.h | 2 +- plugins/SlicerT/SlicerT.cpp | 2 +- plugins/SlicerT/SlicerT.h | 2 +- plugins/SpectrumAnalyzer/Analyzer.cpp | 2 +- plugins/SpectrumAnalyzer/Analyzer.h | 4 +- plugins/SpectrumAnalyzer/DataprocLauncher.h | 4 +- plugins/SpectrumAnalyzer/SaProcessor.cpp | 4 +- plugins/SpectrumAnalyzer/SaProcessor.h | 4 +- plugins/StereoEnhancer/StereoEnhancer.cpp | 4 +- plugins/StereoEnhancer/StereoEnhancer.h | 4 +- plugins/StereoMatrix/StereoMatrix.cpp | 2 +- plugins/StereoMatrix/StereoMatrix.h | 2 +- plugins/Stk/Mallets/Mallets.cpp | 2 +- plugins/Stk/Mallets/Mallets.h | 2 +- plugins/TripleOscillator/TripleOscillator.cpp | 2 +- plugins/TripleOscillator/TripleOscillator.h | 2 +- plugins/Vectorscope/VectorView.cpp | 2 +- plugins/Vectorscope/VectorView.h | 7 +- plugins/Vectorscope/Vectorscope.cpp | 2 +- plugins/Vectorscope/Vectorscope.h | 6 +- plugins/Vestige/Vestige.cpp | 2 +- plugins/Vestige/Vestige.h | 2 +- plugins/Vibed/Vibed.cpp | 2 +- plugins/Vibed/Vibed.h | 2 +- plugins/VstBase/RemoteVstPlugin.cpp | 4 +- plugins/VstEffect/VstEffect.cpp | 8 +- plugins/VstEffect/VstEffect.h | 2 +- plugins/Watsyn/Watsyn.cpp | 16 +- plugins/Watsyn/Watsyn.h | 10 +- plugins/WaveShaper/WaveShaper.cpp | 2 +- plugins/WaveShaper/WaveShaper.h | 2 +- plugins/Xpressive/ExprSynth.cpp | 3 +- plugins/Xpressive/ExprSynth.h | 3 +- plugins/Xpressive/Xpressive.cpp | 2 +- plugins/Xpressive/Xpressive.h | 2 +- plugins/ZynAddSubFx/LocalZynAddSubFx.cpp | 3 +- plugins/ZynAddSubFx/LocalZynAddSubFx.h | 4 +- plugins/ZynAddSubFx/RemoteZynAddSubFx.cpp | 2 +- plugins/ZynAddSubFx/ZynAddSubFx.cpp | 2 +- plugins/ZynAddSubFx/ZynAddSubFx.h | 2 +- src/core/AudioEngine.cpp | 52 +--- src/core/BufferManager.cpp | 20 +- src/core/Effect.cpp | 5 +- src/core/EffectChain.cpp | 2 +- src/core/Instrument.cpp | 8 +- src/core/InstrumentPlayHandle.cpp | 2 +- src/core/InstrumentSoundShaping.cpp | 2 +- src/core/MixHelpers.cpp | 99 ++++---- src/core/Mixer.cpp | 14 +- src/core/NotePlayHandle.cpp | 2 +- src/core/Oscillator.cpp | 28 +-- src/core/PlayHandle.cpp | 4 +- src/core/PresetPreviewPlayHandle.cpp | 2 +- src/core/RemotePlugin.cpp | 13 +- src/core/RingBuffer.cpp | 76 +++--- src/core/Sample.cpp | 10 +- src/core/SampleBuffer.cpp | 10 +- src/core/SampleDecoder.cpp | 6 +- src/core/SamplePlayHandle.cpp | 10 +- src/core/SampleRecordHandle.cpp | 10 +- src/core/audio/AudioAlsa.cpp | 4 +- src/core/audio/AudioDevice.cpp | 10 +- src/core/audio/AudioFileFlac.cpp | 2 +- src/core/audio/AudioFileMP3.cpp | 4 +- src/core/audio/AudioFileOgg.cpp | 2 +- src/core/audio/AudioFileWave.cpp | 2 +- src/core/audio/AudioJack.cpp | 6 +- src/core/audio/AudioOss.cpp | 6 +- src/core/audio/AudioPortAudio.cpp | 8 +- src/core/audio/AudioPulseAudio.cpp | 8 +- src/core/audio/AudioSampleRecorder.cpp | 6 +- src/core/audio/AudioSdl.cpp | 14 +- src/core/audio/AudioSndio.cpp | 6 +- src/core/audio/AudioSoundIo.cpp | 4 +- src/core/lv2/Lv2ControlBase.cpp | 4 +- src/core/lv2/Lv2Ports.cpp | 7 +- src/core/lv2/Lv2Proc.cpp | 4 +- src/gui/AudioAlsaSetupWidget.cpp | 2 +- src/gui/SampleWaveform.cpp | 2 +- src/gui/widgets/Oscilloscope.cpp | 20 +- src/tracks/InstrumentTrack.cpp | 4 +- 199 files changed, 879 insertions(+), 668 deletions(-) create mode 100644 include/SampleFrame.h diff --git a/include/AudioDevice.h b/include/AudioDevice.h index 577bb7d0e..376aee26b 100644 --- a/include/AudioDevice.h +++ b/include/AudioDevice.h @@ -37,6 +37,7 @@ namespace lmms class AudioEngine; class AudioPort; +class SampleFrame; class AudioDevice @@ -92,14 +93,14 @@ public: protected: // subclasses can re-implement this for being used in conjunction with // processNextBuffer() - virtual void writeBuffer(const surroundSampleFrame* /* _buf*/, const fpp_t /*_frames*/) {} + virtual void writeBuffer(const SampleFrame* /* _buf*/, const fpp_t /*_frames*/) {} // called by according driver for fetching new sound-data - fpp_t getNextBuffer( surroundSampleFrame * _ab ); + fpp_t getNextBuffer(SampleFrame* _ab); // convert a given audio-buffer to a buffer in signed 16-bit samples // returns num of bytes in outbuf - int convertToS16( const surroundSampleFrame * _ab, + int convertToS16(const SampleFrame* _ab, const fpp_t _frames, int_sample_t * _output_buffer, const bool _convert_endian = false ); @@ -133,7 +134,7 @@ private: QMutex m_devMutex; - surroundSampleFrame * m_buffer; + SampleFrame* m_buffer; }; diff --git a/include/AudioDummy.h b/include/AudioDummy.h index 6907ad167..607ea40f2 100644 --- a/include/AudioDummy.h +++ b/include/AudioDummy.h @@ -94,7 +94,7 @@ private: while( true ) { timer.reset(); - const surroundSampleFrame* b = audioEngine()->nextBuffer(); + const SampleFrame* b = audioEngine()->nextBuffer(); if( !b ) { break; diff --git a/include/AudioEngine.h b/include/AudioEngine.h index 6aeb293c7..5e94ea6a2 100644 --- a/include/AudioEngine.h +++ b/include/AudioEngine.h @@ -38,6 +38,7 @@ #include #include "lmms_basics.h" +#include "SampleFrame.h" #include "LocklessList.h" #include "FifoBuffer.h" #include "AudioEngineProfiler.h" @@ -58,8 +59,7 @@ const fpp_t DEFAULT_BUFFER_SIZE = 256; const int BYTES_PER_SAMPLE = sizeof( sample_t ); const int BYTES_PER_INT_SAMPLE = sizeof( int_sample_t ); -const int BYTES_PER_FRAME = sizeof( sampleFrame ); -const int BYTES_PER_SURROUND_FRAME = sizeof( surroundSampleFrame ); +const int BYTES_PER_FRAME = sizeof( SampleFrame ); const float OUTPUT_SAMPLE_MULTIPLIER = 32767.0f; @@ -267,15 +267,6 @@ public: } - struct StereoSample - { - StereoSample(sample_t _left, sample_t _right) : left(_left), right(_right) {} - sample_t left; - sample_t right; - }; - StereoSample getPeakValues(sampleFrame * ab, const f_cnt_t _frames) const; - - bool criticalXRuns() const; inline bool hasFifoWriter() const @@ -283,9 +274,9 @@ public: return m_fifoWriter != nullptr; } - void pushInputFrames( sampleFrame * _ab, const f_cnt_t _frames ); + void pushInputFrames( SampleFrame* _ab, const f_cnt_t _frames ); - inline const sampleFrame * inputBuffer() + inline const SampleFrame* inputBuffer() { return m_inputBuffer[ m_inputBufferRead ]; } @@ -295,7 +286,7 @@ public: return m_inputBufferFrames[ m_inputBufferRead ]; } - inline const surroundSampleFrame * nextBuffer() + inline const SampleFrame* nextBuffer() { return hasFifoWriter() ? m_fifo->read() : renderNextBuffer(); } @@ -321,11 +312,11 @@ public: signals: void qualitySettingsChanged(); void sampleRateChanged(); - void nextAudioBuffer( const lmms::surroundSampleFrame * buffer ); + void nextAudioBuffer(const lmms::SampleFrame* buffer); private: - using Fifo = FifoBuffer; + using Fifo = FifoBuffer; class fifoWriter : public QThread { @@ -342,7 +333,7 @@ private: void run() override; - void write( surroundSampleFrame * buffer ); + void write(SampleFrame* buffer); } ; @@ -361,7 +352,7 @@ private: void renderStageEffects(); void renderStageMix(); - const surroundSampleFrame * renderNextBuffer(); + const SampleFrame* renderNextBuffer(); void swapBuffers(); @@ -375,14 +366,14 @@ private: fpp_t m_framesPerPeriod; - sampleFrame * m_inputBuffer[2]; + SampleFrame* m_inputBuffer[2]; f_cnt_t m_inputBufferFrames[2]; f_cnt_t m_inputBufferSize[2]; int m_inputBufferRead; int m_inputBufferWrite; - std::unique_ptr m_outputBufferRead; - std::unique_ptr m_outputBufferWrite; + std::unique_ptr m_outputBufferRead; + std::unique_ptr m_outputBufferWrite; // worker thread stuff std::vector m_workers; diff --git a/include/AudioFileFlac.h b/include/AudioFileFlac.h index 9432f4231..003450afa 100644 --- a/include/AudioFileFlac.h +++ b/include/AudioFileFlac.h @@ -65,7 +65,7 @@ private: SF_INFO m_sfinfo; SNDFILE* m_sf; - void writeBuffer(surroundSampleFrame const* _ab, fpp_t const frames) override; + void writeBuffer(const SampleFrame* _ab, fpp_t const frames) override; bool startEncoding(); void finishEncoding(); diff --git a/include/AudioFileMP3.h b/include/AudioFileMP3.h index 013c93a3e..e56ac0ba3 100644 --- a/include/AudioFileMP3.h +++ b/include/AudioFileMP3.h @@ -58,7 +58,7 @@ public: } protected: - void writeBuffer(const surroundSampleFrame* /* _buf*/, const fpp_t /*_frames*/) override; + void writeBuffer(const SampleFrame* /* _buf*/, const fpp_t /*_frames*/) override; private: void flushRemainingBuffers(); diff --git a/include/AudioFileOgg.h b/include/AudioFileOgg.h index fc3ce25b4..2608da359 100644 --- a/include/AudioFileOgg.h +++ b/include/AudioFileOgg.h @@ -58,7 +58,7 @@ public: private: - void writeBuffer(const surroundSampleFrame* _ab, const fpp_t _frames) override; + void writeBuffer(const SampleFrame* _ab, const fpp_t _frames) override; bool startEncoding(); void finishEncoding(); diff --git a/include/AudioFileWave.h b/include/AudioFileWave.h index 22b124f93..040af95ea 100644 --- a/include/AudioFileWave.h +++ b/include/AudioFileWave.h @@ -56,7 +56,7 @@ public: private: - void writeBuffer(const surroundSampleFrame* _ab, const fpp_t _frames) override; + void writeBuffer(const SampleFrame* _ab, const fpp_t _frames) override; bool startEncoding(); void finishEncoding(); diff --git a/include/AudioJack.h b/include/AudioJack.h index a1f9b777b..234f6ebf2 100644 --- a/include/AudioJack.h +++ b/include/AudioJack.h @@ -111,7 +111,7 @@ private: std::atomic m_midiClient; std::vector m_outputPorts; jack_default_audio_sample_t** m_tempOutBufs; - surroundSampleFrame* m_outBuf; + SampleFrame* m_outBuf; f_cnt_t m_framesDoneInCurBuf; f_cnt_t m_framesToDoInCurBuf; diff --git a/include/AudioPort.h b/include/AudioPort.h index 9e3ce2bd6..12a0ec7d8 100644 --- a/include/AudioPort.h +++ b/include/AudioPort.h @@ -46,7 +46,7 @@ public: BoolModel * mutedModel = nullptr ); virtual ~AudioPort(); - inline sampleFrame * buffer() + inline SampleFrame* buffer() { return m_portBuffer; } @@ -112,7 +112,7 @@ public: private: volatile bool m_bufferUsage; - sampleFrame * m_portBuffer; + SampleFrame* m_portBuffer; QMutex m_portBufferLock; bool m_extOutputEnabled; diff --git a/include/AudioPortAudio.h b/include/AudioPortAudio.h index 4465b18c1..dbe750c4f 100644 --- a/include/AudioPortAudio.h +++ b/include/AudioPortAudio.h @@ -150,7 +150,7 @@ private: bool m_wasPAInitError; - surroundSampleFrame * m_outBuf; + SampleFrame* m_outBuf; int m_outBufPos; int m_outBufSize; diff --git a/include/AudioSampleRecorder.h b/include/AudioSampleRecorder.h index a3e776881..691196be6 100644 --- a/include/AudioSampleRecorder.h +++ b/include/AudioSampleRecorder.h @@ -48,9 +48,9 @@ public: std::shared_ptr createSampleBuffer(); private: - void writeBuffer(const surroundSampleFrame* _ab, const fpp_t _frames) override; + void writeBuffer(const SampleFrame* _ab, const fpp_t _frames) override; - using BufferList = QList>; + using BufferList = QList>; BufferList m_buffers; } ; diff --git a/include/AudioSdl.h b/include/AudioSdl.h index 5062f79ea..fcfe97318 100644 --- a/include/AudioSdl.h +++ b/include/AudioSdl.h @@ -85,7 +85,7 @@ private: SDL_AudioSpec m_audioHandle; - surroundSampleFrame * m_outBuf; + SampleFrame* m_outBuf; #ifdef LMMS_HAVE_SDL2 size_t m_currentBufferFramePos; diff --git a/include/AudioSoundIo.h b/include/AudioSoundIo.h index b327f7d84..1260951bf 100644 --- a/include/AudioSoundIo.h +++ b/include/AudioSoundIo.h @@ -110,7 +110,7 @@ private: SoundIo *m_soundio; SoundIoOutStream *m_outstream; - surroundSampleFrame * m_outBuf; + SampleFrame* m_outBuf; int m_outBufSize; fpp_t m_outBufFramesTotal; fpp_t m_outBufFrameIndex; diff --git a/include/BufferManager.h b/include/BufferManager.h index 712e420ff..98f6703db 100644 --- a/include/BufferManager.h +++ b/include/BufferManager.h @@ -32,20 +32,18 @@ namespace lmms { +class SampleFrame; class LMMS_EXPORT BufferManager { public: static void init( fpp_t fpp ); - static sampleFrame * acquire(); + static SampleFrame* acquire(); // audio-buffer-mgm - static void clear( sampleFrame * ab, const f_cnt_t frames, + static void clear( SampleFrame* ab, const f_cnt_t frames, const f_cnt_t offset = 0 ); -#ifndef LMMS_DISABLE_SURROUND - static void clear( surroundSampleFrame * ab, const f_cnt_t frames, - const f_cnt_t offset = 0 ); -#endif - static void release( sampleFrame * buf ); + + static void release( SampleFrame* buf ); private: static fpp_t s_framesPerPeriod; diff --git a/include/DspEffectLibrary.h b/include/DspEffectLibrary.h index 14dbd7ede..348c70765 100644 --- a/include/DspEffectLibrary.h +++ b/include/DspEffectLibrary.h @@ -28,7 +28,7 @@ #include "lmms_math.h" #include "lmms_constants.h" #include "lmms_basics.h" - +#include "SampleFrame.h" namespace lmms::DspEffectLibrary { @@ -80,6 +80,17 @@ namespace lmms::DspEffectLibrary { } + void setGain(float gain) + { + leftFX().setGain(gain); + rightFX().setGain(gain); + } + + void nextSample(SampleFrame & in) + { + nextSample(in.left(), in.right()); + } + void nextSample( sample_t& inLeft, sample_t& inRight ) { inLeft = m_leftFX.nextSample( inLeft ); diff --git a/include/DummyEffect.h b/include/DummyEffect.h index 0a80b90a9..e2e649ab5 100644 --- a/include/DummyEffect.h +++ b/include/DummyEffect.h @@ -107,7 +107,7 @@ public: return &m_controls; } - bool processAudioBuffer( sampleFrame *, const fpp_t ) override + bool processAudioBuffer( SampleFrame*, const fpp_t ) override { return false; } diff --git a/include/DummyInstrument.h b/include/DummyInstrument.h index aefa035db..0962dcd9e 100644 --- a/include/DummyInstrument.h +++ b/include/DummyInstrument.h @@ -49,10 +49,9 @@ public: ~DummyInstrument() override = default; - void playNote( NotePlayHandle *, sampleFrame * buffer ) override + void playNote( NotePlayHandle*, SampleFrame* buffer ) override { - memset( buffer, 0, sizeof( sampleFrame ) * - Engine::audioEngine()->framesPerPeriod() ); + zeroSampleFrames(buffer, Engine::audioEngine()->framesPerPeriod()); } void saveSettings( QDomDocument &, QDomElement & ) override diff --git a/include/Effect.h b/include/Effect.h index c3745a352..34f8be00a 100644 --- a/include/Effect.h +++ b/include/Effect.h @@ -64,7 +64,7 @@ public: } - virtual bool processAudioBuffer( sampleFrame * _buf, + virtual bool processAudioBuffer( SampleFrame* _buf, const fpp_t _frames ) = 0; inline ch_cnt_t processorCount() const @@ -187,8 +187,8 @@ protected: // some effects might not be capable of higher sample-rates so they can // sample it down before processing and back after processing - inline void sampleDown( const sampleFrame * _src_buf, - sampleFrame * _dst_buf, + inline void sampleDown( const SampleFrame* _src_buf, + SampleFrame* _dst_buf, sample_rate_t _dst_sr ) { resample( 0, _src_buf, @@ -197,8 +197,8 @@ protected: Engine::audioEngine()->framesPerPeriod() ); } - inline void sampleBack( const sampleFrame * _src_buf, - sampleFrame * _dst_buf, + inline void sampleBack( const SampleFrame* _src_buf, + SampleFrame* _dst_buf, sample_rate_t _src_sr ) { resample( 1, _src_buf, _src_sr, _dst_buf, @@ -213,9 +213,9 @@ protected: private: EffectChain * m_parent; - void resample( int _i, const sampleFrame * _src_buf, + void resample( int _i, const SampleFrame* _src_buf, sample_rate_t _src_sr, - sampleFrame * _dst_buf, sample_rate_t _dst_sr, + SampleFrame* _dst_buf, sample_rate_t _dst_sr, const f_cnt_t _frames ); ch_cnt_t m_processors; diff --git a/include/EffectChain.h b/include/EffectChain.h index f9482174e..0af23c4b8 100644 --- a/include/EffectChain.h +++ b/include/EffectChain.h @@ -34,6 +34,7 @@ namespace lmms { class Effect; +class SampleFrame; namespace gui { @@ -62,7 +63,7 @@ public: void removeEffect( Effect * _effect ); void moveDown( Effect * _effect ); void moveUp( Effect * _effect ); - bool processAudioBuffer( sampleFrame * _buf, const fpp_t _frames, bool hasInputNoise ); + bool processAudioBuffer( SampleFrame* _buf, const fpp_t _frames, bool hasInputNoise ); void startRunning(); void clear(); diff --git a/include/Instrument.h b/include/Instrument.h index e2e980372..3f701f12e 100644 --- a/include/Instrument.h +++ b/include/Instrument.h @@ -45,6 +45,7 @@ class InstrumentTrack; class MidiEvent; class NotePlayHandle; class Track; +class SampleFrame; class LMMS_EXPORT Instrument : public Plugin @@ -75,11 +76,11 @@ 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 audio engine period - virtual void play( sampleFrame * _working_buffer ); + virtual void play( SampleFrame* _working_buffer ); // to be implemented by actual plugin virtual void playNote( NotePlayHandle * /* _note_to_play */, - sampleFrame * /* _working_buf */ ) + SampleFrame* /* _working_buf */ ) { } @@ -160,12 +161,12 @@ public: protected: // fade in to prevent clicks - void applyFadeIn(sampleFrame * buf, NotePlayHandle * n); + void applyFadeIn(SampleFrame* buf, NotePlayHandle * n); // instruments may use this to apply a soft fade out at the end of // notes - method does this only if really less or equal // desiredReleaseFrames() frames are left - void applyRelease( sampleFrame * buf, const NotePlayHandle * _n ); + void applyRelease( SampleFrame* buf, const NotePlayHandle * _n ); float computeReleaseTimeMsByFrameCount(f_cnt_t frames) const; diff --git a/include/InstrumentPlayHandle.h b/include/InstrumentPlayHandle.h index dc744b4ff..c3d9c13bc 100644 --- a/include/InstrumentPlayHandle.h +++ b/include/InstrumentPlayHandle.h @@ -41,7 +41,7 @@ public: ~InstrumentPlayHandle() override = default; - void play(sampleFrame * working_buffer) override; + void play(SampleFrame* working_buffer) override; bool isFinished() const override { diff --git a/include/InstrumentSoundShaping.h b/include/InstrumentSoundShaping.h index fb5f1e8bd..7dfeaf58b 100644 --- a/include/InstrumentSoundShaping.h +++ b/include/InstrumentSoundShaping.h @@ -34,6 +34,7 @@ namespace lmms class InstrumentTrack; class EnvelopeAndLfoParameters; class NotePlayHandle; +class SampleFrame; namespace gui { @@ -48,7 +49,7 @@ public: InstrumentSoundShaping( InstrumentTrack * _instrument_track ); ~InstrumentSoundShaping() override = default; - void processAudioBuffer( sampleFrame * _ab, const fpp_t _frames, + void processAudioBuffer( SampleFrame* _ab, const fpp_t _frames, NotePlayHandle * _n ); enum class Target diff --git a/include/InstrumentTrack.h b/include/InstrumentTrack.h index 3d84df597..45060f055 100644 --- a/include/InstrumentTrack.h +++ b/include/InstrumentTrack.h @@ -66,7 +66,7 @@ public: ~InstrumentTrack() override; // used by instrument - void processAudioBuffer( sampleFrame * _buf, const fpp_t _frames, + void processAudioBuffer( SampleFrame* _buf, const fpp_t _frames, NotePlayHandle * _n ); MidiEvent applyMasterKey( const MidiEvent& event ); @@ -86,7 +86,7 @@ public: // for capturing note-play-events -> need that for arpeggio, // filter and so on - void playNote( NotePlayHandle * _n, sampleFrame * _working_buffer ); + void playNote( NotePlayHandle * _n, SampleFrame* _working_buffer ); QString instrumentName() const; const Instrument *instrument() const diff --git a/include/Lv2ControlBase.h b/include/Lv2ControlBase.h index 9bfb40f87..8ee235ad8 100644 --- a/include/Lv2ControlBase.h +++ b/include/Lv2ControlBase.h @@ -43,6 +43,7 @@ namespace lmms class Lv2Proc; class PluginIssue; +class SampleFrame; /** Common base class for Lv2 plugins @@ -118,9 +119,9 @@ protected: void copyModelsToLmms() const; //! Copy buffer passed by LMMS into our ports - void copyBuffersFromLmms(const sampleFrame *buf, fpp_t frames); + void copyBuffersFromLmms(const SampleFrame* buf, fpp_t frames); //! Copy our ports into buffers passed by LMMS - void copyBuffersToLmms(sampleFrame *buf, fpp_t frames) const; + void copyBuffersToLmms(SampleFrame* buf, fpp_t frames) const; //! Run the Lv2 plugin instance for @param frames frames void run(fpp_t frames); diff --git a/include/Lv2Ports.h b/include/Lv2Ports.h index e4c896ff3..1b2986938 100644 --- a/include/Lv2Ports.h +++ b/include/Lv2Ports.h @@ -41,6 +41,7 @@ namespace lmms { +class SampleFrame; struct ConnectPortVisitor; using LV2_Evbuf = struct LV2_Evbuf_Impl; @@ -184,15 +185,15 @@ struct Audio : public VisitablePort //! Copy buffer passed by LMMS into our ports //! @param channel channel index into each sample frame - void copyBuffersFromCore(const sampleFrame *lmmsBuf, + void copyBuffersFromCore(const SampleFrame* lmmsBuf, unsigned channel, fpp_t frames); //! Add buffer passed by LMMS into our ports, and halve the result //! @param channel channel index into each sample frame - void averageWithBuffersFromCore(const sampleFrame *lmmsBuf, + void averageWithBuffersFromCore(const SampleFrame* lmmsBuf, unsigned channel, fpp_t frames); //! Copy our ports into buffers passed by LMMS //! @param channel channel index into each sample frame - void copyBuffersToCore(sampleFrame *lmmsBuf, + void copyBuffersToCore(SampleFrame* lmmsBuf, unsigned channel, fpp_t frames) const; bool isSideChain() const { return m_sidechain; } diff --git a/include/Lv2Proc.h b/include/Lv2Proc.h index 36b0fa600..f315c5d7a 100644 --- a/include/Lv2Proc.h +++ b/include/Lv2Proc.h @@ -49,6 +49,7 @@ namespace lmms { class PluginIssue; +class SampleFrame; // forward declare port structs/enums namespace Lv2Ports @@ -134,7 +135,7 @@ public: * @param num Number of channels we must read from @param buf (starting at * @p offset) */ - void copyBuffersFromCore(const sampleFrame *buf, + void copyBuffersFromCore(const SampleFrame* buf, unsigned firstChan, unsigned num, fpp_t frames); /** * Copy our ports into buffers passed by the core @@ -147,7 +148,7 @@ public: * @param num Number of channels we must write to @param buf (starting at * @p offset) */ - void copyBuffersToCore(sampleFrame *buf, unsigned firstChan, unsigned num, + void copyBuffersToCore(SampleFrame* buf, unsigned firstChan, unsigned num, fpp_t frames) const; //! Run the Lv2 plugin instance for @param frames frames void run(fpp_t frames); diff --git a/include/MixHelpers.h b/include/MixHelpers.h index dde17dd02..a55ad6058 100644 --- a/include/MixHelpers.h +++ b/include/MixHelpers.h @@ -31,52 +31,54 @@ namespace lmms { class ValueBuffer; +class SampleFrame; + namespace MixHelpers { -bool isSilent( const sampleFrame* src, int frames ); +bool isSilent( const SampleFrame* src, int frames ); bool useNaNHandler(); void setNaNHandler( bool use ); -bool sanitize( sampleFrame * src, int frames ); +bool sanitize( SampleFrame* src, int frames ); /*! \brief Add samples from src to dst */ -void add( sampleFrame* dst, const sampleFrame* src, int frames ); +void add( SampleFrame* dst, const SampleFrame* src, int frames ); /*! \brief Multiply samples from `dst` by `coeff` */ -void multiply(sampleFrame* dst, float coeff, int frames); +void multiply(SampleFrame* dst, float coeff, int frames); /*! \brief Add samples from src multiplied by coeffSrc to dst */ -void addMultiplied( sampleFrame* dst, const sampleFrame* src, float coeffSrc, int frames ); +void addMultiplied( SampleFrame* dst, const SampleFrame* src, float coeffSrc, int frames ); /*! \brief Add samples from src multiplied by coeffSrc to dst, swap inputs */ -void addSwappedMultiplied( sampleFrame* dst, const sampleFrame* src, float coeffSrc, int frames ); +void addSwappedMultiplied( SampleFrame* dst, const SampleFrame* src, float coeffSrc, int frames ); /*! \brief Add samples from src multiplied by coeffSrc and coeffSrcBuf to dst */ -void addMultipliedByBuffer( sampleFrame* dst, const sampleFrame* src, float coeffSrc, ValueBuffer * coeffSrcBuf, int frames ); +void addMultipliedByBuffer( SampleFrame* dst, const SampleFrame* src, float coeffSrc, ValueBuffer * coeffSrcBuf, int frames ); /*! \brief Add samples from src multiplied by coeffSrc and coeffSrcBuf to dst */ -void addMultipliedByBuffers( sampleFrame* dst, const sampleFrame* src, ValueBuffer * coeffSrcBuf1, ValueBuffer * coeffSrcBuf2, int frames ); +void addMultipliedByBuffers( SampleFrame* dst, const SampleFrame* src, ValueBuffer * coeffSrcBuf1, ValueBuffer * coeffSrcBuf2, int frames ); /*! \brief Same as addMultiplied, but sanitize output (strip out infs/nans) */ -void addSanitizedMultiplied( sampleFrame* dst, const sampleFrame* src, float coeffSrc, int frames ); +void addSanitizedMultiplied( SampleFrame* dst, const SampleFrame* src, float coeffSrc, int frames ); /*! \brief Add samples from src multiplied by coeffSrc and coeffSrcBuf to dst - sanitized version */ -void addSanitizedMultipliedByBuffer( sampleFrame* dst, const sampleFrame* src, float coeffSrc, ValueBuffer * coeffSrcBuf, int frames ); +void addSanitizedMultipliedByBuffer( SampleFrame* dst, const SampleFrame* src, float coeffSrc, ValueBuffer * coeffSrcBuf, int frames ); /*! \brief Add samples from src multiplied by coeffSrc and coeffSrcBuf to dst - sanitized version */ -void addSanitizedMultipliedByBuffers( sampleFrame* dst, const sampleFrame* src, ValueBuffer * coeffSrcBuf1, ValueBuffer * coeffSrcBuf2, int frames ); +void addSanitizedMultipliedByBuffers( SampleFrame* dst, const SampleFrame* src, ValueBuffer * coeffSrcBuf1, ValueBuffer * coeffSrcBuf2, int frames ); /*! \brief Add samples from src multiplied by coeffSrcLeft/coeffSrcRight to dst */ -void addMultipliedStereo( sampleFrame* dst, const sampleFrame* src, float coeffSrcLeft, float coeffSrcRight, int frames ); +void addMultipliedStereo( SampleFrame* dst, const SampleFrame* src, float coeffSrcLeft, float coeffSrcRight, int frames ); /*! \brief Multiply dst by coeffDst and add samples from src multiplied by coeffSrc */ -void multiplyAndAddMultiplied( sampleFrame* dst, const sampleFrame* src, float coeffDst, float coeffSrc, int frames ); +void multiplyAndAddMultiplied( SampleFrame* dst, const SampleFrame* src, float coeffDst, float coeffSrc, int frames ); /*! \brief Multiply dst by coeffDst and add samples from srcLeft/srcRight multiplied by coeffSrc */ -void multiplyAndAddMultipliedJoined( sampleFrame* dst, const sample_t* srcLeft, const sample_t* srcRight, float coeffDst, float coeffSrc, int frames ); +void multiplyAndAddMultipliedJoined( SampleFrame* dst, const sample_t* srcLeft, const sample_t* srcRight, float coeffDst, float coeffSrc, int frames ); } // namespace MixHelpers diff --git a/include/Mixer.h b/include/Mixer.h index 302492cab..e65bde010 100644 --- a/include/Mixer.h +++ b/include/Mixer.h @@ -56,7 +56,7 @@ class MixerChannel : public ThreadableJob float m_peakLeft; float m_peakRight; - sampleFrame * m_buffer; + SampleFrame* m_buffer; bool m_muteBeforeSolo; BoolModel m_muteModel; BoolModel m_soloModel; @@ -137,10 +137,10 @@ public: Mixer(); ~Mixer() override; - void mixToChannel( const sampleFrame * _buf, mix_ch_t _ch ); + void mixToChannel( const SampleFrame* _buf, mix_ch_t _ch ); void prepareMasterMix(); - void masterMix( sampleFrame * _buf ); + void masterMix( SampleFrame* _buf ); void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; void loadSettings( const QDomElement & _this ) override; diff --git a/include/NotePlayHandle.h b/include/NotePlayHandle.h index f70268132..0c0acf694 100644 --- a/include/NotePlayHandle.h +++ b/include/NotePlayHandle.h @@ -110,7 +110,7 @@ public: float currentDetuning() const { return m_baseDetuning->value(); } /*! Renders one chunk using the attached instrument into the buffer */ - void play( sampleFrame* buffer ) override; + void play( SampleFrame* buffer ) override; /*! Returns whether playback of note is finished and thus handle can be deleted */ bool isFinished() const override diff --git a/include/Oscillator.h b/include/Oscillator.h index e7eccea50..f537044dc 100644 --- a/include/Oscillator.h +++ b/include/Oscillator.h @@ -109,7 +109,7 @@ public: m_userAntiAliasWaveTable = waveform; } - void update(sampleFrame* ab, const fpp_t frames, const ch_cnt_t chnl, bool modulator = false); + void update(SampleFrame* ab, const fpp_t frames, const ch_cnt_t chnl, bool modulator = false); // now follow the wave-shape-routines... static inline sample_t sinSample( const float _sample ) @@ -282,40 +282,40 @@ private: /* End Multiband wavetable */ - void updateNoSub( sampleFrame * _ab, const fpp_t _frames, + void updateNoSub( SampleFrame* _ab, const fpp_t _frames, const ch_cnt_t _chnl ); - void updatePM( sampleFrame * _ab, const fpp_t _frames, + void updatePM( SampleFrame* _ab, const fpp_t _frames, const ch_cnt_t _chnl ); - void updateAM( sampleFrame * _ab, const fpp_t _frames, + void updateAM( SampleFrame* _ab, const fpp_t _frames, const ch_cnt_t _chnl ); - void updateMix( sampleFrame * _ab, const fpp_t _frames, + void updateMix( SampleFrame* _ab, const fpp_t _frames, const ch_cnt_t _chnl ); - void updateSync( sampleFrame * _ab, const fpp_t _frames, + void updateSync( SampleFrame* _ab, const fpp_t _frames, const ch_cnt_t _chnl ); - void updateFM( sampleFrame * _ab, const fpp_t _frames, + void updateFM( SampleFrame* _ab, const fpp_t _frames, const ch_cnt_t _chnl ); - float syncInit( sampleFrame * _ab, const fpp_t _frames, + float syncInit( SampleFrame* _ab, const fpp_t _frames, const ch_cnt_t _chnl ); inline bool syncOk( float _osc_coeff ); template - void updateNoSub( sampleFrame * _ab, const fpp_t _frames, + void updateNoSub( SampleFrame* _ab, const fpp_t _frames, const ch_cnt_t _chnl ); template - void updatePM( sampleFrame * _ab, const fpp_t _frames, + void updatePM( SampleFrame* _ab, const fpp_t _frames, const ch_cnt_t _chnl ); template - void updateAM( sampleFrame * _ab, const fpp_t _frames, + void updateAM( SampleFrame* _ab, const fpp_t _frames, const ch_cnt_t _chnl ); template - void updateMix( sampleFrame * _ab, const fpp_t _frames, + void updateMix( SampleFrame* _ab, const fpp_t _frames, const ch_cnt_t _chnl ); template - void updateSync( sampleFrame * _ab, const fpp_t _frames, + void updateSync( SampleFrame* _ab, const fpp_t _frames, const ch_cnt_t _chnl ); template - void updateFM( sampleFrame * _ab, const fpp_t _frames, + void updateFM( SampleFrame* _ab, const fpp_t _frames, const ch_cnt_t _chnl ); template diff --git a/include/Oscilloscope.h b/include/Oscilloscope.h index 13c946aa5..1e3c52b1e 100644 --- a/include/Oscilloscope.h +++ b/include/Oscilloscope.h @@ -30,6 +30,13 @@ #include "lmms_basics.h" +namespace lmms +{ + +class SampleFrame; + +} + namespace lmms::gui { @@ -67,7 +74,7 @@ protected: protected slots: - void updateAudioBuffer( const lmms::surroundSampleFrame * buffer ); + void updateAudioBuffer(const lmms::SampleFrame* buffer); private: bool clips(float level) const; @@ -76,7 +83,7 @@ private: QPixmap m_background; QPointF * m_points; - sampleFrame * m_buffer; + SampleFrame* m_buffer; bool m_active; QColor m_leftChannelColor; diff --git a/include/PlayHandle.h b/include/PlayHandle.h index 8f5d771ed..f2e87136a 100644 --- a/include/PlayHandle.h +++ b/include/PlayHandle.h @@ -41,6 +41,7 @@ namespace lmms class Track; class AudioPort; +class SampleFrame; class LMMS_EXPORT PlayHandle : public ThreadableJob { @@ -105,7 +106,7 @@ public: { return m_processingLock.tryLock(); } - virtual void play( sampleFrame* buffer ) = 0; + virtual void play( SampleFrame* buffer ) = 0; virtual bool isFinished() const = 0; // returns the frameoffset at the start of the playhandle, @@ -145,14 +146,14 @@ public: void releaseBuffer(); - sampleFrame * buffer(); + SampleFrame* buffer(); private: Type m_type; f_cnt_t m_offset; QThread* m_affinity; QMutex m_processingLock; - sampleFrame* m_playHandleBuffer; + SampleFrame* m_playHandleBuffer; bool m_bufferReleased; bool m_usesBuffer; AudioPort * m_audioPort; diff --git a/include/PresetPreviewPlayHandle.h b/include/PresetPreviewPlayHandle.h index b8199a71b..e464cf615 100644 --- a/include/PresetPreviewPlayHandle.h +++ b/include/PresetPreviewPlayHandle.h @@ -47,7 +47,7 @@ public: return true; } - void play( sampleFrame* buffer ) override; + void play( SampleFrame* buffer ) override; bool isFinished() const override; bool isFromTrack( const Track * _track ) const override; diff --git a/include/RemotePlugin.h b/include/RemotePlugin.h index c5fcd7dd2..d4676b52e 100644 --- a/include/RemotePlugin.h +++ b/include/RemotePlugin.h @@ -37,6 +37,7 @@ namespace lmms class RemotePlugin; +class SampleFrame; class ProcessWatcher : public QThread { @@ -96,7 +97,7 @@ public: bool processMessage( const message & _m ) override; - bool process( const sampleFrame * _in_buf, sampleFrame * _out_buf ); + bool process( const SampleFrame* _in_buf, SampleFrame* _out_buf ); void processMidiEvent( const MidiEvent&, const f_cnt_t _offset ); diff --git a/include/RemotePluginClient.h b/include/RemotePluginClient.h index 77eef68f0..22158f1b8 100644 --- a/include/RemotePluginClient.h +++ b/include/RemotePluginClient.h @@ -44,6 +44,8 @@ namespace lmms { +class SampleFrame; + class RemotePluginClient : public RemotePluginBase { public: @@ -58,8 +60,8 @@ public: bool processMessage( const message & _m ) override; - virtual void process( const sampleFrame * _in_buf, - sampleFrame * _out_buf ) = 0; + virtual void process( const SampleFrame* _in_buf, + SampleFrame* _out_buf ) = 0; virtual void processMidiEvent( const MidiEvent&, const f_cnt_t /* _offset */ ) { @@ -342,8 +344,8 @@ void RemotePluginClient::doProcessing() { if (m_audioBuffer) { - process( (sampleFrame *)( m_inputCount > 0 ? m_audioBuffer.get() : nullptr ), - (sampleFrame *)( m_audioBuffer.get() + + process( (SampleFrame*)( m_inputCount > 0 ? m_audioBuffer.get() : nullptr ), + (SampleFrame*)( m_audioBuffer.get() + ( m_inputCount*m_bufferSize ) ) ); } else diff --git a/include/RingBuffer.h b/include/RingBuffer.h index 98f726475..41595be19 100644 --- a/include/RingBuffer.h +++ b/include/RingBuffer.h @@ -35,6 +35,7 @@ namespace lmms { +class SampleFrame; /** \brief A basic LMMS ring buffer for single-thread use. For thread and realtime safe alternative see LocklessRingBuffer. */ @@ -105,7 +106,7 @@ public: * to a specified destination, and advances the position by one period * \param dst Destination pointer */ - void pop( sampleFrame * dst ); + void pop( SampleFrame* dst ); // note: ringbuffer position is unaffected by all other read functions beside pop() @@ -113,27 +114,27 @@ public: * \param dst Destination pointer * \param offset Offset in frames against current position, may be negative */ - void read( sampleFrame * dst, f_cnt_t offset=0 ); + void read( SampleFrame* dst, f_cnt_t offset = 0 ); /** \brief Reads a period-sized buffer from the ringbuffer and writes it to a specified destination * \param dst Destination pointer * \param offset Offset in milliseconds against current position, may be negative */ - void read( sampleFrame * dst, float offset ); + void read( SampleFrame* dst, float offset ); /** \brief Reads a buffer of specified size from the ringbuffer and writes it to a specified destination * \param dst Destination pointer * \param offset Offset in frames against current position, may be negative * \param length Length in frames of the buffer to read - must not be higher than the size of the ringbuffer! */ - void read( sampleFrame * dst, f_cnt_t offset, f_cnt_t length ); + void read( SampleFrame* dst, f_cnt_t offset, f_cnt_t length ); /** \brief Reads a buffer of specified size from the ringbuffer and writes it to a specified destination * \param dst Destination pointer * \param offset Offset in milliseconds against current position, may be negative * \param length Length in frames of the buffer to read - must not be higher than the size of the ringbuffer! */ - void read( sampleFrame * dst, float offset, f_cnt_t length ); + void read( SampleFrame* dst, float offset, f_cnt_t length ); // write functions @@ -143,28 +144,28 @@ public: * \param offset Offset in frames against current position, may *NOT* be negative * \param length Length of the source buffer, if zero, period size is used - must not be higher than the size of the ringbuffer! */ - void write( sampleFrame * src, f_cnt_t offset=0, f_cnt_t length=0 ); + void write( SampleFrame* src, f_cnt_t offset=0, f_cnt_t length=0 ); /** \brief Writes a buffer of sampleframes to the ringbuffer at specified position * \param src Pointer to the source buffer * \param offset Offset in milliseconds against current position, may *NOT* be negative * \param length Length of the source buffer, if zero, period size is used - must not be higher than the size of the ringbuffer! */ - void write( sampleFrame * src, float offset, f_cnt_t length=0 ); + void write( SampleFrame* src, float offset, f_cnt_t length=0 ); /** \brief Mixes a buffer of sampleframes additively to the ringbuffer at specified position * \param src Pointer to the source buffer * \param offset Offset in frames against current position, may *NOT* be negative * \param length Length of the source buffer, if zero, period size is used - must not be higher than the size of the ringbuffer! */ - void writeAdding( sampleFrame * src, f_cnt_t offset=0, f_cnt_t length=0 ); + void writeAdding( SampleFrame* src, f_cnt_t offset=0, f_cnt_t length=0 ); /** \brief Mixes a buffer of sampleframes additively to the ringbuffer at specified position * \param src Pointer to the source buffer * \param offset Offset in milliseconds against current position, may *NOT* be negative * \param length Length of the source buffer, if zero, period size is used - must not be higher than the size of the ringbuffer! */ - void writeAdding( sampleFrame * src, float offset, f_cnt_t length=0 ); + void writeAdding( SampleFrame* src, float offset, f_cnt_t length=0 ); /** \brief Mixes a buffer of sampleframes additively to the ringbuffer at specified position, with * a specified multiplier applied to the frames @@ -173,7 +174,7 @@ public: * \param length Length of the source buffer, if zero, period size is used - must not be higher than the size of the ringbuffer! * \param level Multiplier applied to the frames before they're written to the ringbuffer */ - void writeAddingMultiplied( sampleFrame * src, f_cnt_t offset, f_cnt_t length, float level ); + void writeAddingMultiplied( SampleFrame* src, f_cnt_t offset, f_cnt_t length, float level ); /** \brief Mixes a buffer of sampleframes additively to the ringbuffer at specified position, with * a specified multiplier applied to the frames @@ -182,7 +183,7 @@ public: * \param length Length of the source buffer, if zero, period size is used * \param level Multiplier applied to the frames before they're written to the ringbuffer */ - void writeAddingMultiplied( sampleFrame * src, float offset, f_cnt_t length, float level ); + void writeAddingMultiplied( SampleFrame* src, float offset, f_cnt_t length, float level ); /** \brief Mixes a buffer of sampleframes additively to the ringbuffer at specified position, with * a specified multiplier applied to the frames, with swapped channels @@ -191,7 +192,7 @@ public: * \param length Length of the source buffer, if zero, period size is used - must not be higher than the size of the ringbuffer! * \param level Multiplier applied to the frames before they're written to the ringbuffer */ - void writeSwappedAddingMultiplied( sampleFrame * src, f_cnt_t offset, f_cnt_t length, float level ); + void writeSwappedAddingMultiplied( SampleFrame* src, f_cnt_t offset, f_cnt_t length, float level ); /** \brief Mixes a buffer of sampleframes additively to the ringbuffer at specified position, with * a specified multiplier applied to the frames, with swapped channels @@ -200,7 +201,7 @@ public: * \param length Length of the source buffer, if zero, period size is used * \param level Multiplier applied to the frames before they're written to the ringbuffer */ - void writeSwappedAddingMultiplied( sampleFrame * src, float offset, f_cnt_t length, float level ); + void writeSwappedAddingMultiplied( SampleFrame* src, float offset, f_cnt_t length, float level ); protected slots: @@ -215,7 +216,7 @@ private: const fpp_t m_fpp; sample_rate_t m_samplerate; size_t m_size; - sampleFrame * m_buffer; + SampleFrame* m_buffer; volatile unsigned int m_position; }; diff --git a/include/Sample.h b/include/Sample.h index 92ac1a58a..3fd5bc38e 100644 --- a/include/Sample.h +++ b/include/Sample.h @@ -78,7 +78,7 @@ public: Sample() = default; Sample(const QByteArray& base64, int sampleRate = Engine::audioEngine()->outputSampleRate()); - Sample(const sampleFrame* data, size_t numFrames, int sampleRate = Engine::audioEngine()->outputSampleRate()); + Sample(const SampleFrame* data, size_t numFrames, int sampleRate = Engine::audioEngine()->outputSampleRate()); Sample(const Sample& other); Sample(Sample&& other); explicit Sample(const QString& audioFile); @@ -87,7 +87,7 @@ public: auto operator=(const Sample&) -> Sample&; auto operator=(Sample&&) -> Sample&; - auto play(sampleFrame* dst, PlaybackState* state, size_t numFrames, float desiredFrequency = DefaultBaseFreq, + auto play(SampleFrame* dst, PlaybackState* state, size_t numFrames, float desiredFrequency = DefaultBaseFreq, Loop loopMode = Loop::Off) const -> bool; auto sampleDuration() const -> std::chrono::milliseconds; @@ -97,7 +97,7 @@ public: auto toBase64() const -> QString { return m_buffer->toBase64(); } - auto data() const -> const sampleFrame* { return m_buffer->data(); } + auto data() const -> const SampleFrame* { return m_buffer->data(); } auto buffer() const -> std::shared_ptr { return m_buffer; } auto startFrame() const -> int { return m_startFrame.load(std::memory_order_relaxed); } auto endFrame() const -> int { return m_endFrame.load(std::memory_order_relaxed); } @@ -117,7 +117,7 @@ public: void setReversed(bool reversed) { m_reversed.store(reversed, std::memory_order_relaxed); } private: - void playRaw(sampleFrame* dst, size_t numFrames, const PlaybackState* state, Loop loopMode) const; + void playRaw(SampleFrame* dst, size_t numFrames, const PlaybackState* state, Loop loopMode) const; void advance(PlaybackState* state, size_t advanceAmount, Loop loopMode) const; private: diff --git a/include/SampleBuffer.h b/include/SampleBuffer.h index 6f40b33d1..8ec6c5886 100644 --- a/include/SampleBuffer.h +++ b/include/SampleBuffer.h @@ -41,22 +41,22 @@ namespace lmms { class LMMS_EXPORT SampleBuffer { public: - using value_type = sampleFrame; - using reference = sampleFrame&; - using const_reference = const sampleFrame&; - using iterator = std::vector::iterator; - using const_iterator = std::vector::const_iterator; - using difference_type = std::vector::difference_type; - using size_type = std::vector::size_type; - using reverse_iterator = std::vector::reverse_iterator; - using const_reverse_iterator = std::vector::const_reverse_iterator; + using value_type = SampleFrame; + using reference = SampleFrame&; + using const_reference = const SampleFrame&; + using iterator = std::vector::iterator; + using const_iterator = std::vector::const_iterator; + using difference_type = std::vector::difference_type; + using size_type = std::vector::size_type; + using reverse_iterator = std::vector::reverse_iterator; + using const_reverse_iterator = std::vector::const_reverse_iterator; SampleBuffer() = default; explicit SampleBuffer(const QString& audioFile); SampleBuffer(const QString& base64, int sampleRate); - SampleBuffer(std::vector data, int sampleRate); + SampleBuffer(std::vector data, int sampleRate); SampleBuffer( - const sampleFrame* data, size_t numFrames, int sampleRate = Engine::audioEngine()->outputSampleRate()); + const SampleFrame* data, size_t numFrames, int sampleRate = Engine::audioEngine()->outputSampleRate()); friend void swap(SampleBuffer& first, SampleBuffer& second) noexcept; auto toBase64() const -> QString; @@ -82,14 +82,14 @@ public: auto crbegin() const -> const_reverse_iterator { return m_data.crbegin(); } auto crend() const -> const_reverse_iterator { return m_data.crend(); } - auto data() const -> const sampleFrame* { return m_data.data(); } + auto data() const -> const SampleFrame* { return m_data.data(); } auto size() const -> size_type { return m_data.size(); } auto empty() const -> bool { return m_data.empty(); } static auto emptyBuffer() -> std::shared_ptr; private: - std::vector m_data; + std::vector m_data; QString m_audioFile; sample_rate_t m_sampleRate = Engine::audioEngine()->outputSampleRate(); }; diff --git a/include/SampleDecoder.h b/include/SampleDecoder.h index d7ce076dd..2cfd00977 100644 --- a/include/SampleDecoder.h +++ b/include/SampleDecoder.h @@ -32,6 +32,7 @@ #include #include "lmms_basics.h" +#include "SampleFrame.h" namespace lmms { class SampleDecoder @@ -39,7 +40,7 @@ class SampleDecoder public: struct Result { - std::vector data; + std::vector data; int sampleRate; }; diff --git a/include/SampleFrame.h b/include/SampleFrame.h new file mode 100644 index 000000000..5f02cd352 --- /dev/null +++ b/include/SampleFrame.h @@ -0,0 +1,229 @@ +/* + * SampleFrame.h - Representation of a stereo sample + * + * Copyright (c) 2004-2009 Tobias Doerffel + * Copyright (c) 2024- Michael Gregorius + * + * This file is part of LMMS - https://lmms.io + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + +#ifndef LMMS_SAMPLEFRAME_H +#define LMMS_SAMPLEFRAME_H + +#include "lmms_basics.h" + +#include + + +namespace lmms +{ + +class SampleFrame +{ +public: + SampleFrame() : SampleFrame(0., 0.) + { + } + + explicit SampleFrame(sample_t value) : SampleFrame(value, value) + { + } + + SampleFrame(sample_t left, sample_t right) : + m_samples({ left, right }) + { + } + + sample_t* data() + { + return m_samples.data(); + } + + const sample_t* data() const + { + return m_samples.data(); + } + + sample_t& left() + { + return m_samples[0]; + } + + const sample_t& left() const + { + return m_samples[0]; + } + + void setLeft(const sample_t& value) + { + m_samples[0] = value; + } + + sample_t& right() + { + return m_samples[1]; + } + + const sample_t& right() const + { + return m_samples[1]; + } + + void setRight(const sample_t& value) + { + m_samples[1] = value; + } + + sample_t& operator[](size_t index) + { + return m_samples[index]; + } + + const sample_t& operator[](size_t index) const + { + return m_samples[index]; + } + + SampleFrame operator+(const SampleFrame& other) const + { + return SampleFrame(left() + other.left(), right() + other.right()); + } + + SampleFrame& operator+=(const SampleFrame& other) + { + auto & l = left(); + auto & r = right(); + + l += other.left(); + r += other.right(); + + return *this; + } + + SampleFrame operator*(float value) const + { + return SampleFrame(left() * value, right() * value); + } + + SampleFrame& operator*=(float value) + { + setLeft(left() * value); + setRight(right() * value); + + return *this; + } + + SampleFrame operator*(const SampleFrame& other) const + { + return SampleFrame(left() * other.left(), right() * other.right()); + } + + void operator*=(const SampleFrame& other) + { + left() *= other.left(); + right() *= other.right(); + } + + sample_t sumOfSquaredAmplitudes() const + { + return left() * left() + right() * right(); + } + + SampleFrame abs() const + { + return SampleFrame{std::abs(this->left()), std::abs(this->right())}; + } + + SampleFrame absMax(const SampleFrame& other) + { + const auto a = abs(); + const auto b = other.abs(); + + return SampleFrame(std::max(a.left(), b.left()), std::max(a.right(), b.right())); + } + + sample_t average() const + { + return (left() + right()) / 2; + } + + void clamp(sample_t low, sample_t high) + { + auto & l = left(); + l = std::clamp(l, low, high); + + auto & r = right(); + r = std::clamp(r, low, high); + } + + bool containsInf() const + { + return std::isinf(left()) || std::isinf(right()); + } + + bool containsNaN() const + { + return std::isnan(left()) || std::isnan(right()); + } + +private: + std::array m_samples; +}; + +inline void zeroSampleFrames(SampleFrame* buffer, fpp_t frames) +{ + // The equivalent of the following operation which yields compiler warnings + // memset(buffer, 0, sizeof(SampleFrame) * frames); + + std::fill(buffer, buffer + frames, SampleFrame()); +} + +inline SampleFrame getAbsPeakValues(SampleFrame* buffer, fpp_t frames) +{ + SampleFrame peaks; + + for (f_cnt_t i = 0; i < frames; ++i) + { + peaks = peaks.absMax(buffer[i]); + } + + return peaks; +} + +inline void copyToSampleFrames(SampleFrame* target, const float* source, fpp_t frames) +{ + for (fpp_t i = 0; i < frames; ++i) + { + target[i].setLeft(source[2*i]); + target[i].setRight(source[2*i + 1]); + } +} + +inline void copyFromSampleFrames(float* target, const SampleFrame* source, fpp_t frames) +{ + for (fpp_t i = 0; i < frames; ++i) + { + target[2*i] = source[i].left(); + target[2*i + 1] = source[i].right(); + } +} + +} // namespace lmms + +#endif // LMMS_SAMPLEFRAME_H diff --git a/include/SamplePlayHandle.h b/include/SamplePlayHandle.h index 280010b06..dde29b49b 100644 --- a/include/SamplePlayHandle.h +++ b/include/SamplePlayHandle.h @@ -55,7 +55,7 @@ public: } - void play( sampleFrame * buffer ) override; + void play( SampleFrame* buffer ) override; bool isFinished() const override; bool isFromTrack( const Track * _track ) const override; diff --git a/include/SampleRecordHandle.h b/include/SampleRecordHandle.h index df2d7c772..b650c6760 100644 --- a/include/SampleRecordHandle.h +++ b/include/SampleRecordHandle.h @@ -48,7 +48,7 @@ public: SampleRecordHandle( SampleClip* clip ); ~SampleRecordHandle() override; - void play( sampleFrame * _working_buffer ) override; + void play( SampleFrame* _working_buffer ) override; bool isFinished() const override; bool isFromTrack( const Track * _track ) const override; @@ -58,10 +58,10 @@ public: private: - virtual void writeBuffer( const sampleFrame * _ab, + virtual void writeBuffer( const SampleFrame* _ab, const f_cnt_t _frames ); - using bufferList = QList>; + using bufferList = QList>; bufferList m_buffers; f_cnt_t m_framesRecorded; TimePos m_minLength; diff --git a/include/SampleWaveform.h b/include/SampleWaveform.h index 0185e0e98..ccfc9fb60 100644 --- a/include/SampleWaveform.h +++ b/include/SampleWaveform.h @@ -36,7 +36,7 @@ class LMMS_EXPORT SampleWaveform public: struct Parameters { - const sampleFrame* buffer; + const SampleFrame* buffer; size_t size; float amplification; bool reversed; diff --git a/include/SweepOscillator.h b/include/SweepOscillator.h index b5521da3b..c7c7938d1 100644 --- a/include/SweepOscillator.h +++ b/include/SweepOscillator.h @@ -43,7 +43,7 @@ public: virtual ~SweepOscillator() = default; - void update( sampleFrame* buf, const fpp_t frames, const float freq1, const float freq2, const float sampleRate ) + void update( SampleFrame* buf, const fpp_t frames, const float freq1, const float freq2, const float sampleRate ) { const float df = freq2 - freq1; for( fpp_t frame = 0; frame < frames; ++frame ) diff --git a/include/lmms_basics.h b/include/lmms_basics.h index 5c7292ab0..4695b4f8a 100644 --- a/include/lmms_basics.h +++ b/include/lmms_basics.h @@ -33,6 +33,9 @@ #include #include +#include +#include + namespace lmms { @@ -48,7 +51,7 @@ using int_sample_t = int16_t; // 16-bit-int-sample using sample_rate_t = uint32_t; // sample-rate using fpp_t = int16_t; // frames per period (0-16384) using f_cnt_t = int32_t; // standard frame-count -using ch_cnt_t = uint8_t; // channel-count (0-SURROUND_CHANNELS) +using ch_cnt_t = uint8_t; // channel-count (0-DEFAULT_CHANNELS) using bpm_t = uint16_t; // tempo (MIN_BPM to MAX_BPM) using bitrate_t = uint16_t; // bitrate in kbps using mix_ch_t = uint16_t; // Mixer-channel (0 to MAX_CHANNEL) @@ -109,14 +112,6 @@ inline bool typeInfo::isEqual( float x, float y ) constexpr ch_cnt_t DEFAULT_CHANNELS = 2; -constexpr ch_cnt_t SURROUND_CHANNELS = -#define LMMS_DISABLE_SURROUND -#ifndef LMMS_DISABLE_SURROUND - 4; -#else - 2; -#endif - constexpr char LADSPA_PATH_SEPERATOR = #ifdef LMMS_BUILD_WIN32 ';'; @@ -126,10 +121,6 @@ constexpr char LADSPA_PATH_SEPERATOR = -using sampleFrame = std::array; -using surroundSampleFrame = std::array; - - #define LMMS_STRINGIFY(s) LMMS_STR(s) #define LMMS_STR(PN) #PN diff --git a/plugins/Amplifier/Amplifier.cpp b/plugins/Amplifier/Amplifier.cpp index ac5fdf23b..2f4e57f77 100644 --- a/plugins/Amplifier/Amplifier.cpp +++ b/plugins/Amplifier/Amplifier.cpp @@ -57,7 +57,7 @@ AmplifierEffect::AmplifierEffect(Model* parent, const Descriptor::SubPluginFeatu } -bool AmplifierEffect::processAudioBuffer(sampleFrame* buf, const fpp_t frames) +bool AmplifierEffect::processAudioBuffer(SampleFrame* buf, const fpp_t frames) { if (!isEnabled() || !isRunning()) { return false ; } @@ -80,14 +80,14 @@ bool AmplifierEffect::processAudioBuffer(sampleFrame* buf, const fpp_t frames) const float panLeft = std::min(1.0f, 1.0f - pan); const float panRight = std::min(1.0f, 1.0f + pan); - auto s = std::array{buf[f][0], buf[f][1]}; + auto& currentFrame = buf[f]; - s[0] *= volume * left * panLeft; - s[1] *= volume * right * panRight; + const auto s = currentFrame * SampleFrame(left * panLeft, right * panRight) * volume; - buf[f][0] = d * buf[f][0] + w * s[0]; - buf[f][1] = d * buf[f][1] + w * s[1]; - outSum += buf[f][0] * buf[f][0] + buf[f][1] * buf[f][1]; + // Dry/wet mix + currentFrame = currentFrame * d + s * w; + + outSum += currentFrame.sumOfSquaredAmplitudes(); } checkGate(outSum / frames); diff --git a/plugins/Amplifier/Amplifier.h b/plugins/Amplifier/Amplifier.h index 8a39ffeb6..8be938001 100644 --- a/plugins/Amplifier/Amplifier.h +++ b/plugins/Amplifier/Amplifier.h @@ -37,7 +37,7 @@ class AmplifierEffect : public Effect public: AmplifierEffect(Model* parent, const Descriptor::SubPluginFeatures::Key* key); ~AmplifierEffect() override = default; - bool processAudioBuffer(sampleFrame* buf, const fpp_t frames) override; + bool processAudioBuffer(SampleFrame* buf, const fpp_t frames) override; EffectControls* controls() override { diff --git a/plugins/AudioFileProcessor/AudioFileProcessor.cpp b/plugins/AudioFileProcessor/AudioFileProcessor.cpp index fbbcbca73..767d15e73 100644 --- a/plugins/AudioFileProcessor/AudioFileProcessor.cpp +++ b/plugins/AudioFileProcessor/AudioFileProcessor.cpp @@ -105,7 +105,7 @@ AudioFileProcessor::AudioFileProcessor( InstrumentTrack * _instrument_track ) : void AudioFileProcessor::playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ) + SampleFrame* _working_buffer ) { const fpp_t frames = _n->framesLeftForCurrentPeriod(); const f_cnt_t offset = _n->noteOffset(); @@ -165,7 +165,7 @@ void AudioFileProcessor::playNote( NotePlayHandle * _n, } else { - memset( _working_buffer, 0, ( frames + offset ) * sizeof( sampleFrame ) ); + zeroSampleFrames(_working_buffer, frames + offset); emit isPlaying( 0 ); } } diff --git a/plugins/AudioFileProcessor/AudioFileProcessor.h b/plugins/AudioFileProcessor/AudioFileProcessor.h index 00ad92129..b39342fd1 100644 --- a/plugins/AudioFileProcessor/AudioFileProcessor.h +++ b/plugins/AudioFileProcessor/AudioFileProcessor.h @@ -44,7 +44,7 @@ public: AudioFileProcessor( InstrumentTrack * _instrument_track ); void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ) override; + SampleFrame* _working_buffer ) override; void deleteNotePluginData( NotePlayHandle * _n ) override; void saveSettings(QDomDocument& doc, QDomElement& elem) override; diff --git a/plugins/BassBooster/BassBooster.cpp b/plugins/BassBooster/BassBooster.cpp index aa0d3ebcd..f12fd6ace 100644 --- a/plugins/BassBooster/BassBooster.cpp +++ b/plugins/BassBooster/BassBooster.cpp @@ -69,7 +69,7 @@ BassBoosterEffect::BassBoosterEffect( Model* parent, const Descriptor::SubPlugin -bool BassBoosterEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) +bool BassBoosterEffect::processAudioBuffer( SampleFrame* buf, const fpp_t frames ) { if( !isEnabled() || !isRunning () ) { @@ -91,23 +91,19 @@ bool BassBoosterEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames const float d = dryLevel(); const float w = wetLevel(); - for( fpp_t f = 0; f < frames; ++f ) + for (fpp_t f = 0; f < frames; ++f) { - float gain = const_gain; - if (gainBuffer) { - //process period using sample exact data - gain = gainBuffer->value( f ); - } - //float gain = gainBuffer ? gainBuffer[f] : gain; - m_bbFX.leftFX().setGain( gain ); - m_bbFX.rightFX().setGain( gain); + auto& currentFrame = buf[f]; - auto s = std::array{buf[f][0], buf[f][1]}; - m_bbFX.nextSample( s[0], s[1] ); + // Process copy of current sample frame + m_bbFX.setGain(gainBuffer ? gainBuffer->value(f) : const_gain); + auto s = currentFrame; + m_bbFX.nextSample(s); - buf[f][0] = d * buf[f][0] + w * s[0]; - buf[f][1] = d * buf[f][1] + w * s[1]; - outSum += buf[f][0] * buf[f][0] + buf[f][1] * buf[f][1]; + // Dry/wet mix + currentFrame = currentFrame * d + s * w; + + outSum += currentFrame.sumOfSquaredAmplitudes(); } checkGate( outSum / frames ); diff --git a/plugins/BassBooster/BassBooster.h b/plugins/BassBooster/BassBooster.h index ea3ba2d98..64c4e354d 100644 --- a/plugins/BassBooster/BassBooster.h +++ b/plugins/BassBooster/BassBooster.h @@ -38,7 +38,7 @@ class BassBoosterEffect : public Effect public: BassBoosterEffect( Model* parent, const Descriptor::SubPluginFeatures::Key* key ); ~BassBoosterEffect() override = default; - bool processAudioBuffer( sampleFrame* buf, const fpp_t frames ) override; + bool processAudioBuffer( SampleFrame* buf, const fpp_t frames ) override; EffectControls* controls() override { diff --git a/plugins/BitInvader/BitInvader.cpp b/plugins/BitInvader/BitInvader.cpp index 21940182b..8d9bef4d3 100644 --- a/plugins/BitInvader/BitInvader.cpp +++ b/plugins/BitInvader/BitInvader.cpp @@ -256,7 +256,7 @@ QString BitInvader::nodeName() const void BitInvader::playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ) + SampleFrame* _working_buffer ) { if (!_n->m_pluginData) { @@ -274,11 +274,7 @@ void BitInvader::playNote( NotePlayHandle * _n, auto ps = static_cast(_n->m_pluginData); for( fpp_t frame = offset; frame < frames + offset; ++frame ) { - const sample_t cur = ps->nextStringSample( m_graph.length() ); - for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) - { - _working_buffer[frame][chnl] = cur; - } + _working_buffer[frame] = SampleFrame(ps->nextStringSample(m_graph.length())); } applyRelease( _working_buffer, _n ); diff --git a/plugins/BitInvader/BitInvader.h b/plugins/BitInvader/BitInvader.h index f4d248ec8..2ed2dde1b 100644 --- a/plugins/BitInvader/BitInvader.h +++ b/plugins/BitInvader/BitInvader.h @@ -75,7 +75,7 @@ public: ~BitInvader() override = default; void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ) override; + SampleFrame* _working_buffer ) override; void deleteNotePluginData( NotePlayHandle * _n ) override; diff --git a/plugins/Bitcrush/Bitcrush.cpp b/plugins/Bitcrush/Bitcrush.cpp index 251750a32..76e8b9681 100644 --- a/plugins/Bitcrush/Bitcrush.cpp +++ b/plugins/Bitcrush/Bitcrush.cpp @@ -62,7 +62,7 @@ BitcrushEffect::BitcrushEffect( Model * parent, const Descriptor::SubPluginFeatu m_sampleRate( Engine::audioEngine()->outputSampleRate() ), m_filter( m_sampleRate ) { - m_buffer = new sampleFrame[Engine::audioEngine()->framesPerPeriod() * OS_RATE]; + m_buffer = new SampleFrame[Engine::audioEngine()->framesPerPeriod() * OS_RATE]; m_filter.setLowpass( m_sampleRate * ( CUTOFF_RATIO * OS_RATIO ) ); m_needsUpdate = true; @@ -100,7 +100,7 @@ inline float BitcrushEffect::noise( float amt ) return fastRandf( amt * 2.0f ) - amt; } -bool BitcrushEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) +bool BitcrushEffect::processAudioBuffer( SampleFrame* buf, const fpp_t frames ) { if( !isEnabled() || !isRunning () ) { diff --git a/plugins/Bitcrush/Bitcrush.h b/plugins/Bitcrush/Bitcrush.h index a6e5556a2..009c7c02d 100644 --- a/plugins/Bitcrush/Bitcrush.h +++ b/plugins/Bitcrush/Bitcrush.h @@ -41,7 +41,7 @@ class BitcrushEffect : public Effect public: BitcrushEffect( Model* parent, const Descriptor::SubPluginFeatures::Key* key ); ~BitcrushEffect() override; - bool processAudioBuffer( sampleFrame* buf, const fpp_t frames ) override; + bool processAudioBuffer( SampleFrame* buf, const fpp_t frames ) override; EffectControls* controls() override { @@ -55,7 +55,7 @@ private: BitcrushControls m_controls; - sampleFrame * m_buffer; + SampleFrame* m_buffer; float m_sampleRate; StereoLinkwitzRiley m_filter; diff --git a/plugins/CarlaBase/Carla.cpp b/plugins/CarlaBase/Carla.cpp index 197971ee9..f5d5aa574 100644 --- a/plugins/CarlaBase/Carla.cpp +++ b/plugins/CarlaBase/Carla.cpp @@ -495,11 +495,11 @@ void CarlaInstrument::loadSettings(const QDomElement& elem) #endif } -void CarlaInstrument::play(sampleFrame* workingBuffer) +void CarlaInstrument::play(SampleFrame* workingBuffer) { const uint bufsize = Engine::audioEngine()->framesPerPeriod(); - std::memset(workingBuffer, 0, sizeof(sample_t)*bufsize*DEFAULT_CHANNELS); + zeroSampleFrames(workingBuffer, bufsize); if (fHandle == nullptr) { diff --git a/plugins/CarlaBase/Carla.h b/plugins/CarlaBase/Carla.h index da0ae67cc..d8eab5fc4 100644 --- a/plugins/CarlaBase/Carla.h +++ b/plugins/CarlaBase/Carla.h @@ -193,7 +193,7 @@ public: QString nodeName() const override; void saveSettings(QDomDocument& doc, QDomElement& parent) override; void loadSettings(const QDomElement& elem) override; - void play(sampleFrame* workingBuffer) override; + void play(SampleFrame* workingBuffer) override; bool handleMidiEvent(const MidiEvent& event, const TimePos& time, f_cnt_t offset) override; gui::PluginView* instantiateView(QWidget* parent) override; diff --git a/plugins/Compressor/Compressor.cpp b/plugins/Compressor/Compressor.cpp index 1c51d6ddc..c04893361 100755 --- a/plugins/Compressor/Compressor.cpp +++ b/plugins/Compressor/Compressor.cpp @@ -233,7 +233,7 @@ void CompressorEffect::calcMix() -bool CompressorEffect::processAudioBuffer(sampleFrame* buf, const fpp_t frames) +bool CompressorEffect::processAudioBuffer(SampleFrame* buf, const fpp_t frames) { if (!isEnabled() || !isRunning()) { diff --git a/plugins/Compressor/Compressor.h b/plugins/Compressor/Compressor.h index 4d6c05d7e..af322de97 100755 --- a/plugins/Compressor/Compressor.h +++ b/plugins/Compressor/Compressor.h @@ -43,7 +43,7 @@ class CompressorEffect : public Effect public: CompressorEffect(Model* parent, const Descriptor::SubPluginFeatures::Key* key); ~CompressorEffect() override = default; - bool processAudioBuffer(sampleFrame* buf, const fpp_t frames) override; + bool processAudioBuffer(SampleFrame* buf, const fpp_t frames) override; EffectControls* controls() override { @@ -105,7 +105,7 @@ private: float m_coeffPrecalc; - sampleFrame m_maxLookaheadVal; + SampleFrame m_maxLookaheadVal; int m_maxLookaheadTimer[2] = {1, 1}; diff --git a/plugins/CrossoverEQ/CrossoverEQ.cpp b/plugins/CrossoverEQ/CrossoverEQ.cpp index 6e59627f6..2784f9b6b 100644 --- a/plugins/CrossoverEQ/CrossoverEQ.cpp +++ b/plugins/CrossoverEQ/CrossoverEQ.cpp @@ -64,9 +64,9 @@ CrossoverEQEffect::CrossoverEQEffect( Model* parent, const Descriptor::SubPlugin m_hp4( m_sampleRate ), m_needsUpdate( true ) { - m_tmp2 = new sampleFrame[Engine::audioEngine()->framesPerPeriod()]; - m_tmp1 = new sampleFrame[Engine::audioEngine()->framesPerPeriod()]; - m_work = new sampleFrame[Engine::audioEngine()->framesPerPeriod()]; + m_tmp2 = new SampleFrame[Engine::audioEngine()->framesPerPeriod()]; + m_tmp1 = new SampleFrame[Engine::audioEngine()->framesPerPeriod()]; + m_work = new SampleFrame[Engine::audioEngine()->framesPerPeriod()]; } CrossoverEQEffect::~CrossoverEQEffect() @@ -89,7 +89,7 @@ void CrossoverEQEffect::sampleRateChanged() } -bool CrossoverEQEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) +bool CrossoverEQEffect::processAudioBuffer( SampleFrame* buf, const fpp_t frames ) { if( !isEnabled() || !isRunning () ) { @@ -139,7 +139,7 @@ bool CrossoverEQEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames m_needsUpdate = false; - memset( m_work, 0, sizeof( sampleFrame ) * frames ); + zeroSampleFrames(m_work, frames); // run temp bands for( int f = 0; f < frames; ++f ) diff --git a/plugins/CrossoverEQ/CrossoverEQ.h b/plugins/CrossoverEQ/CrossoverEQ.h index fe9b4541b..078e51c21 100644 --- a/plugins/CrossoverEQ/CrossoverEQ.h +++ b/plugins/CrossoverEQ/CrossoverEQ.h @@ -40,7 +40,7 @@ class CrossoverEQEffect : public Effect public: CrossoverEQEffect( Model* parent, const Descriptor::SubPluginFeatures::Key* key ); ~CrossoverEQEffect() override; - bool processAudioBuffer( sampleFrame* buf, const fpp_t frames ) override; + bool processAudioBuffer( SampleFrame* buf, const fpp_t frames ) override; EffectControls* controls() override { @@ -69,9 +69,9 @@ private: StereoLinkwitzRiley m_hp3; StereoLinkwitzRiley m_hp4; - sampleFrame * m_tmp1; - sampleFrame * m_tmp2; - sampleFrame * m_work; + SampleFrame* m_tmp1; + SampleFrame* m_tmp2; + SampleFrame* m_work; bool m_needsUpdate; diff --git a/plugins/Delay/DelayEffect.cpp b/plugins/Delay/DelayEffect.cpp index 71f6fdf9a..4e90c0fa8 100644 --- a/plugins/Delay/DelayEffect.cpp +++ b/plugins/Delay/DelayEffect.cpp @@ -81,7 +81,7 @@ DelayEffect::~DelayEffect() -bool DelayEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) +bool DelayEffect::processAudioBuffer( SampleFrame* buf, const fpp_t frames ) { if( !isEnabled() || !isRunning () ) { @@ -91,9 +91,8 @@ bool DelayEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) const float sr = Engine::audioEngine()->outputSampleRate(); const float d = dryLevel(); const float w = wetLevel(); - auto dryS = std::array{}; - float lPeak = 0.0; - float rPeak = 0.0; + + SampleFrame peak; float length = m_delayControls.m_delayTimeModel.value(); float amplitude = m_delayControls.m_lfoAmountModel.value() * sr; float lfoTime = 1.0 / m_delayControls.m_lfoTimeModel.value(); @@ -116,26 +115,28 @@ bool DelayEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) m_outGain = dbfsToAmp( m_delayControls.m_outGainModel.value() ); } - for( fpp_t f = 0; f < frames; ++f ) + for (fpp_t f = 0; f < frames; ++f) { - dryS[0] = buf[f][0]; - dryS[1] = buf[f][1]; + auto& currentFrame = buf[f]; + const auto dryS = currentFrame; + // Prepare delay for current sample m_delay->setFeedback( *feedbackPtr ); m_lfo->setFrequency( *lfoTimePtr ); m_currentLength = static_cast(*lengthPtr * Engine::audioEngine()->outputSampleRate()); m_delay->setLength( m_currentLength + ( *amplitudePtr * ( float )m_lfo->tick() ) ); - m_delay->tick( buf[f] ); - buf[f][0] *= m_outGain; - buf[f][1] *= m_outGain; + // Process the wet signal + m_delay->tick( currentFrame ); + currentFrame *= m_outGain; - lPeak = buf[f][0] > lPeak ? buf[f][0] : lPeak; - rPeak = buf[f][1] > rPeak ? buf[f][1] : rPeak; + // Calculate peak of wet signal + peak = peak.absMax(currentFrame); - buf[f][0] = ( d * dryS[0] ) + ( w * buf[f][0] ); - buf[f][1] = ( d * dryS[1] ) + ( w * buf[f][1] ); - outSum += buf[f][0]*buf[f][0] + buf[f][1]*buf[f][1]; + // Dry/wet mix + currentFrame = dryS * d + currentFrame * w; + + outSum += currentFrame.sumOfSquaredAmplitudes(); lengthPtr += lengthInc; amplitudePtr += amplitudeInc; @@ -143,8 +144,8 @@ bool DelayEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) feedbackPtr += feedbackInc; } checkGate( outSum / frames ); - m_delayControls.m_outPeakL = lPeak; - m_delayControls.m_outPeakR = rPeak; + m_delayControls.m_outPeakL = peak.left(); + m_delayControls.m_outPeakR = peak.right(); return isRunning(); } diff --git a/plugins/Delay/DelayEffect.h b/plugins/Delay/DelayEffect.h index b6c090ff0..b7e2cfef0 100644 --- a/plugins/Delay/DelayEffect.h +++ b/plugins/Delay/DelayEffect.h @@ -39,7 +39,7 @@ class DelayEffect : public Effect public: DelayEffect(Model* parent , const Descriptor::SubPluginFeatures::Key* key ); ~DelayEffect() override; - bool processAudioBuffer( sampleFrame* buf, const fpp_t frames ) override; + bool processAudioBuffer( SampleFrame* buf, const fpp_t frames ) override; EffectControls* controls() override { return &m_delayControls; diff --git a/plugins/Delay/StereoDelay.cpp b/plugins/Delay/StereoDelay.cpp index c03cf68d0..3187b3f2a 100644 --- a/plugins/Delay/StereoDelay.cpp +++ b/plugins/Delay/StereoDelay.cpp @@ -23,7 +23,9 @@ */ #include "StereoDelay.h" + #include "lmms_basics.h" +#include "SampleFrame.h" namespace lmms { @@ -55,7 +57,7 @@ StereoDelay::~StereoDelay() -void StereoDelay::tick( sampleFrame& frame ) +void StereoDelay::tick( SampleFrame& frame ) { m_writeIndex = ( m_writeIndex + 1 ) % ( int )m_maxLength; int readIndex = m_writeIndex - static_cast(m_length); @@ -81,7 +83,7 @@ void StereoDelay::setSampleRate( int sampleRate ) } int bufferSize = ( int )( sampleRate * m_maxTime ); - m_buffer = new sampleFrame[bufferSize]; + m_buffer = new SampleFrame[bufferSize]; for( int i = 0 ; i < bufferSize ; i++) { m_buffer[i][0] = 0.0; diff --git a/plugins/Delay/StereoDelay.h b/plugins/Delay/StereoDelay.h index 0ea0efeed..ad0e020b5 100644 --- a/plugins/Delay/StereoDelay.h +++ b/plugins/Delay/StereoDelay.h @@ -31,6 +31,8 @@ namespace lmms { +class SampleFrame; + class StereoDelay { public: @@ -49,11 +51,11 @@ public: m_feedback = feedback; } - void tick( sampleFrame& frame ); + void tick( SampleFrame& frame ); void setSampleRate( int sampleRate ); private: - sampleFrame* m_buffer; + SampleFrame* m_buffer; int m_maxLength; float m_length; int m_writeIndex; diff --git a/plugins/Dispersion/Dispersion.cpp b/plugins/Dispersion/Dispersion.cpp index 72e4c2103..a2fada615 100644 --- a/plugins/Dispersion/Dispersion.cpp +++ b/plugins/Dispersion/Dispersion.cpp @@ -58,7 +58,7 @@ DispersionEffect::DispersionEffect(Model* parent, const Descriptor::SubPluginFea } -bool DispersionEffect::processAudioBuffer(sampleFrame* buf, const fpp_t frames) +bool DispersionEffect::processAudioBuffer(SampleFrame* buf, const fpp_t frames) { if (!isEnabled() || !isRunning()) { diff --git a/plugins/Dispersion/Dispersion.h b/plugins/Dispersion/Dispersion.h index 9e2014baf..e3d5d4b5c 100644 --- a/plugins/Dispersion/Dispersion.h +++ b/plugins/Dispersion/Dispersion.h @@ -41,7 +41,7 @@ class DispersionEffect : public Effect public: DispersionEffect(Model* parent, const Descriptor::SubPluginFeatures::Key* key); ~DispersionEffect() override = default; - bool processAudioBuffer(sampleFrame* buf, const fpp_t frames) override; + bool processAudioBuffer(SampleFrame* buf, const fpp_t frames) override; EffectControls* controls() override { diff --git a/plugins/DualFilter/DualFilter.cpp b/plugins/DualFilter/DualFilter.cpp index 6f91bb251..b337e1003 100644 --- a/plugins/DualFilter/DualFilter.cpp +++ b/plugins/DualFilter/DualFilter.cpp @@ -77,7 +77,7 @@ DualFilterEffect::~DualFilterEffect() -bool DualFilterEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) +bool DualFilterEffect::processAudioBuffer( SampleFrame* buf, const fpp_t frames ) { if( !isEnabled() || !isRunning () ) { diff --git a/plugins/DualFilter/DualFilter.h b/plugins/DualFilter/DualFilter.h index 29161039a..6c53f61ef 100644 --- a/plugins/DualFilter/DualFilter.h +++ b/plugins/DualFilter/DualFilter.h @@ -40,7 +40,7 @@ class DualFilterEffect : public Effect public: DualFilterEffect( Model* parent, const Descriptor::SubPluginFeatures::Key* key ); ~DualFilterEffect() override; - bool processAudioBuffer( sampleFrame* buf, const fpp_t frames ) override; + bool processAudioBuffer( SampleFrame* buf, const fpp_t frames ) override; EffectControls* controls() override { diff --git a/plugins/DynamicsProcessor/DynamicsProcessor.cpp b/plugins/DynamicsProcessor/DynamicsProcessor.cpp index a11cc28c6..5b251a6f0 100644 --- a/plugins/DynamicsProcessor/DynamicsProcessor.cpp +++ b/plugins/DynamicsProcessor/DynamicsProcessor.cpp @@ -91,7 +91,7 @@ inline void DynProcEffect::calcRelease() } -bool DynProcEffect::processAudioBuffer( sampleFrame * _buf, +bool DynProcEffect::processAudioBuffer( SampleFrame* _buf, const fpp_t _frames ) { if( !isEnabled() || !isRunning () ) diff --git a/plugins/DynamicsProcessor/DynamicsProcessor.h b/plugins/DynamicsProcessor/DynamicsProcessor.h index 576accdcc..970690d8d 100644 --- a/plugins/DynamicsProcessor/DynamicsProcessor.h +++ b/plugins/DynamicsProcessor/DynamicsProcessor.h @@ -42,7 +42,7 @@ public: DynProcEffect( Model * _parent, const Descriptor::SubPluginFeatures::Key * _key ); ~DynProcEffect() override; - bool processAudioBuffer( sampleFrame * _buf, + bool processAudioBuffer( SampleFrame* _buf, const fpp_t _frames ) override; EffectControls * controls() override diff --git a/plugins/Eq/EqEffect.cpp b/plugins/Eq/EqEffect.cpp index b81512c1c..662b85a8e 100644 --- a/plugins/Eq/EqEffect.cpp +++ b/plugins/Eq/EqEffect.cpp @@ -64,7 +64,7 @@ EqEffect::EqEffect( Model *parent, const Plugin::Descriptor::SubPluginFeatures:: -bool EqEffect::processAudioBuffer( sampleFrame *buf, const fpp_t frames ) +bool EqEffect::processAudioBuffer( SampleFrame* buf, const fpp_t frames ) { const int sampleRate = Engine::audioEngine()->outputSampleRate(); @@ -157,7 +157,7 @@ bool EqEffect::processAudioBuffer( sampleFrame *buf, const fpp_t frames ) } const float outGain = m_outGain; - sampleFrame m_inPeak = { 0, 0 }; + SampleFrame m_inPeak = { 0, 0 }; if(m_eqControls.m_analyseInModel.value( true ) && outSum > 0 && m_eqControls.isViewVisible() ) { @@ -263,7 +263,7 @@ bool EqEffect::processAudioBuffer( sampleFrame *buf, const fpp_t frames ) } - sampleFrame outPeak = { 0, 0 }; + SampleFrame outPeak = { 0, 0 }; gain( buf, frames, outGain, &outPeak ); m_eqControls.m_outPeakL = m_eqControls.m_outPeakL < outPeak[0] ? outPeak[0] : m_eqControls.m_outPeakL; m_eqControls.m_outPeakR = m_eqControls.m_outPeakR < outPeak[1] ? outPeak[1] : m_eqControls.m_outPeakR; diff --git a/plugins/Eq/EqEffect.h b/plugins/Eq/EqEffect.h index 7e91ee401..ca0ebb1b9 100644 --- a/plugins/Eq/EqEffect.h +++ b/plugins/Eq/EqEffect.h @@ -40,12 +40,12 @@ class EqEffect : public Effect public: EqEffect( Model * parent , const Descriptor::SubPluginFeatures::Key * key ); ~EqEffect() override = default; - bool processAudioBuffer( sampleFrame * buf, const fpp_t frames ) override; + bool processAudioBuffer( SampleFrame* buf, const fpp_t frames ) override; EffectControls * controls() override { return &m_eqControls; } - inline void gain( sampleFrame * buf, const fpp_t frames, float scale, sampleFrame * peak ) + inline void gain( SampleFrame* buf, const fpp_t frames, float scale, SampleFrame* peak ) { peak[0][0] = 0.0f; peak[0][1] = 0.0f; for( fpp_t f = 0; f < frames; ++f ) diff --git a/plugins/Eq/EqFilter.h b/plugins/Eq/EqFilter.h index df2b50493..5408d131c 100644 --- a/plugins/Eq/EqFilter.h +++ b/plugins/Eq/EqFilter.h @@ -432,7 +432,7 @@ public: - virtual void processBuffer( sampleFrame* buf, const fpp_t frames ) + virtual void processBuffer( SampleFrame* buf, const fpp_t frames ) { for ( fpp_t f = 0 ; f < frames ; ++f) { diff --git a/plugins/Eq/EqSpectrumView.cpp b/plugins/Eq/EqSpectrumView.cpp index 427fff796..75be48697 100644 --- a/plugins/Eq/EqSpectrumView.cpp +++ b/plugins/Eq/EqSpectrumView.cpp @@ -75,7 +75,7 @@ EqAnalyser::~EqAnalyser() -void EqAnalyser::analyze( sampleFrame *buf, const fpp_t frames ) +void EqAnalyser::analyze( SampleFrame* buf, const fpp_t frames ) { //only analyse if the view is visible if ( m_active ) diff --git a/plugins/Eq/EqSpectrumView.h b/plugins/Eq/EqSpectrumView.h index 947c55434..448c0e378 100644 --- a/plugins/Eq/EqSpectrumView.h +++ b/plugins/Eq/EqSpectrumView.h @@ -32,6 +32,7 @@ namespace lmms { +class SampleFrame; const int MAX_BANDS = 2048; class EqAnalyser @@ -44,7 +45,7 @@ public: bool getInProgress(); void clear(); - void analyze( sampleFrame *buf, const fpp_t frames ); + void analyze( SampleFrame* buf, const fpp_t frames ); float getEnergy() const; int getSampleRate() const; diff --git a/plugins/Flanger/FlangerEffect.cpp b/plugins/Flanger/FlangerEffect.cpp index c06747137..b8bb9d692 100644 --- a/plugins/Flanger/FlangerEffect.cpp +++ b/plugins/Flanger/FlangerEffect.cpp @@ -90,7 +90,7 @@ FlangerEffect::~FlangerEffect() -bool FlangerEffect::processAudioBuffer( sampleFrame *buf, const fpp_t frames ) +bool FlangerEffect::processAudioBuffer( SampleFrame* buf, const fpp_t frames ) { if( !isEnabled() || !isRunning () ) { diff --git a/plugins/Flanger/FlangerEffect.h b/plugins/Flanger/FlangerEffect.h index 8428d89a3..c4afb8841 100644 --- a/plugins/Flanger/FlangerEffect.h +++ b/plugins/Flanger/FlangerEffect.h @@ -42,7 +42,7 @@ class FlangerEffect : public Effect public: FlangerEffect( Model* parent , const Descriptor::SubPluginFeatures::Key* key ); ~FlangerEffect() override; - bool processAudioBuffer( sampleFrame *buf, const fpp_t frames ) override; + bool processAudioBuffer( SampleFrame* buf, const fpp_t frames ) override; EffectControls* controls() override { return &m_flangerControls; diff --git a/plugins/FreeBoy/FreeBoy.cpp b/plugins/FreeBoy/FreeBoy.cpp index 07497f6c0..d801e82d4 100644 --- a/plugins/FreeBoy/FreeBoy.cpp +++ b/plugins/FreeBoy/FreeBoy.cpp @@ -228,7 +228,7 @@ float FreeBoyInstrument::desiredReleaseTimeMs() const -void FreeBoyInstrument::playNote(NotePlayHandle* nph, sampleFrame* workingBuffer) +void FreeBoyInstrument::playNote(NotePlayHandle* nph, SampleFrame* workingBuffer) { const f_cnt_t tfp = nph->totalFramesPlayed(); const int samplerate = Engine::audioEngine()->outputSampleRate(); diff --git a/plugins/FreeBoy/FreeBoy.h b/plugins/FreeBoy/FreeBoy.h index bba00efbf..3a178fdb1 100644 --- a/plugins/FreeBoy/FreeBoy.h +++ b/plugins/FreeBoy/FreeBoy.h @@ -55,7 +55,7 @@ public: FreeBoyInstrument( InstrumentTrack * _instrument_track ); ~FreeBoyInstrument() override = default; - void playNote(NotePlayHandle* nph, sampleFrame* workingBuffer) override; + void playNote(NotePlayHandle* nph, SampleFrame* workingBuffer) override; void deleteNotePluginData(NotePlayHandle* nph) override; void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; diff --git a/plugins/GigPlayer/GigPlayer.cpp b/plugins/GigPlayer/GigPlayer.cpp index 7c0d0d26b..b6613de7f 100644 --- a/plugins/GigPlayer/GigPlayer.cpp +++ b/plugins/GigPlayer/GigPlayer.cpp @@ -289,7 +289,7 @@ QString GigInstrument::getCurrentPatchName() // A key has been pressed -void GigInstrument::playNote( NotePlayHandle * _n, sampleFrame * ) +void GigInstrument::playNote( NotePlayHandle * _n, SampleFrame* ) { const float LOG440 = 2.643452676f; @@ -320,7 +320,7 @@ void GigInstrument::playNote( NotePlayHandle * _n, sampleFrame * ) // Process the notes and output a certain number of frames (e.g. 256, set in // the preferences) -void GigInstrument::play( sampleFrame * _working_buffer ) +void GigInstrument::play( SampleFrame* _working_buffer ) { const fpp_t frames = Engine::audioEngine()->framesPerPeriod(); const int rate = Engine::audioEngine()->outputSampleRate(); @@ -441,7 +441,7 @@ void GigInstrument::play( sampleFrame * _working_buffer ) } // Load this note's data - sampleFrame sampleData[samples]; + SampleFrame sampleData[samples]; loadSample(sample, sampleData, samples); // Apply ADSR using a copy so if we don't use these samples when @@ -458,7 +458,7 @@ void GigInstrument::play( sampleFrame * _working_buffer ) // Output the data resampling if needed if( resample == true ) { - sampleFrame convertBuf[frames]; + SampleFrame convertBuf[frames]; // Only output if resampling is successful (note that "used" is output) if (sample.convertSampleRate(*sampleData, *convertBuf, samples, frames, freq_factor, used)) @@ -499,7 +499,7 @@ void GigInstrument::play( sampleFrame * _working_buffer ) -void GigInstrument::loadSample( GigSample& sample, sampleFrame* sampleData, f_cnt_t samples ) +void GigInstrument::loadSample( GigSample& sample, SampleFrame* sampleData, f_cnt_t samples ) { if( sampleData == nullptr || samples < 1 ) { @@ -1182,7 +1182,7 @@ void GigSample::updateSampleRate() -bool GigSample::convertSampleRate( sampleFrame & oldBuf, sampleFrame & newBuf, +bool GigSample::convertSampleRate( SampleFrame & oldBuf, SampleFrame & newBuf, f_cnt_t oldSize, f_cnt_t newSize, float freq_factor, f_cnt_t& used ) { if( srcState == nullptr ) diff --git a/plugins/GigPlayer/GigPlayer.h b/plugins/GigPlayer/GigPlayer.h index 50d1acd40..685c7f546 100644 --- a/plugins/GigPlayer/GigPlayer.h +++ b/plugins/GigPlayer/GigPlayer.h @@ -157,7 +157,7 @@ public: // Needed since libsamplerate stores data internally between calls void updateSampleRate(); - bool convertSampleRate( sampleFrame & oldBuf, sampleFrame & newBuf, + bool convertSampleRate( SampleFrame & oldBuf, SampleFrame & newBuf, f_cnt_t oldSize, f_cnt_t newSize, float freq_factor, f_cnt_t& used ); gig::Sample * sample; @@ -243,10 +243,10 @@ public: GigInstrument( InstrumentTrack * _instrument_track ); ~GigInstrument() override; - void play( sampleFrame * _working_buffer ) override; + void play( SampleFrame* _working_buffer ) override; void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ) override; + SampleFrame* _working_buffer ) override; void deleteNotePluginData( NotePlayHandle * _n ) override; @@ -312,7 +312,7 @@ private: Dimension getDimensions( gig::Region * pRegion, int velocity, bool release ); // Load sample data from the Gig file, looping the sample where needed - void loadSample( GigSample& sample, sampleFrame* sampleData, f_cnt_t samples ); + void loadSample( GigSample& sample, SampleFrame* sampleData, f_cnt_t samples ); f_cnt_t getLoopedIndex( f_cnt_t index, f_cnt_t startf, f_cnt_t endf ) const; f_cnt_t getPingPongIndex( f_cnt_t index, f_cnt_t startf, f_cnt_t endf ) const; diff --git a/plugins/GranularPitchShifter/GranularPitchShifterEffect.cpp b/plugins/GranularPitchShifter/GranularPitchShifterEffect.cpp index 90c6e86d3..e5af1e8bf 100755 --- a/plugins/GranularPitchShifter/GranularPitchShifterEffect.cpp +++ b/plugins/GranularPitchShifter/GranularPitchShifterEffect.cpp @@ -60,7 +60,7 @@ GranularPitchShifterEffect::GranularPitchShifterEffect(Model* parent, const Desc } -bool GranularPitchShifterEffect::processAudioBuffer(sampleFrame* buf, const fpp_t frames) +bool GranularPitchShifterEffect::processAudioBuffer(SampleFrame* buf, const fpp_t frames) { if (!isEnabled() || !isRunning()) { return false; } diff --git a/plugins/GranularPitchShifter/GranularPitchShifterEffect.h b/plugins/GranularPitchShifter/GranularPitchShifterEffect.h index a50ea8238..c904b4c13 100755 --- a/plugins/GranularPitchShifter/GranularPitchShifterEffect.h +++ b/plugins/GranularPitchShifter/GranularPitchShifterEffect.h @@ -48,7 +48,7 @@ class GranularPitchShifterEffect : public Effect public: GranularPitchShifterEffect(Model* parent, const Descriptor::SubPluginFeatures::Key* key); ~GranularPitchShifterEffect() override = default; - bool processAudioBuffer(sampleFrame* buf, const fpp_t frames) override; + bool processAudioBuffer(SampleFrame* buf, const fpp_t frames) override; EffectControls* controls() override { diff --git a/plugins/Kicker/Kicker.cpp b/plugins/Kicker/Kicker.cpp index 06385608f..a71941fc6 100644 --- a/plugins/Kicker/Kicker.cpp +++ b/plugins/Kicker/Kicker.cpp @@ -156,7 +156,7 @@ using DistFX = DspEffectLibrary::Distortion; using SweepOsc = KickerOsc>; void KickerInstrument::playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ) + SampleFrame* _working_buffer ) { const fpp_t frames = _n->framesLeftForCurrentPeriod(); const f_cnt_t offset = _n->noteOffset(); diff --git a/plugins/Kicker/Kicker.h b/plugins/Kicker/Kicker.h index 508787707..2eadaa333 100644 --- a/plugins/Kicker/Kicker.h +++ b/plugins/Kicker/Kicker.h @@ -56,7 +56,7 @@ public: ~KickerInstrument() override = default; void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ) override; + SampleFrame* _working_buffer ) override; void deleteNotePluginData( NotePlayHandle * _n ) override; void saveSettings(QDomDocument& doc, QDomElement& elem) override; diff --git a/plugins/Kicker/KickerOsc.h b/plugins/Kicker/KickerOsc.h index 69436c5fc..420373512 100644 --- a/plugins/Kicker/KickerOsc.h +++ b/plugins/Kicker/KickerOsc.h @@ -60,7 +60,7 @@ public: virtual ~KickerOsc() = default; - void update( sampleFrame* buf, const fpp_t frames, const float sampleRate ) + void update( SampleFrame* buf, const fpp_t frames, const float sampleRate ) { for( fpp_t frame = 0; frame < frames; ++frame ) { diff --git a/plugins/LOMM/LOMM.cpp b/plugins/LOMM/LOMM.cpp index 72478f6b5..7c4574cd1 100644 --- a/plugins/LOMM/LOMM.cpp +++ b/plugins/LOMM/LOMM.cpp @@ -101,7 +101,7 @@ void LOMMEffect::changeSampleRate() } -bool LOMMEffect::processAudioBuffer(sampleFrame* buf, const fpp_t frames) +bool LOMMEffect::processAudioBuffer(SampleFrame* buf, const fpp_t frames) { if (!isEnabled() || !isRunning()) { diff --git a/plugins/LOMM/LOMM.h b/plugins/LOMM/LOMM.h index 9e03dc343..783233c5f 100644 --- a/plugins/LOMM/LOMM.h +++ b/plugins/LOMM/LOMM.h @@ -45,7 +45,7 @@ class LOMMEffect : public Effect public: LOMMEffect(Model* parent, const Descriptor::SubPluginFeatures::Key* key); ~LOMMEffect() override = default; - bool processAudioBuffer(sampleFrame* buf, const fpp_t frames) override; + bool processAudioBuffer(SampleFrame* buf, const fpp_t frames) override; EffectControls* controls() override { diff --git a/plugins/LadspaEffect/LadspaEffect.cpp b/plugins/LadspaEffect/LadspaEffect.cpp index ccf92474b..26901c65f 100644 --- a/plugins/LadspaEffect/LadspaEffect.cpp +++ b/plugins/LadspaEffect/LadspaEffect.cpp @@ -129,7 +129,7 @@ void LadspaEffect::changeSampleRate() -bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, +bool LadspaEffect::processAudioBuffer( SampleFrame* _buf, const fpp_t _frames ) { m_pluginMutex.lock(); @@ -140,13 +140,13 @@ bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, } int frames = _frames; - sampleFrame * o_buf = nullptr; - QVarLengthArray sBuf(_frames * DEFAULT_CHANNELS); + SampleFrame* o_buf = nullptr; + QVarLengthArray sBuf(_frames); if( m_maxSampleRate < Engine::audioEngine()->outputSampleRate() ) { o_buf = _buf; - _buf = reinterpret_cast(sBuf.data()); + _buf = sBuf.data(); sampleDown( o_buf, _buf, m_maxSampleRate ); frames = _frames * m_maxSampleRate / Engine::audioEngine()->outputSampleRate(); diff --git a/plugins/LadspaEffect/LadspaEffect.h b/plugins/LadspaEffect/LadspaEffect.h index 8ad4f1411..d5b93d4e2 100644 --- a/plugins/LadspaEffect/LadspaEffect.h +++ b/plugins/LadspaEffect/LadspaEffect.h @@ -47,7 +47,7 @@ public: const Descriptor::SubPluginFeatures::Key * _key ); ~LadspaEffect() override; - bool processAudioBuffer( sampleFrame * _buf, + bool processAudioBuffer( SampleFrame* _buf, const fpp_t _frames ) override; void setControl( int _control, LADSPA_Data _data ); diff --git a/plugins/Lb302/Lb302.cpp b/plugins/Lb302/Lb302.cpp index 17c9b7424..02038239a 100644 --- a/plugins/Lb302/Lb302.cpp +++ b/plugins/Lb302/Lb302.cpp @@ -462,7 +462,7 @@ inline float GET_INC(float freq) { return freq/Engine::audioEngine()->outputSampleRate(); // TODO: Use actual sampling rate. } -int Lb302Synth::process(sampleFrame *outbuf, const int size) +int Lb302Synth::process(SampleFrame* outbuf, const int size) { const float sampleRatio = 44100.f / Engine::audioEngine()->outputSampleRate(); @@ -732,7 +732,7 @@ void Lb302Synth::initSlide() } -void Lb302Synth::playNote( NotePlayHandle * _n, sampleFrame * _working_buffer ) +void Lb302Synth::playNote( NotePlayHandle * _n, SampleFrame* _working_buffer ) { if( _n->isMasterNote() || ( _n->hasParent() && _n->isReleased() ) ) { @@ -791,7 +791,7 @@ void Lb302Synth::processNote( NotePlayHandle * _n ) -void Lb302Synth::play( sampleFrame * _working_buffer ) +void Lb302Synth::play( SampleFrame* _working_buffer ) { m_notesMutex.lock(); while( ! m_notes.isEmpty() ) diff --git a/plugins/Lb302/Lb302.h b/plugins/Lb302/Lb302.h index 2be9e9567..25a08592c 100644 --- a/plugins/Lb302/Lb302.h +++ b/plugins/Lb302/Lb302.h @@ -152,9 +152,9 @@ public: Lb302Synth( InstrumentTrack * _instrument_track ); ~Lb302Synth() override; - void play( sampleFrame * _working_buffer ) override; + void play( SampleFrame* _working_buffer ) override; void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ) override; + SampleFrame* _working_buffer ) override; void deleteNotePluginData( NotePlayHandle * _n ) override; @@ -246,7 +246,7 @@ private: void recalcFilter(); - int process(sampleFrame *outbuf, const int size); + int process(SampleFrame* outbuf, const int size); friend class gui::Lb302SynthView; diff --git a/plugins/Lv2Effect/Lv2Effect.cpp b/plugins/Lv2Effect/Lv2Effect.cpp index eef6305cc..d6b89a229 100644 --- a/plugins/Lv2Effect/Lv2Effect.cpp +++ b/plugins/Lv2Effect/Lv2Effect.cpp @@ -68,7 +68,7 @@ Lv2Effect::Lv2Effect(Model* parent, const Descriptor::SubPluginFeatures::Key *ke -bool Lv2Effect::processAudioBuffer(sampleFrame *buf, const fpp_t frames) +bool Lv2Effect::processAudioBuffer(SampleFrame* buf, const fpp_t frames) { if (!isEnabled() || !isRunning()) { return false; } Q_ASSERT(frames <= static_cast(m_tmpOutputSmps.size())); diff --git a/plugins/Lv2Effect/Lv2Effect.h b/plugins/Lv2Effect/Lv2Effect.h index a28182132..bc81eb590 100644 --- a/plugins/Lv2Effect/Lv2Effect.h +++ b/plugins/Lv2Effect/Lv2Effect.h @@ -42,7 +42,7 @@ public: */ Lv2Effect(Model* parent, const Descriptor::SubPluginFeatures::Key* _key); - bool processAudioBuffer( sampleFrame* buf, const fpp_t frames ) override; + bool processAudioBuffer( SampleFrame* buf, const fpp_t frames ) override; EffectControls* controls() override { return &m_controls; } Lv2FxControls* lv2Controls() { return &m_controls; } @@ -50,7 +50,7 @@ public: private: Lv2FxControls m_controls; - std::vector m_tmpOutputSmps; + std::vector m_tmpOutputSmps; }; diff --git a/plugins/Lv2Instrument/Lv2Instrument.cpp b/plugins/Lv2Instrument/Lv2Instrument.cpp index 766790cc1..8da2d913e 100644 --- a/plugins/Lv2Instrument/Lv2Instrument.cpp +++ b/plugins/Lv2Instrument/Lv2Instrument.cpp @@ -177,7 +177,7 @@ bool Lv2Instrument::handleMidiEvent( // not yet working #ifndef LV2_INSTRUMENT_USE_MIDI -void Lv2Instrument::playNote(NotePlayHandle *nph, sampleFrame *) +void Lv2Instrument::playNote(NotePlayHandle *nph, SampleFrame*) { } #endif @@ -185,7 +185,7 @@ void Lv2Instrument::playNote(NotePlayHandle *nph, sampleFrame *) -void Lv2Instrument::play(sampleFrame *buf) +void Lv2Instrument::play(SampleFrame* buf) { copyModelsFromLmms(); diff --git a/plugins/Lv2Instrument/Lv2Instrument.h b/plugins/Lv2Instrument/Lv2Instrument.h index 9ae48c64c..268e7fd10 100644 --- a/plugins/Lv2Instrument/Lv2Instrument.h +++ b/plugins/Lv2Instrument/Lv2Instrument.h @@ -77,9 +77,9 @@ public: bool handleMidiEvent(const MidiEvent &event, const TimePos &time = TimePos(), f_cnt_t offset = 0) override; #else - void playNote(NotePlayHandle *nph, sampleFrame *) override; + void playNote(NotePlayHandle *nph, SampleFrame*) override; #endif - void play(sampleFrame *buf) override; + void play(SampleFrame* buf) override; /* misc diff --git a/plugins/Monstro/Monstro.cpp b/plugins/Monstro/Monstro.cpp index 4278b7cdb..c9b715ba7 100644 --- a/plugins/Monstro/Monstro.cpp +++ b/plugins/Monstro/Monstro.cpp @@ -110,7 +110,7 @@ MonstroSynth::MonstroSynth( MonstroInstrument * _i, NotePlayHandle * _nph ) : } -void MonstroSynth::renderOutput( fpp_t _frames, sampleFrame * _buf ) +void MonstroSynth::renderOutput( fpp_t _frames, SampleFrame* _buf ) { float modtmp; // temp variable for freq modulation // macros for modulating with env/lfos @@ -1062,7 +1062,7 @@ MonstroInstrument::MonstroInstrument( InstrumentTrack * _instrument_track ) : void MonstroInstrument::playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ) + SampleFrame* _working_buffer ) { const fpp_t frames = _n->framesLeftForCurrentPeriod(); const f_cnt_t offset = _n->noteOffset(); diff --git a/plugins/Monstro/Monstro.h b/plugins/Monstro/Monstro.h index 0df18d5c4..da705b9ff 100644 --- a/plugins/Monstro/Monstro.h +++ b/plugins/Monstro/Monstro.h @@ -177,7 +177,7 @@ public: MonstroSynth( MonstroInstrument * _i, NotePlayHandle * _nph ); virtual ~MonstroSynth() = default; - void renderOutput( fpp_t _frames, sampleFrame * _buf ); + void renderOutput( fpp_t _frames, SampleFrame* _buf ); private: @@ -357,7 +357,7 @@ public: ~MonstroInstrument() override = default; void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ) override; + SampleFrame* _working_buffer ) override; void deleteNotePluginData( NotePlayHandle * _n ) override; void saveSettings( QDomDocument & _doc, diff --git a/plugins/MultitapEcho/MultitapEcho.cpp b/plugins/MultitapEcho/MultitapEcho.cpp index c64567f9b..e779f2283 100644 --- a/plugins/MultitapEcho/MultitapEcho.cpp +++ b/plugins/MultitapEcho/MultitapEcho.cpp @@ -58,7 +58,7 @@ MultitapEchoEffect::MultitapEchoEffect( Model* parent, const Descriptor::SubPlug m_sampleRate( Engine::audioEngine()->outputSampleRate() ), m_sampleRatio( 1.0f / m_sampleRate ) { - m_work = new sampleFrame[Engine::audioEngine()->framesPerPeriod()]; + m_work = new SampleFrame[Engine::audioEngine()->framesPerPeriod()]; m_buffer.reset(); m_stages = static_cast( m_controls.m_stages.value() ); updateFilters( 0, 19 ); @@ -83,7 +83,7 @@ void MultitapEchoEffect::updateFilters( int begin, int end ) } -void MultitapEchoEffect::runFilter( sampleFrame * dst, sampleFrame * src, StereoOnePole & filter, const fpp_t frames ) +void MultitapEchoEffect::runFilter( SampleFrame* dst, SampleFrame* src, StereoOnePole & filter, const fpp_t frames ) { for( int f = 0; f < frames; ++f ) { @@ -93,7 +93,7 @@ void MultitapEchoEffect::runFilter( sampleFrame * dst, sampleFrame * src, Stereo } -bool MultitapEchoEffect::processAudioBuffer( sampleFrame * buf, const fpp_t frames ) +bool MultitapEchoEffect::processAudioBuffer( SampleFrame* buf, const fpp_t frames ) { if( !isEnabled() || !isRunning () ) { diff --git a/plugins/MultitapEcho/MultitapEcho.h b/plugins/MultitapEcho/MultitapEcho.h index 6145b9f86..d6e981fbd 100644 --- a/plugins/MultitapEcho/MultitapEcho.h +++ b/plugins/MultitapEcho/MultitapEcho.h @@ -40,7 +40,7 @@ class MultitapEchoEffect : public Effect public: MultitapEchoEffect( Model* parent, const Descriptor::SubPluginFeatures::Key* key ); ~MultitapEchoEffect() override; - bool processAudioBuffer( sampleFrame* buf, const fpp_t frames ) override; + bool processAudioBuffer( SampleFrame* buf, const fpp_t frames ) override; EffectControls* controls() override { @@ -49,7 +49,7 @@ public: private: void updateFilters( int begin, int end ); - void runFilter( sampleFrame * dst, sampleFrame * src, StereoOnePole & filter, const fpp_t frames ); + void runFilter( SampleFrame* dst, SampleFrame* src, StereoOnePole & filter, const fpp_t frames ); inline void setFilterFreq( float fc, StereoOnePole & f ) { @@ -70,7 +70,7 @@ private: float m_sampleRate; float m_sampleRatio; - sampleFrame * m_work; + SampleFrame* m_work; friend class MultitapEchoControls; diff --git a/plugins/Nes/Nes.cpp b/plugins/Nes/Nes.cpp index c5cc3b0d0..fb7c52459 100644 --- a/plugins/Nes/Nes.cpp +++ b/plugins/Nes/Nes.cpp @@ -103,7 +103,7 @@ NesObject::NesObject( NesInstrument * nes, const sample_rate_t samplerate, NoteP } -void NesObject::renderOutput( sampleFrame * buf, fpp_t frames ) +void NesObject::renderOutput( SampleFrame* buf, fpp_t frames ) { //////////////////////////////// // // @@ -545,7 +545,7 @@ NesInstrument::NesInstrument( InstrumentTrack * instrumentTrack ) : -void NesInstrument::playNote( NotePlayHandle * n, sampleFrame * workingBuffer ) +void NesInstrument::playNote( NotePlayHandle * n, SampleFrame* workingBuffer ) { const fpp_t frames = n->framesLeftForCurrentPeriod(); const f_cnt_t offset = n->noteOffset(); diff --git a/plugins/Nes/Nes.h b/plugins/Nes/Nes.h index e65cb3b13..207c22e83 100644 --- a/plugins/Nes/Nes.h +++ b/plugins/Nes/Nes.h @@ -95,7 +95,7 @@ public: NesObject( NesInstrument * nes, const sample_rate_t samplerate, NotePlayHandle * nph ); virtual ~NesObject() = default; - void renderOutput( sampleFrame * buf, fpp_t frames ); + void renderOutput( SampleFrame* buf, fpp_t frames ); void updateVibrato( float * freq ); void updatePitch(); @@ -212,7 +212,7 @@ public: ~NesInstrument() override = default; void playNote( NotePlayHandle * n, - sampleFrame * workingBuffer ) override; + SampleFrame* workingBuffer ) override; void deleteNotePluginData( NotePlayHandle * n ) override; diff --git a/plugins/OpulenZ/OpulenZ.cpp b/plugins/OpulenZ/OpulenZ.cpp index 3c6004477..5fd4bf58a 100644 --- a/plugins/OpulenZ/OpulenZ.cpp +++ b/plugins/OpulenZ/OpulenZ.cpp @@ -390,7 +390,7 @@ gui::PluginView* OpulenzInstrument::instantiateView( QWidget * _parent ) } -void OpulenzInstrument::play( sampleFrame * _working_buffer ) +void OpulenzInstrument::play( SampleFrame* _working_buffer ) { emulatorMutex.lock(); theEmulator->update(renderbuffer, frameCount); diff --git a/plugins/OpulenZ/OpulenZ.h b/plugins/OpulenZ/OpulenZ.h index a245b03ad..bd51c9cf5 100644 --- a/plugins/OpulenZ/OpulenZ.h +++ b/plugins/OpulenZ/OpulenZ.h @@ -65,7 +65,7 @@ public: gui::PluginView* instantiateView( QWidget * _parent ) override; bool handleMidiEvent( const MidiEvent& event, const TimePos& time, f_cnt_t offset = 0 ) override; - void play( sampleFrame * _working_buffer ) override; + void play( SampleFrame* _working_buffer ) override; void saveSettings( QDomDocument & _doc, QDomElement & _this ) override; void loadSettings( const QDomElement & _this ) override; diff --git a/plugins/Organic/Organic.cpp b/plugins/Organic/Organic.cpp index e7b0cf792..54c36a510 100644 --- a/plugins/Organic/Organic.cpp +++ b/plugins/Organic/Organic.cpp @@ -221,7 +221,7 @@ QString OrganicInstrument::nodeName() const void OrganicInstrument::playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ) + SampleFrame* _working_buffer ) { const fpp_t frames = _n->framesLeftForCurrentPeriod(); const f_cnt_t offset = _n->noteOffset(); diff --git a/plugins/Organic/Organic.h b/plugins/Organic/Organic.h index e50550e5e..5a066af43 100644 --- a/plugins/Organic/Organic.h +++ b/plugins/Organic/Organic.h @@ -125,7 +125,7 @@ public: ~OrganicInstrument() override; void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ) override; + SampleFrame* _working_buffer ) override; void deleteNotePluginData( NotePlayHandle * _n ) override; diff --git a/plugins/Patman/Patman.cpp b/plugins/Patman/Patman.cpp index d2f4aee4e..6165bd537 100644 --- a/plugins/Patman/Patman.cpp +++ b/plugins/Patman/Patman.cpp @@ -134,7 +134,7 @@ QString PatmanInstrument::nodeName() const void PatmanInstrument::playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ) + SampleFrame* _working_buffer ) { if( m_patchFile == "" ) { @@ -160,7 +160,7 @@ void PatmanInstrument::playNote( NotePlayHandle * _n, } else { - memset( _working_buffer, 0, ( frames + offset ) * sizeof( sampleFrame ) ); + zeroSampleFrames(_working_buffer, frames + offset); } } @@ -342,7 +342,7 @@ PatmanInstrument::LoadError PatmanInstrument::loadPatch( } } - auto data = new sampleFrame[frames]; + auto data = new SampleFrame[frames]; for( f_cnt_t frame = 0; frame < frames; ++frame ) { diff --git a/plugins/Patman/Patman.h b/plugins/Patman/Patman.h index 16b98deee..a77c2607f 100644 --- a/plugins/Patman/Patman.h +++ b/plugins/Patman/Patman.h @@ -60,7 +60,7 @@ public: ~PatmanInstrument() override; void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ) override; + SampleFrame* _working_buffer ) override; void deleteNotePluginData( NotePlayHandle * _n ) override; diff --git a/plugins/PeakControllerEffect/PeakControllerEffect.cpp b/plugins/PeakControllerEffect/PeakControllerEffect.cpp index 7aff6f803..af64d0095 100644 --- a/plugins/PeakControllerEffect/PeakControllerEffect.cpp +++ b/plugins/PeakControllerEffect/PeakControllerEffect.cpp @@ -93,7 +93,7 @@ PeakControllerEffect::~PeakControllerEffect() } -bool PeakControllerEffect::processAudioBuffer( sampleFrame * _buf, +bool PeakControllerEffect::processAudioBuffer( SampleFrame* _buf, const fpp_t _frames ) { PeakControllerEffectControls & c = m_peakControls; diff --git a/plugins/PeakControllerEffect/PeakControllerEffect.h b/plugins/PeakControllerEffect/PeakControllerEffect.h index f2bafedda..dc6e507f3 100644 --- a/plugins/PeakControllerEffect/PeakControllerEffect.h +++ b/plugins/PeakControllerEffect/PeakControllerEffect.h @@ -41,7 +41,7 @@ public: PeakControllerEffect( Model * parent, const Descriptor::SubPluginFeatures::Key * _key ); ~PeakControllerEffect() override; - bool processAudioBuffer( sampleFrame * _buf, + bool processAudioBuffer( SampleFrame* _buf, const fpp_t _frames ) override; EffectControls * controls() override diff --git a/plugins/ReverbSC/ReverbSC.cpp b/plugins/ReverbSC/ReverbSC.cpp index c73e421ec..2def88d1d 100644 --- a/plugins/ReverbSC/ReverbSC.cpp +++ b/plugins/ReverbSC/ReverbSC.cpp @@ -75,7 +75,7 @@ ReverbSCEffect::~ReverbSCEffect() sp_destroy(&sp); } -bool ReverbSCEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) +bool ReverbSCEffect::processAudioBuffer( SampleFrame* buf, const fpp_t frames ) { if( !isEnabled() || !isRunning () ) { diff --git a/plugins/ReverbSC/ReverbSC.h b/plugins/ReverbSC/ReverbSC.h index 2cb119bff..f3c196f5b 100644 --- a/plugins/ReverbSC/ReverbSC.h +++ b/plugins/ReverbSC/ReverbSC.h @@ -45,7 +45,7 @@ class ReverbSCEffect : public Effect public: ReverbSCEffect( Model* parent, const Descriptor::SubPluginFeatures::Key* key ); ~ReverbSCEffect() override; - bool processAudioBuffer( sampleFrame* buf, const fpp_t frames ) override; + bool processAudioBuffer( SampleFrame* buf, const fpp_t frames ) override; EffectControls* controls() override { diff --git a/plugins/Sf2Player/Sf2Player.cpp b/plugins/Sf2Player/Sf2Player.cpp index c2a9eca98..fd1d6b1a3 100644 --- a/plugins/Sf2Player/Sf2Player.cpp +++ b/plugins/Sf2Player/Sf2Player.cpp @@ -647,7 +647,7 @@ void Sf2Instrument::reloadSynth() -void Sf2Instrument::playNote( NotePlayHandle * _n, sampleFrame * ) +void Sf2Instrument::playNote( NotePlayHandle * _n, SampleFrame* ) { if( _n->isMasterNote() || ( _n->hasParent() && _n->isReleased() ) ) { @@ -782,7 +782,7 @@ void Sf2Instrument::noteOff( Sf2PluginData * n ) } -void Sf2Instrument::play( sampleFrame * _working_buffer ) +void Sf2Instrument::play( SampleFrame* _working_buffer ) { const fpp_t frames = Engine::audioEngine()->framesPerPeriod(); @@ -868,7 +868,7 @@ void Sf2Instrument::play( sampleFrame * _working_buffer ) } -void Sf2Instrument::renderFrames( f_cnt_t frames, sampleFrame * buf ) +void Sf2Instrument::renderFrames( f_cnt_t frames, SampleFrame* buf ) { m_synthMutex.lock(); fluid_synth_get_gain(m_synth); // This flushes voice updates as a side effect @@ -877,9 +877,9 @@ void Sf2Instrument::renderFrames( f_cnt_t frames, sampleFrame * buf ) { const fpp_t f = frames * m_internalSampleRate / Engine::audioEngine()->outputSampleRate(); #ifdef __GNUC__ - sampleFrame tmp[f]; + SampleFrame tmp[f]; #else - sampleFrame * tmp = new sampleFrame[f]; + SampleFrame* tmp = new SampleFrame[f]; #endif fluid_synth_write_float( m_synth, f, tmp, 0, 2, tmp, 1, 2 ); diff --git a/plugins/Sf2Player/Sf2Player.h b/plugins/Sf2Player/Sf2Player.h index ec7ace47f..b752cd9c3 100644 --- a/plugins/Sf2Player/Sf2Player.h +++ b/plugins/Sf2Player/Sf2Player.h @@ -64,10 +64,10 @@ public: Sf2Instrument( InstrumentTrack * _instrument_track ); ~Sf2Instrument() override; - void play( sampleFrame * _working_buffer ) override; + void play( SampleFrame* _working_buffer ) override; void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ) override; + SampleFrame* _working_buffer ) override; void deleteNotePluginData( NotePlayHandle * _n ) override; @@ -150,7 +150,7 @@ private: void freeFont(); void noteOn( Sf2PluginData * n ); void noteOff( Sf2PluginData * n ); - void renderFrames( f_cnt_t frames, sampleFrame * buf ); + void renderFrames( f_cnt_t frames, SampleFrame* buf ); friend class gui::Sf2InstrumentView; diff --git a/plugins/Sfxr/Sfxr.cpp b/plugins/Sfxr/Sfxr.cpp index 3817706fc..0279eb41a 100644 --- a/plugins/Sfxr/Sfxr.cpp +++ b/plugins/Sfxr/Sfxr.cpp @@ -157,7 +157,7 @@ void SfxrSynth::resetSample( bool restart ) -void SfxrSynth::update( sampleFrame * buffer, const int32_t frameNum ) +void SfxrSynth::update( SampleFrame* buffer, const int32_t frameNum ) { for(int i=0;ioutputSampleRate(); @@ -454,7 +454,7 @@ void SfxrInstrument::playNote( NotePlayHandle * _n, sampleFrame * _working_buffe } else if( static_cast(_n->m_pluginData)->isPlaying() == false ) { - memset(_working_buffer + offset, 0, sizeof(sampleFrame) * frameNum); + zeroSampleFrames(_working_buffer + offset, frameNum); _n->noteOff(); return; } @@ -467,7 +467,7 @@ void SfxrInstrument::playNote( NotePlayHandle * _n, sampleFrame * _working_buffe // debug code // qDebug( "pFN %d", pitchedFrameNum ); - auto pitchedBuffer = new sampleFrame[pitchedFrameNum]; + auto pitchedBuffer = new SampleFrame[pitchedFrameNum]; static_cast(_n->m_pluginData)->update( pitchedBuffer, pitchedFrameNum ); for( fpp_t i=0; ioutputSampleRate(); diff --git a/plugins/Sid/SidInstrument.h b/plugins/Sid/SidInstrument.h index 8d5af8df0..79ad7f32a 100644 --- a/plugins/Sid/SidInstrument.h +++ b/plugins/Sid/SidInstrument.h @@ -102,7 +102,7 @@ public: ~SidInstrument() override = default; void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ) override; + SampleFrame* _working_buffer ) override; void deleteNotePluginData( NotePlayHandle * _n ) override; diff --git a/plugins/SlicerT/SlicerT.cpp b/plugins/SlicerT/SlicerT.cpp index d01cdfc36..3644060ed 100644 --- a/plugins/SlicerT/SlicerT.cpp +++ b/plugins/SlicerT/SlicerT.cpp @@ -75,7 +75,7 @@ SlicerT::SlicerT(InstrumentTrack* instrumentTrack) m_sliceSnap.setValue(0); } -void SlicerT::playNote(NotePlayHandle* handle, sampleFrame* workingBuffer) +void SlicerT::playNote(NotePlayHandle* handle, SampleFrame* workingBuffer) { if (m_originalSample.sampleSize() <= 1) { return; } diff --git a/plugins/SlicerT/SlicerT.h b/plugins/SlicerT/SlicerT.h index 010985dfc..06b55687b 100644 --- a/plugins/SlicerT/SlicerT.h +++ b/plugins/SlicerT/SlicerT.h @@ -75,7 +75,7 @@ signals: public: SlicerT(InstrumentTrack* instrumentTrack); - void playNote(NotePlayHandle* handle, sampleFrame* workingBuffer) override; + void playNote(NotePlayHandle* handle, SampleFrame* workingBuffer) override; void deleteNotePluginData(NotePlayHandle* handle) override; void saveSettings(QDomDocument& document, QDomElement& element) override; diff --git a/plugins/SpectrumAnalyzer/Analyzer.cpp b/plugins/SpectrumAnalyzer/Analyzer.cpp index 0bbada7db..dc2108eb9 100644 --- a/plugins/SpectrumAnalyzer/Analyzer.cpp +++ b/plugins/SpectrumAnalyzer/Analyzer.cpp @@ -77,7 +77,7 @@ Analyzer::~Analyzer() } // Take audio data and pass them to the spectrum processor. -bool Analyzer::processAudioBuffer(sampleFrame *buffer, const fpp_t frame_count) +bool Analyzer::processAudioBuffer(SampleFrame* buffer, const fpp_t frame_count) { // Measure time spent in audio thread; both average and peak should be well under 1 ms. #ifdef SA_DEBUG diff --git a/plugins/SpectrumAnalyzer/Analyzer.h b/plugins/SpectrumAnalyzer/Analyzer.h index 5be1f9ba8..da87ffd35 100644 --- a/plugins/SpectrumAnalyzer/Analyzer.h +++ b/plugins/SpectrumAnalyzer/Analyzer.h @@ -45,7 +45,7 @@ public: Analyzer(Model *parent, const Descriptor::SubPluginFeatures::Key *key); ~Analyzer() override; - bool processAudioBuffer(sampleFrame *buffer, const fpp_t frame_count) override; + bool processAudioBuffer(SampleFrame* buffer, const fpp_t frame_count) override; EffectControls *controls() override {return &m_controls;} SaProcessor *getProcessor() {return &m_processor;} @@ -63,7 +63,7 @@ private: //m_processorThread = QThread::create([=]{m_processor.analyze(m_inputBuffer);}); DataprocLauncher m_processorThread; - LocklessRingBuffer m_inputBuffer; + LocklessRingBuffer m_inputBuffer; #ifdef SA_DEBUG int m_last_dump_time; diff --git a/plugins/SpectrumAnalyzer/DataprocLauncher.h b/plugins/SpectrumAnalyzer/DataprocLauncher.h index 4325284c9..43bac6a43 100644 --- a/plugins/SpectrumAnalyzer/DataprocLauncher.h +++ b/plugins/SpectrumAnalyzer/DataprocLauncher.h @@ -37,7 +37,7 @@ namespace lmms class DataprocLauncher : public QThread { public: - explicit DataprocLauncher(SaProcessor &proc, LocklessRingBuffer &buffer) + explicit DataprocLauncher(SaProcessor &proc, LocklessRingBuffer &buffer) : m_processor(&proc), m_inputBuffer(&buffer) { @@ -50,7 +50,7 @@ private: } SaProcessor *m_processor; - LocklessRingBuffer *m_inputBuffer; + LocklessRingBuffer *m_inputBuffer; }; diff --git a/plugins/SpectrumAnalyzer/SaProcessor.cpp b/plugins/SpectrumAnalyzer/SaProcessor.cpp index b991ad3ea..e0eef8b59 100644 --- a/plugins/SpectrumAnalyzer/SaProcessor.cpp +++ b/plugins/SpectrumAnalyzer/SaProcessor.cpp @@ -98,9 +98,9 @@ SaProcessor::~SaProcessor() // Load data from audio thread ringbuffer and run FFT analysis if buffer is full enough. -void SaProcessor::analyze(LocklessRingBuffer &ring_buffer) +void SaProcessor::analyze(LocklessRingBuffer &ring_buffer) { - LocklessRingBufferReader reader(ring_buffer); + LocklessRingBufferReader reader(ring_buffer); // Processing thread loop while (!m_terminate) diff --git a/plugins/SpectrumAnalyzer/SaProcessor.h b/plugins/SpectrumAnalyzer/SaProcessor.h index 66b79788d..3903bf9d6 100644 --- a/plugins/SpectrumAnalyzer/SaProcessor.h +++ b/plugins/SpectrumAnalyzer/SaProcessor.h @@ -43,7 +43,7 @@ template class LocklessRingBuffer; class SaControls; - +class SampleFrame; //! Receives audio data, runs FFT analysis and stores the result. @@ -54,7 +54,7 @@ public: virtual ~SaProcessor(); // analysis thread and a method to terminate it - void analyze(LocklessRingBuffer &ring_buffer); + void analyze(LocklessRingBuffer &ring_buffer); void terminate() {m_terminate = true;} // inform processor if any processing is actually required diff --git a/plugins/StereoEnhancer/StereoEnhancer.cpp b/plugins/StereoEnhancer/StereoEnhancer.cpp index 784003056..d5ed8d99d 100644 --- a/plugins/StereoEnhancer/StereoEnhancer.cpp +++ b/plugins/StereoEnhancer/StereoEnhancer.cpp @@ -58,7 +58,7 @@ StereoEnhancerEffect::StereoEnhancerEffect( const Descriptor::SubPluginFeatures::Key * _key ) : Effect( &stereoenhancer_plugin_descriptor, _parent, _key ), m_seFX( DspEffectLibrary::StereoEnhancer( 0.0f ) ), - m_delayBuffer( new sampleFrame[DEFAULT_BUFFER_SIZE] ), + m_delayBuffer( new SampleFrame[DEFAULT_BUFFER_SIZE] ), m_currFrame( 0 ), m_bbControls( this ) { @@ -82,7 +82,7 @@ StereoEnhancerEffect::~StereoEnhancerEffect() -bool StereoEnhancerEffect::processAudioBuffer( sampleFrame * _buf, +bool StereoEnhancerEffect::processAudioBuffer( SampleFrame* _buf, const fpp_t _frames ) { diff --git a/plugins/StereoEnhancer/StereoEnhancer.h b/plugins/StereoEnhancer/StereoEnhancer.h index 5872100d3..861187f8f 100644 --- a/plugins/StereoEnhancer/StereoEnhancer.h +++ b/plugins/StereoEnhancer/StereoEnhancer.h @@ -40,7 +40,7 @@ public: StereoEnhancerEffect( Model * parent, const Descriptor::SubPluginFeatures::Key * _key ); ~StereoEnhancerEffect() override; - bool processAudioBuffer( sampleFrame * _buf, + bool processAudioBuffer( SampleFrame* _buf, const fpp_t _frames ) override; EffectControls * controls() override @@ -54,7 +54,7 @@ public: private: DspEffectLibrary::StereoEnhancer m_seFX; - sampleFrame * m_delayBuffer; + SampleFrame* m_delayBuffer; int m_currFrame; StereoEnhancerControls m_bbControls; diff --git a/plugins/StereoMatrix/StereoMatrix.cpp b/plugins/StereoMatrix/StereoMatrix.cpp index b96d2e107..c4384fddd 100644 --- a/plugins/StereoMatrix/StereoMatrix.cpp +++ b/plugins/StereoMatrix/StereoMatrix.cpp @@ -64,7 +64,7 @@ StereoMatrixEffect::StereoMatrixEffect( -bool StereoMatrixEffect::processAudioBuffer( sampleFrame * _buf, +bool StereoMatrixEffect::processAudioBuffer( SampleFrame* _buf, const fpp_t _frames ) { diff --git a/plugins/StereoMatrix/StereoMatrix.h b/plugins/StereoMatrix/StereoMatrix.h index ae7a59724..a254264f8 100644 --- a/plugins/StereoMatrix/StereoMatrix.h +++ b/plugins/StereoMatrix/StereoMatrix.h @@ -39,7 +39,7 @@ public: StereoMatrixEffect( Model * parent, const Descriptor::SubPluginFeatures::Key * _key ); ~StereoMatrixEffect() override = default; - bool processAudioBuffer( sampleFrame * _buf, + bool processAudioBuffer( SampleFrame* _buf, const fpp_t _frames ) override; EffectControls* controls() override diff --git a/plugins/Stk/Mallets/Mallets.cpp b/plugins/Stk/Mallets/Mallets.cpp index 4a3068d1c..00ddbf422 100644 --- a/plugins/Stk/Mallets/Mallets.cpp +++ b/plugins/Stk/Mallets/Mallets.cpp @@ -278,7 +278,7 @@ QString MalletsInstrument::nodeName() const void MalletsInstrument::playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ) + SampleFrame* _working_buffer ) { if( m_filesMissing ) { diff --git a/plugins/Stk/Mallets/Mallets.h b/plugins/Stk/Mallets/Mallets.h index 91e2dfce1..cf05ace66 100644 --- a/plugins/Stk/Mallets/Mallets.h +++ b/plugins/Stk/Mallets/Mallets.h @@ -189,7 +189,7 @@ public: ~MalletsInstrument() override = default; void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ) override; + SampleFrame* _working_buffer ) override; void deleteNotePluginData( NotePlayHandle * _n ) override; diff --git a/plugins/TripleOscillator/TripleOscillator.cpp b/plugins/TripleOscillator/TripleOscillator.cpp index 97b773e67..f04cee818 100644 --- a/plugins/TripleOscillator/TripleOscillator.cpp +++ b/plugins/TripleOscillator/TripleOscillator.cpp @@ -307,7 +307,7 @@ QString TripleOscillator::nodeName() const void TripleOscillator::playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ) + SampleFrame* _working_buffer ) { if (!_n->m_pluginData) { diff --git a/plugins/TripleOscillator/TripleOscillator.h b/plugins/TripleOscillator/TripleOscillator.h index 011352de4..fd6fc85ee 100644 --- a/plugins/TripleOscillator/TripleOscillator.h +++ b/plugins/TripleOscillator/TripleOscillator.h @@ -112,7 +112,7 @@ public: ~TripleOscillator() override = default; void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ) override; + SampleFrame* _working_buffer ) override; void deleteNotePluginData( NotePlayHandle * _n ) override; diff --git a/plugins/Vectorscope/VectorView.cpp b/plugins/Vectorscope/VectorView.cpp index c4776a688..2077d12cd 100644 --- a/plugins/Vectorscope/VectorView.cpp +++ b/plugins/Vectorscope/VectorView.cpp @@ -37,7 +37,7 @@ namespace lmms::gui { -VectorView::VectorView(VecControls *controls, LocklessRingBuffer *inputBuffer, unsigned short displaySize, QWidget *parent) : +VectorView::VectorView(VecControls *controls, LocklessRingBuffer *inputBuffer, unsigned short displaySize, QWidget *parent) : QWidget(parent), m_controls(controls), m_inputBuffer(inputBuffer), diff --git a/plugins/Vectorscope/VectorView.h b/plugins/Vectorscope/VectorView.h index 59ac99a77..c828fd139 100644 --- a/plugins/Vectorscope/VectorView.h +++ b/plugins/Vectorscope/VectorView.h @@ -30,6 +30,7 @@ namespace lmms { class VecControls; +class SampleFrame; } //#define VEC_DEBUG @@ -43,7 +44,7 @@ class VectorView : public QWidget { Q_OBJECT public: - explicit VectorView(VecControls *controls, LocklessRingBuffer *inputBuffer, unsigned short displaySize, QWidget *parent = 0); + explicit VectorView(VecControls *controls, LocklessRingBuffer *inputBuffer, unsigned short displaySize, QWidget *parent = 0); ~VectorView() override = default; QSize sizeHint() const override {return QSize(300, 300);} @@ -59,8 +60,8 @@ private slots: private: VecControls *m_controls; - LocklessRingBuffer *m_inputBuffer; - LocklessRingBufferReader m_bufferReader; + LocklessRingBuffer *m_inputBuffer; + LocklessRingBufferReader m_bufferReader; std::vector m_displayBuffer; const unsigned short m_displaySize; diff --git a/plugins/Vectorscope/Vectorscope.cpp b/plugins/Vectorscope/Vectorscope.cpp index f843fc86d..c94eb5d28 100644 --- a/plugins/Vectorscope/Vectorscope.cpp +++ b/plugins/Vectorscope/Vectorscope.cpp @@ -58,7 +58,7 @@ Vectorscope::Vectorscope(Model *parent, const Plugin::Descriptor::SubPluginFeatu // Take audio data and store them for processing and display in the GUI thread. -bool Vectorscope::processAudioBuffer(sampleFrame *buffer, const fpp_t frame_count) +bool Vectorscope::processAudioBuffer(SampleFrame* buffer, const fpp_t frame_count) { if (!isEnabled() || !isRunning ()) {return false;} diff --git a/plugins/Vectorscope/Vectorscope.h b/plugins/Vectorscope/Vectorscope.h index 54022ab90..66d20e639 100644 --- a/plugins/Vectorscope/Vectorscope.h +++ b/plugins/Vectorscope/Vectorscope.h @@ -39,16 +39,16 @@ public: Vectorscope(Model *parent, const Descriptor::SubPluginFeatures::Key *key); ~Vectorscope() override = default; - bool processAudioBuffer(sampleFrame *buffer, const fpp_t frame_count) override; + bool processAudioBuffer(SampleFrame* buffer, const fpp_t frame_count) override; EffectControls *controls() override {return &m_controls;} - LocklessRingBuffer *getBuffer() {return &m_inputBuffer;} + LocklessRingBuffer *getBuffer() {return &m_inputBuffer;} private: VecControls m_controls; // Maximum LMMS buffer size (hard coded, the actual constant is hard to get) const unsigned int m_maxBufferSize = 4096; - LocklessRingBuffer m_inputBuffer; + LocklessRingBuffer m_inputBuffer; }; diff --git a/plugins/Vestige/Vestige.cpp b/plugins/Vestige/Vestige.cpp index 1de713960..ffed82af7 100644 --- a/plugins/Vestige/Vestige.cpp +++ b/plugins/Vestige/Vestige.cpp @@ -395,7 +395,7 @@ void VestigeInstrument::loadFile( const QString & _file ) -void VestigeInstrument::play( sampleFrame * _buf ) +void VestigeInstrument::play( SampleFrame* _buf ) { if (!m_pluginMutex.tryLock(Engine::getSong()->isExporting() ? -1 : 0)) {return;} diff --git a/plugins/Vestige/Vestige.h b/plugins/Vestige/Vestige.h index 529893ba0..6a308ad2c 100644 --- a/plugins/Vestige/Vestige.h +++ b/plugins/Vestige/Vestige.h @@ -61,7 +61,7 @@ public: VestigeInstrument( InstrumentTrack * _instrument_track ); virtual ~VestigeInstrument(); - virtual void play( sampleFrame * _working_buffer ); + virtual void play( SampleFrame* _working_buffer ); virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); virtual void loadSettings( const QDomElement & _this ); diff --git a/plugins/Vibed/Vibed.cpp b/plugins/Vibed/Vibed.cpp index f99c9140d..c4dd08afa 100644 --- a/plugins/Vibed/Vibed.cpp +++ b/plugins/Vibed/Vibed.cpp @@ -201,7 +201,7 @@ QString Vibed::nodeName() const return vibedstrings_plugin_descriptor.name; } -void Vibed::playNote(NotePlayHandle* n, sampleFrame* workingBuffer) +void Vibed::playNote(NotePlayHandle* n, SampleFrame* workingBuffer) { if (!n->m_pluginData) { diff --git a/plugins/Vibed/Vibed.h b/plugins/Vibed/Vibed.h index ec8395da1..f02f810de 100644 --- a/plugins/Vibed/Vibed.h +++ b/plugins/Vibed/Vibed.h @@ -57,7 +57,7 @@ public: Vibed(InstrumentTrack* instrumentTrack); ~Vibed() override = default; - void playNote(NotePlayHandle* n, sampleFrame* workingBuffer) override; + void playNote(NotePlayHandle* n, SampleFrame* workingBuffer) override; void deleteNotePluginData(NotePlayHandle* n) override; void saveSettings(QDomDocument& doc, QDomElement& elem) override; diff --git a/plugins/VstBase/RemoteVstPlugin.cpp b/plugins/VstBase/RemoteVstPlugin.cpp index 0ec60bea4..ba40bcb68 100644 --- a/plugins/VstBase/RemoteVstPlugin.cpp +++ b/plugins/VstBase/RemoteVstPlugin.cpp @@ -191,7 +191,7 @@ public: void hideEditor(); void destroyEditor(); - virtual void process( const sampleFrame * _in, sampleFrame * _out ); + virtual void process( const SampleFrame* _in, SampleFrame* _out ); virtual void processMidiEvent( const MidiEvent& event, const f_cnt_t offset ); @@ -1027,7 +1027,7 @@ bool RemoteVstPlugin::load( const std::string & _plugin_file ) -void RemoteVstPlugin::process( const sampleFrame * _in, sampleFrame * _out ) +void RemoteVstPlugin::process( const SampleFrame* _in, SampleFrame* _out ) { // first we gonna post all MIDI-events we enqueued so far if( m_midiEvents.size() ) diff --git a/plugins/VstEffect/VstEffect.cpp b/plugins/VstEffect/VstEffect.cpp index bdbdea806..ecb8240c8 100644 --- a/plugins/VstEffect/VstEffect.cpp +++ b/plugins/VstEffect/VstEffect.cpp @@ -76,7 +76,7 @@ VstEffect::VstEffect( Model * _parent, -bool VstEffect::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames ) +bool VstEffect::processAudioBuffer( SampleFrame* _buf, const fpp_t _frames ) { if( !isEnabled() || !isRunning () ) { @@ -87,11 +87,11 @@ bool VstEffect::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames ) { const float d = dryLevel(); #ifdef __GNUC__ - sampleFrame buf[_frames]; + SampleFrame buf[_frames]; #else - sampleFrame * buf = new sampleFrame[_frames]; + SampleFrame* buf = new SampleFrame[_frames]; #endif - memcpy( buf, _buf, sizeof( sampleFrame ) * _frames ); + memcpy( buf, _buf, sizeof( SampleFrame ) * _frames ); if (m_pluginMutex.tryLock(Engine::getSong()->isExporting() ? -1 : 0)) { m_plugin->process( buf, buf ); diff --git a/plugins/VstEffect/VstEffect.h b/plugins/VstEffect/VstEffect.h index 987b1ecc2..c3f6e8091 100644 --- a/plugins/VstEffect/VstEffect.h +++ b/plugins/VstEffect/VstEffect.h @@ -45,7 +45,7 @@ public: const Descriptor::SubPluginFeatures::Key * _key ); ~VstEffect() override = default; - bool processAudioBuffer( sampleFrame * _buf, + bool processAudioBuffer( SampleFrame* _buf, const fpp_t _frames ) override; EffectControls * controls() override diff --git a/plugins/Watsyn/Watsyn.cpp b/plugins/Watsyn/Watsyn.cpp index 822f9b519..2749b2daf 100644 --- a/plugins/Watsyn/Watsyn.cpp +++ b/plugins/Watsyn/Watsyn.cpp @@ -74,8 +74,8 @@ WatsynObject::WatsynObject( float * _A1wave, float * _A2wave, m_fpp( _frames ), m_parent( _w ) { - m_abuf = new sampleFrame[_frames]; - m_bbuf = new sampleFrame[_frames]; + m_abuf = new SampleFrame[_frames]; + m_bbuf = new SampleFrame[_frames]; m_lphase[A1_OSC] = 0.0f; m_lphase[A2_OSC] = 0.0f; @@ -107,9 +107,9 @@ WatsynObject::~WatsynObject() void WatsynObject::renderOutput( fpp_t _frames ) { if( m_abuf == nullptr ) - m_abuf = new sampleFrame[m_fpp]; + m_abuf = new SampleFrame[m_fpp]; if( m_bbuf == nullptr ) - m_bbuf = new sampleFrame[m_fpp]; + m_bbuf = new SampleFrame[m_fpp]; for( fpp_t frame = 0; frame < _frames; frame++ ) { @@ -327,7 +327,7 @@ WatsynInstrument::WatsynInstrument( InstrumentTrack * _instrument_track ) : void WatsynInstrument::playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ) + SampleFrame* _working_buffer ) { if (!_n->m_pluginData) { @@ -339,12 +339,12 @@ void WatsynInstrument::playNote( NotePlayHandle * _n, const fpp_t frames = _n->framesLeftForCurrentPeriod(); const f_cnt_t offset = _n->noteOffset(); - sampleFrame * buffer = _working_buffer + offset; + SampleFrame* buffer = _working_buffer + offset; auto w = static_cast(_n->m_pluginData); - sampleFrame * abuf = w->abuf(); - sampleFrame * bbuf = w->bbuf(); + SampleFrame* abuf = w->abuf(); + SampleFrame* bbuf = w->bbuf(); w-> renderOutput( frames ); diff --git a/plugins/Watsyn/Watsyn.h b/plugins/Watsyn/Watsyn.h index b34e28f60..aebc74645 100644 --- a/plugins/Watsyn/Watsyn.h +++ b/plugins/Watsyn/Watsyn.h @@ -96,11 +96,11 @@ public: void renderOutput( fpp_t _frames ); - inline sampleFrame * abuf() const + inline SampleFrame* abuf() const { return m_abuf; } - inline sampleFrame * bbuf() const + inline SampleFrame* bbuf() const { return m_bbuf; } @@ -120,8 +120,8 @@ private: WatsynInstrument * m_parent; - sampleFrame * m_abuf; - sampleFrame * m_bbuf; + SampleFrame* m_abuf; + SampleFrame* m_bbuf; float m_lphase [NUM_OSCS]; float m_rphase [NUM_OSCS]; @@ -140,7 +140,7 @@ public: ~WatsynInstrument() override = default; void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ) override; + SampleFrame* _working_buffer ) override; void deleteNotePluginData( NotePlayHandle * _n ) override; diff --git a/plugins/WaveShaper/WaveShaper.cpp b/plugins/WaveShaper/WaveShaper.cpp index acd5a933b..373785408 100644 --- a/plugins/WaveShaper/WaveShaper.cpp +++ b/plugins/WaveShaper/WaveShaper.cpp @@ -66,7 +66,7 @@ WaveShaperEffect::WaveShaperEffect( Model * _parent, -bool WaveShaperEffect::processAudioBuffer( sampleFrame * _buf, +bool WaveShaperEffect::processAudioBuffer( SampleFrame* _buf, const fpp_t _frames ) { if( !isEnabled() || !isRunning () ) diff --git a/plugins/WaveShaper/WaveShaper.h b/plugins/WaveShaper/WaveShaper.h index 4c63d5806..4c9d6e962 100644 --- a/plugins/WaveShaper/WaveShaper.h +++ b/plugins/WaveShaper/WaveShaper.h @@ -40,7 +40,7 @@ public: WaveShaperEffect( Model * _parent, const Descriptor::SubPluginFeatures::Key * _key ); ~WaveShaperEffect() override = default; - bool processAudioBuffer( sampleFrame * _buf, + bool processAudioBuffer( SampleFrame* _buf, const fpp_t _frames ) override; EffectControls * controls() override diff --git a/plugins/Xpressive/ExprSynth.cpp b/plugins/Xpressive/ExprSynth.cpp index 0dde9ff96..ef5d3dbf1 100644 --- a/plugins/Xpressive/ExprSynth.cpp +++ b/plugins/Xpressive/ExprSynth.cpp @@ -34,6 +34,7 @@ #include "interpolation.h" #include "lmms_math.h" #include "NotePlayHandle.h" +#include "SampleFrame.h" #include @@ -735,7 +736,7 @@ ExprSynth::~ExprSynth() } } -void ExprSynth::renderOutput(fpp_t frames, sampleFrame *buf) +void ExprSynth::renderOutput(fpp_t frames, SampleFrame* buf) { try { diff --git a/plugins/Xpressive/ExprSynth.h b/plugins/Xpressive/ExprSynth.h index 5d664c85e..3348ed9f4 100644 --- a/plugins/Xpressive/ExprSynth.h +++ b/plugins/Xpressive/ExprSynth.h @@ -37,6 +37,7 @@ namespace lmms class ExprFrontData; class NotePlayHandle; +class SampleFrame; namespace gui { @@ -106,7 +107,7 @@ public: const sample_rate_t sample_rate, const FloatModel* pan1, const FloatModel* pan2, float rel_trans); virtual ~ExprSynth(); - void renderOutput(fpp_t frames, sampleFrame* buf ); + void renderOutput(fpp_t frames, SampleFrame* buf ); private: diff --git a/plugins/Xpressive/Xpressive.cpp b/plugins/Xpressive/Xpressive.cpp index e90abb24c..3fb1fc5f2 100644 --- a/plugins/Xpressive/Xpressive.cpp +++ b/plugins/Xpressive/Xpressive.cpp @@ -196,7 +196,7 @@ QString Xpressive::nodeName() const { return (xpressive_plugin_descriptor.name); } -void Xpressive::playNote(NotePlayHandle* nph, sampleFrame* working_buffer) { +void Xpressive::playNote(NotePlayHandle* nph, SampleFrame* working_buffer) { m_A1=m_parameterA1.value(); m_A2=m_parameterA2.value(); m_A3=m_parameterA3.value(); diff --git a/plugins/Xpressive/Xpressive.h b/plugins/Xpressive/Xpressive.h index 974b82b17..7dd8dcfaa 100644 --- a/plugins/Xpressive/Xpressive.h +++ b/plugins/Xpressive/Xpressive.h @@ -68,7 +68,7 @@ public: Xpressive(InstrumentTrack* instrument_track ); void playNote(NotePlayHandle* nph, - sampleFrame* working_buffer ) override; + SampleFrame* working_buffer ) override; void deleteNotePluginData( NotePlayHandle* nph ) override; diff --git a/plugins/ZynAddSubFx/LocalZynAddSubFx.cpp b/plugins/ZynAddSubFx/LocalZynAddSubFx.cpp index a98cfa1e1..5dc8fb205 100644 --- a/plugins/ZynAddSubFx/LocalZynAddSubFx.cpp +++ b/plugins/ZynAddSubFx/LocalZynAddSubFx.cpp @@ -36,6 +36,7 @@ #endif #include "MidiEvent.h" +#include "SampleFrame.h" #include #include @@ -265,7 +266,7 @@ void LocalZynAddSubFx::processMidiEvent( const MidiEvent& event ) -void LocalZynAddSubFx::processAudio( sampleFrame * _out ) +void LocalZynAddSubFx::processAudio( SampleFrame* _out ) { #ifdef _MSC_VER const auto outputl = static_cast(_alloca(synth->buffersize * sizeof(float))); diff --git a/plugins/ZynAddSubFx/LocalZynAddSubFx.h b/plugins/ZynAddSubFx/LocalZynAddSubFx.h index f37a3e0f4..096534d5e 100644 --- a/plugins/ZynAddSubFx/LocalZynAddSubFx.h +++ b/plugins/ZynAddSubFx/LocalZynAddSubFx.h @@ -34,10 +34,12 @@ namespace lmms { class MidiEvent; +class SampleFrame; class LocalZynAddSubFx { + public: LocalZynAddSubFx(); ~LocalZynAddSubFx(); @@ -59,7 +61,7 @@ public: void processMidiEvent( const MidiEvent& event ); - void processAudio( sampleFrame * _out ); + void processAudio( SampleFrame* _out ); inline Master * master() { diff --git a/plugins/ZynAddSubFx/RemoteZynAddSubFx.cpp b/plugins/ZynAddSubFx/RemoteZynAddSubFx.cpp index 104be5cac..d6b3b7b34 100644 --- a/plugins/ZynAddSubFx/RemoteZynAddSubFx.cpp +++ b/plugins/ZynAddSubFx/RemoteZynAddSubFx.cpp @@ -141,7 +141,7 @@ public: } - void process( const sampleFrame * _in, sampleFrame * _out ) override + void process( const SampleFrame* _in, SampleFrame* _out ) override { LocalZynAddSubFx::processAudio( _out ); } diff --git a/plugins/ZynAddSubFx/ZynAddSubFx.cpp b/plugins/ZynAddSubFx/ZynAddSubFx.cpp index a058c5b1e..c0287cd8b 100644 --- a/plugins/ZynAddSubFx/ZynAddSubFx.cpp +++ b/plugins/ZynAddSubFx/ZynAddSubFx.cpp @@ -328,7 +328,7 @@ QString ZynAddSubFxInstrument::nodeName() const -void ZynAddSubFxInstrument::play( sampleFrame * _buf ) +void ZynAddSubFxInstrument::play( SampleFrame* _buf ) { if (!m_pluginMutex.tryLock(Engine::getSong()->isExporting() ? -1 : 0)) {return;} if( m_remotePlugin ) diff --git a/plugins/ZynAddSubFx/ZynAddSubFx.h b/plugins/ZynAddSubFx/ZynAddSubFx.h index 2b30c6a3e..a35bc8f79 100644 --- a/plugins/ZynAddSubFx/ZynAddSubFx.h +++ b/plugins/ZynAddSubFx/ZynAddSubFx.h @@ -74,7 +74,7 @@ public: ZynAddSubFxInstrument( InstrumentTrack * _instrument_track ); ~ZynAddSubFxInstrument() override; - void play( sampleFrame * _working_buffer ) override; + void play( SampleFrame* _working_buffer ) override; bool handleMidiEvent( const MidiEvent& event, const TimePos& time = TimePos(), f_cnt_t offset = 0 ) override; diff --git a/src/core/AudioEngine.cpp b/src/core/AudioEngine.cpp index d4fd643ac..8bb8648ac 100644 --- a/src/core/AudioEngine.cpp +++ b/src/core/AudioEngine.cpp @@ -95,7 +95,7 @@ AudioEngine::AudioEngine( bool renderOnly ) : { m_inputBufferFrames[i] = 0; m_inputBufferSize[i] = DEFAULT_BUFFER_SIZE * 100; - m_inputBuffer[i] = new sampleFrame[ DEFAULT_BUFFER_SIZE * 100 ]; + m_inputBuffer[i] = new SampleFrame[ DEFAULT_BUFFER_SIZE * 100 ]; BufferManager::clear( m_inputBuffer[i], m_inputBufferSize[i] ); } @@ -136,8 +136,8 @@ AudioEngine::AudioEngine( bool renderOnly ) : // now that framesPerPeriod is fixed initialize global BufferManager BufferManager::init( m_framesPerPeriod ); - m_outputBufferRead = std::make_unique(m_framesPerPeriod); - m_outputBufferWrite = std::make_unique(m_framesPerPeriod); + m_outputBufferRead = std::make_unique(m_framesPerPeriod); + m_outputBufferWrite = std::make_unique(m_framesPerPeriod); for( int i = 0; i < m_numWorkers+1; ++i ) @@ -279,19 +279,19 @@ bool AudioEngine::criticalXRuns() const -void AudioEngine::pushInputFrames( sampleFrame * _ab, const f_cnt_t _frames ) +void AudioEngine::pushInputFrames( SampleFrame* _ab, const f_cnt_t _frames ) { requestChangeInModel(); f_cnt_t frames = m_inputBufferFrames[ m_inputBufferWrite ]; int size = m_inputBufferSize[ m_inputBufferWrite ]; - sampleFrame * buf = m_inputBuffer[ m_inputBufferWrite ]; + SampleFrame* buf = m_inputBuffer[ m_inputBufferWrite ]; if( frames + _frames > size ) { size = std::max(size * 2, frames + _frames); - auto ab = new sampleFrame[size]; - memcpy( ab, buf, frames * sizeof( sampleFrame ) ); + auto ab = new SampleFrame[size]; + memcpy( ab, buf, frames * sizeof( SampleFrame ) ); delete [] buf; m_inputBufferSize[ m_inputBufferWrite ] = size; @@ -300,7 +300,7 @@ void AudioEngine::pushInputFrames( sampleFrame * _ab, const f_cnt_t _frames ) buf = ab; } - memcpy( &buf[ frames ], _ab, _frames * sizeof( sampleFrame ) ); + memcpy( &buf[ frames ], _ab, _frames * sizeof( SampleFrame ) ); m_inputBufferFrames[ m_inputBufferWrite ] += _frames; doneChangeInModel(); @@ -429,7 +429,7 @@ void AudioEngine::renderStageMix() -const surroundSampleFrame* AudioEngine::renderNextBuffer() +const SampleFrame* AudioEngine::renderNextBuffer() { const auto lock = std::lock_guard{m_changeMutex}; @@ -457,7 +457,7 @@ void AudioEngine::swapBuffers() m_inputBufferFrames[m_inputBufferWrite] = 0; std::swap(m_outputBufferRead, m_outputBufferWrite); - std::fill_n(m_outputBufferWrite.get(), m_framesPerPeriod, surroundSampleFrame{}); + zeroSampleFrames(m_outputBufferWrite.get(), m_framesPerPeriod); } @@ -548,32 +548,6 @@ void AudioEngine::clearInternal() -AudioEngine::StereoSample AudioEngine::getPeakValues(sampleFrame * ab, const f_cnt_t frames) const -{ - sample_t peakLeft = 0.0f; - sample_t peakRight = 0.0f; - - for (f_cnt_t f = 0; f < frames; ++f) - { - float const absLeft = std::abs(ab[f][0]); - float const absRight = std::abs(ab[f][1]); - if (absLeft > peakLeft) - { - peakLeft = absLeft; - } - - if (absRight > peakRight) - { - peakRight = absRight; - } - } - - return StereoSample(peakLeft, peakRight); -} - - - - void AudioEngine::changeQuality(const struct qualitySettings & qs) { // don't delete the audio-device @@ -1226,9 +1200,9 @@ void AudioEngine::fifoWriter::run() const fpp_t frames = m_audioEngine->framesPerPeriod(); while( m_writing ) { - auto buffer = new surroundSampleFrame[frames]; - const surroundSampleFrame * b = m_audioEngine->renderNextBuffer(); - memcpy( buffer, b, frames * sizeof( surroundSampleFrame ) ); + auto buffer = new SampleFrame[frames]; + const SampleFrame* b = m_audioEngine->renderNextBuffer(); + memcpy(buffer, b, frames * sizeof(SampleFrame)); m_fifo->write(buffer); } diff --git a/src/core/BufferManager.cpp b/src/core/BufferManager.cpp index 2362be85a..a7a051e26 100644 --- a/src/core/BufferManager.cpp +++ b/src/core/BufferManager.cpp @@ -26,6 +26,8 @@ #include "BufferManager.h" +#include "SampleFrame.h" + #include @@ -40,26 +42,18 @@ void BufferManager::init( fpp_t fpp ) } -sampleFrame * BufferManager::acquire() +SampleFrame* BufferManager::acquire() { - return new sampleFrame[s_framesPerPeriod]; + return new SampleFrame[s_framesPerPeriod]; } -void BufferManager::clear( sampleFrame *ab, const f_cnt_t frames, const f_cnt_t offset ) +void BufferManager::clear( SampleFrame* ab, const f_cnt_t frames, const f_cnt_t offset ) { - memset( ab + offset, 0, sizeof( *ab ) * frames ); + zeroSampleFrames(ab + offset, frames); } -#ifndef LMMS_DISABLE_SURROUND -void BufferManager::clear( surroundSampleFrame * ab, const f_cnt_t frames, - const f_cnt_t offset ) -{ - memset( ab + offset, 0, sizeof( *ab ) * frames ); -} -#endif - -void BufferManager::release( sampleFrame * buf ) +void BufferManager::release( SampleFrame* buf ) { delete[] buf; } diff --git a/src/core/Effect.cpp b/src/core/Effect.cpp index aa6e56cd2..61680be2a 100644 --- a/src/core/Effect.cpp +++ b/src/core/Effect.cpp @@ -31,6 +31,7 @@ #include "EffectView.h" #include "ConfigManager.h" +#include "SampleFrame.h" namespace lmms { @@ -199,9 +200,9 @@ void Effect::reinitSRC() -void Effect::resample( int _i, const sampleFrame * _src_buf, +void Effect::resample( int _i, const SampleFrame* _src_buf, sample_rate_t _src_sr, - sampleFrame * _dst_buf, sample_rate_t _dst_sr, + SampleFrame* _dst_buf, sample_rate_t _dst_sr, f_cnt_t _frames ) { if( m_srcState[_i] == nullptr ) diff --git a/src/core/EffectChain.cpp b/src/core/EffectChain.cpp index 4da5c5197..0a6a496f3 100644 --- a/src/core/EffectChain.cpp +++ b/src/core/EffectChain.cpp @@ -184,7 +184,7 @@ void EffectChain::moveUp( Effect * _effect ) -bool EffectChain::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames, bool hasInputNoise ) +bool EffectChain::processAudioBuffer( SampleFrame* _buf, const fpp_t _frames, bool hasInputNoise ) { if( m_enabledModel.value() == false ) { diff --git a/src/core/Instrument.cpp b/src/core/Instrument.cpp index ca7ea7f25..893fccbf5 100644 --- a/src/core/Instrument.cpp +++ b/src/core/Instrument.cpp @@ -45,7 +45,7 @@ Instrument::Instrument(InstrumentTrack * _instrument_track, { } -void Instrument::play( sampleFrame * ) +void Instrument::play( SampleFrame* ) { } @@ -89,7 +89,7 @@ bool Instrument::isFromTrack( const Track * _track ) const } // helper function for Instrument::applyFadeIn -static int countZeroCrossings(sampleFrame *buf, fpp_t start, fpp_t frames) +static int countZeroCrossings(SampleFrame* buf, fpp_t start, fpp_t frames) { // zero point crossing counts of all channels auto zeroCrossings = std::array{}; @@ -128,7 +128,7 @@ fpp_t getFadeInLength(float maxLength, fpp_t frames, int zeroCrossings) } -void Instrument::applyFadeIn(sampleFrame * buf, NotePlayHandle * n) +void Instrument::applyFadeIn(SampleFrame* buf, NotePlayHandle * n) { const static float MAX_FADE_IN_LENGTH = 85.0; f_cnt_t total = n->totalFramesPlayed(); @@ -179,7 +179,7 @@ void Instrument::applyFadeIn(sampleFrame * buf, NotePlayHandle * n) } } -void Instrument::applyRelease( sampleFrame * buf, const NotePlayHandle * _n ) +void Instrument::applyRelease( SampleFrame* buf, const NotePlayHandle * _n ) { const auto fpp = Engine::audioEngine()->framesPerPeriod(); const auto releaseFrames = desiredReleaseFrames(); diff --git a/src/core/InstrumentPlayHandle.cpp b/src/core/InstrumentPlayHandle.cpp index ef7d78f3f..afae852a0 100644 --- a/src/core/InstrumentPlayHandle.cpp +++ b/src/core/InstrumentPlayHandle.cpp @@ -40,7 +40,7 @@ InstrumentPlayHandle::InstrumentPlayHandle(Instrument * instrument, InstrumentTr setAudioPort(instrumentTrack->audioPort()); } -void InstrumentPlayHandle::play(sampleFrame * working_buffer) +void InstrumentPlayHandle::play(SampleFrame* working_buffer) { InstrumentTrack * instrumentTrack = m_instrument->instrumentTrack(); diff --git a/src/core/InstrumentSoundShaping.cpp b/src/core/InstrumentSoundShaping.cpp index a7e344a7a..a57ce6ce5 100644 --- a/src/core/InstrumentSoundShaping.cpp +++ b/src/core/InstrumentSoundShaping.cpp @@ -127,7 +127,7 @@ float InstrumentSoundShaping::volumeLevel( NotePlayHandle* n, const f_cnt_t fram -void InstrumentSoundShaping::processAudioBuffer( sampleFrame* buffer, +void InstrumentSoundShaping::processAudioBuffer( SampleFrame* buffer, const fpp_t frames, NotePlayHandle* n ) { diff --git a/src/core/MixHelpers.cpp b/src/core/MixHelpers.cpp index 209640b70..01ea0386e 100644 --- a/src/core/MixHelpers.cpp +++ b/src/core/MixHelpers.cpp @@ -32,6 +32,7 @@ #include #include "ValueBuffer.h" +#include "SampleFrame.h" @@ -43,7 +44,7 @@ namespace lmms::MixHelpers /*! \brief Function for applying MIXOP on all sample frames */ template -static inline void run( sampleFrame* dst, const sampleFrame* src, int frames, const MIXOP& OP ) +static inline void run( SampleFrame* dst, const SampleFrame* src, int frames, const MIXOP& OP ) { for( int i = 0; i < frames; ++i ) { @@ -53,18 +54,18 @@ static inline void run( sampleFrame* dst, const sampleFrame* src, int frames, co /*! \brief Function for applying MIXOP on all sample frames - split source */ template -static inline void run( sampleFrame* dst, const sample_t* srcLeft, const sample_t* srcRight, int frames, const MIXOP& OP ) +static inline void run( SampleFrame* dst, const sample_t* srcLeft, const sample_t* srcRight, int frames, const MIXOP& OP ) { for( int i = 0; i < frames; ++i ) { - const sampleFrame src = { srcLeft[i], srcRight[i] }; + const SampleFrame src = { srcLeft[i], srcRight[i] }; OP( dst[i], src ); } } -bool isSilent( const sampleFrame* src, int frames ) +bool isSilent( const SampleFrame* src, int frames ) { const float silenceThreshold = 0.0000001f; @@ -90,55 +91,49 @@ void setNaNHandler( bool use ) } /*! \brief Function for sanitizing a buffer of infs/nans - returns true if those are found */ -bool sanitize( sampleFrame * src, int frames ) +bool sanitize( SampleFrame* src, int frames ) { if( !useNaNHandler() ) { return false; } - bool found = false; - for( int f = 0; f < frames; ++f ) + for (int f = 0; f < frames; ++f) { - for( int c = 0; c < 2; ++c ) + auto& currentFrame = src[f]; + + if (currentFrame.containsInf() || currentFrame.containsNaN()) { - if( std::isinf( src[f][c] ) || std::isnan( src[f][c] ) ) - { - #ifdef LMMS_DEBUG + #ifdef LMMS_DEBUG // TODO don't use printf here printf("Bad data, clearing buffer. frame: "); - printf("%d: value %f\n", f, src[f][c]); - #endif - for( int f = 0; f < frames; ++f ) - { - for( int c = 0; c < 2; ++c ) - { - src[f][c] = 0.0f; - } - } - found = true; - return found; - } - else - { - src[f][c] = std::clamp(src[f][c], -1000.0f, 1000.0f); - } + printf("%d: value %f, %f\n", f, currentFrame.left(), currentFrame.right()); + #endif + + // Clear the whole buffer if a problem is found + zeroSampleFrames(src, frames); + + return true; } - } - return found; + else + { + currentFrame.clamp(sample_t(-1000.0), sample_t(1000.0)); + } + }; + + return false; } struct AddOp { - void operator()( sampleFrame& dst, const sampleFrame& src ) const + void operator()( SampleFrame& dst, const SampleFrame& src ) const { - dst[0] += src[0]; - dst[1] += src[1]; + dst += src; } } ; -void add( sampleFrame* dst, const sampleFrame* src, int frames ) +void add( SampleFrame* dst, const SampleFrame* src, int frames ) { run<>( dst, src, frames, AddOp() ); } @@ -149,17 +144,16 @@ struct AddMultipliedOp { AddMultipliedOp( float coeff ) : m_coeff( coeff ) { } - void operator()( sampleFrame& dst, const sampleFrame& src ) const + void operator()( SampleFrame& dst, const SampleFrame& src ) const { - dst[0] += src[0] * m_coeff; - dst[1] += src[1] * m_coeff; + dst += src * m_coeff; } const float m_coeff; } ; -void addMultiplied( sampleFrame* dst, const sampleFrame* src, float coeffSrc, int frames ) +void addMultiplied( SampleFrame* dst, const SampleFrame* src, float coeffSrc, int frames ) { run<>( dst, src, frames, AddMultipliedOp(coeffSrc) ); } @@ -169,7 +163,7 @@ struct AddSwappedMultipliedOp { AddSwappedMultipliedOp( float coeff ) : m_coeff( coeff ) { } - void operator()( sampleFrame& dst, const sampleFrame& src ) const + void operator()( SampleFrame& dst, const SampleFrame& src ) const { dst[0] += src[1] * m_coeff; dst[1] += src[0] * m_coeff; @@ -178,22 +172,21 @@ struct AddSwappedMultipliedOp const float m_coeff; }; -void multiply(sampleFrame* dst, float coeff, int frames) +void multiply(SampleFrame* dst, float coeff, int frames) { for (int i = 0; i < frames; ++i) { - dst[i][0] *= coeff; - dst[i][1] *= coeff; + dst[i] *= coeff; } } -void addSwappedMultiplied( sampleFrame* dst, const sampleFrame* src, float coeffSrc, int frames ) +void addSwappedMultiplied( SampleFrame* dst, const SampleFrame* src, float coeffSrc, int frames ) { run<>( dst, src, frames, AddSwappedMultipliedOp(coeffSrc) ); } -void addMultipliedByBuffer( sampleFrame* dst, const sampleFrame* src, float coeffSrc, ValueBuffer * coeffSrcBuf, int frames ) +void addMultipliedByBuffer( SampleFrame* dst, const SampleFrame* src, float coeffSrc, ValueBuffer * coeffSrcBuf, int frames ) { for( int f = 0; f < frames; ++f ) { @@ -202,7 +195,7 @@ void addMultipliedByBuffer( sampleFrame* dst, const sampleFrame* src, float coef } } -void addMultipliedByBuffers( sampleFrame* dst, const sampleFrame* src, ValueBuffer * coeffSrcBuf1, ValueBuffer * coeffSrcBuf2, int frames ) +void addMultipliedByBuffers( SampleFrame* dst, const SampleFrame* src, ValueBuffer * coeffSrcBuf1, ValueBuffer * coeffSrcBuf2, int frames ) { for( int f = 0; f < frames; ++f ) { @@ -212,7 +205,7 @@ void addMultipliedByBuffers( sampleFrame* dst, const sampleFrame* src, ValueBuff } -void addSanitizedMultipliedByBuffer( sampleFrame* dst, const sampleFrame* src, float coeffSrc, ValueBuffer * coeffSrcBuf, int frames ) +void addSanitizedMultipliedByBuffer( SampleFrame* dst, const SampleFrame* src, float coeffSrc, ValueBuffer * coeffSrcBuf, int frames ) { if ( !useNaNHandler() ) { @@ -228,7 +221,7 @@ void addSanitizedMultipliedByBuffer( sampleFrame* dst, const sampleFrame* src, f } } -void addSanitizedMultipliedByBuffers( sampleFrame* dst, const sampleFrame* src, ValueBuffer * coeffSrcBuf1, ValueBuffer * coeffSrcBuf2, int frames ) +void addSanitizedMultipliedByBuffers( SampleFrame* dst, const SampleFrame* src, ValueBuffer * coeffSrcBuf1, ValueBuffer * coeffSrcBuf2, int frames ) { if ( !useNaNHandler() ) { @@ -254,7 +247,7 @@ struct AddSanitizedMultipliedOp { AddSanitizedMultipliedOp( float coeff ) : m_coeff( coeff ) { } - void operator()( sampleFrame& dst, const sampleFrame& src ) const + void operator()( SampleFrame& dst, const SampleFrame& src ) const { dst[0] += ( std::isinf( src[0] ) || std::isnan( src[0] ) ) ? 0.0f : src[0] * m_coeff; dst[1] += ( std::isinf( src[1] ) || std::isnan( src[1] ) ) ? 0.0f : src[1] * m_coeff; @@ -263,7 +256,7 @@ struct AddSanitizedMultipliedOp const float m_coeff; }; -void addSanitizedMultiplied( sampleFrame* dst, const sampleFrame* src, float coeffSrc, int frames ) +void addSanitizedMultiplied( SampleFrame* dst, const SampleFrame* src, float coeffSrc, int frames ) { if ( !useNaNHandler() ) { @@ -284,7 +277,7 @@ struct AddMultipliedStereoOp m_coeffs[1] = coeffRight; } - void operator()( sampleFrame& dst, const sampleFrame& src ) const + void operator()( SampleFrame& dst, const SampleFrame& src ) const { dst[0] += src[0] * m_coeffs[0]; dst[1] += src[1] * m_coeffs[1]; @@ -294,7 +287,7 @@ struct AddMultipliedStereoOp } ; -void addMultipliedStereo( sampleFrame* dst, const sampleFrame* src, float coeffSrcLeft, float coeffSrcRight, int frames ) +void addMultipliedStereo( SampleFrame* dst, const SampleFrame* src, float coeffSrcLeft, float coeffSrcRight, int frames ) { run<>( dst, src, frames, AddMultipliedStereoOp(coeffSrcLeft, coeffSrcRight) ); @@ -312,7 +305,7 @@ struct MultiplyAndAddMultipliedOp m_coeffs[1] = coeffSrc; } - void operator()( sampleFrame& dst, const sampleFrame& src ) const + void operator()( SampleFrame& dst, const SampleFrame& src ) const { dst[0] = dst[0]*m_coeffs[0] + src[0]*m_coeffs[1]; dst[1] = dst[1]*m_coeffs[0] + src[1]*m_coeffs[1]; @@ -322,14 +315,14 @@ struct MultiplyAndAddMultipliedOp } ; -void multiplyAndAddMultiplied( sampleFrame* dst, const sampleFrame* src, float coeffDst, float coeffSrc, int frames ) +void multiplyAndAddMultiplied( SampleFrame* dst, const SampleFrame* src, float coeffDst, float coeffSrc, int frames ) { run<>( dst, src, frames, MultiplyAndAddMultipliedOp(coeffDst, coeffSrc) ); } -void multiplyAndAddMultipliedJoined( sampleFrame* dst, +void multiplyAndAddMultipliedJoined( SampleFrame* dst, const sample_t* srcLeft, const sample_t* srcRight, float coeffDst, float coeffSrc, int frames ) diff --git a/src/core/Mixer.cpp b/src/core/Mixer.cpp index dd68b55d3..0b0689eb5 100644 --- a/src/core/Mixer.cpp +++ b/src/core/Mixer.cpp @@ -64,7 +64,7 @@ MixerChannel::MixerChannel( int idx, Model * _parent ) : m_stillRunning( false ), m_peakLeft( 0.0f ), m_peakRight( 0.0f ), - m_buffer( new sampleFrame[Engine::audioEngine()->framesPerPeriod()] ), + m_buffer( new SampleFrame[Engine::audioEngine()->framesPerPeriod()] ), m_muteModel( false, _parent ), m_soloModel( false, _parent ), m_volumeModel(1.f, 0.f, 2.f, 0.001f, _parent), @@ -134,7 +134,7 @@ void MixerChannel::doProcessing() ValueBuffer * volBuf = sender->m_volumeModel.valueBuffer(); // mix it's output with this one's output - sampleFrame * ch_buf = sender->m_buffer; + SampleFrame* ch_buf = sender->m_buffer; // use sample-exact mixing if sample-exact values are available if( ! volBuf && ! sendBuf ) // neither volume nor send has sample-exact data... @@ -171,9 +171,9 @@ void MixerChannel::doProcessing() m_stillRunning = m_fxChain.processAudioBuffer( m_buffer, fpp, m_hasInput ); - AudioEngine::StereoSample peakSamples = Engine::audioEngine()->getPeakValues(m_buffer, fpp); - m_peakLeft = std::max(m_peakLeft, peakSamples.left * v); - m_peakRight = std::max(m_peakRight, peakSamples.right * v); + SampleFrame peakSamples = getAbsPeakValues(m_buffer, fpp); + m_peakLeft = std::max(m_peakLeft, peakSamples[0] * v); + m_peakRight = std::max(m_peakRight, peakSamples[1] * v); } else { @@ -596,7 +596,7 @@ FloatModel * Mixer::channelSendModel( mix_ch_t fromChannel, mix_ch_t toChannel ) -void Mixer::mixToChannel( const sampleFrame * _buf, mix_ch_t _ch ) +void Mixer::mixToChannel( const SampleFrame* _buf, mix_ch_t _ch ) { if( m_mixerChannels[_ch]->m_muteModel.value() == false ) { @@ -618,7 +618,7 @@ void Mixer::prepareMasterMix() -void Mixer::masterMix( sampleFrame * _buf ) +void Mixer::masterMix( SampleFrame* _buf ) { const int fpp = Engine::audioEngine()->framesPerPeriod(); diff --git a/src/core/NotePlayHandle.cpp b/src/core/NotePlayHandle.cpp index d7882b525..4ee30054a 100644 --- a/src/core/NotePlayHandle.cpp +++ b/src/core/NotePlayHandle.cpp @@ -183,7 +183,7 @@ int NotePlayHandle::midiKey() const -void NotePlayHandle::play( sampleFrame * _working_buffer ) +void NotePlayHandle::play( SampleFrame* _working_buffer ) { if (m_muted) { diff --git a/src/core/Oscillator.cpp b/src/core/Oscillator.cpp index e45a3aa87..d24e82d98 100644 --- a/src/core/Oscillator.cpp +++ b/src/core/Oscillator.cpp @@ -77,7 +77,7 @@ Oscillator::Oscillator(const IntModel *wave_shape_model, -void Oscillator::update(sampleFrame* ab, const fpp_t frames, const ch_cnt_t chnl, bool modulator) +void Oscillator::update(SampleFrame* ab, const fpp_t frames, const ch_cnt_t chnl, bool modulator) { if (m_freq >= Engine::audioEngine()->outputSampleRate() / 2) { @@ -316,7 +316,7 @@ void Oscillator::generateWaveTables() -void Oscillator::updateNoSub( sampleFrame * _ab, const fpp_t _frames, +void Oscillator::updateNoSub( SampleFrame* _ab, const fpp_t _frames, const ch_cnt_t _chnl ) { switch( static_cast(m_waveShapeModel->value()) ) @@ -352,7 +352,7 @@ void Oscillator::updateNoSub( sampleFrame * _ab, const fpp_t _frames, -void Oscillator::updatePM( sampleFrame * _ab, const fpp_t _frames, +void Oscillator::updatePM( SampleFrame* _ab, const fpp_t _frames, const ch_cnt_t _chnl ) { switch( static_cast(m_waveShapeModel->value()) ) @@ -388,7 +388,7 @@ void Oscillator::updatePM( sampleFrame * _ab, const fpp_t _frames, -void Oscillator::updateAM( sampleFrame * _ab, const fpp_t _frames, +void Oscillator::updateAM( SampleFrame* _ab, const fpp_t _frames, const ch_cnt_t _chnl ) { switch( static_cast(m_waveShapeModel->value()) ) @@ -424,7 +424,7 @@ void Oscillator::updateAM( sampleFrame * _ab, const fpp_t _frames, -void Oscillator::updateMix( sampleFrame * _ab, const fpp_t _frames, +void Oscillator::updateMix( SampleFrame* _ab, const fpp_t _frames, const ch_cnt_t _chnl ) { switch( static_cast(m_waveShapeModel->value()) ) @@ -460,7 +460,7 @@ void Oscillator::updateMix( sampleFrame * _ab, const fpp_t _frames, -void Oscillator::updateSync( sampleFrame * _ab, const fpp_t _frames, +void Oscillator::updateSync( SampleFrame* _ab, const fpp_t _frames, const ch_cnt_t _chnl ) { switch( static_cast(m_waveShapeModel->value()) ) @@ -496,7 +496,7 @@ void Oscillator::updateSync( sampleFrame * _ab, const fpp_t _frames, -void Oscillator::updateFM( sampleFrame * _ab, const fpp_t _frames, +void Oscillator::updateFM( SampleFrame* _ab, const fpp_t _frames, const ch_cnt_t _chnl ) { switch( static_cast(m_waveShapeModel->value()) ) @@ -558,7 +558,7 @@ inline bool Oscillator::syncOk( float _osc_coeff ) -float Oscillator::syncInit( sampleFrame * _ab, const fpp_t _frames, +float Oscillator::syncInit( SampleFrame* _ab, const fpp_t _frames, const ch_cnt_t _chnl ) { if( m_subOsc != nullptr ) @@ -574,7 +574,7 @@ float Oscillator::syncInit( sampleFrame * _ab, const fpp_t _frames, // if we have no sub-osc, we can't do any modulation... just get our samples template -void Oscillator::updateNoSub( sampleFrame * _ab, const fpp_t _frames, +void Oscillator::updateNoSub( SampleFrame* _ab, const fpp_t _frames, const ch_cnt_t _chnl ) { recalcPhase(); @@ -592,7 +592,7 @@ void Oscillator::updateNoSub( sampleFrame * _ab, const fpp_t _frames, // do pm by using sub-osc as modulator template -void Oscillator::updatePM( sampleFrame * _ab, const fpp_t _frames, +void Oscillator::updatePM( SampleFrame* _ab, const fpp_t _frames, const ch_cnt_t _chnl ) { m_subOsc->update( _ab, _frames, _chnl, true ); @@ -613,7 +613,7 @@ void Oscillator::updatePM( sampleFrame * _ab, const fpp_t _frames, // do am by using sub-osc as modulator template -void Oscillator::updateAM( sampleFrame * _ab, const fpp_t _frames, +void Oscillator::updateAM( SampleFrame* _ab, const fpp_t _frames, const ch_cnt_t _chnl ) { m_subOsc->update( _ab, _frames, _chnl, false ); @@ -632,7 +632,7 @@ void Oscillator::updateAM( sampleFrame * _ab, const fpp_t _frames, // do mix by using sub-osc as mix-sample template -void Oscillator::updateMix( sampleFrame * _ab, const fpp_t _frames, +void Oscillator::updateMix( SampleFrame* _ab, const fpp_t _frames, const ch_cnt_t _chnl ) { m_subOsc->update( _ab, _frames, _chnl, false ); @@ -652,7 +652,7 @@ void Oscillator::updateMix( sampleFrame * _ab, const fpp_t _frames, // sync with sub-osc (every time sub-osc starts new period, we also start new // period) template -void Oscillator::updateSync( sampleFrame * _ab, const fpp_t _frames, +void Oscillator::updateSync( SampleFrame* _ab, const fpp_t _frames, const ch_cnt_t _chnl ) { const float sub_osc_coeff = m_subOsc->syncInit( _ab, _frames, _chnl ); @@ -675,7 +675,7 @@ void Oscillator::updateSync( sampleFrame * _ab, const fpp_t _frames, // do fm by using sub-osc as modulator template -void Oscillator::updateFM( sampleFrame * _ab, const fpp_t _frames, +void Oscillator::updateFM( SampleFrame* _ab, const fpp_t _frames, const ch_cnt_t _chnl ) { m_subOsc->update( _ab, _frames, _chnl, true ); diff --git a/src/core/PlayHandle.cpp b/src/core/PlayHandle.cpp index 168121e0f..eb90f6b65 100644 --- a/src/core/PlayHandle.cpp +++ b/src/core/PlayHandle.cpp @@ -70,9 +70,9 @@ void PlayHandle::releaseBuffer() m_bufferReleased = true; } -sampleFrame* PlayHandle::buffer() +SampleFrame* PlayHandle::buffer() { - return m_bufferReleased ? nullptr : reinterpret_cast(m_playHandleBuffer); + return m_bufferReleased ? nullptr : m_playHandleBuffer; }; } // namespace lmms \ No newline at end of file diff --git a/src/core/PresetPreviewPlayHandle.cpp b/src/core/PresetPreviewPlayHandle.cpp index 0930de0de..8db5644c6 100644 --- a/src/core/PresetPreviewPlayHandle.cpp +++ b/src/core/PresetPreviewPlayHandle.cpp @@ -206,7 +206,7 @@ PresetPreviewPlayHandle::~PresetPreviewPlayHandle() -void PresetPreviewPlayHandle::play( sampleFrame * _working_buffer ) +void PresetPreviewPlayHandle::play( SampleFrame* _working_buffer ) { // Do nothing; the preview instrument is played by m_previewNote, which // has been added to the audio engine diff --git a/src/core/RemotePlugin.cpp b/src/core/RemotePlugin.cpp index b46c547da..4cfcc313c 100644 --- a/src/core/RemotePlugin.cpp +++ b/src/core/RemotePlugin.cpp @@ -325,7 +325,7 @@ 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::audioEngine()->framesPerPeriod(); @@ -376,11 +376,12 @@ bool RemotePlugin::process( const sampleFrame * _in_buf, sampleFrame * _out_buf } else if( inputs == DEFAULT_CHANNELS ) { - memcpy( m_audioBuffer.get(), _in_buf, frames * BYTES_PER_FRAME ); + auto target = m_audioBuffer.get(); + copyFromSampleFrames(target, _in_buf, frames); } else { - auto o = (sampleFrame*)m_audioBuffer.get(); + auto o = (SampleFrame*)m_audioBuffer.get(); for( ch_cnt_t ch = 0; ch < inputs; ++ch ) { for( fpp_t frame = 0; frame < frames; ++frame ) @@ -418,12 +419,12 @@ bool RemotePlugin::process( const sampleFrame * _in_buf, sampleFrame * _out_buf } else if( outputs == DEFAULT_CHANNELS ) { - memcpy( _out_buf, m_audioBuffer.get() + m_inputCount * frames, - frames * BYTES_PER_FRAME ); + auto source = m_audioBuffer.get() + m_inputCount * frames; + copyToSampleFrames(_out_buf, source, frames); } else { - auto o = (sampleFrame*)(m_audioBuffer.get() + m_inputCount * frames); + auto o = (SampleFrame*)(m_audioBuffer.get() + m_inputCount * frames); // clear buffer, if plugin didn't fill up both channels BufferManager::clear( _out_buf, frames ); diff --git a/src/core/RingBuffer.cpp b/src/core/RingBuffer.cpp index 6cd3613ed..133af843a 100644 --- a/src/core/RingBuffer.cpp +++ b/src/core/RingBuffer.cpp @@ -37,8 +37,8 @@ RingBuffer::RingBuffer( f_cnt_t size ) : m_samplerate( Engine::audioEngine()->outputSampleRate() ), m_size( size + m_fpp ) { - m_buffer = new sampleFrame[ m_size ]; - memset( m_buffer, 0, m_size * sizeof( sampleFrame ) ); + m_buffer = new SampleFrame[ m_size ]; + zeroSampleFrames(m_buffer, m_size); m_position = 0; } @@ -48,8 +48,8 @@ RingBuffer::RingBuffer( float size ) : m_samplerate( Engine::audioEngine()->outputSampleRate() ) { m_size = msToFrames( size ) + m_fpp; - m_buffer = new sampleFrame[ m_size ]; - memset( m_buffer, 0, m_size * sizeof( sampleFrame ) ); + m_buffer = new SampleFrame[ m_size ]; + zeroSampleFrames(m_buffer, m_size); m_position = 0; setSamplerateAware( true ); //qDebug( "m_size %d, m_position %d", m_size, m_position ); @@ -64,7 +64,7 @@ RingBuffer::~RingBuffer() void RingBuffer::reset() { - memset( m_buffer, 0, m_size * sizeof( sampleFrame ) ); + zeroSampleFrames(m_buffer, m_size); m_position = 0; } @@ -72,10 +72,10 @@ void RingBuffer::reset() void RingBuffer::changeSize( f_cnt_t size ) { size += m_fpp; - sampleFrame * tmp = m_buffer; + SampleFrame* tmp = m_buffer; m_size = size; - m_buffer = new sampleFrame[ m_size ]; - memset( m_buffer, 0, m_size * sizeof( sampleFrame ) ); + m_buffer = new SampleFrame[ m_size ]; + zeroSampleFrames(m_buffer, m_size); m_position = 0; delete[] tmp; } @@ -118,111 +118,111 @@ void RingBuffer::movePosition( float amount ) } -void RingBuffer::pop( sampleFrame * dst ) +void RingBuffer::pop( SampleFrame* dst ) { if( m_position + m_fpp <= m_size ) // we won't go over the edge so we can just memcpy here { - memcpy( dst, & m_buffer [ m_position ], m_fpp * sizeof( sampleFrame ) ); - memset( & m_buffer[m_position], 0, m_fpp * sizeof( sampleFrame ) ); + memcpy( dst, & m_buffer [ m_position ], m_fpp * sizeof( SampleFrame ) ); + zeroSampleFrames(&m_buffer[m_position], m_fpp); } else { f_cnt_t first = m_size - m_position; f_cnt_t second = m_fpp - first; - memcpy( dst, & m_buffer [ m_position ], first * sizeof( sampleFrame ) ); - memset( & m_buffer [m_position], 0, first * sizeof( sampleFrame ) ); + memcpy( dst, & m_buffer [ m_position ], first * sizeof( SampleFrame ) ); + zeroSampleFrames(&m_buffer[m_position], first); - memcpy( & dst [first], m_buffer, second * sizeof( sampleFrame ) ); - memset( m_buffer, 0, second * sizeof( sampleFrame ) ); + memcpy( & dst [first], m_buffer, second * sizeof( SampleFrame ) ); + zeroSampleFrames(m_buffer, second); } m_position = ( m_position + m_fpp ) % m_size; } -void RingBuffer::read( sampleFrame * dst, f_cnt_t offset ) +void RingBuffer::read( SampleFrame* dst, f_cnt_t offset ) { f_cnt_t pos = ( m_position + offset ) % m_size; if( pos < 0 ) { pos += m_size; } if( pos + m_fpp <= m_size ) // we won't go over the edge so we can just memcpy here { - memcpy( dst, & m_buffer [pos], m_fpp * sizeof( sampleFrame ) ); + memcpy( dst, & m_buffer [pos], m_fpp * sizeof( SampleFrame ) ); } else { f_cnt_t first = m_size - pos; f_cnt_t second = m_fpp - first; - memcpy( dst, & m_buffer [pos], first * sizeof( sampleFrame ) ); + memcpy( dst, & m_buffer [pos], first * sizeof( SampleFrame ) ); - memcpy( & dst [first], m_buffer, second * sizeof( sampleFrame ) ); + memcpy( & dst [first], m_buffer, second * sizeof( SampleFrame ) ); } } -void RingBuffer::read( sampleFrame * dst, float offset ) +void RingBuffer::read( SampleFrame* dst, float offset ) { read( dst, msToFrames( offset ) ); } -void RingBuffer::read( sampleFrame * dst, f_cnt_t offset, f_cnt_t length ) +void RingBuffer::read( SampleFrame* dst, f_cnt_t offset, f_cnt_t length ) { f_cnt_t pos = ( m_position + offset ) % m_size; if( pos < 0 ) { pos += m_size; } if( pos + length <= m_size ) // we won't go over the edge so we can just memcpy here { - memcpy( dst, & m_buffer [pos], length * sizeof( sampleFrame ) ); + memcpy( dst, & m_buffer [pos], length * sizeof( SampleFrame ) ); } else { f_cnt_t first = m_size - pos; f_cnt_t second = length - first; - memcpy( dst, & m_buffer [pos], first * sizeof( sampleFrame ) ); + memcpy( dst, & m_buffer [pos], first * sizeof( SampleFrame ) ); - memcpy( & dst [first], m_buffer, second * sizeof( sampleFrame ) ); + memcpy( & dst [first], m_buffer, second * sizeof( SampleFrame ) ); } } -void RingBuffer::read( sampleFrame * dst, float offset, f_cnt_t length ) +void RingBuffer::read( SampleFrame* dst, float offset, f_cnt_t length ) { read( dst, msToFrames( offset ), length ); } -void RingBuffer::write( sampleFrame * src, f_cnt_t offset, f_cnt_t length ) +void RingBuffer::write( SampleFrame* src, f_cnt_t offset, f_cnt_t length ) { const f_cnt_t pos = ( m_position + offset ) % m_size; if( length == 0 ) { length = m_fpp; } if( pos + length <= m_size ) // we won't go over the edge so we can just memcpy here { - memcpy( & m_buffer [pos], src, length * sizeof( sampleFrame ) ); + memcpy( & m_buffer [pos], src, length * sizeof( SampleFrame ) ); } else { f_cnt_t first = m_size - pos; f_cnt_t second = length - first; - memcpy( & m_buffer [pos], src, first * sizeof( sampleFrame ) ); + memcpy( & m_buffer [pos], src, first * sizeof( SampleFrame ) ); - memcpy( m_buffer, & src [first], second * sizeof( sampleFrame ) ); + memcpy( m_buffer, & src [first], second * sizeof( SampleFrame ) ); } } -void RingBuffer::write( sampleFrame * src, float offset, f_cnt_t length ) +void RingBuffer::write( SampleFrame* src, float offset, f_cnt_t length ) { write( src, msToFrames( offset ), length ); } -void RingBuffer::writeAdding( sampleFrame * src, f_cnt_t offset, f_cnt_t length ) +void RingBuffer::writeAdding( SampleFrame* src, f_cnt_t offset, f_cnt_t length ) { const f_cnt_t pos = ( m_position + offset ) % m_size; if( length == 0 ) { length = m_fpp; } @@ -243,13 +243,13 @@ void RingBuffer::writeAdding( sampleFrame * src, f_cnt_t offset, f_cnt_t length } -void RingBuffer::writeAdding( sampleFrame * src, float offset, f_cnt_t length ) +void RingBuffer::writeAdding( SampleFrame* src, float offset, f_cnt_t length ) { writeAdding( src, msToFrames( offset ), length ); } -void RingBuffer::writeAddingMultiplied( sampleFrame * src, f_cnt_t offset, f_cnt_t length, float level ) +void RingBuffer::writeAddingMultiplied( SampleFrame* src, f_cnt_t offset, f_cnt_t length, float level ) { const f_cnt_t pos = ( m_position + offset ) % m_size; //qDebug( "pos %d m_pos %d ofs %d siz %d", pos, m_position, offset, m_size ); @@ -271,14 +271,14 @@ void RingBuffer::writeAddingMultiplied( sampleFrame * src, f_cnt_t offset, f_cnt } -void RingBuffer::writeAddingMultiplied( sampleFrame * src, float offset, f_cnt_t length, float level ) +void RingBuffer::writeAddingMultiplied( SampleFrame* src, float offset, f_cnt_t length, float level ) { f_cnt_t ofs = msToFrames( offset ); writeAddingMultiplied( src, ofs, length, level ); } -void RingBuffer::writeSwappedAddingMultiplied( sampleFrame * src, f_cnt_t offset, f_cnt_t length, float level ) +void RingBuffer::writeSwappedAddingMultiplied( SampleFrame* src, f_cnt_t offset, f_cnt_t length, float level ) { const f_cnt_t pos = ( m_position + offset ) % m_size; if( length == 0 ) { length = m_fpp; } @@ -299,7 +299,7 @@ void RingBuffer::writeSwappedAddingMultiplied( sampleFrame * src, f_cnt_t offset } -void RingBuffer::writeSwappedAddingMultiplied( sampleFrame * src, float offset, f_cnt_t length, float level ) +void RingBuffer::writeSwappedAddingMultiplied( SampleFrame* src, float offset, f_cnt_t length, float level ) { writeSwappedAddingMultiplied( src, msToFrames( offset ), length, level ); } @@ -311,8 +311,8 @@ void RingBuffer::updateSamplerate() m_size = static_cast( ceilf( newsize ) ) + m_fpp; m_samplerate = Engine::audioEngine()->outputSampleRate(); delete[] m_buffer; - m_buffer = new sampleFrame[ m_size ]; - memset( m_buffer, 0, m_size * sizeof( sampleFrame ) ); + m_buffer = new SampleFrame[ m_size ]; + zeroSampleFrames(m_buffer, m_size); m_position = 0; } diff --git a/src/core/Sample.cpp b/src/core/Sample.cpp index f1fe1ec1a..7bbb4e9b9 100644 --- a/src/core/Sample.cpp +++ b/src/core/Sample.cpp @@ -46,7 +46,7 @@ Sample::Sample(const QByteArray& base64, int sampleRate) { } -Sample::Sample(const sampleFrame* data, size_t numFrames, int sampleRate) +Sample::Sample(const SampleFrame* data, size_t numFrames, int sampleRate) : m_buffer(std::make_shared(data, numFrames, sampleRate)) , m_startFrame(0) , m_endFrame(m_buffer->size()) @@ -116,7 +116,7 @@ auto Sample::operator=(Sample&& other) -> Sample& return *this; } -bool Sample::play(sampleFrame* dst, PlaybackState* state, size_t numFrames, float desiredFrequency, Loop loopMode) const +bool Sample::play(SampleFrame* dst, PlaybackState* state, size_t numFrames, float desiredFrequency, Loop loopMode) const { assert(numFrames > 0); assert(desiredFrequency > 0); @@ -131,7 +131,7 @@ bool Sample::play(sampleFrame* dst, PlaybackState* state, size_t numFrames, floa state->m_frameIndex = std::max(m_startFrame, state->m_frameIndex); - auto playBuffer = std::vector(numFrames / resampleRatio + marginSize); + auto playBuffer = std::vector(numFrames / resampleRatio + marginSize); playRaw(playBuffer.data(), playBuffer.size(), state, loopMode); state->resampler().setRatio(resampleRatio); @@ -141,7 +141,7 @@ bool Sample::play(sampleFrame* dst, PlaybackState* state, size_t numFrames, floa advance(state, resampleResult.inputFramesUsed, loopMode); const auto outputFrames = resampleResult.outputFramesGenerated; - if (outputFrames < numFrames) { std::fill_n(dst + outputFrames, numFrames - outputFrames, sampleFrame{}); } + if (outputFrames < numFrames) { std::fill_n(dst + outputFrames, numFrames - outputFrames, SampleFrame{}); } if (!typeInfo::isEqual(m_amplification, 1.0f)) { @@ -170,7 +170,7 @@ void Sample::setAllPointFrames(int startFrame, int endFrame, int loopStartFrame, setLoopEndFrame(loopEndFrame); } -void Sample::playRaw(sampleFrame* dst, size_t numFrames, const PlaybackState* state, Loop loopMode) const +void Sample::playRaw(SampleFrame* dst, size_t numFrames, const PlaybackState* state, Loop loopMode) const { if (m_buffer->size() < 1) { return; } diff --git a/src/core/SampleBuffer.cpp b/src/core/SampleBuffer.cpp index 6483dd522..fda3f2f66 100644 --- a/src/core/SampleBuffer.cpp +++ b/src/core/SampleBuffer.cpp @@ -31,7 +31,7 @@ namespace lmms { -SampleBuffer::SampleBuffer(const sampleFrame* data, size_t numFrames, int sampleRate) +SampleBuffer::SampleBuffer(const SampleFrame* data, size_t numFrames, int sampleRate) : m_data(data, data + numFrames) , m_sampleRate(sampleRate) { @@ -60,11 +60,11 @@ SampleBuffer::SampleBuffer(const QString& base64, int sampleRate) { // TODO: Replace with non-Qt equivalent const auto bytes = QByteArray::fromBase64(base64.toUtf8()); - m_data.resize(bytes.size() / sizeof(sampleFrame)); - std::memcpy(reinterpret_cast(m_data.data()), bytes, m_data.size() * sizeof(sampleFrame)); + m_data.resize(bytes.size() / sizeof(SampleFrame)); + std::memcpy(reinterpret_cast(m_data.data()), bytes, m_data.size() * sizeof(SampleFrame)); } -SampleBuffer::SampleBuffer(std::vector data, int sampleRate) +SampleBuffer::SampleBuffer(std::vector data, int sampleRate) : m_data(std::move(data)) , m_sampleRate(sampleRate) { @@ -82,7 +82,7 @@ QString SampleBuffer::toBase64() const { // TODO: Replace with non-Qt equivalent const auto data = reinterpret_cast(m_data.data()); - const auto size = static_cast(m_data.size() * sizeof(sampleFrame)); + const auto size = static_cast(m_data.size() * sizeof(SampleFrame)); const auto byteArray = QByteArray{data, size}; return byteArray.toBase64(); } diff --git a/src/core/SampleDecoder.cpp b/src/core/SampleDecoder.cpp index ec0fcc39a..1e1ddb545 100644 --- a/src/core/SampleDecoder.cpp +++ b/src/core/SampleDecoder.cpp @@ -75,7 +75,7 @@ auto decodeSampleSF(const QString& audioFile) -> std::optional(sfInfo.frames); + auto result = std::vector(sfInfo.frames); for (int i = 0; i < static_cast(result.size()); ++i) { if (sfInfo.channels == 1) @@ -107,7 +107,7 @@ auto decodeSampleDS(const QString& audioFile) -> std::optional(frames); + auto result = std::vector(frames); src_short_to_float_array(data.get(), &result[0][0], frames * DEFAULT_CHANNELS); return SampleDecoder::Result{std::move(result), static_cast(engineRate)}; @@ -173,7 +173,7 @@ auto decodeSampleOggVorbis(const QString& audioFile) -> std::optional(totalSamplesRead / numChannels); + auto result = std::vector(totalSamplesRead / numChannels); for (int i = 0; i < result.size(); ++i) { if (numChannels == 1) { result[i] = {buffer[i], buffer[i]}; } diff --git a/src/core/SamplePlayHandle.cpp b/src/core/SamplePlayHandle.cpp index e23cfa473..f2ddc2a4a 100644 --- a/src/core/SamplePlayHandle.cpp +++ b/src/core/SamplePlayHandle.cpp @@ -85,23 +85,23 @@ SamplePlayHandle::~SamplePlayHandle() -void SamplePlayHandle::play( sampleFrame * buffer ) +void SamplePlayHandle::play( SampleFrame* buffer ) { const fpp_t fpp = Engine::audioEngine()->framesPerPeriod(); //play( 0, _try_parallelizing ); if( framesDone() >= totalFrames() ) { - memset( buffer, 0, sizeof( sampleFrame ) * fpp ); + zeroSampleFrames(buffer, fpp); return; } - sampleFrame * workingBuffer = buffer; + SampleFrame* workingBuffer = buffer; f_cnt_t frames = fpp; // apply offset for the first period if( framesDone() == 0 ) { - memset( buffer, 0, sizeof( sampleFrame ) * offset() ); + zeroSampleFrames(buffer, offset()); workingBuffer += offset(); frames -= offset(); } @@ -116,7 +116,7 @@ void SamplePlayHandle::play( sampleFrame * buffer ) // it is used only for previews, SampleTracks and the metronome. if (!m_sample->play(workingBuffer, &m_state, frames, DefaultBaseFreq)) { - memset(workingBuffer, 0, frames * sizeof(sampleFrame)); + zeroSampleFrames(workingBuffer, frames); } } diff --git a/src/core/SampleRecordHandle.cpp b/src/core/SampleRecordHandle.cpp index 6857efa83..f7003f3be 100644 --- a/src/core/SampleRecordHandle.cpp +++ b/src/core/SampleRecordHandle.cpp @@ -64,9 +64,9 @@ SampleRecordHandle::~SampleRecordHandle() -void SampleRecordHandle::play( sampleFrame * /*_working_buffer*/ ) +void SampleRecordHandle::play( SampleFrame* /*_working_buffer*/ ) { - const sampleFrame * recbuf = Engine::audioEngine()->inputBuffer(); + const SampleFrame* recbuf = Engine::audioEngine()->inputBuffer(); const f_cnt_t frames = Engine::audioEngine()->inputBufferFrames(); writeBuffer( recbuf, frames ); m_framesRecorded += frames; @@ -110,7 +110,7 @@ std::shared_ptr SampleRecordHandle::createSampleBuffer() { const f_cnt_t frames = framesRecorded(); // create buffer to store all recorded buffers in - auto bigBuffer = std::vector(frames); + auto bigBuffer = std::vector(frames); // now copy all buffers into big buffer auto framesCopied = 0; @@ -127,9 +127,9 @@ std::shared_ptr SampleRecordHandle::createSampleBuffer() -void SampleRecordHandle::writeBuffer( const sampleFrame * _ab, const f_cnt_t _frames ) +void SampleRecordHandle::writeBuffer( const SampleFrame* _ab, const f_cnt_t _frames ) { - auto buf = new sampleFrame[_frames]; + auto buf = new SampleFrame[_frames]; for( f_cnt_t frame = 0; frame < _frames; ++frame ) { for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) diff --git a/src/core/audio/AudioAlsa.cpp b/src/core/audio/AudioAlsa.cpp index eda0f7a31..c41703e22 100644 --- a/src/core/audio/AudioAlsa.cpp +++ b/src/core/audio/AudioAlsa.cpp @@ -39,7 +39,7 @@ AudioAlsa::AudioAlsa( bool & _success_ful, AudioEngine* _audioEngine ) : AudioDevice(std::clamp( ConfigManager::inst()->value("audioalsa", "channels").toInt(), DEFAULT_CHANNELS, - SURROUND_CHANNELS), _audioEngine), + DEFAULT_CHANNELS), _audioEngine), m_handle( nullptr ), m_hwParams( nullptr ), m_swParams( nullptr ), @@ -242,7 +242,7 @@ void AudioAlsa::stopProcessing() void AudioAlsa::run() { - auto temp = new surroundSampleFrame[audioEngine()->framesPerPeriod()]; + auto temp = new SampleFrame[audioEngine()->framesPerPeriod()]; auto outbuf = new int_sample_t[audioEngine()->framesPerPeriod() * channels()]; auto pcmbuf = new int_sample_t[m_periodSize * channels()]; diff --git a/src/core/audio/AudioDevice.cpp b/src/core/audio/AudioDevice.cpp index 988230d5b..2047fffe9 100644 --- a/src/core/audio/AudioDevice.cpp +++ b/src/core/audio/AudioDevice.cpp @@ -37,7 +37,7 @@ AudioDevice::AudioDevice( const ch_cnt_t _channels, AudioEngine* _audioEngine ) m_sampleRate( _audioEngine->outputSampleRate() ), m_channels( _channels ), m_audioEngine( _audioEngine ), - m_buffer( new surroundSampleFrame[audioEngine()->framesPerPeriod()] ) + m_buffer(new SampleFrame[audioEngine()->framesPerPeriod()]) { } @@ -64,14 +64,14 @@ void AudioDevice::processNextBuffer() } } -fpp_t AudioDevice::getNextBuffer(surroundSampleFrame* _ab) +fpp_t AudioDevice::getNextBuffer(SampleFrame* _ab) { fpp_t frames = audioEngine()->framesPerPeriod(); + const SampleFrame* b = audioEngine()->nextBuffer(); - const surroundSampleFrame* b = audioEngine()->nextBuffer(); if (!b) { return 0; } - memcpy(_ab, b, frames * sizeof(surroundSampleFrame)); + memcpy(_ab, b, frames * sizeof(SampleFrame)); if (audioEngine()->hasFifoWriter()) { delete[] b; } return frames; @@ -127,7 +127,7 @@ void AudioDevice::renamePort( AudioPort * ) { } -int AudioDevice::convertToS16( const surroundSampleFrame * _ab, +int AudioDevice::convertToS16(const SampleFrame* _ab, const fpp_t _frames, int_sample_t * _output_buffer, const bool _convert_endian ) diff --git a/src/core/audio/AudioFileFlac.cpp b/src/core/audio/AudioFileFlac.cpp index 097fbdd89..dfb97a6be 100644 --- a/src/core/audio/AudioFileFlac.cpp +++ b/src/core/audio/AudioFileFlac.cpp @@ -89,7 +89,7 @@ bool AudioFileFlac::startEncoding() return true; } -void AudioFileFlac::writeBuffer(surroundSampleFrame const* _ab, fpp_t const frames) +void AudioFileFlac::writeBuffer(const SampleFrame* _ab, fpp_t const frames) { OutputSettings::BitDepth depth = getOutputSettings().getBitDepth(); float clipvalue = std::nextafterf( -1.0f, 0.0f ); diff --git a/src/core/audio/AudioFileMP3.cpp b/src/core/audio/AudioFileMP3.cpp index 2141fabfc..4d1dbc020 100644 --- a/src/core/audio/AudioFileMP3.cpp +++ b/src/core/audio/AudioFileMP3.cpp @@ -25,6 +25,8 @@ #include "AudioFileMP3.h" +#include "SampleFrame.h" + #ifdef LMMS_HAVE_MP3LAME @@ -53,7 +55,7 @@ AudioFileMP3::~AudioFileMP3() tearDownEncoder(); } -void AudioFileMP3::writeBuffer(const surroundSampleFrame* _buf, const fpp_t _frames) +void AudioFileMP3::writeBuffer(const SampleFrame* _buf, const fpp_t _frames) { if (_frames < 1) { diff --git a/src/core/audio/AudioFileOgg.cpp b/src/core/audio/AudioFileOgg.cpp index 3818273d6..59b796730 100644 --- a/src/core/audio/AudioFileOgg.cpp +++ b/src/core/audio/AudioFileOgg.cpp @@ -179,7 +179,7 @@ bool AudioFileOgg::startEncoding() return true; } -void AudioFileOgg::writeBuffer(const surroundSampleFrame* _ab, const fpp_t _frames) +void AudioFileOgg::writeBuffer(const SampleFrame* _ab, const fpp_t _frames) { int eos = 0; diff --git a/src/core/audio/AudioFileWave.cpp b/src/core/audio/AudioFileWave.cpp index 612b98982..4b4b928c5 100644 --- a/src/core/audio/AudioFileWave.cpp +++ b/src/core/audio/AudioFileWave.cpp @@ -93,7 +93,7 @@ bool AudioFileWave::startEncoding() return true; } -void AudioFileWave::writeBuffer(const surroundSampleFrame* _ab, const fpp_t _frames) +void AudioFileWave::writeBuffer(const SampleFrame* _ab, const fpp_t _frames) { OutputSettings::BitDepth bitDepth = getOutputSettings().getBitDepth(); diff --git a/src/core/audio/AudioJack.cpp b/src/core/audio/AudioJack.cpp index 4d27602ef..bd5b8e514 100644 --- a/src/core/audio/AudioJack.cpp +++ b/src/core/audio/AudioJack.cpp @@ -48,7 +48,7 @@ AudioJack::AudioJack(bool& successful, AudioEngine* audioEngineParam) std::clamp( ConfigManager::inst()->value("audiojack", "channels").toInt(), DEFAULT_CHANNELS, - SURROUND_CHANNELS + DEFAULT_CHANNELS ), // clang-format on audioEngineParam) @@ -56,7 +56,7 @@ AudioJack::AudioJack(bool& successful, AudioEngine* audioEngineParam) , m_active(false) , m_midiClient(nullptr) , m_tempOutBufs(new jack_default_audio_sample_t*[channels()]) - , m_outBuf(new surroundSampleFrame[audioEngine()->framesPerPeriod()]) + , m_outBuf(new SampleFrame[audioEngine()->framesPerPeriod()]) , m_framesDoneInCurBuf(0) , m_framesToDoInCurBuf(0) { @@ -392,7 +392,7 @@ AudioJack::setupWidget::setupWidget(QWidget* parent) form->addRow(tr("Client name"), m_clientName); auto m = new gui::LcdSpinBoxModel(/* this */); - m->setRange(DEFAULT_CHANNELS, SURROUND_CHANNELS); + m->setRange(DEFAULT_CHANNELS, DEFAULT_CHANNELS); m->setStep(2); m->setValue(ConfigManager::inst()->value("audiojack", "channels").toInt()); diff --git a/src/core/audio/AudioOss.cpp b/src/core/audio/AudioOss.cpp index e18260d61..1321a8a24 100644 --- a/src/core/audio/AudioOss.cpp +++ b/src/core/audio/AudioOss.cpp @@ -72,7 +72,7 @@ AudioOss::AudioOss( bool & _success_ful, AudioEngine* _audioEngine ) : AudioDevice(std::clamp( ConfigManager::inst()->value("audiooss", "channels").toInt(), DEFAULT_CHANNELS, - SURROUND_CHANNELS), _audioEngine), + DEFAULT_CHANNELS), _audioEngine), m_convertEndian( false ) { _success_ful = false; @@ -256,7 +256,7 @@ void AudioOss::stopProcessing() void AudioOss::run() { - auto temp = new surroundSampleFrame[audioEngine()->framesPerPeriod()]; + auto temp = new SampleFrame[audioEngine()->framesPerPeriod()]; auto outbuf = new int_sample_t[audioEngine()->framesPerPeriod() * channels()]; while( true ) @@ -291,7 +291,7 @@ AudioOss::setupWidget::setupWidget( QWidget * _parent ) : form->addRow(tr("Device"), m_device); auto m = new gui::LcdSpinBoxModel(/* this */); - m->setRange( DEFAULT_CHANNELS, SURROUND_CHANNELS ); + m->setRange(DEFAULT_CHANNELS, DEFAULT_CHANNELS); m->setStep( 2 ); m->setValue( ConfigManager::inst()->value( "audiooss", "channels" ).toInt() ); diff --git a/src/core/audio/AudioPortAudio.cpp b/src/core/audio/AudioPortAudio.cpp index bc5d7dd9d..00bbec2e4 100644 --- a/src/core/audio/AudioPortAudio.cpp +++ b/src/core/audio/AudioPortAudio.cpp @@ -64,10 +64,10 @@ AudioPortAudio::AudioPortAudio( bool & _success_ful, AudioEngine * _audioEngine AudioDevice(std::clamp( ConfigManager::inst()->value("audioportaudio", "channels").toInt(), DEFAULT_CHANNELS, - SURROUND_CHANNELS), _audioEngine), + DEFAULT_CHANNELS), _audioEngine), m_paStream( nullptr ), m_wasPAInitError( false ), - m_outBuf( new surroundSampleFrame[audioEngine()->framesPerPeriod()] ), + m_outBuf(new SampleFrame[audioEngine()->framesPerPeriod()]), m_outBufPos( 0 ) { _success_ful = false; @@ -236,7 +236,7 @@ int AudioPortAudio::process_callback( { if( supportsCapture() ) { - audioEngine()->pushInputFrames( (sampleFrame*)_inputBuffer, _framesPerBuffer ); + audioEngine()->pushInputFrames( (SampleFrame*)_inputBuffer, _framesPerBuffer ); } if( m_stopped ) @@ -387,7 +387,7 @@ AudioPortAudio::setupWidget::setupWidget( QWidget * _parent ) : form->addRow(tr("Device"), m_device); /* LcdSpinBoxModel * m = new LcdSpinBoxModel( ); - m->setRange( DEFAULT_CHANNELS, SURROUND_CHANNELS ); + m->setRange( DEFAULT_CHANNELS, DEFAULT_CHANNELS ); m->setStep( 2 ); m->setValue( ConfigManager::inst()->value( "audioportaudio", "channels" ).toInt() ); diff --git a/src/core/audio/AudioPulseAudio.cpp b/src/core/audio/AudioPulseAudio.cpp index b32e6eaf2..aa4344871 100644 --- a/src/core/audio/AudioPulseAudio.cpp +++ b/src/core/audio/AudioPulseAudio.cpp @@ -49,7 +49,7 @@ AudioPulseAudio::AudioPulseAudio( bool & _success_ful, AudioEngine* _audioEngin AudioDevice(std::clamp( ConfigManager::inst()->value("audiopa", "channels").toInt(), DEFAULT_CHANNELS, - SURROUND_CHANNELS), _audioEngine), + DEFAULT_CHANNELS), _audioEngine), m_s( nullptr ), m_quit( false ), m_convertEndian( false ) @@ -230,7 +230,7 @@ void AudioPulseAudio::run() else { const fpp_t fpp = audioEngine()->framesPerPeriod(); - auto temp = new surroundSampleFrame[fpp]; + auto temp = new SampleFrame[fpp]; while( getNextBuffer( temp ) ) { } @@ -249,7 +249,7 @@ void AudioPulseAudio::run() void AudioPulseAudio::streamWriteCallback( pa_stream *s, size_t length ) { const fpp_t fpp = audioEngine()->framesPerPeriod(); - auto temp = new surroundSampleFrame[fpp]; + auto temp = new SampleFrame[fpp]; auto pcmbuf = (int_sample_t*)pa_xmalloc(fpp * channels() * sizeof(int_sample_t)); size_t fd = 0; @@ -298,7 +298,7 @@ AudioPulseAudio::setupWidget::setupWidget( QWidget * _parent ) : form->addRow(tr("Device"), m_device); auto m = new gui::LcdSpinBoxModel(); - m->setRange( DEFAULT_CHANNELS, SURROUND_CHANNELS ); + m->setRange(DEFAULT_CHANNELS, DEFAULT_CHANNELS); m->setStep( 2 ); m->setValue( ConfigManager::inst()->value( "audiopa", "channels" ).toInt() ); diff --git a/src/core/audio/AudioSampleRecorder.cpp b/src/core/audio/AudioSampleRecorder.cpp index c9448b89e..0e51c9d2d 100644 --- a/src/core/audio/AudioSampleRecorder.cpp +++ b/src/core/audio/AudioSampleRecorder.cpp @@ -71,7 +71,7 @@ std::shared_ptr AudioSampleRecorder::createSampleBuffer() { const f_cnt_t frames = framesRecorded(); // create buffer to store all recorded buffers in - auto bigBuffer = std::vector(frames); + auto bigBuffer = std::vector(frames); // now copy all buffers into big buffer auto framesCopied = 0; @@ -85,9 +85,9 @@ std::shared_ptr AudioSampleRecorder::createSampleBuffer() return std::make_shared(std::move(bigBuffer), sampleRate()); } -void AudioSampleRecorder::writeBuffer(const surroundSampleFrame* _ab, const fpp_t _frames) +void AudioSampleRecorder::writeBuffer(const SampleFrame* _ab, const fpp_t _frames) { - auto buf = new sampleFrame[_frames]; + auto buf = new SampleFrame[_frames]; for( fpp_t frame = 0; frame < _frames; ++frame ) { for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) diff --git a/src/core/audio/AudioSdl.cpp b/src/core/audio/AudioSdl.cpp index 0d960c107..2a5414049 100644 --- a/src/core/audio/AudioSdl.cpp +++ b/src/core/audio/AudioSdl.cpp @@ -38,7 +38,7 @@ namespace lmms AudioSdl::AudioSdl( bool & _success_ful, AudioEngine* _audioEngine ) : AudioDevice( DEFAULT_CHANNELS, _audioEngine ), - m_outBuf( new surroundSampleFrame[audioEngine()->framesPerPeriod()] ) + m_outBuf(new SampleFrame[audioEngine()->framesPerPeriod()]) { _success_ful = false; @@ -225,13 +225,13 @@ void AudioSdl::sdlAudioCallback( Uint8 * _buf, int _len ) m_currentBufferFramesCount = frames; } - const uint min_frames_count = std::min(_len/sizeof(sampleFrame), + const uint min_frames_count = std::min(_len/sizeof(SampleFrame), m_currentBufferFramesCount - m_currentBufferFramePos); - memcpy( _buf, m_outBuf + m_currentBufferFramePos, min_frames_count*sizeof(sampleFrame) ); - _buf += min_frames_count*sizeof(sampleFrame); - _len -= min_frames_count*sizeof(sampleFrame); + memcpy( _buf, m_outBuf + m_currentBufferFramePos, min_frames_count*sizeof(SampleFrame) ); + _buf += min_frames_count*sizeof(SampleFrame); + _len -= min_frames_count*sizeof(SampleFrame); m_currentBufferFramePos += min_frames_count; m_currentBufferFramePos %= m_currentBufferFramesCount; @@ -274,8 +274,8 @@ void AudioSdl::sdlInputAudioCallback(void *_udata, Uint8 *_buf, int _len) { } void AudioSdl::sdlInputAudioCallback(Uint8 *_buf, int _len) { - auto samples_buffer = (sampleFrame*)_buf; - fpp_t frames = _len / sizeof ( sampleFrame ); + auto samples_buffer = (SampleFrame*)_buf; + fpp_t frames = _len / sizeof ( SampleFrame ); audioEngine()->pushInputFrames (samples_buffer, frames); } diff --git a/src/core/audio/AudioSndio.cpp b/src/core/audio/AudioSndio.cpp index 535b885da..95fab473a 100644 --- a/src/core/audio/AudioSndio.cpp +++ b/src/core/audio/AudioSndio.cpp @@ -46,7 +46,7 @@ AudioSndio::AudioSndio(bool & _success_ful, AudioEngine * _audioEngine) : AudioDevice(std::clamp( ConfigManager::inst()->value("audiosndio", "channels").toInt(), DEFAULT_CHANNELS, - SURROUND_CHANNELS), _audioEngine), + DEFAULT_CHANNELS), _audioEngine), m_convertEndian ( false ) { _success_ful = false; @@ -141,7 +141,7 @@ void AudioSndio::stopProcessing() void AudioSndio::run() { - surroundSampleFrame * temp = new surroundSampleFrame[audioEngine()->framesPerPeriod()]; + SampleFrame* temp = new SampleFrame[audioEngine()->framesPerPeriod()]; int_sample_t * outbuf = new int_sample_t[audioEngine()->framesPerPeriod() * channels()]; while( true ) @@ -173,7 +173,7 @@ AudioSndio::setupWidget::setupWidget( QWidget * _parent ) : form->addRow(tr("Device"), m_device); gui::LcdSpinBoxModel * m = new gui::LcdSpinBoxModel( /* this */ ); - m->setRange( DEFAULT_CHANNELS, SURROUND_CHANNELS ); + m->setRange(DEFAULT_CHANNELS, DEFAULT_CHANNELS); m->setStep( 2 ); m->setValue( ConfigManager::inst()->value( "audiosndio", "channels" ).toInt() ); diff --git a/src/core/audio/AudioSoundIo.cpp b/src/core/audio/AudioSoundIo.cpp index c16327a90..c7fa380e4 100644 --- a/src/core/audio/AudioSoundIo.cpp +++ b/src/core/audio/AudioSoundIo.cpp @@ -42,7 +42,7 @@ AudioSoundIo::AudioSoundIo( bool & outSuccessful, AudioEngine * _audioEngine ) : AudioDevice(std::clamp( ConfigManager::inst()->value("audiosoundio", "channels").toInt(), DEFAULT_CHANNELS, - SURROUND_CHANNELS), _audioEngine) + DEFAULT_CHANNELS), _audioEngine) { outSuccessful = false; m_soundio = nullptr; @@ -213,7 +213,7 @@ void AudioSoundIo::startProcessing() m_outBufFramesTotal = 0; m_outBufSize = audioEngine()->framesPerPeriod(); - m_outBuf = new surroundSampleFrame[m_outBufSize]; + m_outBuf = new SampleFrame[m_outBufSize]; if (! m_outstreamStarted) { diff --git a/src/core/lv2/Lv2ControlBase.cpp b/src/core/lv2/Lv2ControlBase.cpp index 5741866e9..0147ebd6e 100644 --- a/src/core/lv2/Lv2ControlBase.cpp +++ b/src/core/lv2/Lv2ControlBase.cpp @@ -137,7 +137,7 @@ void Lv2ControlBase::copyModelsToLmms() const -void Lv2ControlBase::copyBuffersFromLmms(const sampleFrame *buf, fpp_t frames) { +void Lv2ControlBase::copyBuffersFromLmms(const SampleFrame* buf, fpp_t frames) { unsigned firstChan = 0; // tell the procs which channels they shall read from for (const auto& c : m_procs) { @@ -149,7 +149,7 @@ void Lv2ControlBase::copyBuffersFromLmms(const sampleFrame *buf, fpp_t frames) { -void Lv2ControlBase::copyBuffersToLmms(sampleFrame *buf, fpp_t frames) const { +void Lv2ControlBase::copyBuffersToLmms(SampleFrame* buf, fpp_t frames) const { unsigned firstChan = 0; // tell the procs which channels they shall write to for (const auto& c : m_procs) { c->copyBuffersToCore(buf, firstChan, m_channelsPerProc, frames); diff --git a/src/core/lv2/Lv2Ports.cpp b/src/core/lv2/Lv2Ports.cpp index 657046817..bdb0d4f00 100644 --- a/src/core/lv2/Lv2Ports.cpp +++ b/src/core/lv2/Lv2Ports.cpp @@ -34,6 +34,7 @@ #include "Lv2Basics.h" #include "Lv2Manager.h" #include "Lv2Evbuf.h" +#include "SampleFrame.h" namespace lmms::Lv2Ports @@ -311,7 +312,7 @@ Audio::Audio(std::size_t bufferSize, bool isSidechain) -void Audio::copyBuffersFromCore(const sampleFrame *lmmsBuf, +void Audio::copyBuffersFromCore(const SampleFrame* lmmsBuf, unsigned channel, fpp_t frames) { for (std::size_t f = 0; f < static_cast(frames); ++f) @@ -323,7 +324,7 @@ void Audio::copyBuffersFromCore(const sampleFrame *lmmsBuf, -void Audio::averageWithBuffersFromCore(const sampleFrame *lmmsBuf, +void Audio::averageWithBuffersFromCore(const SampleFrame* lmmsBuf, unsigned channel, fpp_t frames) { for (std::size_t f = 0; f < static_cast(frames); ++f) @@ -335,7 +336,7 @@ void Audio::averageWithBuffersFromCore(const sampleFrame *lmmsBuf, -void Audio::copyBuffersToCore(sampleFrame *lmmsBuf, +void Audio::copyBuffersToCore(SampleFrame* lmmsBuf, unsigned channel, fpp_t frames) const { for (std::size_t f = 0; f < static_cast(frames); ++f) diff --git a/src/core/lv2/Lv2Proc.cpp b/src/core/lv2/Lv2Proc.cpp index 7dfdbc767..27d18ef27 100644 --- a/src/core/lv2/Lv2Proc.cpp +++ b/src/core/lv2/Lv2Proc.cpp @@ -324,7 +324,7 @@ void Lv2Proc::copyModelsToCore() -void Lv2Proc::copyBuffersFromCore(const sampleFrame *buf, +void Lv2Proc::copyBuffersFromCore(const SampleFrame* buf, unsigned firstChan, unsigned num, fpp_t frames) { @@ -349,7 +349,7 @@ void Lv2Proc::copyBuffersFromCore(const sampleFrame *buf, -void Lv2Proc::copyBuffersToCore(sampleFrame* buf, +void Lv2Proc::copyBuffersToCore(SampleFrame* buf, unsigned firstChan, unsigned num, fpp_t frames) const { diff --git a/src/gui/AudioAlsaSetupWidget.cpp b/src/gui/AudioAlsaSetupWidget.cpp index bc0ecde8e..43872a12f 100644 --- a/src/gui/AudioAlsaSetupWidget.cpp +++ b/src/gui/AudioAlsaSetupWidget.cpp @@ -70,7 +70,7 @@ AudioAlsaSetupWidget::AudioAlsaSetupWidget( QWidget * _parent ) : form->addRow(tr("Device"), m_deviceComboBox); auto m = new LcdSpinBoxModel(/* this */); - m->setRange( DEFAULT_CHANNELS, SURROUND_CHANNELS ); + m->setRange(DEFAULT_CHANNELS, DEFAULT_CHANNELS); m->setStep( 2 ); m->setValue( ConfigManager::inst()->value( "audioalsa", "channels" ).toInt() ); diff --git a/src/gui/SampleWaveform.cpp b/src/gui/SampleWaveform.cpp index 783543ac5..91b6e26c3 100644 --- a/src/gui/SampleWaveform.cpp +++ b/src/gui/SampleWaveform.cpp @@ -59,7 +59,7 @@ void SampleWaveform::visualize(Parameters parameters, QPainter& painter, const Q const int frameIndex = !parameters.reversed ? i : maxFrames - i; const auto& frame = parameters.buffer[frameIndex]; - const float value = std::accumulate(frame.begin(), frame.end(), 0.0f) / frame.size(); + const auto value = frame.average(); if (value > max[pixelIndex]) { max[pixelIndex] = value; } if (value < min[pixelIndex]) { min[pixelIndex] = value; } diff --git a/src/gui/widgets/Oscilloscope.cpp b/src/gui/widgets/Oscilloscope.cpp index 8c342cc34..8cb840592 100644 --- a/src/gui/widgets/Oscilloscope.cpp +++ b/src/gui/widgets/Oscilloscope.cpp @@ -55,7 +55,7 @@ Oscilloscope::Oscilloscope( QWidget * _p ) : setActive( ConfigManager::inst()->value( "ui", "displaywaveform").toInt() ); const fpp_t frames = Engine::audioEngine()->framesPerPeriod(); - m_buffer = new sampleFrame[frames]; + m_buffer = new SampleFrame[frames]; BufferManager::clear( m_buffer, frames ); @@ -75,12 +75,12 @@ Oscilloscope::~Oscilloscope() -void Oscilloscope::updateAudioBuffer( const surroundSampleFrame * buffer ) +void Oscilloscope::updateAudioBuffer(const SampleFrame* buffer) { if( !Engine::getSong()->isExporting() ) { const fpp_t fpp = Engine::audioEngine()->framesPerPeriod(); - memcpy( m_buffer, buffer, sizeof( surroundSampleFrame ) * fpp ); + memcpy(m_buffer, buffer, sizeof(SampleFrame) * fpp); } } @@ -96,8 +96,8 @@ void Oscilloscope::setActive( bool _active ) SIGNAL(periodicUpdate()), this, SLOT(update())); connect( Engine::audioEngine(), - SIGNAL(nextAudioBuffer(const lmms::surroundSampleFrame*)), - this, SLOT(updateAudioBuffer(const lmms::surroundSampleFrame*)) ); + SIGNAL(nextAudioBuffer(const lmms::SampleFrame*)), + this, SLOT(updateAudioBuffer(const lmms::SampleFrame*))); } else { @@ -105,8 +105,8 @@ void Oscilloscope::setActive( bool _active ) SIGNAL(periodicUpdate()), this, SLOT(update())); disconnect( Engine::audioEngine(), - SIGNAL( nextAudioBuffer( const lmms::surroundSampleFrame* ) ), - this, SLOT( updateAudioBuffer( const lmms::surroundSampleFrame* ) ) ); + SIGNAL(nextAudioBuffer(const lmms::SampleFrame*)), + this, SLOT(updateAudioBuffer(const lmms::SampleFrame*))); // we have to update (remove last waves), // because timer doesn't do that anymore update(); @@ -168,10 +168,10 @@ void Oscilloscope::paintEvent( QPaintEvent * ) float masterOutput = audioEngine->masterGain(); const fpp_t frames = audioEngine->framesPerPeriod(); - AudioEngine::StereoSample peakValues = audioEngine->getPeakValues(m_buffer, frames); + SampleFrame peakValues = getAbsPeakValues(m_buffer, frames); - auto const leftChannelClips = clips(peakValues.left * masterOutput); - auto const rightChannelClips = clips(peakValues.right * masterOutput); + auto const leftChannelClips = clips(peakValues.left() * masterOutput); + auto const rightChannelClips = clips(peakValues.right() * masterOutput); p.setRenderHint( QPainter::Antialiasing ); diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index 3317ea71b..14cf19153 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -220,7 +220,7 @@ InstrumentTrack::~InstrumentTrack() -void InstrumentTrack::processAudioBuffer( sampleFrame* buf, const fpp_t frames, NotePlayHandle* n ) +void InstrumentTrack::processAudioBuffer( SampleFrame* buf, const fpp_t frames, NotePlayHandle* n ) { // we must not play the sound if this InstrumentTrack is muted... if( isMuted() || ( Engine::getSong()->playMode() != Song::PlayMode::MidiClip && @@ -567,7 +567,7 @@ f_cnt_t InstrumentTrack::beatLen( NotePlayHandle * _n ) const -void InstrumentTrack::playNote( NotePlayHandle* n, sampleFrame* workingBuffer ) +void InstrumentTrack::playNote( NotePlayHandle* n, SampleFrame* workingBuffer ) { // Note: under certain circumstances the working buffer is a nullptr. // These cases are triggered in PlayHandle::doProcessing when the play method is called with a nullptr.