[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-users] loop in routine, causes SC hang



Hi everyone,

I'm back on the list after being away for a few years... enjoying getting back into supercollider. :)

I'm having trouble with a loop in a routine (below). It causes SC to hang and I'm not sure why. I basically want the loop to automatically start a new synth, and then eventually kill that synth and start another one after a time value chosen from a range. The function works if I take out the loop (but obviously it doesn't loop). I figure I'm probably missing something simple but I can't find it.

Thanks,
Aaron

(
~myFunction = { arg buf, pan_range=0.6, pitch_range=0.2, grain_rate=25; 
// buf is an array of buffers formatted as [ [buffer, length], [buffer, length] ]
var r, waitTime, thisBuf;
r = Routine.new({
loop {
waitTime = 10.0.linrand;
thisBuf = buf.choose;
Synth.new(\sample_granulator, [
\out_bus, 0,
\sound_buf, thisBuf[0].bufnum,
\pan_rng, pan_range,
\pitch_rng, pitch_range,
\trig_rate, grain_rate,
\length, waitTime
]);
};
waitTime.yield;
});
SystemClock.play(r);
};
)