The Patchbay_

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.

Short answer. Talking to hardware or writing exact MIDI files → mido. Analysing music, extracting notes, feeding an ML pipeline → pretty_midi.

Side by side

Mido pretty_midi
LevelLow — messages, ticksHigh — instruments, notes, seconds
Live MIDI I/OYes — portsNo
Time unitsTicks and delta timesSeconds
Analysis helpersNoPiano roll, chroma, beats
Byte-exact file controlYesAbstracted away
Typical useDevices, exact filesResearch, ML, analysis
LanguagePythonPython
LicenseMITMIT
PlatformsmacOS Windows LinuxmacOS Windows Linux
First released2013~2014
MaintainedYesYes

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…

Choose pretty_midi when…

Mido detailspretty_midi detailsAll ML & generative

← All comparisons