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

User-defined file loading #201

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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: 4 additions & 1 deletion pretty_midi/pretty_midi.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,11 @@ def __init__(self, midi_file=None, resolution=220, initial_tempo=120.):

"""
if midi_file is not None:
# File passed in is already loaded, just use it
if isinstance(midi_file, mido.MidiFile):
midi_data = midi_file
# Load in the MIDI data using the midi module
if isinstance(midi_file, six.string_types):
elif isinstance(midi_file, six.string_types):
# If a string was given, pass it as the string filename
midi_data = mido.MidiFile(filename=midi_file)
else:
Expand Down