Questions tagged [music21]

0

votes
0

answer
5

Views

How to make MIDI file from notes with Flute instrument in Python (music21 library)

I have some notes and what I want is create the MIDI file with Flute instrument. But what happens is that the output MIDI file plays Piano, instead of Flute. I tried other instruments, but it's always the same, Piano. What is going on? (...) new_note = note.Note(pattern) new_note.offset = offset new...
demo
1

votes
1

answer
722

Views

Music21 Getting All notes with Durations

Im trying to get all notes with their durations(measures). from music21 import * allBach = corpus.search('bach') x = allBach[0] p = x.parse() partStream = p.parts.stream() for n in p.pitches: print 'Pitch: ' + str(n) print '*************' for n in p.notes: print 'Note: ' + str(n) #print 'Duration '...
Nerzid
1

votes
1

answer
332

Views

music21: writing notes to MIDI file by note position

I am using music21 to write midi file from the note values. Following code writes three notes sequentially. However, how do I insert an 'empty' space between the notes? It would be very easy if I could just insert the notes by their 'position' so that I wouldn't have to calculate the position/length...
ytrewq
1

votes
1

answer
702

Views

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 project, I am using the Python Library 'Music21'. from m...
Ikechukwu Anude
1

votes
1

answer
170

Views

data exchange between R and python (music21)

My goal is to take a text file with a number list generated by R (e.g 1 2 3 4), and 'translate' the numbers into music21 notes (that is, to compose a melody when each note is identified with a number). Having the number list, one idea I had was creating a R vector with strings that matches with mus...
VR_1312
3

votes
2

answer
4.7k

Views

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 cents flat to sharp) # and play a Bach Chorale on it i...
5

votes
2

answer
1.8k

Views

Creating images of notes in music21

I get an error when running: from music21 import * n1 = note.Note('C4', quarterLength=1) n2 = note.Note('A4', quarterLength=1) s = stream.Stream() s.append(n1) s.append(n2) s.show('lily.svg') Traceback (most recent call last): File 'C:\Python34\test.py', line 7, in s.show('lily.svg') File 'C:\Pytho...
Christian
6

votes
2

answer
2.4k

Views

How can I produce real-time audio output from music made with Music21?

How can I produce real-time audio output from music made with Music21. Failing that, how can i produce ANY audio output from music made with Music21 via open-source software? Thanks for the help.
5

votes
3

answer
137

Views

Install by default, “optional” dependencies in Python (setuptools)

Is there a way to specify optional dependencies for a Python package that should be installed by default from pip but for which an install should not be considered a failure if they cannot be installed? I know that I can specify install_requires so that the packages will be installed for the 90% of...
2

votes
1

answer
454

Views

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 maybe position of the note)). Documentation for mu...
ytrewq
2

votes
1

answer
324

Views

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, below is my code: from music21 import * import os fp...
pc101
2

votes
1

answer
488

Views

How to set application path in music21

I'm using Ubuntu 14.04 64bit. I don't know what to set on path to application. I have installed music21 in anaconda3, but I got output as follows: music21.converter.subConverters.SubConverterException: Cannot find a valid application path for format midi. Specify this in your Environment by calling...
Július Marko
2

votes
3

answer
240

Views

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 music21 and get the required sound characteristics? If...
Kirill Liubun
2

votes
0

answer
642

Views

music21: read MIDI file's BPM and instrument info and write it back to file

I'm trying to implement a code that reads MIDI file and writes it back. I have the following code to parse the duration,pitch,and position. import music21 from music21 import * piece=converter.parse('input.mid') all_parts=[] for part in piece.parts: part_tuples=[] try: track_name = part[0].bestName(...
ytrewq
3

votes
1

answer
1.4k

Views

Generating pdf & midi from musicxml

I've been trying to load a MusicXML file, edit it (removing several parts), and create a PDF sheet document + midi/mp3, all of this using Python. I've first looked at music21, that would load my MusicXML file right, but as far as I could find, would not output a proper file (all the details in the o...
Joachim Jablon
2

votes
1

answer
1k

Views

Music21: Get all Notes per Instrument from a MIDI File

I am parsing a MIDI file as instructed here. My code looks like this: from music21 import converter,instrument # or import * file = converter.parse('sample.mid') components = [] for element in file.recurse(): components.append(element) The components list now contains data as follows: , , , , , , ,...
sri
4

votes
4

answer
1.3k

Views

Display of music21, musicXML PNG objects using iPython Notebook/Enthought Canopy

I am experimenting with the music21 library, in preparation for a Machine Learning project that involves genre classification and categorization. I and following some tutorials available here. I am using MuseScore as my MusicXML program, and I am trying to run the whole thing from iPython. Although...
Luis Miguel
1

votes
1

answer
212

Views

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 = score.parts[0].pitches[0] >>> p0sharp = p0.transpose(1) >>> print p0 A3 >>> print p0sharp B-3 >>>...
AndyP
2

votes
2

answer
124

Views

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', 'C5']) dmaj7 = chord.Chord(['D4', 'F#4', 'A4', 'C#5']) chor...
lukassz
2

votes
1

answer
154

Views

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 simplest steps are the hardest. For example, how d...
psychemedia
2

votes
1

answer
56

Views

music21 parse files parallel

I would like to parse midi files parallel using music21 library, because sometimes script hang-ups and CPU is loaded to 100%. The problem is that my function return list of notes from files and when I use common.runParallel for this function I get TypeError: 'list' object is not callable from music2...
lukassz
2

votes
1

answer
571

Views

Showing midi pitch numbers from Mid file with music21

I am using music21 to extract the midi pitch numbers (in order) for a bunch of midi files. I have been reading through the documentation and I can load one file like this: from music21 import * sBach = corpus.parse('bach/bwv7.7') Now how do I show a sequence of midi numbers? I am sure this is poss...
dorien
2

votes
1

answer
721

Views

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 work with intervals or number of tones, not fixed...
VR_1312
3

votes
2

answer
401

Views

Iterating over all notes in Music21

I am trying to get a table of information like the following for each note: Pitch - Octave - AbsoluteStart - Duration - Tied - MeterOfMeasure - Quarterlength For each of the notes in a stream (which can contain voices etc.). Is there an easy way to iterate over all the notes, so I can just call the...
dorien
2

votes
1

answer
132

Views

Getting parts from a kern score with music21 (python) - why doesn't it find the parts?

I have parsed a collection of krn files with music21 and they all consist of a number of parts. I want to remix the parts and save them as a different file. However, for a few of the kern files music21 says that is has 0 parts: >>> s = converter.parse('./data/Benedictus_23.krn') >>> print len(s.part...
dorien
2

votes
3

answer
131

Views

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
2

votes
3

answer
1.9k

Views

Saving output in music21 as a MIDI file

I want to ask how to save audio output in python using music21 module. I have read the entire user's guide of said module: http://music21.readthedocs.org/en/latest/usersGuide/index.html, but I couldn't find any information about saving output as an audio file that can be recognised by windows withou...
Ignas Juodžbalis
3

votes
1

answer
572

Views

Playing drum sounds in Python Music21 library

It's been a couple of weeks since I started reading the book 'Making music with computers: creative programming in Python' and now i'm stucked while trying to play drum sounds with this library. I'm using Mit's music21 library, as the one proposed by the book didn't work for me (it's called simply '...
Julian