skillfed

pretty-midi

Functions and classes for handling MIDI data conveniently.

pretty-midi v0.2.11.post0 255.6K downloads/30d#8,475 on PyPI1,035
Permissive license MIT Active released

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-midi

uv

uv add pretty-midi

poetry

poetry add pretty-midi

Installing 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

Development Status :: 3 - AlphaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: PythonTopic :: Multimedia :: Sound/Audio :: MIDI

Tags

midi file parsing pythonmidi note manipulationmusic information retrievalmidi synthesis audiomidi tempo analysismidi chord creationmidi data extraction
music-information-retrievalmidi-synthesis

More MIDI packages