1
votes

Given a BPM (beats per minute) MIDI delta time (leftmost bit off) with speed of 192:

0x00C0

I want to convert it to a FPS/TPM (frames per second / ticks per minute) delta time (leftmost bit on), but it should be the same (or the most accurate) speed value if you know what I mean.

For more info about MIDI Delta Time please take a look at Midi File Format under Header Chunk -> Time Division.

I am looking for a formula that will convert between these two deltatime types.

1

1 Answers

2
votes

If you're talking about 0x00C0 being the time division field, what you're referring to is not 192 beats per minute, but rather 192 ticks per beat, quite a different beast. BPM is specified indirectly via "Set Tempo" events, given in microseconds per beat (with the lamentably ubiquitous 120 BPM being assumed to begin with). The trickiness of time division with this format is that the length of a tick will grow and shrink depending on the tempo changes in the song.

Let's say the time division you want to convert to has F as the frames per second (24, 25, 29.97, or 30) and G as the ticks per frame (note: it's not ticks per minute!). Further, let's assume that the current tempo in microseconds per beat is p. Then the formula to convert a given duration in ticksold to ticksnew (the unit analysis really helps!) is:

y = x ticksold * (1/192) beat/ticksold * p μsec/beat * (1/106) sec/μsec * F frames/sec * G ticksnew/frame
   = ((x * p * F * G)/(192*106)) ticksnew