2

// My code is below

do{
    file = try AKAudioFile(readFileName: "Sound1.mp3", baseDir: .resources)
    //    file =  try AKAudioFile(forReading: SingletonClass.sharedInstance.recordedURLs[SingletonClass.sharedInstance.recordedURL]!)

    //     AKSettings.defaultToSpeaker = true
}
catch {

}

do {
    player = try AKAudioPlayer(file : file)

}
catch {

}

let lfoAmplitude = 1_000
let lfoRate = 1.0 / 3.428

_ = 0.9

//filter section effect below
filterSectionEffect = AKOperationEffect(tracker) { input, _ in
    let lfo = AKOperation.sineWave(frequency: lfoRate, amplitude: lfoAmplitude)
    return input.moogLadderFilter(cutoffFrequency: lfo + cutoffFrequency,
                                  resonance: resonance)
}
Audiokit.output = filterSectionEffect
Audiokit.start()

And whenever I play the audio using a button with code player.play , the audio gets played properly. And if I connect the headphones, it gets played properly as well but as soon as I disconnect the headphones, I see the error:

Image showing the error

It happens in same way for both wired as well as bluetooth headphones. My app with stuck because of this issue only that too happens only with AKOperationEffect. Any help would be appreciated.

Hexfire
  • 5,945
  • 8
  • 32
  • 42
  • 1
    I don't think you're doing anything wrong. Instead, I think you've found a legitimate bug in AudioKit. It seems to handle the first audio route change okay, but then have troubles the second time around. I'm not yet sure of the fix, but I wanted to at least acknowledge that we're probably at fault here, not your implementation. – Aurelius Prochazka Dec 25 '17 at 07:40
  • Thanks for reply. Yes, its just second time audio route change issue. – Kunal Verma Dec 25 '17 at 08:12
  • This issue is now resolved. – Kunal Verma Apr 12 '18 at 06:19

1 Answers1

1

The comment from Kunal Verma that this is fixed is correct, but just for completeness here is the commit that fixed it.

https://github.com/AudioKit/AudioKit/commit/ffac4acbe93553764f6095011e9bf5d71fdc88c2

Aurelius Prochazka
  • 4,510
  • 2
  • 11
  • 34