Hi There,
Whenever I want to use the microphone for my ShazamKit app while connected to AirPods my app crashes with a "Invalid input sample rate."
message.
I've tried multiple formats but keep getting this crash. Any pointers would be really helpful.
func configureAudioEngine() {
do {
try audioSession.setCategory(.playAndRecord, options: [.mixWithOthers, .defaultToSpeaker, .allowAirPlay, .allowBluetoothA2DP ,.allowBluetooth])
try audioSession.setActive(false, options: .notifyOthersOnDeactivation)
} catch {
print(error.localizedDescription)
}
guard let engine = audioEngine else { return }
let inputNode = engine.inputNode
let inputNodeFormat = inputNode.inputFormat(forBus: 0)
let audioFormat = AVAudioFormat(
standardFormatWithSampleRate: inputNodeFormat.sampleRate,
channels: 1
)
// Install a "tap" in the audio engine's input so that we can send buffers from the microphone to the signature generator.
engine.inputNode.installTap(onBus: 0, bufferSize: 1024, format: audioFormat) { buffer, audioTime in
self.addAudio(buffer: buffer, audioTime: audioTime)
}
}
```