Flip a MIDI
Updates
- [2017-02-21, 01:33 GMT] Fixed a subtle bug where the site could output corrupt MIDI files, caused by incorrectly applying MIDI running status to events other than MIDI channel events. This could manifest as any number of oddities, including a changed tempo.
- [2017-02-03, 04:16 GMT] If you encountered an issue with the flipped MIDIs being squashed into one track where the original wasn't, this issue should now be fixed! A technical explanation of the issue can be found on Hacker News.
What the heck is this?
Have you ever wondered how a MIDI file would sound if you took its notes and inverted them, so that the high notes were low and the low notes were high, while preserving the tonal distance between the notes?
No?
Well, Andrew Huang (@andrewismusic) has, and after inverting "Für Elise" by Beethoven, he made a YouTube video of the results. They're surprisingly good!
At the end of the video, he called for people to make their own flipped MIDIs and share them with the Twitter hashtag #midiflip via Twitter. I (Sophie Hamilton, aka @Sophira), thought that I could do one better.
After reading the MIDI specification and working out just how much of it can be ignored, I cobbled together AutoMIDIFlip in Perl to automatically flip any MIDI file you give it. It works a little bit differently to Andrew's original idea, though - rather than using the first note of the melody as an anchor point, AutoMIDIFlip simply inverts the entire range. Where you previously had 0-127 as note numbers, you now have 127-0, which prevents any flipped notes from going out of range.
There are a few other things to note about AutoMIDIFlip:
- AutoMIDIFlip correctly inverts pitch bends and portamento changes, but does not yet invert the GM Fine Tuning and Coarse Tuning RPNs. This may be implemented later.
- MIDI channel 10 is assumed to be a drum channel, and is not flipped. This allows sensible drumbeats to remain on MIDI files that have them.
- AutoMIDIFlip currently will not accept files larger than 150 KiB. This limit may be increased later.
To use it, simply use the box above to give it a MIDI file to flip. You can also check out some examples:
Other MIDI flipper projects
I'm not the only one who had this idea. Here are links to some other projects that do similar things:
- GitHub: pvrs12/midi_invert: Open source (MIT/Expat), Python. Uses the music21 Python module to synthesise a new MIDI file containing the flipped notes. The Twitter bot associated with this project is no longer online.
- GitHub: RetSamys/midiflip: Open source (GPLv3), Python. Console-only Python program which inverts MIDI files by tweaking the MIDI data directly.
- Automatic MIDI Inverter: Open source (ISC), Python, Web-based. Created by @dscush. Uses the mido Python module to read the MIDI file and change it.
- MidiFlip: Open source (MIT), Node.js, CLI-based but with web interface (using local HTML+JS). Created by @1j01. Installable via npm, can convert multiple files at once, and allows for advanced mathematical transformations.