-
Notifications
You must be signed in to change notification settings - Fork 746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EventStreamPlayer could easily support hanging on Conditions #4967
Comments
Just to be sure I get this right: 1.) We would gain a way to halt an event stream in the middle, without thereby clearing the cleanup. This is like what can be done with the message 2.) The return value of the event stream should signal what will happen. Apart from the returned event being played, it is only variants of resting (essentially time values) or finishing up (nil). But because we can encode any functionality in the event returned, we can simply call your function from an event. An event is really just a function with default arguments that is called on This works: (
d = Pbind(*[dur: 0.3, degree: Pseries(0, 1, 8)])
q = Condition.new;
(Prout({|ev| (play: { q.hang }).yield; loop { ev = ev.yield } }) <> d).play;
)
q.unhang; Do you see a reason why this won't do it? |
1.) Yes, that's the point. 2.) And yes, that's fairly valid workaround, but the duration (implicit 1) is still contained in the custom-play Event, and the next event is delayed by that much (1 sec, in your example); if you make it For a bit more context, the reason I was doing this is that if you use Pgate to achieve the same thing (with an initial rest) you have exactly the same problem, that you get an initial delay when "unhanging"; albeit you could make that one pretty short too. But with Pgate it's actually a worse problem, because it spams the initial rest until you enable the gate, so you can't make the rest way short, which you can with your custom-play solution. The Pgate thing that motivated this:
|
It's a bomb when looping infinitely over a constant delta (which is admittedly a common case), but hanging/unhanging a thread is not an infinite loop. One could create a |
Motivation
Presently
Description of Proposed Feature
Well, EventStreamPlayer could easily support
hang
by just yielding that when it sees it as an event.Plan for Implementation
Quickly tested with this derivative:
And an actual test for that code, since I used a different class "just in case".
Seems to work ok for me. I can submit a pull req on this as an actual patch to
EventStreamPlayer
proper if there are no objections to these minor semantics improvement, i.e. making it support hangs (via Conditions).Looking at
prTempoClock_Sched
(C++) it seems anything that's not a double will be treated as "no op", not just\hang
, so probably the test I've added to EventStreamPlayercould be made more general to yield/return any "rubbish" that doesn't respond to
playAndDelta
"as is". But doing this could obscure some bugs in user code, i.e. instead of getting an error due to playAndDelta on a a buggy stream (that was meant to return events but somehow doesn't) it will be silent when played. InterestinglySimpleNumber
does defineplayAndDelta
as{ }
thus returning itself, so a number can be used as "rest" in an event stream (due to howsched
works and because the additionnextBeat = inTime + nextTime
is fine for numbers):The text was updated successfully, but these errors were encountered: