Stop Nested Routines w/out Pspawner?

Hello! Hoping to not have to redesign a somewhat complicated patch. In the example below, is there a way to stop all routines?

(
r = { |freqLo=220, freqHi=1500|
	fork({
		inf.do({
			s.sendBundle(0.1, ["/s_new", \sin, -1, 0, 0, \freq, rrand(freqLo, freqHi)]);
			[0.25, 1/3, 0.5].choose.wait;
		});
	});
};
)

~a1 = Array.fill(4, {2.do{r.value}}); 

~a1.collect{|i| i.stop}; //how to stop the child routines?

Thanks!
-jz

If instead of writing this

You wrote it like this

//~a1 = Array.fill(4, r); 
~a1 = Array.fill(4, r!2); 

Then you array would contain a reference to the routines, and the you could stop them:

// the "isArray" is for the case one work with MultiChannel expansion
~a1.collect{|i| i.isArray.if({i.collect(_.stop)},{i.stop})}; /

That’s fantastic. Thanks so much!
-j

Ran into another question. Why does this work as expected

~a1 = Array.fill(4, r!2);

but not this:

~a1 = Array.fill(4, {r.value(350, 700)!2})

Thanks again

Should be like this, I think:

~a1 = Array.fill(4, { { r.value(350, 700) } ! 2 })

// or, using consistent syntax
~a1 = Array.fill(4, { Array.fill(2, { r.value(350, 700) }) })

hjh

Awesome. Thanks, James! Hope you’re well!
-j