The following code works on my iPhone 5, meaning it correctly "reads" the microphone.
let input = audioEngine.inputNode
let mixer = AVAudioMixerNode()
audioEngine.attach(mixer)
let format = AVAudioFormat(commonFormat: AVAudioCommonFormat.pcmFormatFloat32, sampleRate: SAMPLE_RATE, channels: 1, interleaved: false)
audioEngine.connect(input, to: mixer, format: input.inputFormat(forBus: 0))
mixer.installTap(onBus: 0, bufferSize: 2048, format: format) {
(buffer: AVAudioPCMBuffer!, time: AVAudioTime!) -> Void in ... }
Unfortunately, it only outputs 0.0 samples when using the app in the simulator. The microphone works generally (tested Siri in the simulator), but in my app does not get the samples correctly.
Is it somehow possible to read samples from the microphone in the simulator at a desired sample rate? I need to send the samples @ 16khz to a server, so there is no option to sample at 44100hz.