The Pproto help page says:
A cleanupFunction that deallocates resources when the pattern ends or is stopped is automatically created. It can be replaced with a user defined cleanup if needed. This function receives two arguments: proto, the prototype event, and flag, which is set false if all nodes have been freed already by CmdPeriod.
Unfortunately the highlighted sentence seems a serious misstatement of the present implementation, i.e. Pproto
doesn’t work at all like that with respect to a user-provided cleanup. Try
p = Pbind(\dur, Pseq([1, 2, 5, inf])); // intentional final inf dur
r = Pproto({ ~group = (type: \group).yield; }, p,
{"Not actually called.".postln;}).play
r.stop // stops even the infinite event, but prints nothing
Basically if there is any auto-generated clean-up (and there is one for type: \group
), then the user provided cleanup function is completely ignored by Pproto
. I’m not sure this is a good thing (e.g. one might want to release the group rather than kill it right away) and more importantly, the Pproto
behavior of ignoring the user-provided cleanup clearly contradicts the documentation…
Actually it seems even more serious than that. The user provided cleanup seems ignored in all circumstances, even:
p = Pbind(\dur, Pseq([1, 2], inf)); // non infinite notes here
r = Pproto({}, p, {"Not called either!".postln;}).play // intentional no-op init
r.stop
SC version I tried these on: 3.10.4.
Oh, it seems to be exactly this open bug…