How long one beat lasts at a given tempo, and how long to hold each frame so a whole number of frames fills it exactly.
It is, for a video. Not for a GIF. The format stores a delay per frame in hundredths of a second, so the only durations available are 10ms, 20ms, 30ms and so on. At 120 BPM over eight frames a beat wants 62.5ms and the nearest a GIF can hold is 60ms. That loses 20ms a beat, or 2.4 seconds a minute.
Short delays are worse: most browsers substitute a tenth of a second for one hundredth, so a loop written at 10ms a frame plays ten times too slow. This is why Gifsync writes an MP4, where timestamps go to the microsecond.
| Tempo | One beat | 4 frames | 8 frames | 12 frames | 16 frames |
|---|---|---|---|---|---|
| 60 BPM | 1000.0ms | 250.0ms | 125.0ms | 83.3ms | 62.5ms |
| 70 BPM | 857.1ms | 214.3ms | 107.1ms | 71.4ms | 53.6ms |
| 80 BPM | 750.0ms | 187.5ms | 93.8ms | 62.5ms | 46.9ms |
| 90 BPM | 666.7ms | 166.7ms | 83.3ms | 55.6ms | 41.7ms |
| 100 BPM | 600.0ms | 150.0ms | 75.0ms | 50.0ms | 37.5ms |
| 110 BPM | 545.5ms | 136.4ms | 68.2ms | 45.5ms | 34.1ms |
| 120 BPM | 500.0ms | 125.0ms | 62.5ms | 41.7ms | 31.2ms |
| 128 BPM | 468.8ms | 117.2ms | 58.6ms | 39.1ms | 29.3ms |
| 130 BPM | 461.5ms | 115.4ms | 57.7ms | 38.5ms | 28.8ms |
| 140 BPM | 428.6ms | 107.1ms | 53.6ms | 35.7ms | 26.8ms |
| 150 BPM | 400.0ms | 100.0ms | 50.0ms | 33.3ms | 25.0ms |
| 160 BPM | 375.0ms | 93.8ms | 46.9ms | 31.2ms | 23.4ms |
| 170 BPM | 352.9ms | 88.2ms | 44.1ms | 29.4ms | 22.1ms |
| 174 BPM | 344.8ms | 86.2ms | 43.1ms | 28.7ms | 21.6ms |
| 180 BPM | 333.3ms | 83.3ms | 41.7ms | 27.8ms | 20.8ms |
Below about 16.7ms, one refresh of a 60Hz screen, a frame will not be seen however exactly it is timed. Nothing in the table is quite that short. 16 frames at 180 BPM is close.
Divide the frame count by the beats you want and check it comes out whole. Twenty frames over eight beats gives 2.5, so some beats hold three frames and others two, a 50% swing in speed you can see. Over ten beats it gives two, even all the way round.
Line a GIF up with a song