I want to control EnvGen’s gate through Pbind by specifying the instrument as trigger control in Synthdef(ex. t_gate), but even though it is properly specified as doneAction:2, Synth does not disappear from NodeTree.
How can I fix this?
When Pbind controls the gate value and the envelope is complete, I want to make the synth disappear from the node tree.
Thank you.
(
SynthDef(\trig, {
|freq=220, amp=0.5, t_gate=1, pan=0|
var sig, env;
sig = SinOsc.ar(freq);
env = EnvGen.kr(Env.adsr, t_gate, doneAction:2); //The synth does not disappear even when the envelope is completed.
sig = sig * env * amp;
sig = Pan2.ar(sig, pan);
Out.ar(0, sig);
}).add
)
(
Pbind(
\instrument, \trig,
\gate, Pseq([1, 0, 0, 0, 0, 1], inf),
\dur, 0.25,
\freq, Pexprand(50, 500, inf),
).play
)