AudioKit / AudioKit

Audio synthesis, processing, & analysis platform for iOS, macOS and tvOS
http://audiokit.io
MIT License
10.63k stars 1.55k forks source link

Adjusting rate +10% plays a little too slow, offset increases over time #1960

Closed hipwelljo closed 4 years ago

hipwelljo commented 4 years ago

In our app we have found that if the AKTimePitch.rate is adjusted, it does not play at the same rate as other audio programs such as Pro Tools and FFmpeg. With the rate set to 1.1 (+10%), the audio position at about 3.5 minutes into a song is offset by about 80 milliseconds, and by 7.5 minutes it's off by 160 milliseconds.

I've created a sample iOS project that plays the file at 1.1 rate, available to download at the link below.

To visualize the offset, we recorded the sound played by the app, then added it to Audacity alongside that same audio file sped up 10% via FFmpeg. This Audacity project can be downloaded as well at the link below. Zooming in on the waveforms you can see how they increasingly diverge over time with the app playing a little too slow. At 3:21.118 seconds there's a spike that's not played until 3:21.198 from the app, behind about 80 milliseconds. And at the end 7:38.034 vs 7:38.194, behind about 160 milliseconds.

Link to Xcode and Audacity projects

Screen Shot 2020-01-28 at 2 35 58 PM

Interestingly, this issue does not occur on an iPad Mini running 12.4.3, but does occur on two different iPad Pros both running 13.3.1. Unfortunately we don't have more devices to further nail down if it's device or OS specific.

Thank you!

hipwelljo commented 4 years ago

We've tried this out with AVAudioUnitTimePitch directly and confirmed it plays too slow there as well, thus it seems this is an issue in iOS not AudioKit. Will go ahead and close this issue.