How to Stop Clicks When Changing / Turning On a Delay Synth

Hi everyone:

I have a DSP question. I’m getting click sounds whenever I switch to a new delay duration quickly, or quickly turn on the synth with a gate. I’ve attached a recording of both examples.

Anyone have any advice on how to stop this? I tried changing envelope times in the second attempt but no luck. Thanks!

Example 1: First Half of the Recording:

SynthDef("delay", {
	arg duration=1/2;
	var input,delay;
	input = In.ar(12); // Takes in Dry Mic Output Channel
	delay = CombL.ar(
		in:input,
		maxdelaytime: 4,
		delaytime: duration,
		decaytime: 4,
		mul: 0.5);
	//duration.poll;
	Out.ar(13,delay); // Send to Bus 11...Called  "Delay Bus Out Channel";
}).add;


~delay_synth  = Synth.new("delay",[\duration,~half],target:~delay_group);
~delay_synth.set(\duration,~sixteenth);

Example 2: Second Half of the Recording:

SynthDef.new(\delay1, {
	arg in=0, out=0,mul = 0,gate=0,attackTime=3.5;
	var sig,env, amp_env;
	sig = In.ar(in, 2);
	//env.poll();
	sig = CombN.ar(
		in:sig,
		maxdelaytime: 1,
		delaytime: 1/6,
		decaytime: 4,
		mul: mul,
	);
	
	env = EnvGen.kr(Env.adsr(
		attackTime: attackTime,
		decayTime: 0.5,
		sustainLevel: 1,
		releaseTime: 3,
		peakLevel: 1.0,
		curve: -4.0,
		bias: 0.0),
	gate:gate,
	doneAction:2
	);

	sig = sig * env;

	Out.ar(out, sig);
}).add;

["/s_new",["delay1", 300,0,delay_group, "in", delay1_bus_index, "out", 0,"gate",1,"mul",1.0]],

A couple of suggestions:
Add a Fade In envelope to the input signal

// input = In.ar(12); // Takes in Dry Mic Output Channel
input = Line.kr(0, 1, 1) * In.ar(12); // added fade in envelope

Add Lag or Ramp to the delay time

delaytime: Ramp.kr(duration, 1), // added Ramp
// delaytime: Lag.kr(duration, 1), // added Lag

Best,
Paul

1 Like

Thanks for the response! I’m going to play around with it tomorrow and report back!

@TXMod worked like a charm. thanks you a million times!

Also check out XFadeDelay from wslib:

1 Like