remove delay clicks

Florian Wittenburg's icon

Hi All,

I still have one problem with my first max patch (please see attached): when I change the delay time (randomly on bang) clicks in the resulting audio are audible. Does anyone maybe know how to remove those clicks? How to mute the signal briefly and smoothly, so that no clicks are audible anymore?

Thanks in advance.

Best,

Florian

organ chance canon (1 sample).maxpat
Max Patch

Andy Maskell's icon

Hi Florian,

This is a problem that affects anybody processing audio signals and has only one of two solutions. Audio signals swing up and down above (+volts) and below (-volts) a central baseline at 0 volts. Whenever the audio stream is suddenly cut off, the signal will jump from wherever it is to 0 volts in an instant, determined by the sampling rate. This will produce a sudden "click" in the audio stream that will vary from a tiny sound to a loud bang depending on how far away from the central baseline the signal voltage was at the time. This can be compounded if the signal is suddenly spliced into something else that creates a net swing from positive to negative or vice versa.

One method of eliminating this is to monitor the signal and do the switch when it crosses the zero volt line. You also have to be able to predict when the incoming signal will also cross the baseline and, given that any digital signal jumps in voltage from one sample to next, even that can result in a small click.

The clever way to solve this is to blend the signals during the transition, decreasing the outgoing signal to zero over a number of samples whilst simultaneously adding in the new signal at the same rate. You'd be surprised as to how few samples you need to use to do this (ten samples would be a good starting point) but the more samples you can handle the smoother the transition will be. My suggestion is that you create two audio buffers for the original and new signal. When the delay bang occurs, progressively divide the original signal by the number of samples chosen so that in that period the signal diminishes to zero. At the same time, progressively multiply the new signal in steps to reach its full amplitude as the original signal reaches zero. By adding the two signals together, a smooth, and hopefully inaudible, transition will occur. I appreciate that this will not be easy but the effort will be worthwhile.

If you can't buffer the signals and overlap them then you can almost achieve the same thing by diminishing the original signal to zero and then amplify the new signal from zero to its full amplitude. This might cause a slight "gap" in the signal but if you keep the transition short enough you will hardly notice it.

You can't use "digital" mutes for this as it will essentially leave you with the same unpleasant clicks. Most good mixing desks have voltage controlled amps that slowly decrease the gain to zero when the mute button is pressed, essentially achieving the same gradual transition from sound to silence as I have described above. Unmuting, ramps the gain back up from zero to full amplitude.

Does any of this help/make sense?

Andy.

Florian Wittenburg's icon

Hi Andy,

it makes all sense and helps a bit, but to program it is another cup of tea, especially for me as a beginner.

I think your last suggestion is the easiest to realize and I don’t mind the gaps so much (I realized something similar in kyma, the language I’m more familiar with, and the gaps were barely audible and therefore didn’t matter so much)…do you possibly have an example patch for this? Or, if not, could you give me some hints/tips which max objects I need to accomplish this?

Thanks!

Best,

Florian

Source Audio's icon

here is somewhat shorter answer :
from the patch it looks as you want to loop portion of audio (0 - 1531 ms)
as first you remove metro, activate loop and set loop points
to 0 and 1531.


All that stuff you can see in sfplay help file.
-----
Then - you seem to want to offset playback using delay.
Is that really the goal ?
Would not be easier to use buffer~ based playback and
offset play position ?
-----
But you actually asked about clickless delay...
here is one example patch also with feedback,
you can easily adapt it for your needs.

Max Patch
Copy patch and select New From Clipboard in Max.


P.S. another little tip - auto reset urn


and using delay~ instead

Max Patch
Copy patch and select New From Clipboard in Max.


Andy Maskell's icon

Sorry, my broadband has been off all day! I don't know if this helps at all? I just quickly knocked together a bit of code that will fade between two signal sources. I suspect that there are other more elegant ways to do this but the concept might be useful.

Signal fader.maxpat
text/plain 20.02 KB

Roger's icon

Have a look at Smooth Delay in the BEAP menu

jg's icon

Here's a simple way of doing it that employs two tapouts that alternate. When a new delay time is received, it's sent to the tapout not currently audible, and then crossfades. It has a speed limitation, since (in this form) it takes 10ms to crossfade from one to the other, but you could probably shorten that to 5ms or even less if you needed to. As Andy said, the longer the crossfade, the smoother it sounds.

If you want to add feedback, take the signal output and feed it back into [tapin~].

JohnG

Max Patch
Copy patch and select New From Clipboard in Max.