diff --git a/modules/juce_dsp/processors/juce_DelayLine.cpp b/modules/juce_dsp/processors/juce_DelayLine.cpp index f3479907ca..b31428ae70 100644 --- a/modules/juce_dsp/processors/juce_DelayLine.cpp +++ b/modules/juce_dsp/processors/juce_DelayLine.cpp @@ -40,8 +40,9 @@ DelayLine::DelayLine (int maximumDelayInSamples) { jassert (maximumDelayInSamples >= 0); - totalSize = jmax (4, maximumDelayInSamples + 1); sampleRate = 44100.0; + + setMaximumDelayInSamples (maximumDelayInSamples); } //============================================================================== @@ -81,6 +82,15 @@ void DelayLine::prepare (const ProcessSpec& spec) reset(); } +template +void DelayLine::setMaximumDelayInSamples (int maxDelayInSamples) +{ + jassert (maxDelayInSamples >= 0); + totalSize = jmax (4, maxDelayInSamples + 1); + bufferData.setSize ((int) bufferData.getNumChannels(), totalSize, false, false, true); + reset(); +} + template void DelayLine::reset() { diff --git a/modules/juce_dsp/processors/juce_DelayLine.h b/modules/juce_dsp/processors/juce_DelayLine.h index 00950b72c1..6ab8dc3533 100644 --- a/modules/juce_dsp/processors/juce_DelayLine.h +++ b/modules/juce_dsp/processors/juce_DelayLine.h @@ -112,6 +112,14 @@ public: /** Initialises the processor. */ void prepare (const ProcessSpec& spec); + /** Sets a new maximum delay in samples. + + Also clears the delay line. + + This may allocate internally, so you should never call it from the audio thread. + */ + void setMaximumDelayInSamples (int maxDelayInSamples); + /** Resets the internal state variables of the processor. */ void reset();