Prout called multiple times concurrently


I’ve this Pdef with a Prout.
The goal is to have the Pdef iterating over an array of events, that can be modified in the background without impacting the progression in the array (i.e. if the current index is 8, whatever are the modifications to the backing array, the next event must be the one at the index 9 of the array).

		topEnvironment[\tProgression]{ |step|
			var chord=topEnvironment[\tProgression].wrapAt(step)/*.debug("event")*/;
			format("--Iteration: % (%)--",step, chord.dur).postln;

This Pdef is used in a Ppar with another Pdef, passing the Pdef(\pogression) event (~harmony in the above Pdef):


I’ve got a strange behaviour when I .play, .stop, .play … the Pdef(\walk) :
At some point when I do a Pdef(\walk).play the Pdef(\progression) returns multiple events at once instead of one at the time.

This is the log that I receive at once, while I should receive one line every 4 beats (the eventt’s dur equal 4)

--Iteration: 1 (4)--
--Iteration: 2 (4)--
--Iteration: 3 (4)--
--Iteration: 4 (4)--
--Iteration: 5 (4)--
--Iteration: 6 (4)--
--Iteration: 7 (4)--

Any idea why this Prout is called multiple time at once without waiting for its last event’s dur ?


The Pdef(\line) code:

Solved by adding a “return nil” statement. I’m not sure to able to explain why this is working.
I guess that the Prout must explicitly return a nil value when it is over so that the EvenStreamPlayer knows it must stop fetching values from the Prout.

Pdef(\progression,Prout({{ |step|
		var val=tProgression.wrapAt(step)/*.debug("event")*/;
	nil; // <-- 24/3 : returning nil at the end is mandataory