I need to create a pair of midi devices in Python. The idea is that I can patch the output of a MIDI device into my script, and patch the output of my script into something like SoftSynth. My script would make modifications to the MIDI Stream as they passed through.
I know it’s almost certainly possible, but I can’t seem to find a “batteries included” solution.
There is no built-in MIDI library in Python, largely because there is no cross-platform notion of “MIDI device”. Or, rather, there are about 30 different ones—PortMedia, JACK, SDL, etc.
So, you have to pick one. If this is for personal use, pick the one you’re actually using right now to connect things up. It doesn’t matter whether it’s cross-platform or not; whether you’re using ALSA or PortMedia for MIDI, use a wrapper for that.
So, how do you find a wrapper? Just go to PyPI and search for “alsa” or “portmedia” or whatever, possibly together with “midi”, and there’s a good chance you’ll find a decent wrapper. (This should be your first step whenever you’re looking for libraries to do X in Python if X isn’t built in.)