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
4
votes
1 answer

Unable to write 'rest' objects in midi file

I have a list containing several 'notes', 'chords' and 'rest' object and trying to write them into a midi file. I am trying with following code midi_stream = stream.Stream(output_notes) midi_stream.write('midi', fp='test_output.mid') On reading the…
4
votes
1 answer

split midi file for each bar in python

I want to divide the MIDI file in python into bars and get the notes in that bars. So I use music21 library and I can get the notes but I can't split it up by bar. I want to know what kind of notes are in bar 1 and what are in bar 2. I hope I can…
sudal
  • 41
  • 1
4
votes
1 answer

How to Extract Individual Chords, Rests, and Notes from a midi file?

I am making a program that should be able to extract the notes, rests, and chords from a certain midi file and write the respective pitch (in midi tone numbers - they go from 0-127) of the notes and chords to a csv file for later use. For this…
Ikechukwu Anude
  • 346
  • 1
  • 4
  • 16
4
votes
2 answers

Python -- How to rename Musescore path in package music21?

I tried to install the Python package music21 and am having a problem running it in Windows. Basically, when I tried to run the simple command they give as an example converter.parse("tinynotation: 3/4 c4 d8 f g16 a g f#").show() I got an…
Mr.NoName
  • 125
  • 4
  • 13
4
votes
1 answer

music21 - Transpose streams to a given key

Is there a function or easy way to transpose a stream to a given key? I want to use it in a loop, e.g, take a set of major streams and transpose all of then to C major (so then I can do some statistical work with them). All the transpose tools I saw…
VR_1312
  • 151
  • 1
  • 13
4
votes
2 answers

Music21 Midi Error: type object '_io.StringIO' has no attribute 'StringIO'. How to fix it?

So, I've followed this question in order to get some sound playing with Music21, and here's the code: from music21 import * import random def main(): # Set up a detuned piano # (where each key has a random # but consistent detuning from 30…
Ericson Willians
  • 7,606
  • 11
  • 63
  • 114
3
votes
2 answers

music21 getElementsByClass not showing any output for class stream.Voice

I am struggling to understand why the below code is throwing an error when it ran seamlessly about a year back. The code snippet is from a popular Coursera course. Does the Music21 package has some recent changes around stream.Voice? data_fn =…
maamli
  • 65
  • 6
3
votes
2 answers

Silence music21 warnings

I am getting an abundance of music21 warnings about zero-duration chords: WARNING: midi chord with zero duration will be treated as grace I tried overwriting the warn method on music21.environment.Environment() with the following: def…
duhaime
  • 25,611
  • 17
  • 169
  • 224
3
votes
1 answer

Importing Lilypond file into a local music21 corpus

I'm hoping to run a corpus study on some local Lilypond (.ly) files, but I'm having trouble importing them into a local music21 corpus. I can only assume the answer is on the music21.converter page, but I somehow can't seem to untangle it. As…
3
votes
1 answer

Render compressed png from music21

When I'm trying to save score as a png, sc = stream.Part() ... sc.write('musicxml.png') it sometimes get rendered as follows:
majkrzak
  • 1,332
  • 3
  • 14
  • 30
3
votes
1 answer

How do you color notes in Music21?

How do you color code notes in visual displays with the Music21 Python library? I'm trying to create an animation where specific notes in sheet music are highlighted with a certain color at specific time intervals. So far I'm able to render sheet…
Cerin
  • 60,957
  • 96
  • 316
  • 522
3
votes
2 answers

SubConverterFileIOException - music 21 show()

I just installed music21, and I'm trying to get started on it. I have Musescore3 installed, but I can't make the show() funcion work. I've tried changing the paths, following some instructions I found online, but to no avail from music21 import…
3
votes
1 answer

Music 21 finds notes with duration 1/3 when there are none

I wrote a python script to extract all the notes, their offset, and durations from a midi file. I have achieved this, but I have a problem with the quarterlengths (the duration in quarter notes). I get many notes with duration 1/3, or some other…
Pseudo Nym
  • 175
  • 1
  • 5
3
votes
3 answers

Unable to .show scores in Music21

I'm working in Jupyter Notebook. I've installed music21, musescore, set the xml path as below: us = environment.UserSettings() us['musicxmlPath'] ='Applications/musescore.app' I've also run config, and see that musescore is being detected by…
Pyper
  • 75
  • 1
  • 7
3
votes
2 answers

Python music21 library create png from stream

I have a problem with generate png file from stream object in music21. I read documentation and I use ConverterLilypond to do this. chords = stream.Stream() d7 = chord.Chord(['D4', 'F4', 'A4', 'C5']) dmin7 = chord.Chord(['D4', 'F-4', 'A4',…
lukassz
  • 3,135
  • 7
  • 32
  • 72
1
2
3
10 11