Beethoven
Beethoven copied to clipboard
Crash upon engine start
I am getting multiple instances of the same fatal exception, across iOS 12 and 13.
Fatal Exception: com.apple.coreaudio.avfaudio
required condition is false: IsFormatSampleRateAndChannelCountValid(format)
The app is crashing when the pitch engine starts. Here is the relevant code:
private let engine = PitchEngine()
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
engine.start()
}
I found a stack overflow post referencing this crash, but it seems to be marginally helpful at best.
I dug around a bit in the Beethoven code, and traced this engine.start()
call back to the audio session setup:
https://github.com/vadymmarkov/Beethoven/blob/master/Source/SignalTracking/Units/InputSignalTracker.swift#L41
Is this something you've seen before? Any ideas on how to resolve? Thanks
I haven't experienced this, but you can try one of the solutions from that stack overflow post, such as replacing node.outputFormat(forBus: 0)
with AVAudioFormat
, and make a pull request if it fixes your issue.
@hannah-bennett I guess you're getting this error when using simulator, try to run your code on an actual device
Thanks for the response. These are device crashes, not simulator crashes. I'll dig into it and see if I can pinpoint what's going on.
you should call removeTap before install. Give it a try.
InputSignalTracker.swift
func start() throws {
...
inputNode.removeTap(onBus: bus)
let format = inputNode.outputFormat(forBus: bus)
inputNode.installTap(onBus: bus, bufferSize: bufferSize, format: format) { buffer, time in
Wouldn't it make more sense to set inputNode.inputFormat()
instead of inputNode.outputFormat
?