Reputation: 175
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
Upvotes: 3
Views: 384
Reputation: 3648
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.
Upvotes: 3