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

Minor Python 3 compatibility fixes #98

Merged
merged 4 commits into from
Oct 4, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pretty_midi/pretty_midi.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import warnings
import collections
import copy
import functools

from .instrument import Instrument
from .containers import (KeySignature, TimeSignature, Lyric, Note,
Expand Down Expand Up @@ -1271,7 +1272,7 @@ def event_compare(event1, event2):
mid.tracks.append(timing_track)
# Create a list of possible channels to assign - this seems to matter
# for some synths.
channels = range(16)
channels = list(range(16))
# Don't assign the drum channel by mistake!
channels.remove(9)
for n, instrument in enumerate(self.instruments):
Expand Down Expand Up @@ -1314,7 +1315,7 @@ def event_compare(event1, event2):
channel=channel, control=control_change.number,
value=control_change.value))
# Sort all the events using the event_compare comparator.
track = sorted(track, cmp=event_compare)
track = sorted(track, key=functools.cmp_to_key(event_compare))

# If there's a note off event and a note on event with the same
# tick and pitch, put the note off event first
Expand Down