Pedal should not be considered up at the exact moment when it goes down #41
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We're using this in an app that plays MIDI files in sync with an interactive piano roll visualization. Overall it's working incredibly well, but we've encountered one scenario in which the app and the Piano can get into an inconsistent state: if a
Piano.pedalDown()
is followed immediately by aPiano.pedalUp()
on the same timestamp, the falseisDown()
check causes thePiano.pedalUp()
to terminate without changing the pedal state. The app thus assumes that the pedal is up when in fact the Piano still has it in the "down" state.We could sidestep this scenario by rewriting our app to avoid overlapping pedal events, or by artificially incrementing the
time
parameter between them. But the proposed change below is the simplest, and moreover, in our view it makes the Piano's behavior a bit more logically consistent. At least, we can't see any case in which it's beneficial to consider the pedal not to be down at the very moment at which it has moved to the "down" state.