pretty_midi
Utility library for handling MIDI data intuitively for analysis and MIR workflows.
| Language | Python |
|---|---|
| Category | MIDI tools |
| License | MIT |
| Platforms | macOS Windows Linux |
| Install | pip install pretty_midi |
| First released | ~2014 |
| Maintained | Yes |
| Links | Website · Source |
Strengths
- Convenient note/instrument objects with times in seconds
- Feature extraction (piano roll, beats, tempo, chroma)
- Optional fluidsynth audio synthesis
Limitations
- Audio synthesis requires external fluidsynth
- Not for real-time MIDI I/O
Best for
MIR/ML preprocessing: extracting features and piano rolls from MIDI files.
Minimal example
import pretty_midi
pm = pretty_midi.PrettyMIDI()
inst = pretty_midi.Instrument(program=0)
inst.notes.append(pretty_midi.Note(velocity=100, pitch=60, start=0, end=1))
pm.instruments.append(inst)