I’ve noticed that if Pmono is playing a long \dur note and you sent a stop to its EventStreamPlayer, the note gets released right away, whereas Pbind doesn’t do this, i.e. it only “stops” after the current note has fully played its previously scheduled duration.
p = Pmono.new(\default, \dur, 5, \amp, 0.8, \degree, Pseq([1,2], inf)).play
p.stop // hit after a note just starts -> releases quickly
p = Pbind.new(\instrument, \default, \dur, 5, \amp, 0.8, \degree, Pseq([1,2], inf)).play
p.stop // doesn't release the current note!
Interestingly–or for my use case annoyingly–PmonoArtic has the Pmono stop behavior for notes with legato >=1 and the Pbind stop behavior otherwise. I’m trying to hack PmonoArtic so it will immediately release a note on stop regardless of the note’s legato. Any ideas how to do this?
I have a hack that works around the behavior by changing the clock tempo, i.e. something like
p.stop
p.clock.tempo = 100 // really fast stop now even for Pbind
but it’s not entirely satisfactory because the release is now extremely accelerated i.e. it’s still a different release time for the legato=1 and non-legato notes…
Looking at EventStreamPlayer
internals, the difference in behavior seems to come from the call to cleanup.terminate
. Pmono sets up cleanup while Pbind doesn’t. PmonoArticStream
does something rather complicated, removing the cleanup in the sustain<delta
(i.e. legato<1
) notes. I’m honestly not sure why it is necessary for it do this, i.e. why can’t it leave the cleanup on for all notes…
Well, the termination function is basically moved from the cleaner to the clock’s queue, so a way to release early with release time preservation is to do something like
p.stop
p.clock.queue[2].value // this calls the release function for Pbind
This is pretty brittle though, depending on what other stuff there might be in the queue. (Also prints a failure in server when the clock tries to do the same action a bit later, when it was scheduled). I guess there might be a way to have the clock “jump” to next event, but I can’t figure out the canonical way to do that right now.