Stopping all child streams/routines

Hi!

I am defining a bunch of processes in the shape of Routines which each start a number of sub-Routines and/or streams (Pbinds etc.). Is there an easy way to stop all of these child processes when the main process is stopped without manually storing them in a global variable and creating a separate stop function for every super process?

Here is an example of what I mean:

(
{
	r = Routine({
		Pbind(
			\scale, Scale.chinese,
			\degree, Pseq((0..7) ++ (6..1), inf),
			\dur, 0.3,
			\amp, Pwhite(0.1, 0.5),
		).play;
		Pbind(
			\scale, Scale.hijaz,
			\degree, Pseq((0..7) ++ (6..1), inf),
			\dur, 0.2,
			\amp, Pwhite(0.1, 0.5),
		).play;
		loop {
			"routine is running".postln;
			1.wait;
		};
	}).play();
	3.wait;
	// This will stop the routine, but not the Pbind streams
	r.stop;
}.fork;
)

Take a look at Pspawner

http://doc.sccode.org/Classes/Pspawner.html

Thanks! This seems to work very well:

(
c = Spawner();

c.par(Routine({ var i = 0;
	loop {
		("routine playing " + i.asString).postln;
		0.5.wait;
		i = i + 1;
	};
}));
c.par(Pbind(
	\scale, Scale.hijaz,
	\degree, Pseq((0..7) ++ (6..1), inf),
	\dur, 0.2,
	\amp, Pwhite(0.1, 0.5),
)
);

c.play();
)
c.suspendAll