From 15799329c564571a59e19562cf9ca80383a5dbd5 Mon Sep 17 00:00:00 2001 From: Veratil Date: Thu, 22 Jun 2023 15:52:48 -0500 Subject: [PATCH 01/15] Test remove rpmalloc --- include/MemoryManager.h | 10 ++-- src/core/AudioEngineWorkerThread.cpp | 2 +- src/core/MemoryManager.cpp | 75 ++++++++++++++-------------- src/core/ProjectRenderer.cpp | 2 +- 4 files changed, 45 insertions(+), 44 deletions(-) diff --git a/include/MemoryManager.h b/include/MemoryManager.h index fa2fe8110f4..38c77a31ddb 100644 --- a/include/MemoryManager.h +++ b/include/MemoryManager.h @@ -39,11 +39,11 @@ namespace lmms class LMMS_EXPORT MemoryManager { public: - struct ThreadGuard - { - ThreadGuard(); - ~ThreadGuard(); - }; + //struct ThreadGuard + //{ + // ThreadGuard(); + // ~ThreadGuard(); + //}; static void * alloc( size_t size ); static void free( void * ptr ); diff --git a/src/core/AudioEngineWorkerThread.cpp b/src/core/AudioEngineWorkerThread.cpp index 528841c7128..288a663d13d 100644 --- a/src/core/AudioEngineWorkerThread.cpp +++ b/src/core/AudioEngineWorkerThread.cpp @@ -167,7 +167,7 @@ void AudioEngineWorkerThread::startAndWaitForJobs() void AudioEngineWorkerThread::run() { - MemoryManager::ThreadGuard mmThreadGuard; Q_UNUSED(mmThreadGuard); + //MemoryManager::ThreadGuard mmThreadGuard; Q_UNUSED(mmThreadGuard); disable_denormals(); QMutex m; diff --git a/src/core/MemoryManager.cpp b/src/core/MemoryManager.cpp index bd3168f1487..e480e4a4905 100644 --- a/src/core/MemoryManager.cpp +++ b/src/core/MemoryManager.cpp @@ -24,60 +24,61 @@ #include "MemoryManager.h" +#include -#include -#include "rpmalloc.h" +//#include +//#include "rpmalloc.h" namespace lmms { /// Global static object handling rpmalloc intializing and finalizing -struct MemoryManagerGlobalGuard { - MemoryManagerGlobalGuard() { - rpmalloc_initialize(); - } - ~MemoryManagerGlobalGuard() { - rpmalloc_finalize(); - } -} static mm_global_guard; - - -namespace { -static thread_local size_t thread_guard_depth; -} - -MemoryManager::ThreadGuard::ThreadGuard() -{ - if (thread_guard_depth++ == 0) { - rpmalloc_thread_initialize(); - } -} - -MemoryManager::ThreadGuard::~ThreadGuard() -{ - if (--thread_guard_depth == 0) { - rpmalloc_thread_finalize(true); - } -} - -static thread_local MemoryManager::ThreadGuard local_mm_thread_guard{}; +//struct MemoryManagerGlobalGuard { +// MemoryManagerGlobalGuard() { +// rpmalloc_initialize(); +// } +// ~MemoryManagerGlobalGuard() { +// rpmalloc_finalize(); +// } +//} static mm_global_guard; + + +//namespace { +//static thread_local size_t thread_guard_depth; +//} + +//MemoryManager::ThreadGuard::ThreadGuard() +//{ +// if (thread_guard_depth++ == 0) { +// rpmalloc_thread_initialize(); +// } +//} + +//MemoryManager::ThreadGuard::~ThreadGuard() +//{ +// if (--thread_guard_depth == 0) { +// rpmalloc_thread_finalize(true); +// } +//} + +//static thread_local MemoryManager::ThreadGuard local_mm_thread_guard{}; void* MemoryManager::alloc(size_t size) { // Reference local thread guard to ensure it is initialized. // Compilers may optimize the instance away otherwise. - Q_UNUSED(&local_mm_thread_guard); - Q_ASSERT_X(rpmalloc_is_thread_initialized(), "MemoryManager::alloc", "Thread not initialized"); - return rpmalloc(size); + //Q_UNUSED(&local_mm_thread_guard); + //Q_ASSERT_X(rpmalloc_is_thread_initialized(), "MemoryManager::alloc", "Thread not initialized"); + return std::malloc(size); } void MemoryManager::free(void * ptr) { - Q_UNUSED(&local_mm_thread_guard); - Q_ASSERT_X(rpmalloc_is_thread_initialized(), "MemoryManager::free", "Thread not initialized"); - return rpfree(ptr); + //Q_UNUSED(&local_mm_thread_guard); + //Q_ASSERT_X(rpmalloc_is_thread_initialized(), "MemoryManager::free", "Thread not initialized"); + return std::free(ptr); } diff --git a/src/core/ProjectRenderer.cpp b/src/core/ProjectRenderer.cpp index 3f101330aeb..c704c0b09b9 100644 --- a/src/core/ProjectRenderer.cpp +++ b/src/core/ProjectRenderer.cpp @@ -159,7 +159,7 @@ void ProjectRenderer::startProcessing() void ProjectRenderer::run() { - MemoryManager::ThreadGuard mmThreadGuard; Q_UNUSED(mmThreadGuard); + //MemoryManager::ThreadGuard mmThreadGuard; Q_UNUSED(mmThreadGuard); #if 0 #if defined(LMMS_BUILD_LINUX) || defined(LMMS_BUILD_FREEBSD) #ifdef LMMS_HAVE_SCHED_H From 432f9862949264fedea2aa18370a67cb723c70dc Mon Sep 17 00:00:00 2001 From: Jonah Janzen Date: Sat, 24 Feb 2024 18:56:58 -0700 Subject: [PATCH 02/15] Remove rpmalloc submodule --- .gitmodules | 3 --- src/3rdparty/rpmalloc/rpmalloc | 1 - 2 files changed, 4 deletions(-) delete mode 160000 src/3rdparty/rpmalloc/rpmalloc diff --git a/.gitmodules b/.gitmodules index c85f7e5d8e0..82f3e464c0f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,6 @@ [submodule "src/3rdparty/qt5-x11embed"] path = src/3rdparty/qt5-x11embed url = https://github.com/Lukas-W/qt5-x11embed.git -[submodule "src/3rdparty/rpmalloc/rpmalloc"] - path = src/3rdparty/rpmalloc/rpmalloc - url = https://github.com/mjansson/rpmalloc.git [submodule "plugins/ZynAddSubFx/zynaddsubfx"] path = plugins/ZynAddSubFx/zynaddsubfx url = https://github.com/lmms/zynaddsubfx.git diff --git a/src/3rdparty/rpmalloc/rpmalloc b/src/3rdparty/rpmalloc/rpmalloc deleted file mode 160000 index 80daac0d539..00000000000 --- a/src/3rdparty/rpmalloc/rpmalloc +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 80daac0d539ab2a8edfd5ca24b1e0c77a4974bbb From 80bba30d6bca90bec9553eb708703d6f47faf118 Mon Sep 17 00:00:00 2001 From: Jonah Janzen Date: Sat, 24 Feb 2024 19:02:26 -0700 Subject: [PATCH 03/15] Remove MemoryManager.h, MemoryManager.cpp, and all references to both Removing MM_FREE and MM_ALLOC references is next up. --- include/AudioPort.h | 2 - include/AutomatableModel.h | 2 - include/BasicFilters.h | 5 - include/Clip.h | 1 - include/DataFile.h | 2 - include/Delay.h | 1 - include/DetuningHelper.h | 2 - include/Effect.h | 2 - include/Instrument.h | 2 - include/InstrumentTrack.h | 1 - include/MemoryManager.h | 111 -------------------- include/MidiEventProcessor.h | 2 - include/NotePlayHandle.h | 4 - include/Plugin.h | 2 - include/RingBuffer.h | 2 - include/Track.h | 1 - include/ValueBuffer.h | 2 - plugins/BitInvader/BitInvader.h | 2 - plugins/FreeBoy/GbApuWrapper.h | 2 - plugins/GigPlayer/GigPlayer.h | 2 - plugins/Kicker/KickerOsc.h | 2 - plugins/LadspaEffect/LadspaEffect.cpp | 1 - plugins/Monstro/Monstro.h | 1 - plugins/Nes/Nes.h | 2 - plugins/Organic/Organic.h | 3 - plugins/Patman/Patman.h | 2 - plugins/Sf2Player/Sf2Player.h | 1 - plugins/Sfxr/Sfxr.h | 2 - plugins/Sid/SidInstrument.h | 1 - plugins/TripleOscillator/TripleOscillator.h | 3 - plugins/Vibed/StringContainer.h | 84 +++++++++++++++ plugins/Watsyn/Watsyn.h | 2 - plugins/Xpressive/ExprSynth.h | 2 - src/3rdparty/CMakeLists.txt | 1 - src/3rdparty/rpmalloc/CMakeLists.txt | 49 --------- src/CMakeLists.txt | 1 - src/core/AudioEngineWorkerThread.cpp | 2 - src/core/BufferManager.cpp | 1 - src/core/CMakeLists.txt | 1 - src/core/MemoryManager.cpp | 85 --------------- src/core/ProjectRenderer.cpp | 1 - 41 files changed, 84 insertions(+), 313 deletions(-) delete mode 100644 include/MemoryManager.h create mode 100644 plugins/Vibed/StringContainer.h delete mode 100644 src/3rdparty/rpmalloc/CMakeLists.txt delete mode 100644 src/core/MemoryManager.cpp diff --git a/include/AudioPort.h b/include/AudioPort.h index d9803d205e8..9e3ce2bd667 100644 --- a/include/AudioPort.h +++ b/include/AudioPort.h @@ -29,7 +29,6 @@ #include #include -#include "MemoryManager.h" #include "PlayHandle.h" namespace lmms @@ -41,7 +40,6 @@ class BoolModel; class AudioPort : public ThreadableJob { - MM_OPERATORS public: AudioPort( const QString & _name, bool _has_effect_chain = true, FloatModel * volumeModel = nullptr, FloatModel * panningModel = nullptr, diff --git a/include/AutomatableModel.h b/include/AutomatableModel.h index 2264a592eda..87adfdc6e7b 100644 --- a/include/AutomatableModel.h +++ b/include/AutomatableModel.h @@ -33,7 +33,6 @@ #include "Model.h" #include "TimePos.h" #include "ValueBuffer.h" -#include "MemoryManager.h" #include "ModelVisitor.h" @@ -77,7 +76,6 @@ class ControllerConnection; class LMMS_EXPORT AutomatableModel : public Model, public JournallingObject { Q_OBJECT - MM_OPERATORS public: using AutoModelVector = std::vector; diff --git a/include/BasicFilters.h b/include/BasicFilters.h index b994aecc6ec..4cde320a638 100644 --- a/include/BasicFilters.h +++ b/include/BasicFilters.h @@ -40,7 +40,6 @@ #include "lmms_basics.h" #include "lmms_constants.h" #include "interpolation.h" -#include "MemoryManager.h" namespace lmms { @@ -50,7 +49,6 @@ template class BasicFilters; template class LinkwitzRiley { - MM_OPERATORS public: LinkwitzRiley( float sampleRate ) { @@ -145,7 +143,6 @@ using StereoLinkwitzRiley = LinkwitzRiley<2>; template class BiQuad { - MM_OPERATORS public: BiQuad() { @@ -188,7 +185,6 @@ using StereoBiQuad = BiQuad<2>; template class OnePole { - MM_OPERATORS public: OnePole() { @@ -222,7 +218,6 @@ using StereoOnePole = OnePole<2>; template class BasicFilters { - MM_OPERATORS public: enum class FilterType { diff --git a/include/Clip.h b/include/Clip.h index 0b540ccfbf7..a520ad4e470 100644 --- a/include/Clip.h +++ b/include/Clip.h @@ -50,7 +50,6 @@ class TrackView; class LMMS_EXPORT Clip : public Model, public JournallingObject { Q_OBJECT - MM_OPERATORS mapPropertyFromModel(bool,isMuted,setMuted,m_mutedModel); mapPropertyFromModel(bool,isSolo,setSolo,m_soloModel); public: diff --git a/include/DataFile.h b/include/DataFile.h index 3f170622906..1da99cf9304 100644 --- a/include/DataFile.h +++ b/include/DataFile.h @@ -30,7 +30,6 @@ #include #include "lmms_export.h" -#include "MemoryManager.h" class QTextStream; @@ -42,7 +41,6 @@ class ProjectVersion; class LMMS_EXPORT DataFile : public QDomDocument { - MM_OPERATORS using UpgradeMethod = void(DataFile::*)(); diff --git a/include/Delay.h b/include/Delay.h index daa871baf4c..6e378d5a42e 100644 --- a/include/Delay.h +++ b/include/Delay.h @@ -29,7 +29,6 @@ #include "lmms_basics.h" #include "lmms_math.h" #include "interpolation.h" -#include "MemoryManager.h" namespace lmms { diff --git a/include/DetuningHelper.h b/include/DetuningHelper.h index e5d5f5712d5..da8eb598350 100644 --- a/include/DetuningHelper.h +++ b/include/DetuningHelper.h @@ -27,7 +27,6 @@ #define LMMS_DETUNING_HELPER_H #include "InlineAutomation.h" -#include "MemoryManager.h" namespace lmms { @@ -35,7 +34,6 @@ namespace lmms class DetuningHelper : public InlineAutomation { Q_OBJECT - MM_OPERATORS public: DetuningHelper() : InlineAutomation() diff --git a/include/Effect.h b/include/Effect.h index f2fb6e80f49..8b2ff81f0c4 100644 --- a/include/Effect.h +++ b/include/Effect.h @@ -31,7 +31,6 @@ #include "AudioEngine.h" #include "AutomatableModel.h" #include "TempoSyncKnobModel.h" -#include "MemoryManager.h" namespace lmms { @@ -49,7 +48,6 @@ class EffectView; class LMMS_EXPORT Effect : public Plugin { - MM_OPERATORS Q_OBJECT public: Effect( const Plugin::Descriptor * _desc, diff --git a/include/Instrument.h b/include/Instrument.h index f23e0b401f3..243bdba61f6 100644 --- a/include/Instrument.h +++ b/include/Instrument.h @@ -31,7 +31,6 @@ #include "Flags.h" #include "lmms_export.h" #include "lmms_basics.h" -#include "MemoryManager.h" #include "Plugin.h" #include "TimePos.h" @@ -47,7 +46,6 @@ class Track; class LMMS_EXPORT Instrument : public Plugin { - MM_OPERATORS public: enum class Flag { diff --git a/include/InstrumentTrack.h b/include/InstrumentTrack.h index 5efafe0c72b..3d84df5979a 100644 --- a/include/InstrumentTrack.h +++ b/include/InstrumentTrack.h @@ -60,7 +60,6 @@ class MidiCCRackView; class LMMS_EXPORT InstrumentTrack : public Track, public MidiEventProcessor { Q_OBJECT - MM_OPERATORS mapPropertyFromModel(int,getVolume,setVolume,m_volumeModel); public: InstrumentTrack( TrackContainer* tc ); diff --git a/include/MemoryManager.h b/include/MemoryManager.h deleted file mode 100644 index 38c77a31ddb..00000000000 --- a/include/MemoryManager.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * MemoryManager.h - * - * Copyright (c) 2017 Lukas W - * Copyright (c) 2014 Vesa Kivimäki - * Copyright (c) 2007-2014 Tobias Doerffel - * - * 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_MEMORY_MANAGER_H -#define LMMS_MEMORY_MANAGER_H - -#include -#include - -#include "lmms_export.h" - -namespace lmms -{ - - -class LMMS_EXPORT MemoryManager -{ -public: - //struct ThreadGuard - //{ - // ThreadGuard(); - // ~ThreadGuard(); - //}; - - static void * alloc( size_t size ); - static void free( void * ptr ); -}; - -template -struct MmAllocator -{ - using value_type = T; - template struct rebind { - using other = MmAllocator; - }; - - T* allocate( std::size_t n ) - { - return reinterpret_cast( MemoryManager::alloc( sizeof(T) * n ) ); - } - - void deallocate( T* p, std::size_t ) - { - MemoryManager::free( p ); - } - - using vector = std::vector>; -}; - - -#define MM_OPERATORS \ -public: \ -static void * operator new ( size_t size ) \ -{ \ - return MemoryManager::alloc( size ); \ -} \ -static void * operator new[] ( size_t size ) \ -{ \ - return MemoryManager::alloc( size ); \ -} \ -static void operator delete ( void * ptr ) \ -{ \ - MemoryManager::free( ptr ); \ -} \ -static void operator delete[] ( void * ptr ) \ -{ \ - MemoryManager::free( ptr ); \ -} - -// for use in cases where overriding new/delete isn't a possibility -template -T* MM_ALLOC(size_t count) -{ - return reinterpret_cast( - MemoryManager::alloc(sizeof(T) * count)); -} - -// and just for symmetry... -template -void MM_FREE(T* ptr) -{ - MemoryManager::free(ptr); -} - - -} // namespace lmms - -#endif // LMMS_MEMORY_MANAGER_H diff --git a/include/MidiEventProcessor.h b/include/MidiEventProcessor.h index 1c45b3e3f5b..0fcb9610ead 100644 --- a/include/MidiEventProcessor.h +++ b/include/MidiEventProcessor.h @@ -26,7 +26,6 @@ #define LMMS_MIDI_EVENT_PROCESSOR_H #include "MidiEvent.h" -#include "MemoryManager.h" #include "TimePos.h" namespace lmms @@ -35,7 +34,6 @@ namespace lmms // all classes being able to process MIDI-events should inherit from this class MidiEventProcessor { - MM_OPERATORS public: MidiEventProcessor() = default; diff --git a/include/NotePlayHandle.h b/include/NotePlayHandle.h index 7105d6672cd..f70268132f8 100644 --- a/include/NotePlayHandle.h +++ b/include/NotePlayHandle.h @@ -32,7 +32,6 @@ #include "Note.h" #include "PlayHandle.h" #include "Track.h" -#include "MemoryManager.h" class QReadWriteLock; @@ -47,7 +46,6 @@ using ConstNotePlayHandleList = QList; class LMMS_EXPORT NotePlayHandle : public PlayHandle, public Note { - MM_OPERATORS public: void * m_pluginData; std::unique_ptr> m_filter; @@ -273,7 +271,6 @@ class LMMS_EXPORT NotePlayHandle : public PlayHandle, public Note private: class BaseDetuning { - MM_OPERATORS public: BaseDetuning( DetuningHelper* detuning ); @@ -341,7 +338,6 @@ const int NPH_CACHE_INCREMENT = 16; class NotePlayHandleManager { - MM_OPERATORS public: static void init(); static NotePlayHandle * acquire( InstrumentTrack* instrumentTrack, diff --git a/include/Plugin.h b/include/Plugin.h index 439dd95ad16..100e9f658eb 100644 --- a/include/Plugin.h +++ b/include/Plugin.h @@ -30,7 +30,6 @@ #include "JournallingObject.h" #include "Model.h" -#include "MemoryManager.h" class QWidget; @@ -71,7 +70,6 @@ class PluginView; */ class LMMS_EXPORT Plugin : public Model, public JournallingObject { - MM_OPERATORS Q_OBJECT public: enum class Type diff --git a/include/RingBuffer.h b/include/RingBuffer.h index 90a607a13a5..4626a8ae672 100644 --- a/include/RingBuffer.h +++ b/include/RingBuffer.h @@ -29,7 +29,6 @@ #include #include #include "lmms_basics.h" -#include "MemoryManager.h" namespace lmms @@ -41,7 +40,6 @@ namespace lmms class LMMS_EXPORT RingBuffer : public QObject { Q_OBJECT - MM_OPERATORS public: /** \brief Constructs a ringbuffer of specified size, will not care about samplerate changes * \param size The size of the buffer in frames. The actual size will be size + period size diff --git a/include/Track.h b/include/Track.h index 1c161984f00..b801bb1828b 100644 --- a/include/Track.h +++ b/include/Track.h @@ -67,7 +67,6 @@ char const *const FILENAME_FILTER = "[\\0000-\x1f\"*/:<>?\\\\|\x7f]"; class LMMS_EXPORT Track : public Model, public JournallingObject { Q_OBJECT - MM_OPERATORS mapPropertyFromModel(bool,isMuted,setMuted,m_mutedModel); mapPropertyFromModel(bool,isSolo,setSolo,m_soloModel); public: diff --git a/include/ValueBuffer.h b/include/ValueBuffer.h index 683d17fb1ff..33d93cde02b 100644 --- a/include/ValueBuffer.h +++ b/include/ValueBuffer.h @@ -28,7 +28,6 @@ #include -#include "MemoryManager.h" #include "lmms_export.h" namespace lmms @@ -37,7 +36,6 @@ namespace lmms class LMMS_EXPORT ValueBuffer : public std::vector { - MM_OPERATORS public: ValueBuffer() = default; ValueBuffer(int length); diff --git a/plugins/BitInvader/BitInvader.h b/plugins/BitInvader/BitInvader.h index a08640e998b..6dce9db8315 100644 --- a/plugins/BitInvader/BitInvader.h +++ b/plugins/BitInvader/BitInvader.h @@ -31,7 +31,6 @@ #include "Instrument.h" #include "InstrumentView.h" #include "Graph.h" -#include "MemoryManager.h" namespace lmms { @@ -48,7 +47,6 @@ class PixmapButton; class BSynth { - MM_OPERATORS public: BSynth( float * sample, NotePlayHandle * _nph, bool _interpolation, float factor, diff --git a/plugins/FreeBoy/GbApuWrapper.h b/plugins/FreeBoy/GbApuWrapper.h index 493a2873153..3b95869d579 100644 --- a/plugins/FreeBoy/GbApuWrapper.h +++ b/plugins/FreeBoy/GbApuWrapper.h @@ -26,7 +26,6 @@ #include "Gb_Apu.h" #include "Multi_Buffer.h" -#include "MemoryManager.h" namespace lmms { @@ -34,7 +33,6 @@ namespace lmms class GbApuWrapper : private Gb_Apu { - MM_OPERATORS public: GbApuWrapper() = default; ~GbApuWrapper() = default; diff --git a/plugins/GigPlayer/GigPlayer.h b/plugins/GigPlayer/GigPlayer.h index e5039f109be..986018654a7 100644 --- a/plugins/GigPlayer/GigPlayer.h +++ b/plugins/GigPlayer/GigPlayer.h @@ -38,7 +38,6 @@ #include "Knob.h" #include "LcdSpinBox.h" #include "LedCheckBox.h" -#include "MemoryManager.h" #include "gig.h" @@ -236,7 +235,6 @@ class GigNote class GigInstrument : public Instrument { Q_OBJECT - MM_OPERATORS mapPropertyFromModel( int, getBank, setBank, m_bankNum ); mapPropertyFromModel( int, getPatch, setPatch, m_patchNum ); diff --git a/plugins/Kicker/KickerOsc.h b/plugins/Kicker/KickerOsc.h index 1accb50a44c..69436c5fc9d 100644 --- a/plugins/Kicker/KickerOsc.h +++ b/plugins/Kicker/KickerOsc.h @@ -31,7 +31,6 @@ #include "lmms_math.h" #include "interpolation.h" -#include "MemoryManager.h" namespace lmms { @@ -40,7 +39,6 @@ namespace lmms template class KickerOsc { - MM_OPERATORS public: KickerOsc( const FX & fx, const float start, const float end, const float noise, const float offset, const float slope, const float env, const float diststart, const float distend, const float length ) : diff --git a/plugins/LadspaEffect/LadspaEffect.cpp b/plugins/LadspaEffect/LadspaEffect.cpp index cc754a82962..645249c3079 100644 --- a/plugins/LadspaEffect/LadspaEffect.cpp +++ b/plugins/LadspaEffect/LadspaEffect.cpp @@ -36,7 +36,6 @@ #include "LadspaControl.h" #include "LadspaSubPluginFeatures.h" #include "AutomationClip.h" -#include "MemoryManager.h" #include "ValueBuffer.h" #include "Song.h" diff --git a/plugins/Monstro/Monstro.h b/plugins/Monstro/Monstro.h index 21efedaf314..919409b2de5 100644 --- a/plugins/Monstro/Monstro.h +++ b/plugins/Monstro/Monstro.h @@ -173,7 +173,6 @@ class ComboBox; class MonstroSynth { - MM_OPERATORS public: MonstroSynth( MonstroInstrument * _i, NotePlayHandle * _nph ); virtual ~MonstroSynth() = default; diff --git a/plugins/Nes/Nes.h b/plugins/Nes/Nes.h index b4102f31d10..a05b3a2f85c 100644 --- a/plugins/Nes/Nes.h +++ b/plugins/Nes/Nes.h @@ -31,7 +31,6 @@ #include "InstrumentView.h" #include "AutomatableModel.h" #include "PixmapButton.h" -#include "MemoryManager.h" #define makeknob( name, x, y, hint, unit, oname ) \ @@ -92,7 +91,6 @@ class NesInstrumentView; class NesObject { - MM_OPERATORS public: NesObject( NesInstrument * nes, const sample_rate_t samplerate, NotePlayHandle * nph ); virtual ~NesObject() = default; diff --git a/plugins/Organic/Organic.h b/plugins/Organic/Organic.h index a46b7882ffa..e50550e5e2d 100644 --- a/plugins/Organic/Organic.h +++ b/plugins/Organic/Organic.h @@ -84,7 +84,6 @@ const float CENT = 1.0f / 1200.0f; class OscillatorObject : public Model { Q_OBJECT - MM_OPERATORS private: int m_numOscillators; IntModel m_waveShape; @@ -159,7 +158,6 @@ public slots: struct oscPtr { - MM_OPERATORS Oscillator * oscLeft; Oscillator * oscRight; float phaseOffsetLeft[NUM_OSCILLATORS]; @@ -196,7 +194,6 @@ class OrganicInstrumentView : public InstrumentViewFixedSize struct OscillatorKnobs { - MM_OPERATORS OscillatorKnobs( Knob * h, Knob * v, diff --git a/plugins/Patman/Patman.h b/plugins/Patman/Patman.h index 8d2c8c6577b..486524522d4 100644 --- a/plugins/Patman/Patman.h +++ b/plugins/Patman/Patman.h @@ -31,7 +31,6 @@ #include "Sample.h" #include "SampleBuffer.h" #include "AutomatableModel.h" -#include "MemoryManager.h" namespace lmms { @@ -87,7 +86,6 @@ public slots: private: struct handle_data { - MM_OPERATORS Sample::PlaybackState* state; bool tuned; std::shared_ptr sample; diff --git a/plugins/Sf2Player/Sf2Player.h b/plugins/Sf2Player/Sf2Player.h index 17ddf550037..1af370e05eb 100644 --- a/plugins/Sf2Player/Sf2Player.h +++ b/plugins/Sf2Player/Sf2Player.h @@ -34,7 +34,6 @@ #include "Instrument.h" #include "InstrumentView.h" #include "LcdSpinBox.h" -#include "MemoryManager.h" class QLabel; diff --git a/plugins/Sfxr/Sfxr.h b/plugins/Sfxr/Sfxr.h index edec0ba6f00..8af8984c953 100644 --- a/plugins/Sfxr/Sfxr.h +++ b/plugins/Sfxr/Sfxr.h @@ -31,7 +31,6 @@ #include "AutomatableModel.h" #include "Instrument.h" #include "InstrumentView.h" -#include "MemoryManager.h" namespace lmms { @@ -78,7 +77,6 @@ class SfxrInstrumentView; class SfxrSynth { - MM_OPERATORS public: SfxrSynth( const SfxrInstrument * s ); virtual ~SfxrSynth() = default; diff --git a/plugins/Sid/SidInstrument.h b/plugins/Sid/SidInstrument.h index 53efa8942f7..1a133b58b1b 100644 --- a/plugins/Sid/SidInstrument.h +++ b/plugins/Sid/SidInstrument.h @@ -48,7 +48,6 @@ class PixmapButton; class VoiceObject : public Model { Q_OBJECT - MM_OPERATORS public: enum class WaveForm { Square = 0, diff --git a/plugins/TripleOscillator/TripleOscillator.h b/plugins/TripleOscillator/TripleOscillator.h index c0258b5448b..4b6d97835e9 100644 --- a/plugins/TripleOscillator/TripleOscillator.h +++ b/plugins/TripleOscillator/TripleOscillator.h @@ -57,7 +57,6 @@ const int NUM_OF_OSCILLATORS = 3; class OscillatorObject : public Model { - MM_OPERATORS Q_OBJECT public: OscillatorObject( Model * _parent, int _idx ); @@ -139,7 +138,6 @@ protected slots: struct oscPtr { - MM_OPERATORS Oscillator * oscLeft; Oscillator * oscRight; } ; @@ -170,7 +168,6 @@ class TripleOscillatorView : public InstrumentViewFixedSize struct OscillatorKnobs { - MM_OPERATORS OscillatorKnobs( Knob * v, Knob * p, Knob * c, diff --git a/plugins/Vibed/StringContainer.h b/plugins/Vibed/StringContainer.h new file mode 100644 index 00000000000..27ed8bb7f45 --- /dev/null +++ b/plugins/Vibed/StringContainer.h @@ -0,0 +1,84 @@ +/* StringContainer.h - contains a collection of strings + * + * Copyright (c) 2006 Danny McRae + * + * 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 _STRING_CONTAINER_H +#define _STRING_CONTAINER_H + +#include + +#include "VibratingString.h" + +namespace lmms +{ + + +class StringContainer +{ +public: + StringContainer(const float _pitch, + const sample_rate_t _sample_rate, + const int _buffer_length, + const int _strings = 9 ); + + void addString( int _harm, + const float _pick, + const float _pickup, + const float * _impluse, + const float _randomize, + const float _string_loss, + const float _detune, + const int _oversample, + const bool _state, + const int _id ); + + bool exists( int _id ) const + { + return m_exists[_id]; + } + + ~StringContainer() + { + int strings = m_strings.count(); + for( int i = 0; i < strings; i++ ) + { + delete m_strings[i]; + } + } + + float getStringSample( int _string ) + { + return m_strings[_string]->nextSample(); + } + +private: + QVector m_strings; + const float m_pitch; + const sample_rate_t m_sampleRate; + const int m_bufferLength; + QVector m_exists; +} ; + + +} // namespace lmms + +#endif diff --git a/plugins/Watsyn/Watsyn.h b/plugins/Watsyn/Watsyn.h index 3a736e1621f..d238edbdea6 100644 --- a/plugins/Watsyn/Watsyn.h +++ b/plugins/Watsyn/Watsyn.h @@ -32,7 +32,6 @@ #include "AutomatableModel.h" #include "TempoSyncKnob.h" #include -#include "MemoryManager.h" namespace lmms { @@ -88,7 +87,6 @@ class WatsynView; class WatsynObject { - MM_OPERATORS public: WatsynObject( float * _A1wave, float * _A2wave, float * _B1wave, float * _B2wave, diff --git a/plugins/Xpressive/ExprSynth.h b/plugins/Xpressive/ExprSynth.h index f338b78fc38..5d664c85e6d 100644 --- a/plugins/Xpressive/ExprSynth.h +++ b/plugins/Xpressive/ExprSynth.h @@ -30,7 +30,6 @@ #include #include "AutomatableModel.h" #include "Graph.h" -#include "MemoryManager.h" namespace lmms { @@ -102,7 +101,6 @@ class WaveSample class ExprSynth { - MM_OPERATORS public: ExprSynth(const WaveSample* gW1, const WaveSample* gW2, const WaveSample* gW3, ExprFront* exprO1, ExprFront* exprO2, NotePlayHandle* nph, const sample_rate_t sample_rate, const FloatModel* pan1, const FloatModel* pan2, float rel_trans); diff --git a/src/3rdparty/CMakeLists.txt b/src/3rdparty/CMakeLists.txt index a95332a0754..f1578a9703e 100644 --- a/src/3rdparty/CMakeLists.txt +++ b/src/3rdparty/CMakeLists.txt @@ -4,7 +4,6 @@ IF(LMMS_BUILD_LINUX AND WANT_VST) ENDIF() ADD_SUBDIRECTORY(hiir) -ADD_SUBDIRECTORY(rpmalloc) ADD_SUBDIRECTORY(weakjack) if(MINGW) diff --git a/src/3rdparty/rpmalloc/CMakeLists.txt b/src/3rdparty/rpmalloc/CMakeLists.txt deleted file mode 100644 index 047c32678c2..00000000000 --- a/src/3rdparty/rpmalloc/CMakeLists.txt +++ /dev/null @@ -1,49 +0,0 @@ -add_library(rpmalloc STATIC - rpmalloc/rpmalloc/rpmalloc.c - rpmalloc/rpmalloc/rpmalloc.h -) - -target_include_directories(rpmalloc PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/rpmalloc/rpmalloc -) - -set_property(TARGET rpmalloc PROPERTY C_STANDARD 11) - -IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") - target_compile_options(rpmalloc - PRIVATE -Wno-unused-variable - ) -endif() - -if (NOT LMMS_BUILD_WIN32) - target_compile_definitions(rpmalloc - PRIVATE -D_GNU_SOURCE - ) -endif() - -if(MINGW) - target_compile_definitions(rpmalloc - PRIVATE -D_WIN32_WINNT=0x600 - ) -endif() - -if (CMAKE_BUILD_TYPE STREQUAL "Debug") - # rpmalloc uses GCC builtin "__builtin_umull_overflow" with ENABLE_VALIDATE_ARGS, - # which is only available starting with GCC 5 - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 5) - set(ENABLE_VALIDATE_ARGS OFF) - else () - set(ENABLE_VALIDATE_ARGS ON) - endif() - target_compile_definitions(rpmalloc - PRIVATE -DENABLE_ASSERTS=1 -DENABLE_VALIDATE_ARGS=${ENABLE_VALIDATE_ARGS} - ) -endif() - -option(LMMS_ENABLE_MALLOC_STATS "Enables statistics for rpmalloc" OFF) - -if (LMMS_ENABLE_MALLOC_STATS) - target_compile_definitions(rpmalloc - PRIVATE -DENABLE_STATISTICS=1 - ) -endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d55a725dd51..d71b34c5944 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -186,7 +186,6 @@ SET(LMMS_REQUIRED_LIBS ${LMMS_REQUIRED_LIBS} ${SUIL_LIBRARIES} ${LILV_LIBRARIES} ${FFTW3F_LIBRARIES} - rpmalloc SampleRate::samplerate SndFile::sndfile ${EXTRA_LIBRARIES} diff --git a/src/core/AudioEngineWorkerThread.cpp b/src/core/AudioEngineWorkerThread.cpp index 288a663d13d..ae459c5e484 100644 --- a/src/core/AudioEngineWorkerThread.cpp +++ b/src/core/AudioEngineWorkerThread.cpp @@ -30,7 +30,6 @@ #include "denormals.h" #include "AudioEngine.h" -#include "MemoryManager.h" #include "ThreadableJob.h" #if __SSE__ @@ -167,7 +166,6 @@ void AudioEngineWorkerThread::startAndWaitForJobs() void AudioEngineWorkerThread::run() { - //MemoryManager::ThreadGuard mmThreadGuard; Q_UNUSED(mmThreadGuard); disable_denormals(); QMutex m; diff --git a/src/core/BufferManager.cpp b/src/core/BufferManager.cpp index ff35e6a194e..126d8dbe5ba 100644 --- a/src/core/BufferManager.cpp +++ b/src/core/BufferManager.cpp @@ -28,7 +28,6 @@ #include -#include "MemoryManager.h" namespace lmms { diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 26d458f9e76..1a4871fc72b 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -39,7 +39,6 @@ set(LMMS_SRCS core/LinkedModelGroups.cpp core/LocklessAllocator.cpp core/MemoryHelper.cpp - core/MemoryManager.cpp core/MeterModel.cpp core/MicroTimer.cpp core/Microtuner.cpp diff --git a/src/core/MemoryManager.cpp b/src/core/MemoryManager.cpp deleted file mode 100644 index e480e4a4905..00000000000 --- a/src/core/MemoryManager.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * MemoryManager.cpp - * - * Copyright (c) 2017 Lukas W - * - * 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. - * - */ - - -#include "MemoryManager.h" -#include - -//#include -//#include "rpmalloc.h" - -namespace lmms -{ - - -/// Global static object handling rpmalloc intializing and finalizing -//struct MemoryManagerGlobalGuard { -// MemoryManagerGlobalGuard() { -// rpmalloc_initialize(); -// } -// ~MemoryManagerGlobalGuard() { -// rpmalloc_finalize(); -// } -//} static mm_global_guard; - - -//namespace { -//static thread_local size_t thread_guard_depth; -//} - -//MemoryManager::ThreadGuard::ThreadGuard() -//{ -// if (thread_guard_depth++ == 0) { -// rpmalloc_thread_initialize(); -// } -//} - -//MemoryManager::ThreadGuard::~ThreadGuard() -//{ -// if (--thread_guard_depth == 0) { -// rpmalloc_thread_finalize(true); -// } -//} - -//static thread_local MemoryManager::ThreadGuard local_mm_thread_guard{}; - -void* MemoryManager::alloc(size_t size) -{ - // Reference local thread guard to ensure it is initialized. - // Compilers may optimize the instance away otherwise. - //Q_UNUSED(&local_mm_thread_guard); - //Q_ASSERT_X(rpmalloc_is_thread_initialized(), "MemoryManager::alloc", "Thread not initialized"); - return std::malloc(size); -} - - -void MemoryManager::free(void * ptr) -{ - //Q_UNUSED(&local_mm_thread_guard); - //Q_ASSERT_X(rpmalloc_is_thread_initialized(), "MemoryManager::free", "Thread not initialized"); - return std::free(ptr); -} - - -} // namespace lmms diff --git a/src/core/ProjectRenderer.cpp b/src/core/ProjectRenderer.cpp index c704c0b09b9..3d83515f22e 100644 --- a/src/core/ProjectRenderer.cpp +++ b/src/core/ProjectRenderer.cpp @@ -159,7 +159,6 @@ void ProjectRenderer::startProcessing() void ProjectRenderer::run() { - //MemoryManager::ThreadGuard mmThreadGuard; Q_UNUSED(mmThreadGuard); #if 0 #if defined(LMMS_BUILD_LINUX) || defined(LMMS_BUILD_FREEBSD) #ifdef LMMS_HAVE_SCHED_H From 18bbc05b6aeddbfe591d7750cf21a340b18529a1 Mon Sep 17 00:00:00 2001 From: Jonah Janzen Date: Sat, 24 Feb 2024 19:04:45 -0700 Subject: [PATCH 04/15] Update wiki --- doc/wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/wiki b/doc/wiki index 48d20dc9311..c9b21bde384 160000 --- a/doc/wiki +++ b/doc/wiki @@ -1 +1 @@ -Subproject commit 48d20dc93111c24175b767301d6fe4074e632aee +Subproject commit c9b21bde3845b20cbb96aa9ece7774f15f3ffacf From 00734d5777866bab4c278dd39c70a747d63cedb6 Mon Sep 17 00:00:00 2001 From: Jonah Janzen Date: Sat, 24 Feb 2024 19:53:04 -0700 Subject: [PATCH 05/15] Remove references to MM_ALLOC and MM_FREE Simply replaced MM_ALLOC with new[] and MM_FREE with delete[]. As a side note, the situation in NotePlayHandle::extend looks like a possible memory leak. --- include/Delay.h | 40 +++++++++++++-------------- plugins/Bitcrush/Bitcrush.cpp | 4 +-- plugins/CrossoverEQ/CrossoverEQ.cpp | 12 ++++---- plugins/LadspaEffect/LadspaEffect.cpp | 12 ++++---- plugins/MultitapEcho/MultitapEcho.cpp | 4 +-- src/core/BufferManager.cpp | 4 +-- src/core/NotePlayHandle.cpp | 12 ++++---- 7 files changed, 44 insertions(+), 44 deletions(-) diff --git a/include/Delay.h b/include/Delay.h index 6e378d5a42e..cfc950f2f4c 100644 --- a/include/Delay.h +++ b/include/Delay.h @@ -73,20 +73,20 @@ class CombFeedback m_delay( 0 ), m_fraction( 0.0 ) { - m_buffer = MM_ALLOC(maxDelay ); + m_buffer = new frame[maxDelay]; memset( m_buffer, 0, sizeof( frame ) * maxDelay ); } virtual ~CombFeedback() { - MM_FREE( m_buffer ); + delete[] m_buffer; } inline void setMaxDelay( int maxDelay ) { if( maxDelay > m_size ) { - MM_FREE( m_buffer ); - m_buffer = MM_ALLOC( maxDelay ); + delete[] m_buffer; + m_buffer = new frame[maxDelay]; memset( m_buffer, 0, sizeof( frame ) * maxDelay ); } m_size = maxDelay; @@ -97,7 +97,7 @@ class CombFeedback { memset( m_buffer, 0, sizeof( frame ) * m_size ); } - + inline void setDelay( double delay ) { m_delay = static_cast( ceil( delay ) ); @@ -144,20 +144,20 @@ class CombFeedfwd m_delay( 0 ), m_fraction( 0.0 ) { - m_buffer = MM_ALLOC( maxDelay ); + m_buffer = new frame[maxDelay]; memset( m_buffer, 0, sizeof( frame ) * maxDelay ); } virtual ~CombFeedfwd() { - MM_FREE( m_buffer ); + delete[] m_buffer; } inline void setMaxDelay( int maxDelay ) { if( maxDelay > m_size ) { - MM_FREE( m_buffer ); - m_buffer = MM_ALLOC( maxDelay ); + delete[] m_buffer; + m_buffer = new frame[maxDelay]; memset( m_buffer, 0, sizeof( frame ) * maxDelay ); } m_size = maxDelay; @@ -168,7 +168,7 @@ class CombFeedfwd { memset( m_buffer, 0, sizeof( frame ) * m_size ); } - + inline void setDelay( double delay ) { m_delay = static_cast( ceil( delay ) ); @@ -215,20 +215,20 @@ class CombFeedbackDualtap m_delay( 0 ), m_fraction( 0.0 ) { - m_buffer = MM_ALLOC( maxDelay ); + m_buffer = new frame[maxDelay]; memset( m_buffer, 0, sizeof( frame ) * maxDelay ); } virtual ~CombFeedbackDualtap() { - MM_FREE( m_buffer ); + delete[] m_buffer; } inline void setMaxDelay( int maxDelay ) { if( maxDelay > m_size ) { - MM_FREE( m_buffer ); - m_buffer = MM_ALLOC( maxDelay ); + delete[] m_buffer; + m_buffer = new frame[maxDelay]; memset( m_buffer, 0, sizeof( frame ) * maxDelay ); } m_size = maxDelay; @@ -239,7 +239,7 @@ class CombFeedbackDualtap { memset( m_buffer, 0, sizeof( frame ) * m_size ); } - + inline void setDelays( double delay1, double delay2 ) { m_delay1 = static_cast( ceil( delay1 ) ); @@ -296,26 +296,26 @@ class AllpassDelay m_delay( 0 ), m_fraction( 0.0 ) { - m_buffer = MM_ALLOC( maxDelay ); + m_buffer = new frame[maxDelay]; memset( m_buffer, 0, sizeof( frame ) * maxDelay ); } virtual ~AllpassDelay() { - MM_FREE( m_buffer ); + delete[] m_buffer; } inline void setMaxDelay( int maxDelay ) { if( maxDelay > m_size ) { - MM_FREE( m_buffer ); - m_buffer = MM_ALLOC( maxDelay ); + delete[] m_buffer; + m_buffer = new frame[maxDelay]; memset( m_buffer, 0, sizeof( frame ) * maxDelay ); } m_size = maxDelay; m_position %= m_size; } - + inline void clearHistory() { memset( m_buffer, 0, sizeof( frame ) * m_size ); diff --git a/plugins/Bitcrush/Bitcrush.cpp b/plugins/Bitcrush/Bitcrush.cpp index 8d29186b5e7..df4a8605dd8 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()->processingSampleRate() ), m_filter( m_sampleRate ) { - m_buffer = MM_ALLOC( 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; @@ -77,7 +77,7 @@ BitcrushEffect::BitcrushEffect( Model * parent, const Descriptor::SubPluginFeatu BitcrushEffect::~BitcrushEffect() { - MM_FREE( m_buffer ); + delete[] m_buffer; } diff --git a/plugins/CrossoverEQ/CrossoverEQ.cpp b/plugins/CrossoverEQ/CrossoverEQ.cpp index c4334677cb4..4dca94a4ccd 100644 --- a/plugins/CrossoverEQ/CrossoverEQ.cpp +++ b/plugins/CrossoverEQ/CrossoverEQ.cpp @@ -64,16 +64,16 @@ CrossoverEQEffect::CrossoverEQEffect( Model* parent, const Descriptor::SubPlugin m_hp4( m_sampleRate ), m_needsUpdate( true ) { - m_tmp1 = MM_ALLOC( Engine::audioEngine()->framesPerPeriod() ); - m_tmp2 = MM_ALLOC( Engine::audioEngine()->framesPerPeriod() ); - m_work = MM_ALLOC( 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() { - MM_FREE( m_tmp1 ); - MM_FREE( m_tmp2 ); - MM_FREE( m_work ); + delete[] m_tmp1; + delete[] m_tmp2; + delete[] m_work; } void CrossoverEQEffect::sampleRateChanged() diff --git a/plugins/LadspaEffect/LadspaEffect.cpp b/plugins/LadspaEffect/LadspaEffect.cpp index 645249c3079..837bd554c2b 100644 --- a/plugins/LadspaEffect/LadspaEffect.cpp +++ b/plugins/LadspaEffect/LadspaEffect.cpp @@ -325,7 +325,7 @@ void LadspaEffect::pluginInstantiation() manager->isPortInput( m_key, port ) ) { p->rate = BufferRate::ChannelIn; - p->buffer = MM_ALLOC( Engine::audioEngine()->framesPerPeriod() ); + p->buffer = new LADSPA_Data[Engine::audioEngine()->framesPerPeriod()]; inbuf[ inputch ] = p->buffer; inputch++; } @@ -340,24 +340,24 @@ void LadspaEffect::pluginInstantiation() } else { - p->buffer = MM_ALLOC( Engine::audioEngine()->framesPerPeriod() ); + p->buffer = new LADSPA_Data[Engine::audioEngine()->framesPerPeriod()]; m_inPlaceBroken = true; } } else if( manager->isPortInput( m_key, port ) ) { p->rate = BufferRate::AudioRateInput; - p->buffer = MM_ALLOC( Engine::audioEngine()->framesPerPeriod() ); + p->buffer = new LADSPA_Data[Engine::audioEngine()->framesPerPeriod()]; } else { p->rate = BufferRate::AudioRateOutput; - p->buffer = MM_ALLOC( Engine::audioEngine()->framesPerPeriod() ); + p->buffer = new LADSPA_Data[Engine::audioEngine()->framesPerPeriod()]; } } else { - p->buffer = MM_ALLOC( 1 ); + p->buffer = new LADSPA_Data[1]; if( manager->isPortInput( m_key, port ) ) { @@ -556,7 +556,7 @@ void LadspaEffect::pluginDestruction() port_desc_t * pp = m_ports.at( proc ).at( port ); if( m_inPlaceBroken || pp->rate != BufferRate::ChannelOut ) { - if( pp->buffer) MM_FREE( pp->buffer ); + if( pp->buffer) delete[] pp->buffer; } delete pp; } diff --git a/plugins/MultitapEcho/MultitapEcho.cpp b/plugins/MultitapEcho/MultitapEcho.cpp index 4f5e9fdf8b3..ff3ca828a27 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()->processingSampleRate() ), m_sampleRatio( 1.0f / m_sampleRate ) { - m_work = MM_ALLOC( 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 ); @@ -67,7 +67,7 @@ MultitapEchoEffect::MultitapEchoEffect( Model* parent, const Descriptor::SubPlug MultitapEchoEffect::~MultitapEchoEffect() { - MM_FREE( m_work ); + delete[] m_work; } diff --git a/src/core/BufferManager.cpp b/src/core/BufferManager.cpp index 126d8dbe5ba..2362be85a3d 100644 --- a/src/core/BufferManager.cpp +++ b/src/core/BufferManager.cpp @@ -42,7 +42,7 @@ void BufferManager::init( fpp_t fpp ) sampleFrame * BufferManager::acquire() { - return MM_ALLOC( s_framesPerPeriod ); + return new sampleFrame[s_framesPerPeriod]; } void BufferManager::clear( sampleFrame *ab, const f_cnt_t frames, const f_cnt_t offset ) @@ -61,7 +61,7 @@ void BufferManager::clear( surroundSampleFrame * ab, const f_cnt_t frames, void BufferManager::release( sampleFrame * buf ) { - MM_FREE( buf ); + delete[] buf; } } // namespace lmms diff --git a/src/core/NotePlayHandle.cpp b/src/core/NotePlayHandle.cpp index 712b64e8917..2c1c2193161 100644 --- a/src/core/NotePlayHandle.cpp +++ b/src/core/NotePlayHandle.cpp @@ -610,9 +610,9 @@ int NotePlayHandleManager::s_size; void NotePlayHandleManager::init() { - s_available = MM_ALLOC( INITIAL_NPH_CACHE ); + s_available = new NotePlayHandle*[INITIAL_NPH_CACHE]; - auto n = MM_ALLOC(INITIAL_NPH_CACHE); + auto n = static_cast(std::malloc(sizeof(NotePlayHandle) * INITIAL_NPH_CACHE)); for( int i=0; i < INITIAL_NPH_CACHE; ++i ) { @@ -655,11 +655,11 @@ void NotePlayHandleManager::release( NotePlayHandle * nph ) void NotePlayHandleManager::extend( int c ) { s_size += c; - auto tmp = MM_ALLOC(s_size); - MM_FREE( s_available ); + auto tmp = new NotePlayHandle*[s_size]; + delete[] s_available; s_available = tmp; - auto n = MM_ALLOC(c); + auto n = static_cast(std::malloc(sizeof(NotePlayHandle) * c)); for( int i=0; i < c; ++i ) { @@ -670,7 +670,7 @@ void NotePlayHandleManager::extend( int c ) void NotePlayHandleManager::free() { - MM_FREE(s_available); + delete[] s_available; } From c9e456bbe325595b645103f98fa081b03f1acac3 Mon Sep 17 00:00:00 2001 From: Jonah Janzen Date: Sat, 24 Feb 2024 20:08:09 -0700 Subject: [PATCH 06/15] Fix headers --- include/DataFile.h | 1 + include/RingBuffer.h | 1 + 2 files changed, 2 insertions(+) diff --git a/include/DataFile.h b/include/DataFile.h index 1da99cf9304..1f191ecb94b 100644 --- a/include/DataFile.h +++ b/include/DataFile.h @@ -28,6 +28,7 @@ #include #include +#include #include "lmms_export.h" diff --git a/include/RingBuffer.h b/include/RingBuffer.h index 4626a8ae672..98f72647593 100644 --- a/include/RingBuffer.h +++ b/include/RingBuffer.h @@ -29,6 +29,7 @@ #include #include #include "lmms_basics.h" +#include "lmms_export.h" namespace lmms From 325c5cc23b42ab17b9f209b36d063a209f9af0a3 Mon Sep 17 00:00:00 2001 From: Jonah Janzen Date: Sat, 24 Feb 2024 20:39:21 -0700 Subject: [PATCH 07/15] Fix rebase issue --- plugins/Vibed/StringContainer.h | 84 --------------------------------- 1 file changed, 84 deletions(-) delete mode 100644 plugins/Vibed/StringContainer.h diff --git a/plugins/Vibed/StringContainer.h b/plugins/Vibed/StringContainer.h deleted file mode 100644 index 27ed8bb7f45..00000000000 --- a/plugins/Vibed/StringContainer.h +++ /dev/null @@ -1,84 +0,0 @@ -/* StringContainer.h - contains a collection of strings - * - * Copyright (c) 2006 Danny McRae - * - * 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 _STRING_CONTAINER_H -#define _STRING_CONTAINER_H - -#include - -#include "VibratingString.h" - -namespace lmms -{ - - -class StringContainer -{ -public: - StringContainer(const float _pitch, - const sample_rate_t _sample_rate, - const int _buffer_length, - const int _strings = 9 ); - - void addString( int _harm, - const float _pick, - const float _pickup, - const float * _impluse, - const float _randomize, - const float _string_loss, - const float _detune, - const int _oversample, - const bool _state, - const int _id ); - - bool exists( int _id ) const - { - return m_exists[_id]; - } - - ~StringContainer() - { - int strings = m_strings.count(); - for( int i = 0; i < strings; i++ ) - { - delete m_strings[i]; - } - } - - float getStringSample( int _string ) - { - return m_strings[_string]->nextSample(); - } - -private: - QVector m_strings; - const float m_pitch; - const sample_rate_t m_sampleRate; - const int m_bufferLength; - QVector m_exists; -} ; - - -} // namespace lmms - -#endif From 19dd8065f8ffc1a403366e9e09c845020a17fa61 Mon Sep 17 00:00:00 2001 From: Jonah Janzen Date: Sat, 24 Feb 2024 20:49:02 -0700 Subject: [PATCH 08/15] Revert "Update wiki" This reverts commit 18bbc05b6aeddbfe591d7750cf21a340b18529a1. --- doc/wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/wiki b/doc/wiki index c9b21bde384..48d20dc9311 160000 --- a/doc/wiki +++ b/doc/wiki @@ -1 +1 @@ -Subproject commit c9b21bde3845b20cbb96aa9ece7774f15f3ffacf +Subproject commit 48d20dc93111c24175b767301d6fe4074e632aee From 41c0c5ac10d6030870a53070b14c202c4e225895 Mon Sep 17 00:00:00 2001 From: Jonah Janzen Date: Sat, 24 Feb 2024 20:49:39 -0700 Subject: [PATCH 09/15] Yet more fixes to Git --- doc/wiki | 2 +- plugins/Vibed/Vibed.cpp | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/doc/wiki b/doc/wiki index 48d20dc9311..c9b21bde384 160000 --- a/doc/wiki +++ b/doc/wiki @@ -1 +1 @@ -Subproject commit 48d20dc93111c24175b767301d6fe4074e632aee +Subproject commit c9b21bde3845b20cbb96aa9ece7774f15f3ffacf diff --git a/plugins/Vibed/Vibed.cpp b/plugins/Vibed/Vibed.cpp index ad6a3942af4..ddf9097a527 100644 --- a/plugins/Vibed/Vibed.cpp +++ b/plugins/Vibed/Vibed.cpp @@ -33,7 +33,6 @@ #include "InstrumentTrack.h" #include "NotePlayHandle.h" #include "VibratingString.h" -#include "MemoryManager.h" #include "base64.h" #include "CaptionMenu.h" #include "volume.h" @@ -67,7 +66,6 @@ Plugin::Descriptor PLUGIN_EXPORT vibedstrings_plugin_descriptor = class Vibed::StringContainer { - MM_OPERATORS public: StringContainer(float pitch, sample_rate_t sampleRate, int bufferLength) : m_pitch(pitch), m_sampleRate(sampleRate), m_bufferLength(bufferLength) {} From 6b4e847daf514eed3f1d28f1996bbb7f09c74c73 Mon Sep 17 00:00:00 2001 From: Jonah Janzen Date: Sat, 24 Feb 2024 20:59:29 -0700 Subject: [PATCH 10/15] Fix wiki submodule hopefully for good --- doc/wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/wiki b/doc/wiki index c9b21bde384..452b36d7a10 160000 --- a/doc/wiki +++ b/doc/wiki @@ -1 +1 @@ -Subproject commit c9b21bde3845b20cbb96aa9ece7774f15f3ffacf +Subproject commit 452b36d7a1059bb97ffb5a8ed5614b0108ba00fd From 49f722ddae831a11801fafefbf41df510eb0f36b Mon Sep 17 00:00:00 2001 From: Jonah Janzen Date: Sat, 24 Feb 2024 21:00:41 -0700 Subject: [PATCH 11/15] It was not fixed. --- doc/wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/wiki b/doc/wiki index 452b36d7a10..48d20dc9311 160000 --- a/doc/wiki +++ b/doc/wiki @@ -1 +1 @@ -Subproject commit 452b36d7a1059bb97ffb5a8ed5614b0108ba00fd +Subproject commit 48d20dc93111c24175b767301d6fe4074e632aee From dec5e739fe53ae1d0c8871bc8bfa6a03210c857d Mon Sep 17 00:00:00 2001 From: Jonah Janzen Date: Sun, 25 Feb 2024 08:57:32 -0700 Subject: [PATCH 12/15] Address review comments --- include/DataFile.h | 1 - include/Delay.h | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/include/DataFile.h b/include/DataFile.h index 1f191ecb94b..ce5d4edf4c2 100644 --- a/include/DataFile.h +++ b/include/DataFile.h @@ -148,7 +148,6 @@ class LMMS_EXPORT DataFile : public QDomDocument QDomElement m_head; Type m_type; unsigned int m_fileVersion; - } ; diff --git a/include/Delay.h b/include/Delay.h index cfc950f2f4c..948280d2a3c 100644 --- a/include/Delay.h +++ b/include/Delay.h @@ -239,7 +239,7 @@ class CombFeedbackDualtap { memset( m_buffer, 0, sizeof( frame ) * m_size ); } - + inline void setDelays( double delay1, double delay2 ) { m_delay1 = static_cast( ceil( delay1 ) ); @@ -315,7 +315,7 @@ class AllpassDelay m_size = maxDelay; m_position %= m_size; } - + inline void clearHistory() { memset( m_buffer, 0, sizeof( frame ) * m_size ); From a1bd081c9ef60d76a783f6915dd878c387bd2f84 Mon Sep 17 00:00:00 2001 From: Jonah Janzen Date: Sun, 25 Feb 2024 08:59:05 -0700 Subject: [PATCH 13/15] Put 2 more tabs back --- include/Delay.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Delay.h b/include/Delay.h index 948280d2a3c..0f814705f31 100644 --- a/include/Delay.h +++ b/include/Delay.h @@ -168,7 +168,7 @@ class CombFeedfwd { memset( m_buffer, 0, sizeof( frame ) * m_size ); } - + inline void setDelay( double delay ) { m_delay = static_cast( ceil( delay ) ); From 611ad98ceccef84d528a27970f09a255b5bff629 Mon Sep 17 00:00:00 2001 From: Jonah Janzen Date: Sun, 25 Feb 2024 09:00:39 -0700 Subject: [PATCH 14/15] Put 1 more tab back for real --- include/Delay.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/Delay.h b/include/Delay.h index 0f814705f31..25a497fc343 100644 --- a/include/Delay.h +++ b/include/Delay.h @@ -97,7 +97,7 @@ class CombFeedback { memset( m_buffer, 0, sizeof( frame ) * m_size ); } - + inline void setDelay( double delay ) { m_delay = static_cast( ceil( delay ) ); @@ -168,7 +168,7 @@ class CombFeedfwd { memset( m_buffer, 0, sizeof( frame ) * m_size ); } - + inline void setDelay( double delay ) { m_delay = static_cast( ceil( delay ) ); From 155424e77b2904ff7c5898f077ee39f4e49ff4cd Mon Sep 17 00:00:00 2001 From: Jonah Janzen Date: Sun, 25 Feb 2024 09:03:01 -0700 Subject: [PATCH 15/15] Fix odd tab issue --- include/Delay.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Delay.h b/include/Delay.h index 25a497fc343..71fbe1b00b1 100644 --- a/include/Delay.h +++ b/include/Delay.h @@ -168,7 +168,7 @@ class CombFeedfwd { memset( m_buffer, 0, sizeof( frame ) * m_size ); } - + inline void setDelay( double delay ) { m_delay = static_cast( ceil( delay ) );