Open idoby opened 3 years ago
I support this PR (assuming conflicts can be resolved in a straightforward way)! This is an extremely convenient way to implement stuff like changing the midi file tempo which appears to be quite complicated to do within the pretty-midi domain.
Not sure how I missed this but thanks for flagging it @a-pillay . My only suggestion is just to provide a new argument rather than overloading midi_file since this certainly isn't a "midi file" when it's a mido object.
Then you run into the trouble of having to check that both arguments weren't passed in. I think this kind of interface is less error-prone for the user as well. Either way, I'm not sure I have the time to fix this...
I wouldn't call that trouble - it's a single if statement, and adding a single if statement is better than making an argument's meaning ambiguous, because the arguments are user-facing.
@a-pillay feel free to pick up this PR if you have time.
Sure, I can take a look at it.
To summarize, this change would involve:
mido_object
in pretty_midi.PrettyMIDI
with default=Nonemido.MidiFile
via a new if-else block:mido_object
and midi_file
arguments are populated?)Could you please confirm this logic before we implement the same?
Yes, that would be fine. I don't think the order of the blocks is terribly important as long as all cases are handled.
I have created #241 to implement this feature.
Allow passing in a loaded mido object to allow more fine-grained control over how mido loads the MIDI file.