Music21 Notes with quarter duration less than 0.25?

280 views Asked by At

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 0.25. Am I doing something wrong or is it a limitation in Music21?

Here's how I read the file:

for file in glob.glob(midi_folder + '/*.mid'):
    midi = converter.parse(file)

    midi_notes = None

    try:
        instruments = instrument.partitionByInstrument(midi)
        for inst in instruments:
            if inst.partName == 'Piano':
                midi_notes = inst.recurse()
                break          
    except:
        midi_notes = midi.flat.notes
        
    for element in midi_notes:
        # do stuff with the note ...
1

There are 1 answers

1
Jacob Walls On

MIDI files are quantized by default. You can read about the quantization arguments to converter.parse--including how to configure or turn off quantization--at: http://web.mit.edu/music21/doc/moduleReference/moduleConverter.html?highlight=converter%20parse#music21.converter.parse