Hi there, I’m using Pspawner to play a mixture of sequential and parallel streams. What I would really like would be to launch a stream using par() and then (at some later point in the Routine) wait for it to end. So, similar to what seq() does, except that it would reference a par stream, and one would be able to wait for it to end before continuing.
In the following example, I can use par for the first four, and seq for the last iteration (I know it will be the last to end playing, since they happen to all have the same duration).
~melo = Pbind(\degree, Pseq([0,4,1,-1], 4), \dur, 1/4, \octave, 4, \scale, Scale.minorPentatonic);
(
Pspawner({ |sp|
5.do{ |i|
var pat = Padd(\degree, i*3, ~melo);
i.debug("starting");
if (i == 4) { sp.seq(pat) } { sp.par(pat); sp.wait(1); };
};
"Done parallel streams".postln;
}).play;
)
Another option would be to just put a wait of the correct duration, as in the next example. However, having to know the overall duration of every Pattern you schedule would be a nuisance (and possibly not knowable, e.g. if randomness is involved)!
(
Pspawner({ |sp|
var meloStreams = 5.collect{ |i|
var pat = Padd(\degree, i*3, ~melo);
var stream;
i.debug("starting");
stream = sp.par(pat);
sp.wait(1);
stream
};
sp.wait(3); // have to figure this duration out for yourself
// or can stop par streams explicitly (possibly before they're done playing)
// meloStreams.do(sp.suspend(_));
"Done parallel streams".postln;
}).play;
)
It would be nicer to launch a bunch of par streams (stored in an array) and then wait for all of them to end (just waiting for a specific one to end would be enough, you could loop on them)… kind of like join on a thread in other languages.
Is there a way to do this now?
Thanks,
Glen.