Synchronization
There are two different methods of synchronisation.
SMTPE and MTC.
SMTPE originates in the movie industry and uses a frame as the unit of time.
To give the extra precision needed for music, midi timings make use also of subframes.
MTC is midi's own timing method based on 24ths of a quarter note.
This is the frequency with which midi time clock messages are sent out for synchronization.
Time stamps for the relative timing of messages in a midi file are also specified using fractions of a quarter note, but this will usually be a smaller unit than a 24th of a quarter note.
The header chunk specifies the timing units either using SMTPE or MTC and the track chunks then use these timing units for timestamps on messages.
Timing may also be modified by tempo and time signature messages.
|
Sources of Timing Info
The following bits of timing info may be available:
- The header chunk
- Message timestamps
- Tempo messages
- Time signature messages
- SMTPE offset
- Cue points
|
The Header Chunk and Timestamps
The header chunk has a field called "division" which determines the timing units.
This is specified either as the number of frames per second and the number of subframes per frame for SMTPE, or as the number of pulses per quarter note (PPQN).
In the former case the timing is done by subframe and the size of this unit of time is 1000/(f * s) milliseconds, (one thousand divided by the product of the number of frames per second and the number of subframes per frame).
In the latter case the length of the timing units is given relative to the length of one quaver, and is therefore not fixed until the tempo is known (temp is number of beats, i.e. crotchets, per minute), which will be set and may be varied by tempo messages in the following tracks.
|
|
Tempo Messages
It is recommended but not required that all tempo messages are included in a separate track (for format 1 files).
Tempo is specified using a tempo meta message (code xFF51) which gives the number of beats per minute.
This is only relevant to the interpretation of timestamps if the division information in the header has specified the number of pulses per quarter note.
The relative time determined by a timestamp TS is then TS*60/(PPQN*TEMPO) in seconds.
|
Time Signature
A time signature may also be provided, using meta message code xFF58.
The time signature serves primarily to determine the division of the music into bars, and is specified as number of notes per bar and duration of each note as a fraction of a note specified as a power of two.
The time signature message also includes two other items of information.
It specifies the number of MTC clicks per quarter note (which is normally 24), and the number of thirty second notes per quarter note, (which is of course normally 8).
I don't know what is the intended effect of using non standard values for these.
|
SMTPE Offset
Meta message code xFF54 gives the SMTPE time for the start of the piece, which is encoded as five bytes giving hours, minutes, seconds, frames and hundredths of a frame in that order.
|
Cue Points
Meta message xFF07 give text describing the some event, e.g. triggering play of an audio file.
The timing of this cue is determined by the timestamp on the cue message.
|
|