I am using the following code to get the audio sample of the 44100 sample rate from the iPhone 11. iPhone 11 has a 48000 sample rate by default.
let audioEngine = AVAudioEngine()
let inputNode = audioEngine.inputNode
let main = audioEngine.mainMixerNode
let inputFormat = inputNode.inputFormat(forBus: 0)
let outputFormat = AVAudioFormat(commonFormat: AVAudioCommonFormat.pcmFormatInt16, sampleRate: 44100, channels: 1, interleaved: true)
audioEngine.attach(downMixer)
audioEngine.connect(inputNode, to: downMixer, format: inputFormat)
audioEngine.connect(downMixer, to: main, format: outputFormat)
downMixer.installTap(onBus: 0, bufferSize: 2048, format: outputFormat) { (buffer, time) -> Void in
print(buffer)
}
I am getting null audio data.