简体   繁体   中英

The sound quality of slow playback using AVPlayer is not good enough even when using AVAudioTimePitchAlgorithmSpectral

In iOS, playback rate can be changed by setting AVPlayer.rate . When AVPlayback rate is set to 0.5, the playback becomes slow.

By default, the sound quality of the playback at 0.5 playback rate is terrible. To increase the quality, you need to set AVPlayerItem.audioTimePitchAlgorithm .

According to the API documentation, setting AVPlayerItem.audioTimePitchAlgorithm to AVAudioTimePitchAlgorithmSpectral makes the quality the highest.

The swift code is:

AVPlayerItem.audioTimePitchAlgorithm = AVAudioTimePitchAlgorithm.spectral // AVAudioTimePitchAlgorithmSpectral

AVAudioTimePitchAlgorithmSpectral increases the quality more than default quality. But the sound quality of AVAudioTimePitchAlgorithmSpectral is not good enough. The sound still echoed and it is stressful to listen to it.

In Podcast App of Apple, when I set playback speed to 1/2, the playback becomes slow and the sound quality is very high, no echo at all.

I want my app to provide the same quality as the Podcast App of Apple.

Are there iOS APIs to increase sound quality much higher than AVAudioTimePitchAlgorithmSpectral ?

If not, why Apple doesn't provide it, even though they use it in their own Podcast App?

Or should I use third party library? Are there good libraries which is free or low price and which many people use to change playback speed?

I've encountered the same issues with increasing/decreasing speed while maintaining some level of quality. I couldn't get it to work well using Apples API's. In the end I found that it's worth taking a look at this excellent 3rd party framework:

https://github.com/AudioKit/AudioKit

which allows you to do that and much more, in a straightforward manner. Hope this helps

I've been searching and trying to learn AudioKit and Audio Unit or even considering purchasing a third party time-stretch audio processing library to fix the quality issue of slow playback for the last 3 weeks.

Now finally I found a super easy solution.

AVPlayer can slow down audio with very good quality by setting AVPlayerItem.audioTimePitchAlgorithm to AVAudioTimePitchAlgorithm.timeDomain instead of AVAudioTimePitchAlgorithm.spectral .

The documentation says:

timeDomain is a modest quality pitch algorithm that is less computationally intensive. Suitable for voice .

This means spectral is suitable for music . timeDomain is suitable for voice .

That's why the voice files which my app uses was echoed.

And that's why Apple's Podcasts App's slowed down audio quality is very high. It must also uses this time domain algorithm.

And that's why AudioKit, which seems to be developed for music use, plays voice audio with bad quality.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM