Parallel routines

Hi there,

I am trying to understand how to play several instances of the same routine, with the second instance starting before the first ends. I’d have a routine such as this:

(
r = Routine{
	
	var rrr = rrand(0.0,1.0);
	
	10.do{rrr.postln;
		0.1.wait;
	}
	
}

)

r.play

This runs for a total of 1 second. I want to call this routine again, say, 0.75 seconds after I called it for the first time, to output a different random number. What would be the best approach here? With patterns, I guess this could be done with some combination of Pspawner and Plazy, but I’d like to keep using routines here.

Thanks!

1 Like

Maybe something like this?

r =  {
	var rrr = rrand(0.0, 1.0);
	"--------".post; rrr.post; "--------".postln;
  	10.do {
		rrr.postln;
		0.5.wait;
	}
};

Routine{ loop {
    r.fork;
    (0.1..2.5).choose.wait;
}}.play

Take a look at Tdef, it has some nice features.

Excellent, thanks so much. This works perfectly.

1 Like