Generated MIDI file deltaTimes

• Mar 3, 2019 - 02:17

Hi,

I'm noticing a kind of an odd thing with a MIDI file generated from a score: the delta times seem to be one off. Here's what I mean:

Say I have a score with a line that starts with a half note and then a quarter note. With the PPQN=480, I would expect the following basic sequence of events:

delta time event
0 NoteOn, velocity X
960 NoteOn, velocity 0
0 NoteOn, velocity X
480 NoteOn, velocity 0

Instead, I see something like the following:

delta time event
0 NoteOn, velocity X
959 NoteOn, velocity 0
0 NoteOn, velocity X
479 NoteOn, velocity 0

This probably doesn't make much difference for playback of the MIDI file (it being only a difference of 1/480th of a quarter note), but I'm trying to write a program that parses MIDI files, and it's kind of choking on the off-by-one errors. I looked at some other MIDI files around the web, and they seem to have the sort of delta times I would expect.

Is this intentional? If so, can someone explain the rationale?


Comments

I think it is on purpose, to avoid cases where some implements respond poorly to the note off and subsequent note on happening on the same tick. I recall complaints in particular about pedal events causing trouble for some sequencers or synths.

I just made a test for my curiosity and shared the result, maybe it's useful for someone:

I did made a test with the free MIDI editor Sekaiju and I saw the following command might be useful:
"Modify Events Duration", Relative ticks, 1 (It simply adds 1 tick to all note values.)
Although it requires an extra step in your work.

Attachment Size
1-before.png 14.11 KB
1-after.png 9.85 KB

Do you still have an unanswered question? Please log in first to post your question.