AI-authored for Sonari Studio. The example was generated, decoded and tested locally. It is not a Sonari capture or a measurement of a DAW.

The first two notes land. The third is 250 ms early, the fourth 500 ms early, and the fifth only 400 ms early. The notes have not moved on the beat grid. An offline converter is using the initial tempo for the whole file.

Reproduce the failure with five notes

In a format-1 Standard MIDI File at 480 pulses per quarter note (PPQ), make the first track a conductor track. Put Set Tempo events at ticks 0, 960 and 1920: 500,000, 750,000 and 400,000 µs per quarter (120, 80 and 150 BPM). On the second track, start the same note at absolute ticks 480, 960, 1440, 1920 and 2400. For a control file, keep the second track byte-for-byte identical and omit the last two tempo changes.

Note tick Tempo map Always 120 BPM Early by
480 0.500 s 0.500 s 0 ms
960 1.000 s 1.000 s 0 ms
1440 1.750 s 1.500 s 250 ms
1920 2.500 s 2.000 s 500 ms
2400 2.900 s 2.500 s 400 ms

At tick 960, two quarters have already elapsed at 500,000 µs each. The new tempo changes the next interval, not the time it took to reach the boundary. The slope changes again at tick 1920, so the accumulated error shrinks on the final note. This is neither a fixed start offset nor live MIDI callback jitter.

Accumulate time before changing tempo

Add delta ticks within each track to get absolute ticks. Pass the conductor track’s decoded tempo events to the converter below; this is not a file parser. It precomputes each segment’s start time, expressed as a weighted numerator, then binary-searches for the relevant segment. The denominator is always PPQ.

function compileTempoMap(ppq, changes) { if (!Number.isInteger(ppq) || ppq < 1 || ppq > 32767) throw new RangeError("expected PPQ division"); const at = [{tick: 0n, weighted: 0n, tempo: 500000n}]; let lastInput = -1n; for (const [tick, tempo] of changes) { if (typeof tick !== "bigint" || tick < 0n || tick <= lastInput || !Number.isInteger(tempo) || tempo < 1 || tempo > 0xffffff) throw new RangeError("expected ascending ticks and valid tempo"); const t = BigInt(tempo), prev = at.at(-1); if (tick === 0n) at[0] = {tick, weighted: 0n, tempo: t}; else at.push({tick, weighted: prev.weighted + (tick - prev.tick) * prev.tempo, tempo: t}); lastInput = tick; } return tick => { if (typeof tick !== "bigint" || tick < 0n) throw new RangeError("expected nonnegative BigInt tick"); let lo = 0, hi = at.length; while (lo + 1 < hi) { const mid = lo + Math.floor((hi - lo) / 2); if (at[mid].tick <= tick) lo = mid; else hi = mid; } const s = at[lo]; return {weighted: s.weighted + (tick - s.tick) * s.tempo, ppq: BigInt(ppq)}; }; } const time = compileTempoMap(480, [[0n, 500000], [960n, 750000], [1920n, 400000]]); const seconds = tick => { const {weighted, ppq} = time(tick); return Number(weighted) / Number(ppq) / 1e6; }; console.log([480n, 960n, 1440n, 1920n, 2400n].map(seconds)); // [0.5, 1, 1.75, 2.5, 2.9] 

The seconds helper converts to floating point only for this short display. Keep the rational result if you are choosing a fixed sample or microsecond rounding policy later. The example assumes PPQ and one global tempo map. It rejects duplicated changes rather than choosing a tie-break and does not implement format 2 or SMPTE division.

Test the note that crosses a boundary

Convert Note On and Note Off separately. If a note runs from tick 900 to 1020, it spends 60 ticks at each tempo. Its length is 62,500 + 93,750 = 156,250 µs. Multiplying its entire 120-tick length by either tempo gives the wrong result.

Five local Node tests cover both decoded fixture columns, the default before a first change, this crossing note, fractional ticks and bad inputs. If your DAW retains its own project tempo on import, the same symptoms can reflect a deliberate import setting rather than a bug. Compare raw note ticks and intended tempo policy before changing the converter.

Sources: Mido Standard MIDI Files documentation and Microsoft MIDI timing documentation.