From b8bee516517a329eca9f1fa3ead7e63c6ba8158a Mon Sep 17 00:00:00 2001 From: Ivan COHEN Date: Wed, 6 Feb 2019 15:24:24 +0100 Subject: [PATCH] DSP: Fixed some FIFO and memory allocation issues in convolutions --- modules/juce_dsp/frequency/juce_Convolution.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/juce_dsp/frequency/juce_Convolution.cpp b/modules/juce_dsp/frequency/juce_Convolution.cpp index 6fa4fdc899..086d4cc246 100644 --- a/modules/juce_dsp/frequency/juce_Convolution.cpp +++ b/modules/juce_dsp/frequency/juce_Convolution.cpp @@ -395,6 +395,10 @@ struct Convolution::Pimpl : private Thread int start1, size1, start2, size2; abstractFifo.prepareToWrite (1, start1, size1, start2, size2); + // If you hit this assertion then you have requested more impulse response + // changes than the Convolution class can handle. + jassert (size1 + size2 > 0); + if (size1 > 0) { fifoRequestsType.setUnchecked (start1, type); @@ -416,6 +420,10 @@ struct Convolution::Pimpl : private Thread int start1, size1, start2, size2; abstractFifo.prepareToWrite (numEntries, start1, size1, start2, size2); + // If you hit this assertion then you have requested more impulse response + // changes than the Convolution class can handle. + jassert (numEntries > 0 && size1 + size2 > 0); + if (size1 > 0) { for (auto i = 0; i < size1; ++i) @@ -479,7 +487,7 @@ struct Convolution::Pimpl : private Thread auto numRequests = 0; // retrieve the information from the FIFO for processing - while (getNumRemainingEntries() > 0) + while (getNumRemainingEntries() > 0 && numRequests < fifoSize) { ChangeRequest type = ChangeRequest::changeEngine; juce::var parameter; @@ -701,6 +709,10 @@ struct Convolution::Pimpl : private Thread { for (auto* e : engines) e->reset(); + + mustInterpolate = false; + + processFifo(); } /** Convolution processing handling interpolation between previous and new states @@ -1010,7 +1022,7 @@ private: //============================================================================== - static constexpr int fifoSize = 256; // the size of the fifo which handles all the change requests + static constexpr int fifoSize = 1024; // the size of the fifo which handles all the change requests AbstractFifo abstractFifo; // the abstract fifo Array fifoRequestsType; // an array of ChangeRequest