Ask how to use trigger control within synthdef (for example, t_gate)

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 =;
	env =, t_gate, doneAction:2); //The synth does not disappear even when the envelope is completed.
	sig = sig * env * amp;
	sig =, pan);, sig);

	\instrument, \trig,
	\gate, Pseq([1, 0, 0, 0, 0, 1], inf),
	\dur, 0.25,
	\freq, Pexprand(50, 500, inf),

The \dur=0.25 will (by default) send a gatte=0 to your every 0.25 beat and start it again. What’s the purpose of trying to control it with the Pseq ?

When you have \gate == 0 in the event, it means that the envelope never starts.

If the envelope never starts, then it can’t reach its end.

If it doesn’t reach its end, then it can’t do doneAction.

I’d suggest \gate, Pseq([1, 0, 0, 0, 0, 1], inf).collect { |a| if(a == 0) { Rest(a) } { a } } instead.


1 Like

I wanted to make a rhythm, but now that I think about it, I can solve it by using ‘\dur’ and ‘\rest’. Thank you.:smile:

Thank you. I’ll try to approach it that way.:smile: