I got a Synth that reads a long buffer (3’).
I’ve also defined 3 Pdef, \clean where the buffer is read without effect, \delayed where a delay is applied, \main which is one that is played and that I define as either \clean or \delayed.
I expected that switching from \clean to \delayed would simply activate/deactivate the delay, but, no, it restarts the reading of the buffer from the start. And I don’t understand why.
Can someone explain me what I should change to seamlessly activate/deactivate the delay ?
~flute = Buffer.read(s, "G:/Enregistrements/Temp/Supercollider/flute.wav");
~flute.bufnum.postln;
SynthDef(\flute, {
var out = \out.kr(0),
amp=\amp.kr(1), pan=\pan.kr(0);
var sig;
var bufnum=~flute.bufnum;
sig = PlayBuf.ar(1, bufnum, BufRateScale.ir(bufnum), doneAction: 2);
sig = sig * amp * EnvGate.new(fadeTime: 3);
Out.ar(out,Pan2.ar(sig,pan));
}).add;
Pdef(\base, Pmono(\flute, \amp, 1, \dur, 20 ));
Pdef(\clean, Pdef(\base));
//Pdef(\delayed, Pfx(Pdef(\base),\delay));
Pdef(\delayed, Pfx(Pdef(\clean),\delay));
)
// Create and/or empty the main pattern
Pdef(\chain, nil).quant = 0;
// Start the main pattern.
// ?? Should remain silence until I explicitly assign a Pdef to \chain. But it always start with the previous definition, even tough I assigned it to nil !!??
q=Pdef(\chain).play();
// active "Clean"
Pdef(\chain, Pdef(\clean)); // Does always restart the \flute synth from the start. Why ? I expect it to Activate/Deactivate the delay without impacting the \flute synth...
// active "Delay"
Pdef(\chain, Pdef(\delayed));