I am attempting to record audio from the input node and sending it to a mixer to convert the audio to a lowered sample rate to be written to disk.
My audio file is created like this:
let sett = [
AVSampleRateKey : NSNumber(double: 22050),
AVNumberOfChannelsKey : NSNumber(int: 2) ]
let file = try! AVAudioFile(forWriting: url, settings: sett)
Then for the audio engine, I at first connected the input node to my mixer node with the connection format the same as the file.processingFormat
. Which crashes with the exception
required condition is false: format.sampleRate == hwFormat.sampleRate
After that I connected the input node to a mixer node with the connection format as the inputNode.outputFormatForBus(0)
and then connected that mixer node to a second mixer node with the connection format of file.processingFormat
. This does not crash, but when I install a tap on the second mixer, the callback is never called. I'm not sure if it's taking a long time to process on the backend or if there is something wrong.