Pause / start AVAudioPlayer without glitchy pops

I play a long sound file (20 seconds or so) using AVAudioPlayer. I need to pause and start in the middle of the file. When I pause or start while playing a sound, a noticeable “pop” appears when the sound starts or ends.

I managed to improve the situation by making a very fast attenuation (setting the volume several times using the performSelector: withObject: afterDelay function. But the sound is still a bit confused by this technique.

Is there a standard way to start / pause AVAudioPlayer without these crashes?

+4
source share
2 answers

Try sending -prepareToPlay to the AVAudioPlayer object when it is paused. This will preload the sound.

If this does not work, try to speed up the gradual decrease by reducing the delay in the execution of the Select: withObject: afterDelay function. Go crazy, milliseconds.

If this does not work, try using a cleaner sound file of a higher quality (without unnecessary background noise).

If this does not work, explain how the audio file in your application is used in more detail.

+2
source

API ( RemoteIO). 1,0 0,0 PCM. DSP. 0.0 1.0 . .

0

Source: https://habr.com/ru/post/1776252/


All Articles