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 understand, the first note/chord have offset 0.0, and let's suppose, its has duration 1.0. Then, the following note/chord have offset 1.0 and duration 0.5. Then, offset 1.5 and duration 2 and so on. But sometimes it has the same value. I'm confused. Code:
s2 = instrument.partitionByInstrument(midi)
duration = s2._elemets[0]._elements[9].duration
"<music21.duration.Duration 12.0>"
offset = s2._elemets[0]._elements[9].offset
"12.0"
Offset is (roughly) the length of time from the start of the piece. Duration is the time the note is held. The offset of a note will only be the sum of the previous durations if there are no rests (silences) in the piece and there are no cases where two notes sound together.