A fairly simple question for which I have a guess, but I can’t find a definitive answer anywhere.
The background: I have a multi-track midi file with TEMPO controls in the first track. I need to translate the ABSOLUTE_TICK count in other tracks to “Seconds” (fractional seconds offset from the beginning of the midi file).
I have the formula to relate ABSOLUTE_TICK to Seconds based on the PulsePerQuarterNote (PPQN) for the file to the tempo (MS per quarter note).
The question is: do TEMPO changes in the first track (track 0) apply to all the other tracks?
If so, then while I’m parsing other tracks (e.g. track 4, which has NOTE_ON and NOTE_OFF messages I am interested in) I will need to keep a finger pointing to the TEMPO changes in track 0 in parallel. Is that right?
Thanks,
Mark
In short, yes. The first track contains the timing info which will be applied for the entire arrangement, so you apply these messages for each of the tracks with the same absolute time. Since all events use an offset in ticks, you need to first extract the tempo change messages, convert them to absolute time, and then as you are reading in the other tracks you will apply these messages based on that timeline.
From the MIDI fanatic’s technical brainwashing center:
That said, some sequencers do break this rule and put actual MIDI events in the first track alongside timing info, since the standard isn’t so specific in this regard. Your program should deal with both cases, since it is likely to encounter MIDI files in the wild which are formatted in this way.