Using SV 1.5 (Windows XP)
When loading a MIDI file as a Notes annotation layer, MIDI files
with SMPTE time-code delta times are loaded incorrectly.
To review, the Standard MIDI File header contains 5 fields:
(1) 4-byte string "MThd" saying that this is the MIDI file header
(2) the length of the header in bytes (after this number) 4-bytes
(3) format (0=single track; 1=multi-track; 2=multisong) 2-bytes
(4) track count, 2-bytes
(5) divisions, two bytes.
The problem is occurring in the interpretation of field (5) in the header. Normally this number
indicates the "ticks" per quarter-note (called a crochet in certain countries). For example,
if the value is 480, then there are 480 delta-time "ticks" per quarter note in the track data
section of the file.
However, if this divisions field is greater than 0x7fff, then the ticks-per-quarter interpretation
is not used. Instead, SMPTE timecode is being specified which as two separate numbers: The number
of frames per seconds, and the number of subframes per frame.
SMPTE timecode settings are particularly useful in SV because it deals with events in terms of
actual seconds rather than tempo. For example, the only SMPTE setting which I use is 25 frames
per seconds, with 40 divisions per frame. This is equivalent to 25 * 40 = 1000 subframes per
seconds, which is equivalent to milliseconds. Thus if two successive events in a MIDI file are separated
125 ticks, the actual time between these two events is 125 milliseconds.
How to decode values larger than 0x7fff in the divisions field of a standard
MIDI file:
The highest 8-bits of the divisions field specifies the (negative) SMPTE frame count per second,
and the lower 8-bits of the divisions field specifies the divisions per frame. Note that the numbers
in MIDI files are stored in big-endian format, so the first byte in the file for the divisions field is the
SMPTE frame count per second, and the second byte is the subdivision count for each frame.
So suppose, that you want to specify 25 frames per second, with 40 subdivisions per frame. In this case
the first byte is set to the number -25 (in hexadecimal: 0xE7). The subdivisions are store without negation,
so in hex the second byte is 0x28 (decimal 40). And the combined 2-byte hex code is 0xE728. This format
of the divisions value in the MIDI header cannot be interpreted as ticks per quarter note because the value
is larger than 0x7FFF, so interpreting 0xE728 as the decimal number 59176 is invalid. Instead it must be
interpreted as two separate 1-byte numbers, with the first number negated to indicate that SMPTE code
is being specified rather than regular ticks-per-quarter note.
Attached are two files:
(1) an example SMPTE-timecode based MIDI file with frames set to 25 per seconds, and 40 divisions per frame.
(the correct length is about 96 seconds).
(2) illustration of how the MIDI file is read into a notes annotation layer in SV, with all of the notes occurring
with the first 0.5 seconds of the sound file.
SMPTE time-code based MIDI file
Example view of current SMPTE notes layer
Fixed in SVN rev 1641
This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).