Python music libraries

Updated Nov 2026

Python music libraries read, write, and analyze music as notes, scores, or audio. A symbolic library treats music as notes and durations rather than as the sampled sound waves that an audio library processes. These libraries let music apps, research tools, and AI models compose, transcribe, and analyze songs in code.

Popularity

Mido has the most monthly downloads in this comparison, at 1.4M.

LibraryMonthly downloadsStarsLast releaseLicense
Mido
1.4M
1.7KOct 2024MIT
Pedalboard
1.1M
6.5KOct 2026GPL-3.0
music21
972.5K
2.6KOct 2026BSD-3-Clause
pretty_midi
690.8K
1.0KJul 2026MIT
Symusic
463.8K
190Apr 2026MIT
Basic Pitch
396.1K
6.1KAug 2024Apache-2.0
python-rtmidi
207.1K
417Nov 2023MIT
Essentia
116.3K
3.8KMay 2026AGPL-3.0-only
Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Features compared

LibraryRead MIDI event modelWrite MIDI filesLive MIDI ports
MidoBuilt-inBuilt-inVia plugin
PedalboardUnsupportedUnsupportedUnsupported
music21Built-inBuilt-inUnsupported
pretty_midiBuilt-inBuilt-inUnsupported
SymusicBuilt-inBuilt-inUnsupported
Basic PitchUnsupportedBuilt-inUnsupported
python-rtmidiUnsupportedUnsupportedBuilt-in
EssentiaUnsupportedUnsupportedUnsupported
Built-inVia pluginNot supported

Libraries and code examples

Provides MIDI message objects, file handling, and APIs for MIDI ports.

Downloads / mo
1.4M
Stars
1.7K
Last release
1.3.3
License
MIT

Strengths

  • Edits individual MIDI messages. Read, change, and save messages within MIDI tracks.
  • Connects to live MIDI ports. Use input and output ports through the selected backend.

Limitations

  • Hardware ports need a backend. Install a supported backend before opening physical MIDI ports.
  • Track times use delta ticks. Convert absolute event positions into delta ticks when building MIDI tracks.

Quickstart

From midi.html
$ python -m pip install mido
import mido
message = mido.Message('note_on', note=60, velocity=64)
print(message)

Mido examples

From open-source projects on GitHub

Pedalboard

Adds effects to audio.

Downloads / mo
1.1M
Stars
6.5K
Last release
0.9.26
License
GPL-3.0

Quickstart

From examples.rst
$ python -m pip install pedalboard mido
from pedalboard import load_plugin
from mido import Message
instrument = load_plugin('your-instrument.vst3')
audio = instrument(
    [Message('note_on', note=60), Message('note_off', note=60, time=5)],
    duration=5, sample_rate=44100,
)
print(audio.shape)

Provides tools for computer-aided musical analysis and score processing.

Downloads / mo
972.5K
Stars
2.6K
Last release
10.5.2
License
BSD-3-Clause

Strengths

  • Structures notes into musical streams. Place notes and nested musical content inside Stream containers.
  • Imports and exports score notation. Read and write MusicXML alongside MIDI and other music formats.

Limitations

  • Graphical notation needs external software. Configure a supported score viewer before calling graphical show.

Quickstart

From README.md
$ python -m pip install music21
from music21 import note
n = note.Note('C4')
print(n)

music21 examples

From open-source projects on GitHub

Represents MIDI instruments and note events for analysis, editing, and synthesis.

Downloads / mo
690.8K
Stars
1.0K
Last release
0.2.11.post0
License
MIT

Strengths

  • Uses seconds for note timing. Read note start and end positions in absolute seconds.
  • Builds piano-roll note matrices. Convert instrument notes into a matrix of pitch activity over time.

Limitations

  • Basic waveform synthesis omits drums. Use a drum-capable synthesizer to render percussion.

Quickstart

From README.md
$ python -m pip install pretty-midi
import pretty_midi
midi = pretty_midi.PrettyMIDI('example.mid')
print(midi.get_end_time())

pretty_midi examples

From open-source projects on GitHub

Parses MIDI files through a high-performance interface.

Downloads / mo
463.8K
Stars
190
Last release
0.6.0
License
MIT

Quickstart

From README.md
$ python -m pip install symusic
from symusic import Score
score = Score('example.mid')
print(score.tpq)

Symusic examples

From open-source projects on GitHub

Converts audio to MIDI and detects pitch bends.

Downloads / mo
396.1K
Stars
6.1K
Last release
0.4.0
License
Apache-2.0

Quickstart

From inference.py
$ python -m pip install basic-pitch
from basic_pitch.inference import predict
model_output, midi_data, note_events = predict('example.wav')
print(len(note_events))

Basic Pitch examples

From open-source projects on GitHub

Binds the RtMidi C++ library to Python with Cython.

Downloads / mo
207.1K
Stars
417
Last release
1.5.8
License
MIT

Quickstart

From rtmidi.rst
$ python -m pip install python-rtmidi
import rtmidi
midiout = rtmidi.MidiOut()
try:
    print(midiout.get_ports())
finally:
    midiout.delete()

python-rtmidi examples

From open-source projects on GitHub

Analyzes, describes, and synthesizes audio and music.

Downloads / mo
116.3K
Stars
3.8K
Last release
2.1b6.dev1438
License
AGPL-3.0-only

Quickstart

From README.md
$ python -m pip install essentia==2.1b6.dev1438
import numpy as np
from essentia.standard import Audio2Midi
detector = Audio2Midi(hopSize=32)
result = detector(np.zeros(32, dtype=np.float32))
print(result[2:])

FAQ

Mido suits MIDI messages and files. music21 suits score analysis with notation, parts, and durations. Pedalboard suits audio effects and rendering instrument plugins.

Basic Pitch converts audio recordings to MIDI and detects pitch bends. Its maintainers recommend it for one instrument at a time.

music21 is a toolkit for computer-aided music analysis that represents music as scores, parts, and streams. It reads MusicXML, MIDI, and other symbolic formats.

Pedalboard adds effects to audio and renders sound from installed instrument plugins. Symusic synthesizes MIDI through SoundFont files.

For coding agents

Found your music library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official