# Digital delay effect: avoiding clicks on delay time change

I'm implementing a digital audio delay effect using a simple circular delay line. Changing the delay time by making the delay line longer or shorter introduces discontinuities in the audio signal, resulting in clicks.

What would be the best (most pleasing for the ears) strategy to avoid such clicks when changing delay time?

• Changing the delay time causes discontinuities as the pointer suddenly jumps to a different index in your circular buffer (delay line). A sudden jump in the waveform causes these click. You can try smoothing out these jumps every time the user changes the delay setting on the delay line. See the RemoveClicks() function here: github.com/audacity/audacity/blob/master/src/effects/… – Atul Ingle Jan 12 '17 at 20:28

If you are not changing the delay length very often, and you don't want to have a Doppler effect that comes from continuously changing the delay length, then try a cross-fade. Both delay lengths should be running simultaneously for a moment, and you would fade the old one out while fading the new one in.

• Was about to suggest interpolating/decimating temporarily to change the delay, but that would have had the frequency change. Still sounds like an interesting choice - like speeding up/slowing down an LP. – Marcus Müller Jan 12 '17 at 23:46
• That can be musically pleasing/useful, too, and appropriate for continuously changing delay control. It needs a fractional delay line with interpolation. – Olli Niemitalo Jan 13 '17 at 8:08

The problem here is a discontinuity in the signal, which results in the click you're hearing. A possible solution is to make the delay variation as smooth as possible so that step-like discontinuities are avoided. If $x(n)$ represents the signal associated to the delay-line control (e.g. a knob) and $y(n)$ represents the signal associated to the effective change in delay that you allow, a possible relationship between the two could be: $$y(n) = \alpha x(n) + (1 - \alpha) x(n-1)$$ with $0<\alpha<1$. This is a computationally inexpensive way of low-pass filtering $x(n)$.

• You mean $y(n-1)$ rather than $x(n-1)$ right? – Olli Niemitalo Jan 13 '17 at 7:53
• In my experience that doesn't work. If you just have a simple delay line you still need to quantize the delay value to an integer multiple of the sample time. Even one sample delay changes cause audible zipper noise. – Hilmar Jan 13 '17 at 12:48

If you have a continuously varying delay like, for example, a chorus or flanger, you need a to implement a time varying fractional delay in addition to your regular (integer) delay line.

If you only need to change the delay occasionally in discrete steps, a cross fade will work fine.