How to use the stereo (2 channel) built in microphone in iPhone XS, inside AVAudioSession?

Viewed 541

I'm trying to get both channels from the supposedly stereo rear microphone out of the iPhone XS but can only ever see a single channel at various points in the AVAudioSession and AVAudioSessionPortDescription's associated with the rear camera.

I have tried using AVAudioSession APIs like setPreferredInputNumberOfChannels:

do {
    try session.setPreferredInputNumberOfChannels(2)
} catch let error {
    debugPrint("\(error)")
}

But get an error:

Error Domain=NSOSStatusErrorDomain Code=-50

Has anyone had experience getting a 2-channel built-in mic route working?

2 Answers

The stereo microphone on the iPhone XS is placed at the bottom on the left side of the lightning connector. The one on the right side of the lightning connector is a noise cancelling microphone. The 2 other microphones are placed next to the front camera and the back camera. But those are only mono microphones. But there is a big BUT when it comes to the bottom stereo microphone. It only records in stereo when using the build in camera app. Voice only in the voice memo app only records in mono. And, the stereo microphone is not compatible with any third party app. It only works when shooting video in the native camera app.

Since iOS 14 and iPadOS 14, you can capture stereo audio with the built-in microphones.

To determine whether a device supports stereo recording, query the audio session’s selected data source to see if its supportedPolarPatterns array contains the stereo polar pattern.

Read more from the documentation.

Related