0

I have a slider that changes audio dependent on its value. It works fine but when the audio is changed, there is a very noticeable pop/clicking sound. Is there any way to get rid of this? This is the set up:

@IBAction func audioSlider(sender: UISlider) {
    let sliderValue = Int(sender.value)
    if sliderValue == 1 {
        soundPlayer2.stop()
        soundPlayer3.stop()
        soundPlayer1.play()
        soundPlayer1.numberOfLoops = -1
    }
    else if sliderValue == 2 {
        soundPlayer1.stop()
        soundPlayer3.stop()
        soundPlayer2.play()
        soundPlayer2.numberOfLoops = -1
    }
    else if sliderValue == 3 {
        soundPlayer1.stop()
        soundPlayer2.stop()
        soundPlayer3.play()
        soundPlayer3.numberOfLoops = -1
    }
    else if sliderValue == 0 {
        soundPlayer1.stop()
        soundPlayer2.stop()
        soundPlayer3.stop()
    }
} 

I'm thinking maybe something that delays the start of the next audio?

I have tried using .pause but the pop still happens.

3
  • Just curious: why do you have three players? Have you tried using a single player but changing the soundURL when sliding?
    – user3821934
    Jun 25, 2016 at 15:57
  • The user interface part is not relevant for causing clicks. The clicks can be only caused on the real time thread, because there is no integration (=smoothing) of control values' abrupt changes, or if there is a sudden change of audio material, without crossfade or if there are some scheduling problems (blocking on the real time thread, memory management, etc). BTW, what do you mean by "slider that changes audio dependent on its value"? Please, post code relevant to your problem. Jun 25, 2016 at 19:06
  • Michael - it's because there are sounds that play for each value that the slider is set to. I have tried changing the if statement so that it looks for a different file User 307- The code is relevant to the problem - read the statement - I don't know how I can make it clearer. Any smoothing suggestions? Does AVFoundation have a delay feature?
    – Mi Ch
    Jun 25, 2016 at 20:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.