From fad3490946d91682cc083b7ca300b2d4e093abf4 Mon Sep 17 00:00:00 2001 From: reuk Date: Tue, 28 Sep 2021 10:25:02 +0100 Subject: [PATCH] DelayLine: Add function to retrieve the maximum possible delay time --- modules/juce_dsp/processors/juce_DelayLine.cpp | 2 +- modules/juce_dsp/processors/juce_DelayLine.h | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/juce_dsp/processors/juce_DelayLine.cpp b/modules/juce_dsp/processors/juce_DelayLine.cpp index b31428ae70..8727230d62 100644 --- a/modules/juce_dsp/processors/juce_DelayLine.cpp +++ b/modules/juce_dsp/processors/juce_DelayLine.cpp @@ -49,7 +49,7 @@ DelayLine::DelayLine (int maximumDelayInSamples) template void DelayLine::setDelay (SampleType newDelayInSamples) { - auto upperLimit = (SampleType) (totalSize - 1); + auto upperLimit = (SampleType) getMaximumDelayInSamples(); jassert (isPositiveAndNotGreaterThan (newDelayInSamples, upperLimit)); delay = jlimit ((SampleType) 0, upperLimit, newDelayInSamples); diff --git a/modules/juce_dsp/processors/juce_DelayLine.h b/modules/juce_dsp/processors/juce_DelayLine.h index 6ab8dc3533..91d8f29ee4 100644 --- a/modules/juce_dsp/processors/juce_DelayLine.h +++ b/modules/juce_dsp/processors/juce_DelayLine.h @@ -120,6 +120,13 @@ public: */ void setMaximumDelayInSamples (int maxDelayInSamples); + /** Gets the maximum possible delay in samples. + + For very short delay times, the result of getMaximumDelayInSamples() may + differ from the last value passed to setMaximumDelayInSamples(). + */ + int getMaximumDelayInSamples() const noexcept { return totalSize - 1; } + /** Resets the internal state variables of the processor. */ void reset();