Delay Line smooth

Hi,

I have instantiate this: dsp::DelayLine<float> latency{MAX_LATENCY}; in the .h of my class that inherit AudioProcessor.

I have this in processBlock:

dsp::AudioBlock<float> audioBlock  { audioBuff  };
latency.process(dsp::ProcessContextReplacing<float>(audioBlock));

but when in my gut I change latency delay (I have a slider that calls latency.setDelay(delay);) some glitches are produced.

there’s a way to avoid this? really thank you!

The delay is set up to delay the signal by a static time, but there are push and pop methods for adding modulated/ adjustable delay times.

1 Like

The documentation for the dsp::DelayLine class says

Note: If you intend to change the delay in real time, you may want to smooth changes to the delay systematically using either a ramp or a low-pass filter.

Consider looking at these options.

A useful class for ramping values to avoid pops and clicks with realtime code is the LinearSmoothedValue or SmoothedValue classes.

1 Like

Really thank you guys, but I cannot figure out how can I integrate LinearSmoothedValue.
Also using push and pop what is the value to smooth.
For example on a gain I can smooth a gain, here I should smooth the num in setDelay? I immagine that also doing this glitches are created anyway…

First, you should call setDelay() in the audio thread.

You could have a class which declare juce::dsp::DelayLine, an atomic and a smoothed value as class members. Then the process function may look like this:

currentDelay = atomicDelay.load()
smoothedDelay.setTargetValue(currentDelay);
if (smoothedDelay.isSmoothing()) {
    // iterate over sample index
        delayLine.setDelay(smoothedDelay.getNextValue())
        // iterate over channel
            // update samples by pushing and poping
} else { // process it as a audio block }
2 Likes

On understand! Really thank you for help, now I try!

ayra_SmoothedDelayLine.h (1.8 KB)
ayra_SmoothedDelayLine.cpp (3.2 KB)

but when I move slider sound pitch is modulated, how to avoid this?

You should call setDelay(smoothedDelay.getNextValue()) per sample instead of per buffer. Because of this, you may need to set the sample index as the outer loop.

BTW, you may set the ramp length as a fixed time length, e.g., samplerate * 0.01.

AFAIK using a low pass might be a better solution (I have seen some discussions here before).

1 Like