Questions tagged [music21]

A toolkit for computer-aided musicology

A python library developed at MIT for helping answer questions about music files. Full documentation here

157 questions
3
votes
1 answer

Music21 Manipulating Specific Instrument

I am using Music21 in Python to read from a MIDI file and I want to only deal with the tracks that use a certain instrument. For example, if, in my MIDI file I have two tracks that use piano I want to be able to print the notes, change the…
FatUglyProud
  • 137
  • 1
  • 12
3
votes
1 answer

How can I display an empty staff using music21?

I am trying to produce a quick reworking of some educational materials on music showing how it may be able to create the associated media assets (images, audio files) from "code" in a Jupyter notebook using the Python music21 package. It seems the…
psychemedia
  • 5,690
  • 7
  • 52
  • 84
3
votes
3 answers

Is it possible to analyze mp3 file using music21?

I am looking for python library to find out a key and tempo of the song recorded in MP3 format. I've found the music21 lib that allows doing that. But it seems like it works only with midi files. Does somebody know how to parse MP3 files using…
Kirill Liubun
  • 1,965
  • 1
  • 17
  • 35
3
votes
1 answer

Converting piano roll to MIDI in music21?

I am using music21 for handling MIDI and mXML files and converting them to a piano roll I am using in my project. My piano roll is made up of sequence of 88-dimensional vectors where each element in a vector represents one pitch. One vector is one…
dosvarog
  • 694
  • 1
  • 6
  • 20
3
votes
3 answers

music21 format stream as ABC+ and save as a file

i'm trying to convert the whole Bach corpus (mxl files) to abc files. is this possible within music21? thanks! v
Van Anders
  • 33
  • 2
3
votes
3 answers

music21: picking out melody track

I'm processing a bulk of midi files that are made for existing pop songs using music21. While channel 10 is reserved for percussions, melodic tracks are all over different channels, so I was wondering if there is an efficient way to pick out the…
ytrewq
  • 3,670
  • 9
  • 42
  • 71
3
votes
1 answer

music21: parsing notes and durations per track

I'm trying to use music21 to convert multi-track midi files into array of notes and durations per each track. For example, given a midi file test.mid with 16 tracks in it, I would like to get 16 arrays of tuples, consisting of (pitch, duration (plus…
ytrewq
  • 3,670
  • 9
  • 42
  • 71
3
votes
1 answer

music21: How to append a chord to a stream simultaneously?

I have a stream object with notes (pitch and duration). I want to add chords to -for example - the first note of each 4 times. But I want them to sound at the same time. The problem is that the only related stuff I found was how to append a chord to…
VR_1312
  • 151
  • 1
  • 13
2
votes
1 answer

find a note by its color in Python music21

Using music21 in python, I need to select all the notes that are red so I can change them to black but I cannot seem to find a way to select notes by their color... Does anyone have an idea ?
Klayrr
  • 21
  • 1
2
votes
1 answer

music21 getElementsByClass

The code snippet is from a popular Coursera course midi_data = converter.parse(data_fn) # Get melody part, compress into single voice. melody_stream = midi_data[5] # For Metheny piece, Melody is Part #5. melody1, melody2 =…
Ahmed Ahdy
  • 21
  • 3
2
votes
1 answer

Identifying time signature with music21

I'm trying to determine the time signature of a midi file in Python using music21. I can obtain the time signature of this sample midi for instance with: import music21 path = 'ambrosia.midi' score = music21.converter.parse(path) time_signature =…
duhaime
  • 25,611
  • 17
  • 169
  • 224
2
votes
1 answer

How do I read midi / musicxml files in music21 for solo piano where there can be multiple notes in a voice simultaneously?

I have written a python script to process midi files with music21 and write again a midi file. This works if the solo piano is "simple" in the sense, that there are not multiple pitches / notes played simultaneously in a…
2
votes
1 answer

Running the same code yields different results on Colab and on local. No randomization or NN training involved

My code yields different results in the local terminal and on Google Colab. However, if I run the same code on Colab but with a terminal command (i.e. !python test.py), it produces the same result as in local. Unlike another post on Stack Overflow,…
2
votes
1 answer

Music21 and MuseScore can't display .png in jupyter notebook

I run this very simple set of commands to display some sheet music: import music21 music21.environment.set("musescoreDirectPNGPath", "/snap/bin/musescore.mscore") bwv295 = music21.corpus.parse('bach/bwv295') bwv295.show() I am getting the…
wprins
  • 846
  • 2
  • 19
  • 35
2
votes
1 answer

Music21 Notes with quarter duration less than 0.25?

I'm want to read a midi file (a Chopin Etude Opus 25 No. 2 from here) using Music21 and then recreate it. When I read the notes from the file all notes that are shorter than a 16th note are "rounded up" and when I use note.quarterLength it returns…
1 2
3
10 11