craffel/pretty-midi
Utility functions for handling MIDI data in a nice/intuitive way.
What it solves
MIDI files are a common format for storing musical information, but working with them directly can be messy. pretty_midi gives you simple Python tools to load, modify, and inspect MIDI data, so you can extract musical insights or create new MIDI files without wrestling with the low-level format.
How it works
The library provides a PrettyMIDI object that loads a MIDI file and gives you easy access to its contents. You can read notes, instruments, and timing, estimate the tempo, and compute harmonic features like chroma. You can also change notes (for example, shift pitches), add new instruments, and write out modified or new MIDI files. Optionally, if you have fluidsynth installed, pretty_midi can synthesize audio from the MIDI data.
Who it's for
It's for anyone working with MIDI in Python: music researchers, developers building music tools, or hobbyists who want to analyze or generate musical scores programmatically.
Highlights
- Load and parse MIDI files into a friendly Python object
- Estimate global tempo from the music
- Compute chroma features (a proxy for key)
- Easily edit notes and instruments (e.g., transpose pitch)
- Create new MIDI files from scratch and write them out
- Synthesize audio using sine waves or fluidsynth (if installed)
Related
- Project
- Project
- Project
- Project