1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-20 01:14:20 +00:00

DelayLine: Allow setting a new maximum delay time after construction

This commit is contained in:
reuk 2021-08-23 17:39:14 +01:00
parent c41f64111f
commit 7b64bd7406
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11
2 changed files with 19 additions and 1 deletions

View file

@ -40,8 +40,9 @@ DelayLine<SampleType, InterpolationType>::DelayLine (int maximumDelayInSamples)
{
jassert (maximumDelayInSamples >= 0);
totalSize = jmax (4, maximumDelayInSamples + 1);
sampleRate = 44100.0;
setMaximumDelayInSamples (maximumDelayInSamples);
}
//==============================================================================
@ -81,6 +82,15 @@ void DelayLine<SampleType, InterpolationType>::prepare (const ProcessSpec& spec)
reset();
}
template <typename SampleType, typename InterpolationType>
void DelayLine<SampleType, InterpolationType>::setMaximumDelayInSamples (int maxDelayInSamples)
{
jassert (maxDelayInSamples >= 0);
totalSize = jmax (4, maxDelayInSamples + 1);
bufferData.setSize ((int) bufferData.getNumChannels(), totalSize, false, false, true);
reset();
}
template <typename SampleType, typename InterpolationType>
void DelayLine<SampleType, InterpolationType>::reset()
{

View file

@ -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();