-
Notifications
You must be signed in to change notification settings - Fork 757
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
Classlib: Fix Pfindur bug where the last event could lose its Rest status #5113
Classlib: Fix Pfindur bug where the last event could lose its Rest status #5113
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ran the tests and checked the code from the PR description and it works. thanks!
i have some questions about one of the class library lines if you'll humor me ^^
@@ -433,7 +434,9 @@ Pfindur : FilterPattern { | |||
if (nextElapsed.roundUp(tolerance) >= localdur) { | |||
// must always copy an event before altering it. | |||
// fix delta time and yield to play the event. | |||
inevent = inevent.copy.put(\delta, localdur - elapsed).yield; | |||
remaining = localdur - elapsed; | |||
if(inevent.isRest) { remaining = Rest(remaining) }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, with this current version, if delta
isn't a rest, and inevent.isRest
is true for another reason, outgoing event's delta
is still a rest (i don't know if this is okay or not but it feels a bit messy). would it be better here to check delta.isRest
? that would also be more efficient -- for any event that isn't a rest, with the line above we'll cycle through all of the key/value pairs every time.
am i right in thinking that inevent.isRest
is true and delta
isn't a rest, and we make a copy of inevent
with a different delta
, then inevent
should still be a rest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be better here to check delta.isRest?
The variable delta
is always a number, because the event-delta primitive unwraps Rests and rejects non-numeric types. So delta.isRest
is always false.
I could change it to inevent[\delta].isRest
.
outgoing event's delta is still a rest (i don't know if this is okay or not but it feels a bit messy.
That's true. I didn't think it was especially harmful because (degree: Rest(0), delta: 1)
and (degree: Rest(0), delta: Rest(1))
are both rests, so there's no change in outward behavior. But we don't know what the user is doing with anEvent[\delta]
so you're right that it would be better to make it more precise.
am i right in thinking that inevent.isRest is true and delta isn't a rest, and we make a copy of inevent with a different delta, then inevent should still be a rest?
Yes. The bug occurs here if delta
is the only Rest inside the event.
(Btw, aside, this is one of those places in the pattern library where the meanings of event
and inevent
are reversed. inevent
should come from the argument or the previous yield and event
should come from the stream. I never understood how this inverted convention got started but this isn't the only embedInStream
method that makes this mistake.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable delta is always a number, because the event-delta primitive unwraps Rests and rejects non-numeric types. So delta.isRest is always false.
I could change it to inevent[\delta].isRest.
ah okay, i didn't realize Event:-delta
is not just a member access, but that makes sense. yeah, i think limiting it that way would be better.
(Btw, aside, this is one of those places in the pattern library where the meanings of event and inevent are reversed. inevent should come from the argument or the previous yield and event should come from the stream. I never understood how this inverted convention got started but this isn't the only embedInStream method that makes this mistake.)
possibly someone misinterpreting inevent
as meaning 'the event we are in' rather than 'the input/incoming event' (is that the intended meaning?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
Purpose and Motivation
When Pfindur reaches the end of its duration, it replaces the original event with a copy, where
delta
has been shortened so that the total duration matches thePfindur
limit.But if
event[\delta]
is a Rest, thenlocaldur - elapsed
is not a rest -- so the event loses itsisRest
status and may play sound, even though the user pattern specified a Rest.(It is valid for a pattern to specify timing using
\delta
, and it's valid for rests to be specified in a\delta
stream -- so, Pfindur should respect that.)Types of changes
To-do list