mirror of
https://github.com/LMMS/lmms.git
synced 2025-12-28 09:08:30 -05:00
refac/memory
13 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
1420a1f7e8 |
Define fpp_t and f_cnt_t to be of size_t (#7363)
Defines `fpp_t` and `f_cnt_t` to be of `size_t` within `lmms_basics.h`. Most of the codebase used `fpp_t` to represent the size of an array of sample frames, which is incorrect, given that `fpp_t` was only 16 bits when sizes greater than 32767 are very possible. `f_cnt_t` was defined as `size_t` as well for consistency. --------- Co-authored-by: Dominic Clark <mrdomclark@gmail.com> |
||
|
|
286e62adf5 |
Simplify sample frame operations (make it a class) (#7156)
* 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> |
||
|
|
71dd300f43 |
Instrument release time in milliseconds (#7217)
Make instruments report their release time in milliseconds so that it becomes independent of the sample rate and sounds the same at any sample rate. Technically this is done by removing the virtual keyword from `desiredReleaseFrames` so that it cannot be overridden anymore. The method now only serves to compute the number of frames from the given release time in milliseconds. A new virtual method `desiredReleaseTimeMs` is added which instruments can override. The default returns 0 ms just like the default implementation previously returned 0 frames. The method `computeReleaseTimeMsByFrameCount` is added for instruments that still use a hard coded release in frames. As of now this is only `SidInstrument`. Add the helper method `getSampleRate` to `Instrument`. Adjust several instruments to report their release times in milliseconds. The times are computed by taking the release in frames and assuming a sample rate of 44.1 kHz. In most cases the times are rounded to a "nice" next value, e.g.: * 64 frames -> 1.5 ms (66 frames) * 128 frames -> 3.0 ms (132 frames) * 512 frames -> 12. ms (529 frames) * 1000 frames -> 23 ms (1014 samples) In parentheses the number of frames are shown which result from the rounded number of milliseconds when converted back assuming a sample rate of 44.1 kHz. The difference should not be noticeable in existing projects. Remove the overrides for instruments that return the same value as the base class `Instrument` anyway. These are: * GigPlayer * Lb302 * Sf2Player For `MonstroInstrument` the implementation is adjusted to behave in a very similar way. First the maximum of the envelope release times is computed. These are already available in milliseconds. Then the maximum of that value and 1.5 ms is taken and returned as the result. |
||
|
|
8e8f68552f |
Disentangle and clean the classes of the Audio File Processor (#7069)
## Extract views Extract the classes `AudioFileProcessorWaveView` and `AudioFileProcessorView` into their own files. Reformat the new classes by removing unnecessary whitespace and underscores. Add spaces to if-statements. Cleanup the includes. ## Remove friend relationship Remove the friend relationship between `AudioFileProcessor` and `AudioFileProcessorView`. Introduce getters for entities that the view is interested in. |
||
|
|
ce722dd6b6 |
Refactor `SampleBuffer` (#6610)
* Add refactored SampleBuffer * Add Sample * Add SampleLoader * Integrate changes into AudioSampleRecorder * Integrate changes into Oscillator * Integrate changes into SampleClip/SamplePlayHandle * Integrate changes into Graph * Remove SampleBuffer include from SampleClipView * Integrate changes into Patman * Reduce indirection to sample buffer from Sample * Integrate changes into AudioFileProcessor * Remove old SampleBuffer * Include memory header in TripleOscillator * Include memory header in Oscillator * Use atomic_load within SampleClip::sample * Include memory header in EnvelopeAndLfoParameters * Use std::atomic_load for most calls to Oscillator::userWaveSample * Revert accidental change on SamplePlayHandle L.111 * Check if audio file is empty before loading * Add asserts to Sample * Add cassert include within Sample * Adjust assert expressions in Sample * Remove use of shared ownership for Sample Sample does not need to be wrapped around a std::shared_ptr. This was to work with the audio thread, but the audio thread can instead have their own Sample separate from the UI's Sample, so changes to the UI's Sample would not leave the audio worker thread using freed data if it had pointed to it. * Use ArrayVector in Sample * Enforce std::atomic_load for users of std::shared_ptr<const SampleBuffer> * Use requestChangesGuard in ClipView::remove Fixes data race when deleting SampleClip * Revert only formatting changes * Update ClipView::remove comment * Revert "Remove use of shared ownership for Sample" This reverts commit |
||
|
|
aa050ae0b7 |
Fix memory leaks (#6879)
* Replace knobFModel with std::vector * Create QPixmap's on the stack * Assign parent for QGraphicsScene A call to QGraphicsView::setScene does not make the view take ownership of the scene. * Do not allocate QList on the heap * Use static QPixmap's The QPixmap's need to be created within the constructor, and not outside where they are defined, since it can't find them otherwise. I'm not too sure why. * Clear m_vi2->knobFModel in destructor * Use local static QPixmap's * Do not allocate QPixmap with new in AudioFileProcessor * Do not allocate QPixmap with new in Nes * Do not allocate QPixmap with new in Organic * Do not allocate QPixmap with new in SaControlsDialog * Do not allocate QPixmap with new in Vestige * Do not allocate QPixmap with new for FileBrowser * Do not allocate QPixmap with new in MixerLine * Do not allocate QPixmap with new in SendButtonIndicator * Do not allocate QPixmap with new in AutomationClipView * Do not allocate QPixmap with new in MidiClipView * Do not allocate QPixmap with new in AutomationEditor * Do not allocate QPixmap with new in PianoRoll * Do not allocate QPixmap with new in TimeLineWidget * Do not allocate QPixmap with new in EnvelopeAndLfoView * Do not allocate QPixmap with new in PianoView * Do not allocate QPixmap with new in ComboBox * Do not allocate QPixmap with new in Fader * Do not allocate QPixmap with new for LcdWidget * Do not allocate QPixmap with new for LedCheckbox * Use m_ as prefix for members * Use uniform initialization I already started using uniform initialization for the QPixmap changes for some reason, so I'm finishing that up. * Uniform initiaization * And then he realized he was making copies... * Do not call QPixmap copy constructor * Do not call QPixmap copy constructor in SaControlsDialog * Do not make pixmap's static for Lcd's and Led's * Initialize pixmaps in-class * Fix few mistakes and formatting |
||
|
|
d9ce7d8d4c | Use remaining sample duration for AFP beat length (#6872) | ||
|
|
f10277715f | Classier enums (#6760) | ||
|
|
5cbf2c5287 |
Fix LMMS plugin issues (#6670)
* Fix Organic automated harmonic parameter loading * Fix Kicker automated end distortion parameter loading * Fix AudioFileProcessor automated interpolation parameter loading * Fix Vibed automated volume parameter loading * Improve coding style/formatting * Fix #6671 * Fix Vibed memory leaks * Refactor Vibed instrument * Fix build * Try to fix build again * Revert previous commit * Replace more raw pointers with smart pointers * Remove unused files * Minor changes * Update plugins/Vibed/Vibed.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Implement suggestions from review * Minor changes * Only check plugin data pointer * Refactor NineButtonSelector * Fix memory leaks during heavy tempo automation * Fix build * Use s_stringCount * Replace some vectors with arrays * Use array instead of switch * Allow compiler to generate move assignment operator * Fix loading of old automated detune values * Fix member variable names * Address review comments --------- Co-authored-by: Kevin Zander <veratil@gmail.com> |
||
|
|
b451e40b51 | clang-tidy: Apply modernize-use-using everywhere (#6453) | ||
|
|
28ec71f91a | clang-tidy: Apply modernize-use-equals-default everywhere (#6450) | ||
|
|
7227c89847 |
Namespace lmms (#6174)
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
|
||
|
|
f6bad88ad3 |
Fix casing of filenames and code in plugins/ (#6350)
No functional changes! No changes to savefiles/presets! Fixes casing of everything that is currently lowercase but should be uppercase. Fixes also some other plugin strings, especially: * opl2 -> OpulenZ (see |