Time division (of a MIDI file)

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 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 message 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).

See also:
Musical Instrument Digital Interface (MIDI)

Comments

admin: First posted on 2015 11 10

Zelnidav, 2015 11 10: G8 m8! I r8 8/8 as the other 8!

Thank you so much! This was so helpful.
I was going to ask though, in the case of the top bit of the division being 0, how do you compute the remaining 15 bits to come up with the number (60 was used as an example, but how do we get to that number from binaries)?

Add new comment

Filtered HTML

  • Freelinking helps you easily create HTML links. Links take the form of [[indicator:target|Title]]. By default (no indicator): Click to view a local node.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.