Hey,
I’m trying to trigger a number of Synths at (basically) the same time and then free them later at (basically) the same time. I’ve tried to do this with iteration, as seen in the last few lines of code here, but this doesn’t seem to work. Would love feedback on how to make this work, or better ways to do the same thing!
(
SynthDef(\a, {
var env, sig;
var buf = \buf.kr(0);
env = Env.asr(\atk.kr(1), 1, \rel.kr(10)).ar(Done.freeSelf, \gate.kr(1));
sig = PlayBuf.ar(1, buf, BufRateScale.ir(buf) * \rate.kr(1, 1.5) * \direction.kr(1), 0, \startPos.kr(0), \loop.kr(0));
sig = sig * env * \amp.kr(1);
sig = Pan2.ar(sig, \pan.kr(0));
Out.ar(\out.kr(0), sig);
}).add;
)
(
Routine {
var rate = Pstutter(2, Pxrand([1, 9/8, 1.5, 0.75, 2], inf)).asStream;
var rate0 = Pxrand([1, 9/8, 1.5, 0.75, 2], inf).asStream;
l = Synth(\a, [buf: ~git[0], rate: rate.next, pan: -1, loop: 1]);
r = Synth(\a, [buf: ~git[0], rate: rate.next * 1.01, pan: 1, loop: 1]);
10.wait;
10.do {
[l,r].do{ |i| i.set(\rate, rate.next) };
rrand(2, 10).wait;
};
10.do {
l.set(\rate, rate0.next);
rrand(2, 10).wait;
r.set(\rate, rate0.next);
};
[a,b,c,d,e,f,g].do { |name| rrand(2,10).wait; name = Synth(\a, [buf: ~git[0], rate: [0.25, 1, 9/8, 1.5, 0.75, 2, 3].choose, pan: rrand(-1.0, 1.0), loop: 1])};
45.wait;
[a,b,c,d,e,f,g,l,r].do { |name| name.set(\gate, 0) };
}.play;
)
Cheers,
Jordan