Is 48kHz audio always in sync with mach_absolute_time()?

Tests made on several devices and iOS versions always showed iOS audio at 48kHz being in sync with the system time (mach_absolute_time()). Audio Unit Timestamps (AudioTimeStamp) provided by Remote I/O unit, for instance, have mSampleTime increasing at the exact same rate as mHostTime (when both are converted to seconds).


Few tests made on USB audio input devices (via lightning) also showed this consistency. AVFoundation as well seems to use mach_absolute_time() for timestamping both audio and video.


On the other hand, tests made on 44.1kHz audio showed drift as if the audio clock wasn't the same as the system clock. This could be perfectly understandable but both 48kHz and 44.1kHz audio should have the same behavior (same hardware clock).


Question: Can we rely on having audio in sync with mach_absolute_time()? Does Apple intentionally compensate time drifts? Isn’t what AVFoundation needs? Why it’s not working for 44.1kHz audio?


Thanks a lot,

Gabe

Replies

On newer iOS devices, the actual hardware audio sample rate clock seems to be 48k (or a multiple thereof). Any 44.1ksps samples delivered by RemoteIO seem to be created by resampling the 48k rate samples using an internal software downsampling filter that could possibly be incurring some sort of rounding error or polyphase timing jitter.

In recent tests I saw the 44.1kHz problem with build-in audio on iPad Pro 10.5'' only. On this iPad, by forcing the hardware clock to 48kHz, then downsampling to 44.1kHz, we optain a sample rate perfectly in sync with the system clock. On the other hand, selecting 44.1kHz directly, results in a sample rate 400ppm apart from the system clock.

400ppm is a lot. This sounds more as a bug than as a clock drift.

Did you submit a bug report (RADAR) with reproducable code?


Multiple developers seem to have reported problems with configuring 44.1kSPS on newer iOS devices which have hardware locked to a 48k sample rate; so the hypothesis of this being a bug seems quite plausible.