3

I am using AVAudioEngine to make some changes on playing music like changing pitch and gain at some frequencies (equalizer) and get audio levels. It all works now.

When I stop and tried to restart AVAudioEngine I faced a problem it does not start as it is supposed to start.

When I only tried start and stop player it is ok but AudioEngine draws some energy it is not good at all.

I start the player and audio engine like this.

Starting

audioEngine.prepare()
do {
    try audioEngine.start()
} catch {
    print("audioEngine couldn't start because of an error.")
}
audioFilePlayer.play()

I stop it like that

audioFilePlayer.stop()
audioEngine.stop()

But then when I tried to restart using the same code I used to start before it shows some erratic behaviors and basically does not start.

Maciej Gad
  • 1,701
  • 16
  • 21
Hope
  • 2,096
  • 3
  • 23
  • 40

1 Answers1

1

Ok I start it like this

do {
            try audioEngine.start()
            audioFilePlayer.play()

        } catch {
            
            print("could not start audio engine")
        
        }

and pause like this

    audioFilePlayer.pause()
    audioEngine.pause()

This worked but after pause / restart I hear a glitch sound.

Hope
  • 2,096
  • 3
  • 23
  • 40