Repository navigation
Does Milkytracker have BPM inaccuracies? #415
Replies: 1 comment
|
Two separate things here, and MilkyTracker lands differently on each. The BPM to tick conversion isn't the problem you're describing. It doesn't round to a whole number of samples per tick, it uses a fixed point accumulator. mp_uint32 getbpmrate(mp_uint32 bpm)
{
mp_uint32 realCiaTempo = (bpm * (baseBpm << 8) / 125) >> 8;
if (!realCiaTempo) realCiaTempo++;
mp_int64 t = ((mp_int64)realCiaTempo)<<(32+2);
const mp_uint32 timerBase = (mp_uint32)(5.0f*500.0f*(MP_BEATLENGTH*MP_TIMERFREQ / (float)MP_BASEFREQ));
return (mp_uint32)(t/timerBase);
}and mp_int64 dummy = (mp_int64)BPMCounter;
dummy+=(mp_int64)adder;
BPMCounter=(mp_sint32)dummy;
// check overflow-carry
if ((dummy>>32))32 fractional bits, and the leftover stays in The sample rate half of what you quoted is real though. The 250 Hz timer is derived by integer division, beatPacketSize = (MP_BEATLENGTH*frequency)/MP_BASEFREQ;with MP_TIMERFREQ = 250,
MP_BASEFREQ = 48000, // is chosen because (48000 % 250) == 0At 48 kHz you get exactly 192 and the timer is exactly 250 Hz. At 44.1 kHz the true value is 176.4 and you get 176, so the timer actually runs at 44100/176 = 250.568 Hz: So at 44.1 kHz everything plays 0.227% fast. A module marked 125 BPM runs at about 125.28, and you drift roughly 1.6 seconds ahead over twelve minutes. Note this is the opposite direction from the OpenMPT description you quoted, where 48 kHz was the slow one. It's tempo only, not pitch. The mixer computes sample stepping from the real output rate, it's just the tick timer that's quantised. Practical answer: set the mixer to 48 kHz and the error is gone, no code change needed. Anything where Whether it's worth a toggle is a maintainer call, but I don't think you'd need an FT2-clone style accurate/classic switch for it. Carrying the remainder of that division into the next packet, the same trick |
Uh oh!
There was an error while loading. Please reload this page.
I just recently learned that many older trackers including OpenMPT have BPM inaccuracies due to a programming decision.
"For performance reasons, most older trackers were implemented with very little to no floating point arithmetic. Some rounding errors when calculating the number of samples that should constitute the length of a tick mean that tempos could be inexact. For this reason, tempo may also differ between various playback rates, e.g. playback might be slightly slower at 48 kHz than at 44 kHz. In OpenMPT, the Classic tempo mode preserves this “old-school” behaviour."
Is this true for Milkytracker as well? If this is true, can we get a fix for this? Like in FT2 Clone, a box where we can choose to have accurate BPM or not.
All reactions