I'm looking for a way to change individual notes in a pre-existing MIDI file in Python. I've found a lot of packages that allow for the writing of MIDI files, but not altering existing ones. Is there a package that could help with this or a a way of parsing the hex of the MIDI file to accomplish this?
The open-source program MIDICSV converts MIDI to text CSV and vice versa. You can open a CSV file as text and edit it easily using Python, without having to rely on any special modules.
For information on the MIDI protocol, please see:
In a recent project I found this work very easy to do.
You probably can't "alter existing files" if you mean modifying them in-place.
But you can just parse the MIDI file, change it (in-memory, or iteratively), and write a new one.
You didn't mention which packages you looked at to write MIDI files, but every one I've ever dealt with can also read MIDI files, so you probably already have everything you need.
And there's nothing requiring you to use the same package for both reading and writing. For example, you can use midiparser
for reading and python-midi
for writing; the code to map MIDI messages from one package's format to the other is trivial.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With