Mido vs pretty_midi
The two standard Python MIDI libraries, and they sit at different levels. mido gives you messages and ports; pretty_midi gives you instruments, notes and seconds.
Side by side
| Mido | pretty_midi | |
|---|---|---|
| Level | Low — messages, ticks | High — instruments, notes, seconds |
| Live MIDI I/O | Yes — ports | No |
| Time units | Ticks and delta times | Seconds |
| Analysis helpers | No | Piano roll, chroma, beats |
| Byte-exact file control | Yes | Abstracted away |
| Typical use | Devices, exact files | Research, ML, analysis |
| Language | Python | Python |
| License | MIT | MIT |
| Platforms | macOS Windows Linux | macOS Windows Linux |
| First released | 2013 | ~2014 |
| Maintained | Yes | Yes |
Where they actually differ
Ticks against seconds is the practical split
mido keeps you in MIDI’s native tick-and-tempo world, which is what you need when the file must be byte-exact or a device is waiting on precise timing. pretty_midi converts to seconds and gives you note objects with start and end times — far easier to reason about, and lossy in ways that matter if you care about the exact bytes.
Only mido talks to hardware
mido opens input and output ports, so live MIDI — controllers, synths, sequencers — is mido’s territory. pretty_midi is a file library with no I/O at all. If a cable is involved, the answer is mido, possibly with python-rtmidi underneath.
pretty_midi is built for analysis
Piano-roll matrices, chroma, beat estimates and per-instrument note lists are one call away. Doing the same from mido means writing the conversion yourself, including tempo-map handling, which is more error-prone than it looks.
They compose well
A common pattern is pretty_midi for analysis and generation, mido for the final write or live playback. They are not really competitors.
Which should you choose?
Choose Mido when…
- You are sending or receiving live MIDI
- You need byte-exact control over the file
- You are working with SysEx or unusual messages
- You want the thinnest possible abstraction
Choose pretty_midi when…
- You are analysing existing MIDI
- You want notes in seconds, not ticks
- You are building an ML dataset
- You want piano roll or chroma without writing it