Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash upon engine start #67

Open
hannah-bennett opened this issue Aug 30, 2019 · 5 comments
Open

Crash upon engine start #67

hannah-bennett opened this issue Aug 30, 2019 · 5 comments

Comments

@hannah-bennett
Copy link

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

@vadymmarkov
Copy link
Owner

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.

@paskowski
Copy link

@hannah-bennett I guess you're getting this error when using simulator, try to run your code on an actual device

@hannah-bennett
Copy link
Author

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.

@OfTheWolf
Copy link

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

@logsol
Copy link

logsol commented Mar 8, 2023

Wouldn't it make more sense to set inputNode.inputFormat() instead of inputNode.outputFormat?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants