I have a MIDI file type 1 which has no error in the code (see pic 1): the last note lasts 120 ticks (a 1/16th note, because PPQ = 480).
But when imported in REAPER, when I zoom at the maximum, I can see that it misses one tick to the note. It does end at the next bar, but exactly a tick before (see pic 2).
The starting position of the MIDI item has slightly shifted.
nope, the MIDI item starts exactly at bar 1, and all other notes of the file start and end at their right points (indicated in the hexa code) ; only the last note is problematic