I'm trying to set up an AudioQueue to stream audio from the microphone on an iPhone.
I create my audio engine:
var audioEngine = AVAudioEngine()
And my audio queue:
// Serial dispatch queue used to analyze incoming audio buffers.
let analysisQueue = DispatchQueue(label: "com.apple.AnalysisQueue")
// Install an audio tap on the audio engine's input node.
audioEngine.inputNode.installTap(onBus: 0,
bufferSize: 8192, // 8k buffer
format: inputFormat) { buffer, time in
// Analyze the current audio buffer.
analysisQueue.async {
}
}
Whenever I run the code on the simulator or the device, I get the following crash:
*** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: inputNode != nullptr || outputNode != nullptr'
I was following some Apple sample code while making this; somewhat confused. Any help appreciated!
EDIT: this question from a few days ago seems to point to a similar issue: AVAudioEngine.connect crash on hardware not simulator