-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix swapped note-on note-off events (#132)
Resolves #131. * Make failing test for reading tracks with overlapping notes. Make two tracks using mido - one good with correct note-on/note-off order, second (bad) with another note-on before note-off at the same tick. Current code fails on the latter. Then read it via PrettyMidi, write it and read it back. It should be the same according to expected values, but due to a bug it differs. * #131 Fix a problem when reading tracks with overlapping notes. In particular when there are two adjacent notes and at the same tick there's first note-on and then note-off, the library incorrectly closes both notes, even though the second note should be still open. Such a MIDI is probably a bit malformed, but the library should not fail on that if it can resolve the situation. Due to this bug the library incorrectly produces zero-duration events and some long open notes. The solution is to keep the note-on event in the list of open notes if it's at the same tick as the note-off event and we're closing some previous notes. Note that we changed the format of time within values of the last_note_on dict - from real time to integer tick. This is to avoid floating point comparison when we have the original integer values. * Fix PEP8 style errors. * Test using NamedTemporaryFile instead of leaving trash files around.
- Loading branch information
Showing
2 changed files
with
93 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters