Skip to content
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

MIDI files with corrupt pitch values are not handled correctly #34

Closed
craffel opened this issue Feb 18, 2015 · 2 comments
Closed

MIDI files with corrupt pitch values are not handled correctly #34

craffel opened this issue Feb 18, 2015 · 2 comments
Assignees
Labels

Comments

@craffel
Copy link
Owner

craffel commented Feb 18, 2015

Sometimes, midi reads in a MIDI file with has NoteOnEvents with data[0] > 127:

In [1]: import midi
In [2]: m = midi.read_midifile("data/clean_midi/mid/Celine Dion/That's The Way It Is.mid")
In [3]: for t in m:
   ...:     for e in t:
   ...:         if type(e) == midi.NoteOnEvent:
   ...:            if e.data[0] > 127:
   ...:                print e
   ...:
midi.NoteOnEvent(tick=4656, channel=7, data=[253, 75])
midi.NoteOnEvent(tick=0, channel=7, data=[254, 75])
midi.NoteOnEvent(tick=48, channel=7, data=[253, 0])
midi.NoteOnEvent(tick=0, channel=7, data=[254, 0])

This is because midi just loads in data via ord https://github.com/vishnubob/python-midi/blob/master/src/fileio.py#L94, so as long as the argument is a 8-bit char it will happily set a data value to a number more than 127. So, this likely happens for other events too, not just NoteOnEvents data[0]. This can create issues later on. Either midi should raise an exception, we should raise an exception, or we should issue a warning and ignore those events with invalid data values.

@craffel craffel added the bug label Feb 18, 2015
@craffel craffel self-assigned this Feb 18, 2015
@craffel
Copy link
Owner Author

craffel commented Sep 28, 2016

This will be resolved by #99, because mido verifies that data bytes are less than 127: https://github.com/olemb/mido/blob/master/mido/midifiles.py#L282

@craffel
Copy link
Owner Author

craffel commented Oct 4, 2016

Resolved in 8fbbdec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant