pretty-midi
Functions and classes for handling MIDI data conveniently.
What it is and what it does
pretty_midi wraps MIDI file handling in Python objects that expose notes, instruments, and timing as directly modifiable attributes rather than raw binary data. It lets you load a MIDI file, inspect its tempo and harmonic content, shift pitches, add or remove notes, and write the result back to disk or synthesize it to audio. The library depends on numpy for numerical operations, mido for MIDI I/O, six for Python 2/3 compatibility, and importlib_resources for resource loading.
The package is designed for music information retrieval and composition workflows—analyzing existing MIDI files to extract features like key or tempo, programmatically creating MIDI from scratch by building instruments and note objects, or transforming MIDI data by iterating over its structure. Audio synthesis is optional and requires external dependencies (fluidsynth and pyfluidsynth).
Use it for:
- Analyze MIDI files to extract tempo, key, or note statistics for music research
- Programmatically generate MIDI files by creating instruments and adding notes with specific pitches and timings
- Transpose or shift all notes in a MIDI file by a fixed interval
- Extract individual instrument tracks or filter notes by criteria for remixing
- Synthesize MIDI to audio waveforms for playback or further processing
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides utilities for reading, modifying, and synthesizing MIDI data in a Python-friendly format, handling note manipulation, tempo estimation, and audio output.
Yes. The package is actively maintained, has low install friction, carries a permissive MIT license, and fills a clear niche in MIDI manipulation. It is well-suited for music information retrieval, composition automation, and MIDI editing workflows. No known vulnerabilities.
Install
pretty-midi on PyPI
pip
pip install pretty-midiuv
uv add pretty-midipoetry
poetry add pretty-midiInstalling pretty-midi
Before you install
Low friction install with four straightforward dependencies. Actively maintained with a recent release and steady commit history.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open and closed projects.
Quickstart
import pretty_midi
midi_data = pretty_midi.PrettyMIDI('example.mid')
print(midi_data.estimate_tempo())
audio_data = midi_data.synthesize()
Synthesize requires fluidsynth program and pyfluidsynth package installed separately; basic MIDI parsing and manipulation work without them.
Verify before relying
- Whether synthesize() output format and sample rate are documented or configurable
- Performance characteristics with large MIDI files or many instruments
- Python version compatibility (requires_python not specified in metadata)
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 4 — numpy, mido, six, importlib_resources |
| Maintenance | actively maintained — 17 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 255,627/month — #8,475 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pretty_midi-0.2.11.post0-py3-none-any.whl
Keywords: audio, music, midi, mir
Tags
More MIDI packages
Mido provides a Python library for creating,…
permissive · top 5,000 on PyPI
music21music21 is a Python toolkit for analyzing,…
permissive · top 15,000 on PyPI
playsoundPlays audio files (MP3, WAV) and URLs from…
permissive · top 15,000 on PyPI
python-rtmidipython-rtmidi provides a Python interface to…
permissive · top 15,000 on PyPI
symusicsymusic parses and transforms MIDI and ABC…
permissive · top 15,000 on PyPI
librosalibrosa provides audio and music signal…
permissive · top 5,000 on PyPI
basic-pitchBasic Pitch converts audio files to MIDI…
unclear · top 15,000 on PyPI
python-stretchPitch-shifts and time-stretches audio using the…
permissive · top 15,000 on PyPI
pyrubberbandProvides Python wrappers for time-stretching…
permissive · top 15,000 on PyPI
syncedlyricsFetches synchronized lyrics in LRC format for…
permissive · top 15,000 on PyPI
mir-evalmir_eval computes standard accuracy metrics for…
permissive · top 15,000 on PyPI