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.