From 8f77cfa563a9659b46517d89a5fb09c963ea851c Mon Sep 17 00:00:00 2001 From: Dalton Messmer Date: Tue, 3 Sep 2024 21:03:28 -0400 Subject: [PATCH] Add `MAXIMUM_BUFFER_SIZE` and use it in VstEffect --- include/AudioEngine.h | 13 +++++++------ plugins/VstEffect/VstEffect.cpp | 3 +-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/AudioEngine.h b/include/AudioEngine.h index f80c860d819..d5172258b51 100644 --- a/include/AudioEngine.h +++ b/include/AudioEngine.h @@ -50,14 +50,15 @@ class AudioPort; class AudioEngineWorkerThread; -const fpp_t MINIMUM_BUFFER_SIZE = 32; -const fpp_t DEFAULT_BUFFER_SIZE = 256; +constexpr fpp_t MINIMUM_BUFFER_SIZE = 32; +constexpr fpp_t DEFAULT_BUFFER_SIZE = 256; +constexpr fpp_t MAXIMUM_BUFFER_SIZE = 4096; -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 ); +constexpr int BYTES_PER_SAMPLE = sizeof(sample_t); +constexpr int BYTES_PER_INT_SAMPLE = sizeof(int_sample_t); +constexpr int BYTES_PER_FRAME = sizeof(SampleFrame); -const float OUTPUT_SAMPLE_MULTIPLIER = 32767.0f; +constexpr float OUTPUT_SAMPLE_MULTIPLIER = 32767.0f; class LMMS_EXPORT AudioEngine : public QObject { diff --git a/plugins/VstEffect/VstEffect.cpp b/plugins/VstEffect/VstEffect.cpp index be06a63d503..f822599a96a 100644 --- a/plugins/VstEffect/VstEffect.cpp +++ b/plugins/VstEffect/VstEffect.cpp @@ -81,8 +81,7 @@ VstEffect::VstEffect( Model * _parent, double VstEffect::processImpl(SampleFrame* buf, const fpp_t frames) { assert(m_plugin != nullptr); - assert(frames <= DEFAULT_BUFFER_SIZE); - static thread_local auto tempBuf = std::array(); + static thread_local auto tempBuf = std::array(); std::memcpy(tempBuf.data(), buf, sizeof(SampleFrame) * frames); if (m_pluginMutex.tryLock(Engine::getSong()->isExporting() ? -1 : 0))