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?
1 Answers
Answers 1
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
0 comments:
Post a Comment