diff --git a/modules/dsp/chowdsp_dsp_utils/Processors/chowdsp_BypassProcessor.cpp b/modules/dsp/chowdsp_dsp_utils/Processors/chowdsp_BypassProcessor.cpp index 92d4ef955..ba687dc02 100644 --- a/modules/dsp/chowdsp_dsp_utils/Processors/chowdsp_BypassProcessor.cpp +++ b/modules/dsp/chowdsp_dsp_utils/Processors/chowdsp_BypassProcessor.cpp @@ -91,6 +91,14 @@ void BypassProcessor +BypassProcessor>>::BypassProcessor (int maxLatencySamples) + : maximumLatencySamples (maxLatencySamples) +{ +} + template void BypassProcessor (spec.maximumBlockSize)); + compDelay->prepare (spec); // sample rate does not matter } template @@ -130,10 +139,10 @@ void BypassProcessorsetDelay ((NumericType) delaySamples); if (juce::approximatelyEqual (delaySamples, (NumericType) 0)) - compDelay.reset(); + compDelay->reset(); prevDelay = delaySamples; } @@ -179,11 +188,11 @@ bool BypassProcessorgetDelay(); } else { - doDelayOp (block, compDelay, DelayOp::Toss); + doDelayOp (block, *compDelay, DelayOp::Toss); } return true; diff --git a/modules/dsp/chowdsp_dsp_utils/Processors/chowdsp_BypassProcessor.h b/modules/dsp/chowdsp_dsp_utils/Processors/chowdsp_BypassProcessor.h index a66525bb4..57f76a15e 100644 --- a/modules/dsp/chowdsp_dsp_utils/Processors/chowdsp_BypassProcessor.h +++ b/modules/dsp/chowdsp_dsp_utils/Processors/chowdsp_BypassProcessor.h @@ -70,7 +70,7 @@ class BypassProcessor; - BypassProcessor() = default; + explicit BypassProcessor (int maxLatencySamples = 1 << 18); /** Converts a parameter handle to a boolean */ static bool toBool (const std::atomic* param) @@ -119,7 +119,8 @@ class BypassProcessor fadeBuffer; BufferView fadeBufferView; - DelayLine compDelay { 1 << 18 }; // max latency = 2^18 = 262144 samples + int maximumLatencySamples = 0; + std::optional> compDelay { std::nullopt }; NumericType prevDelay {}; int latencySampleCount = -1; diff --git a/tests/dsp_tests/chowdsp_dsp_utils_test/BypassTest.cpp b/tests/dsp_tests/chowdsp_dsp_utils_test/BypassTest.cpp index 2759fdba7..f1cda5310 100644 --- a/tests/dsp_tests/chowdsp_dsp_utils_test/BypassTest.cpp +++ b/tests/dsp_tests/chowdsp_dsp_utils_test/BypassTest.cpp @@ -87,7 +87,7 @@ TEST_CASE ("Bypass Test", "[dsp][misc]") auto arenaView = chowdsp::ArenaAllocatorView { arena }; for (auto& arenaPtr : std::vector { nullptr, &arenaView }) { - chowdsp::BypassProcessor bypass; + chowdsp::BypassProcessor bypass {}; std::atomic onOffParam { 0.0f }; bypass.prepare ({ fs, (juce::uint32) nSamples, @@ -123,7 +123,7 @@ TEST_CASE ("Bypass Test", "[dsp][misc]") auto arenaView = chowdsp::ArenaAllocatorView { arena }; for (auto& arenaPtr : std::vector { nullptr, &arenaView }) { - chowdsp::BypassProcessor bypass; + chowdsp::BypassProcessor bypass { static_cast (std::ceil (delaySamp)) }; std::atomic onOffParam { 0.0f }; bypass.prepare ({ fs, (juce::uint32) nSamples,