MarkCWirt / MIDIUtil

A pure Python library for creating multi-track MIDI files
Other
247 stars 49 forks source link

Useful to have a constructor using an existing MIDI file? #2

Closed TravisTag closed 7 years ago

TravisTag commented 7 years ago

I know Python doesn't really do multiple argument signatures, but do you think it would be useful to have something like a class function that returns a MIDIFile object given a filehandle of an existing MIDI file opened for reading? It could be useful to be able to open and edit MIDI files that already exist.

I'm already writing a function to do that, just wondering if you'd want it added here on the repo or not.

MarkCWirt commented 7 years ago

Travis,

Yes, it could be interesting, and at one point I sketched something out. I have a few thoughts on it, but haven't really done any work.

The interesting thing -- and perhaps the challenge -- is what to do with the MIDIEvents once you have them. Presumably you would be processing this file because you wanted to perform some kind of change or alteration. For example, you would read in a file and then, say, transpose the pitch and/or key of the piece. I think this is where you would decide if the work with worth-while; are there are useful and interesting transformations you could apply to the deconstructed MIDI file?

If you would find use for such a function, and if you can figure out a relatively elegant way of incorporating it into the code, I'd be more than happy to merge a pull request!

(BTW, sorry it's taken a while to get back to you -- things have been pretty busy for me).

TravisTag commented 7 years ago

Hi Mark,

So my personal use for this was doing some simple music analysis. Since I was finding music in all kinds of formats, I was trying to use MIDI as an intermediary file-type since it allowed me to easily listen to the pieces as well.

I do think there are probably some interesting transformations as well, I'll think about that. I'll go ahead and fork the repo and try some stuff out!

Thanks, Travis

MarkCWirt commented 7 years ago

Using MIDI as an intermediate file type seems like a reasonable thing to do. Hadn't thought about it from the analysis perspective.