[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [sc-users] routine buildup
On Sep 20, 2005, at 1:59 PM, LF wrote:
Hi folks,
as it turns out, I was releasing all of my Synths properly, but I was still getting a buildup of synths and ugens because of the following: I call it routine build-up. Any solutions?
x=SynthDef(\test,{
Out.ar(0, Pulse.ar(
Rand(50,200),
0.2,
EnvGen.ar(Env.triangle(4,0.3),doneAction:2))
);
}).send(s);
r=Routine({
{
Synth(\test);
2.wait;
1.yield;
}.loop
});
r.play;
// now hit this as a group several times in a row within less than 2 seconds
(
r.stop;
r.reset;
r.play;
)
why do I get several loops overlapping?
is there a way to stop it, so that I only have one loop producing synths?
it seems that if I stop, reset and play the routing before the 2.wait has happened,
then the loop duplicates, and the routine does not stop and reset.
is this an incorrect behavior of Routine?
what is the solution?
LF
.stop tells the Routine to return nil next time someone calls .next. stop has nothing to do with the scheduler. Routine-stop is NOT the opposite of Routine-play.
So your code does not do what you think it does. Your code does this:
r.stop // return nil the next time someone calls .next
r.reset // actually on second thought, start over from the beginning the next time someone calls .next. (this contradicts the previous call)
r.play // also while you're at it, put yourself on the scheduler again.
Thus the result is you get the same Routine on the scheduler 3 times.