I was wondering how to implement “mute groups” in supercollider with patterns. E.g., create a group, and various patterns that play in the group, and always send a \gate, 0
message before creating a new synth.
// So, here's a synth with a gate argument:
SynthDef(\adsr, {
arg freq=200, gate=1, amp=0.2;
var env = EnvGen.ar(Env.adsr(), gate, doneAction:2);
Out.ar(0, SinOsc.ar(freq, mul:amp)!2 * env);
}).add;
// The group to mute
~muteGroup = Group.new(s);
// Start playing something on that group
x = Synth(\adsr, [\freq, 800, \amp, 0.05], ~muteGroup);
// How do I make this Pbind call ~muteGroup.set(\gate, 0)
// each time in creates a new synth??
// (If it works, then x should be automatically
// released when the Pbind starts):
Pbind(
\group, ~muteGroup
,\instrument, \adsr
,\degree, Pseq([0, 4, 7], inf)
,\dur, 4
)]).play;
Perhaps Pfunc
or something would be useful, but I’m not sure how to integrate that here?
Edit: maybe it is as simple as this:
Pbind(
\group, ~muteGroup
,\pattern, Pfunc{ ~muteGroup.set(\gate,0); } // release all synths in this group
,\instrument, \adsr
,\degree, Pseq([0, 4, 7], inf)
,\dur, 4
).play;