Reapply a SynthDef-filter after freeing a previous one

Hello,

I’ve defined this SynthDef-Filter and applied it on a signal. It works fine.

SynthDef(\stomperFilter, {
	arg in=0, out = 0, freq= 440, effect=1, mix=1;
	var orig,sig,rq;
	orig=In.ar(in);
	rq=effect.neg.lincurve(-1,0,0.0001,1,8,\minmax);
	sig=Resonz.ar(orig,freq,rq,1/rq.pow(1.2).sqrt);
	sig=XFade2.ar(orig,sig,mix.linlin(0,1,-1,1));
	ReplaceOut.ar(out, sig);
}).add;
)

// Play noise and apply the effect
(
~noise={WhiteNoise.ar(0.5)}.play;
~filter=Synth.new(\stomperFilter, args: [\in:0, \out:0]);
)
// Stop the effect
~filter.release(1); // KO -- doesn't stop the effect
~filter.free; // OK

However, when I try to apply another SynthDef-Filter after having closed the previous one, it doesn’t work. I still got my plain White Noise.

// And reapply another effect
~filter2=Synth.new(\stomperFilter, args: [\in:0, \out:0]); // KO -- doesn't apply that filter

Why ?

You need to control the order of execution.

http://doc.sccode.org/Guides/Order-of-execution.html

hjh

1 Like
~filter.release(1); // KO -- doesn't stop the effect

That’s because there is no gate in your \stomperFilter synthdef, .release set the gate to 0 to release the synth

1 Like