You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found an issue in MIKMIDIClockSecondsPerMIDITimeStamp: in a real iOS environment (iPad mini 4, iOS 10.3), secondsPerMIDITimeStamp was not accurate, and the clock would drift ~0.60s every 60s (in a 120BPM sequence). After some debugging, and thanks to this entry in StackOverflow (https://stackoverflow.com/questions/675626/coreaudio-audiotimestamp-mhosttime-clock-frequency), I found the issue: timeBaseInfoData.numer is a Float32, but the result is a double. So, the division by 1.0e9 would be inaccurate, and the clock would drift. Yet the solution is, as Robert pointed out:
'By casting the first number to double, GCC automatically casts the second number to double as well and the result will also be double'
Thanks for reporting this. It doesn't show up on x86_64 (ie. macOS and the iOS simulator) where .numer and .denom are both 1, and integer division is fine. On arm64, they're 125, and 3, respectively, so integer division indeed produces an imprecise/incorrect result. I've pushed a fix.
Hi everyone,
I found an issue in MIKMIDIClockSecondsPerMIDITimeStamp: in a real iOS environment (iPad mini 4, iOS 10.3), secondsPerMIDITimeStamp was not accurate, and the clock would drift ~0.60s every 60s (in a 120BPM sequence). After some debugging, and thanks to this entry in StackOverflow (https://stackoverflow.com/questions/675626/coreaudio-audiotimestamp-mhosttime-clock-frequency), I found the issue: timeBaseInfoData.numer is a Float32, but the result is a double. So, the division by 1.0e9 would be inaccurate, and the clock would drift. Yet the solution is, as Robert pointed out:
'By casting the first number to double, GCC automatically casts the second number to double as well and the result will also be double'
The fixed code is below:
The text was updated successfully, but these errors were encountered: