The time division of a MIDI file, also known as "resolution of a MIDI file", is an indication of how MIDI ticks should be translated into time, contained in the thirteenth and fourteenth bytes in the header chunk of the MIDI file.
There are two possible translations of these two bytes (16 bits). If the top bit of the 16 bits is 0, then the time division is in "ticks per beat" (or “pulses per quarter note”). If the top bit is 1, then the time division is in "frames per second".
Pulses per quarter note (PPQ)
When the top bit of the time division bytes is 0, the time division is in ticks per beat. The remaining 15 bits are the number of MIDI ticks per beat (per quarter note). If, for example, these 15 bits compute to the number 60, then the time division is 60 ticks per beat and the length of one tick is
1 tick = microseconds per beat / 60
The variable "microseconds per beat" is specified by a MIDI event carrying the set tempo meta message. If it is not specified then it is 500,000 microseconds by default, which is equivalent to 120 beats per minute. In the example above, if the MIDI time division is 60 ticks per beat and if the microseconds per beat is 500,000, then 1 tick = 500,000 / 60 = 8333.33 microseconds.
Frames per second
When the top bit of the time division bytes is 1, the remaining 15 bits have to be broken in two pieces. The top remaining 7 bits (the rest of the top byte) represent the number of frames per second and could be 24, 25, 29.97 (represented by 29), or 30. The low byte (the low 8 bits) describes the number of ticks per frame. Thus, if, for example, there are 24 frames per second and there are 100 ticks per frame, since there are 1,000,000 microseconds in a second, one tick is equal to
1 tick = 1,000,000 / (24 * 100) = 416.66 microseconds
Thus, when the time division top bit is 1, the length of a tick is strictly defined by the two time division bytes. The first byte is the frames per second and the second byte is the number of ticks per frame, which is enough to specify the tick length exactly. This is not so when the top bit of the time division bytes is 0 and the time division is in pulses per quarter note. The time division in this case defines the ticks per beat, but nothing in the time division specifies the number of beats per second. A MIDI event should be used to specify the number of beats per second (or the length of a beat), or it should be left up to the MIDI device to set the tempo (120 beats per minute by default, as mentioned above).
Musical Instrument Digital Interface (MIDI)