Skip to content

music21

by Michael Cuthbert / MIT

From the music21 website:

music21 is a Python-based toolkit for computer-aided musicology. It helps researchers and students answer musical questions quickly and with scientific rigor by writing scripts to search massive corpora of symbolic musical scores.

Symbolic Music Parsing

Read and write a wide variety of music data formats, including MusicXML, MIDI, Humdrum Kern, and ABC notation.

Computational Analysis

Programmatically search for pitch classes, intervals, voice crossings, Roman numeral progressions, and melodic contours across large datasets.

Algorithmic Generation

Create and manipulate musical scores algorithmically, exporting them instantly to standard notation programs like MuseScore or Sibelius.

Built-In Corpus Search

Includes an extensive preloaded corpus of Bach chorales, Beethoven string quartets, and folk songs for immediate computational research.

from music21 import corpus, roman
# Load a Bach chorale and print its key
s = corpus.parse('bach/bwv66.6')
print(s.analyze('key'))