3

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 multiple of a third. However, as far as I can tell, none of the notes have any duration of 1/3, because they are all quarter notes, half notes, or sixteenth notes. Where are these durations coming from?

I've tried using pieces with different times signatures, but both 4/4 pieces, 3/4 pieces, and 3/2 pieces come up with 1/3 quarter lengths for some of the notes. Here is my code for reference:

lis = []
s = converter.parse("music2/" + "bwv525-1.mid")
a = s.flat
for item in a.notes:
    print(item.duration.type, item.duration.dots, item.quarterLength)

where bwv525-1.mid is the file I am reading

Pseudo Nym
  • 175
  • 1
  • 5
  • 1
    Can you give us a sample output? – moritzg Jan 12 '19 at 19:37
  • Here's part of the output: eighth 0 0.5 eighth 0 1/3 eighth 0 1/3 16th 0 0.25 quarter 0 1.0 eighth 0 1/3 eighth 0 1/3 eighth 0 1/3 eighth 0 1/3 16th 0 0.25 16th 0 0.25 16th 0 0.25 16th 0 0.25 16th 0 0.25 – Pseudo Nym Jan 12 '19 at 19:49
  • Maybe this helps: http://web.mit.edu/music21/doc/moduleReference/moduleDuration.html – moritzg Jan 12 '19 at 20:00

1 Answers1

3

I know this piece well and this encoding: most of its notes are encoded as 1/3 length eighth notes and 1/6 length sixteenth rests to give them some separation.

MIDI files generally encode performance not scores.