7

I have started getting a crash that did not previously happen with initialization of recording with the error:

[avae] AVAEInternal.h:70:_AVAE_Check: required condition is false: [AVAudioIONodeImpl.mm:911:SetOutputFormat: (format.sampleRate == hwFormat.sampleRate)]

This seems to be a tricky error that some people also get with AudioKit.

In that case, it seems to have something to do with using a sample rate of 48k instead of 44.1k. However, in my case, using audio engine, I'm not setting any sample rates at all.

My code is largely boilerplate for recording. The crash occurs at the following line:

inputNode.installTap(onBus: 0, bufferSize: 4096, format: recordingFormat) { (buffer, when) in
print("got here")//never gets here

Can anyone suggest how to fix this when using audioengine for recording?

Thanks for any suggestions.

Edit

This is how I create recordingFormat:

let recordingFormat = inputNode.outputFormat(forBus: 0)

And this is what recordingFormat looks like in the debugger..it seems to be set for 44.1k:

po recordingFormat
<AVAudioFormat 0x282b1e580:  1 ch,  44100 Hz, Float32>

inputNode looks like this:

po inputNode
<AVAudioInputNode: 0x280a0eb70>

(lldb) p inputNode
(AVAudioInputNode) $R4 = 0x0000000280a0eb70 {
  AVFoundation.AVAudioIONode = {
    baseAVAudioNode@0 = <extracting data from value failed>

  }
}  

Edit 2:

The problem seems to have something to do with Apple changing the input format to 48k as explained here:

This illustrates the mismatch:

    print("wrong rate---> session rate: \(AVAudioSession.sharedInstance().sampleRate) input rate: \(recordingFormat.sampleRate)")

However this fix using avaudioconverter seems crazy complicated. How are other people dealing with this?

user6631314
  • 1,751
  • 1
  • 13
  • 44

0 Answers0