Skip to content

Commit

Permalink
Midi fixes
Browse files Browse the repository at this point in the history
Midi fixes agreed from last PR
  • Loading branch information
samg7b5 authored and edudobay committed Nov 15, 2021
1 parent 3b44b33 commit 6558cac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions mingus/midi/midi_file_in.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,12 @@ def parse_midi_event(self, fp):
raise IOError("Couldn't read MIDI event parameters from file.")
param1 = self.bytes_to_int(param1)
param2 = self.bytes_to_int(param2)

# "It is common for a note on with 0 velocity to be interpreted as NOTE OFF." https://stackoverflow.com/questions/48687756/midi-note-on-event-without-off-event
# this should resolve Lilypond midi files which don't seem to use ec 8 to signify NOTE OFF
if param2 == 0:
event_type = 8

return (
{
"event": event_type,
Expand Down
2 changes: 1 addition & 1 deletion mingus/midi/midi_track.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def set_key(self, key="C"):

def key_signature_event(self, key="C"):
"""Return the bytes for a key signature event."""
if key.islower():
if str(key).islower():
val = minor_keys.index(key) - 7
mode = b"\x01"
else:
Expand Down

0 comments on commit 6558cac

Please sign in to comment.