* Move common effect processing code to wrapper method
- Introduce `processImpl` and `sleepImpl` methods, and adapt each effect
plugin to use them
- Use double for RMS out sum in Compressor and LOMM
- Run `checkGate` for GranularPitchShifterEffect
- Minor changes to LadspaEffect
- Remove dynamic allocations and VLAs from VstEffect's process method
- Some minor style/formatting fixes
* Fix VstEffect regression
* GranularPitchShifterEffect should not call `checkGate`
* Apply suggestions from code review
Co-authored-by: saker <sakertooth@gmail.com>
* Follow naming convention for local variables
* Add `MAXIMUM_BUFFER_SIZE` and use it in VstEffect
* Revert "GranularPitchShifterEffect should not call `checkGate`"
This reverts commit 67526f0ffe.
* VstEffect: Simplify setting "Don't Run" state
* Rename `sleepImpl` to `processBypassedImpl`
* Use `MAXIMUM_BUFFER_SIZE` in SetupDialog
* Pass `outSum` as out parameter; Fix LadspaEffect mutex
* Move outSum calculations to wrapper method
* Fix Linux build
* Oops
* Apply suggestions from code review
Co-authored-by: Johannes Lorenz <1042576+JohannesLorenz@users.noreply.github.com>
* Apply suggestions from code review
Co-authored-by: saker <sakertooth@gmail.com>
---------
Co-authored-by: saker <sakertooth@gmail.com>
Co-authored-by: Johannes Lorenz <1042576+JohannesLorenz@users.noreply.github.com>
* 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 <veratil@gmail.com>
* 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 <veratil@gmail.com>
Oversampling can have many different effects to the audio signal such as latency, phase issues, clipping, smearing, etc, so this should really be an option on a per-plugin basis, not globally across all of LMMS (which, in some places, shouldn't really need to oversample at all but were oversampled anyways).
This PR places all LMMS symbols into namespaces to eliminate any potential future name collisions between LMMS and third-party modules.
Also, this PR changes back `LmmsCore` to `Engine`, reverting c519921306 .
Co-authored-by: allejok96 <allejok96@gmail.com>
Summary:
* `NULL` -> `nullptr`
* `gui` -> Function `getGUI()`
* `pluginFactory` -> Function `getPluginFactory()`
* `assert` (redefinition) -> using `NDEBUG` instead, which standard `assert` respects.
* `powf` (C stdlib symbol clash) -> removed and all expansions replaced with calls to `std::pow`.
* `exp10` (nonstandard function symbol clash) -> removed and all expansions replaced with calls to `std::pow`.
* `PATH_DEV_DSP` -> File-scope QString of identical name and value.
* `VST_SNC_SHM_KEY_FILE` -> constexpr char* with identical name and value.
* `MM_ALLOC` and `MM_FREE` -> Functions with identical name and implementation.
* `INVAL`, `OUTVAL`, etc. for automation nodes -> Functions with identical names and implementations.
* BandLimitedWave.h: All integer constant macros replaced with constexpr ints of same name and value.
* `FAST_RAND_MAX` -> constexpr int of same name and value.
* `QSTR_TO_STDSTR` -> Function with identical name and equivalent implementation.
* `CCONST` -> constexpr function template with identical name and implementation.
* `F_OPEN_UTF8` -> Function with identical name and equivalent implementation.
* `LADSPA_PATH_SEPARATOR` -> constexpr char with identical name and value.
* `UI_CTRL_KEY` -> constexpr char* with identical name and value.
* `ALIGN_SIZE` -> Renamed to `LMMS_ALIGN_SIZE` and converted from a macro to a constexpr size_t.
* `JACK_MIDI_BUFFER_MAX` -> constexpr size_t with identical name and value.
* versioninfo.h: `PLATFORM`, `MACHINE` and `COMPILER_VERSION` -> prefixed with `LMMS_BUILDCONF_` and converted from macros to constexpr char* literals.
* Header guard _OSCILLOSCOPE -> renamed to OSCILLOSCOPE_H
* Header guard _TIME_DISPLAY_WIDGET -> renamed to TIME_DISPLAY_WIDGET_H
* C-style typecasts in DrumSynth.cpp have been replaced with `static_cast`.
* constexpr numerical constants are initialized with assignment notation instead of curly brace intializers.
* In portsmf, `Alg_seq::operator[]` will throw an exception instead of returning null if the operator index is out of range.
Additionally, in many places, global constants that were declared as `const T foo = bar;` were changed from const to constexpr, leaving them const and making them potentially evaluable at compile time.
Some macros that only appeared in single source files and were unused in those files have been removed entirely.