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

How to split midi file based on notes pitch using python?

How can I split midi files based on their pitch using python? I tried the music21 library, but I don't really know how this works...
SushiWaUmai
  • 348
  • 6
  • 20
2
votes
1 answer

Output more than one instrument using Music 21 and Python

I am using Python and Music21 to code an algorithm that composes melodies from input music files of violin accompanied by piano pieces.My problem is that when I input a midi file that has two instruments, the output is only in one instrument. I can…
R A
  • 21
  • 1
2
votes
0 answers

Get the tempos of a parsed MusicXML file

In MusicXML, there can be direction tags that have tags, which sets the BPM. For example, Molto vivace
Steve Hemmingsen
  • 383
  • 5
  • 19
2
votes
1 answer

Music21: get track index of a note

I have a multi-track midi file that I'm reading with music21: import music21 f = music21.midi.MidiFile() f.open('1079-02.mid') f.read() stream = music21.midi.translate.midiFileToStream(f).flat note_filter =…
duhaime
  • 25,611
  • 17
  • 169
  • 224
2
votes
0 answers

How can I use the Music21 library to transpose all midi files into a universal key (major and minor)

I need to loop through a given directory as transpose the midi files from their respective keys into a universal key (C). How can I do this in python? Current Code: This will be used to transpose the key in which each midi file is play in such…
AndrewCooper
  • 47
  • 1
  • 4
2
votes
2 answers

Why does stream.Parts not well formed after an insert?

I want to convert the sheet music of a stringorchestra (Muse score Bach Brandenburg concerto no 3 1st movement BWV1048)  to sheet music for piano, so I can play it on piano. I was able to get the separate parts (violins, violas, violoncelli and…
2
votes
1 answer

Music21 Python Library will only output Piano sounds

I'm using the Music21 library and want to hear each track in the instrument is should be played in from within my jupyter notebook (IPython). I can successfully output music on different tracks to a midi file and play through timidity, but am unable…
TFer
  • 21
  • 3
2
votes
1 answer

How do I iterate through a music21 chord object and append each note of the chord together, and store the entire chord into a list as one element?

So I am trying to parse a MIDI song using the Music21 library. This song notes of varying durations, chords, and rests. I want to be able to parse through the song and check to see whether the MIDI event is a note, if so store its MIDI number and…
2
votes
1 answer

What is difference between "duration" and "offset" in MIDI files?

I'm using "music21" library to process MIDI files. Unfortunately, the provided documentation is not so clear for ones who don't understand much about how music is composed. What is the difference between "duration" and "offset"? For what I…
demo
  • 421
  • 5
  • 22
2
votes
0 answers

Music21 Instrument Objects not working as expected

I am trying to predict the next musical instrument note pair in python using an RNN neural network. However, I am having trouble interpreting the music21 documentation for the part I am currently on. In the code below I, am trying to extract the…
2
votes
1 answer

Julia PyCall difficulties in running modules of Music21

I am a beginner having difficulties using Julia's PyCall to interface with the MIT Python music module music21. According to Music21’s website, in order to display a short melody in musical notation one would type this in…
Nakul Tiruviluamala
  • 523
  • 1
  • 3
  • 15
2
votes
1 answer

Extracting note data from a .mxl file using music21

I am quite comfortable with python, but have recently gotten into trying some musical analysis. I have come across music21, and I would like to know how to extract the basic note data (pitch and duration) of every note in a musical .mxl file. I have…
2
votes
0 answers

Music21 - Python: COnvert musicxml to MIDI, mapping String info to channel

I took a look at the music21 documentation, but I don't know if what I am looking for is possible. For fretted instrument, musicXML can have a tag. I am looking to convert musicXML files with String infos in MIDI files, with string ID mapped to the…
X-Raym
  • 31
  • 3
2
votes
1 answer

How to replace pitches in a music21 Score

I'm trying to replace one pitch in a score with another pitch (the end goal being to generate harmony parts). >>> from music21 import * >>> score = converter.parse('test.mid') >>> type(score) >>> p0 =…
mathandy
  • 1,892
  • 25
  • 32
2
votes
1 answer

Extract acoustic bass drum from midi file by using music21 library

I downloaded the midi file from here: Taylor Swift - You Belong With Me.mid Then I want to only extract the acoustic bass drum part, which means I want the output acoustic bass drum.mid of this song. I used music21 library to parse the midi file,…
pc101
  • 66
  • 5