Is there a way for RemoteIO unit to pick up back microphone on iPhone 5 ? I can configure AVAudioSession
to choose between front microphone or bottom microphone but I can't find a way to select the back Microphone.
The AVFoundation framework
for sure uses the back microphone for video recording when using the back camera, but I want a way to choose the same using CoreAudio. Is that possible ?
Go to Settings > Privacy > Microphone. Make sure that the app is enabled.
Setting kAudioSessionProperty_Mode
to kAudioSessionMode_VideoRecording
with AudioSessionSetProperty
uses the microphone nearest to the camera, which should be the back microphone. That's if you use the Audio Session Services. AVAudioSessionModeVideoRecording
if you're using AVFoundation to record. The doc says "Using this mode may result in the system providing appropriate audio signal processing." which I interpet as "we may also use the other mics for noise cancelling".
Use AVAudioSession to get available inputs. On my iPhone 5 it looks like this.
NSLog(@"%@", [AVAudioSession sharedInstance].availableInputs);
"<AVAudioSessionPortDescription: 0x14554400, type = MicrophoneBuiltIn; name = iPhone Microphone; UID = Built-In Microphone; selectedDataSource = Back>"
Then use one of these inputs to get availableDataSources, like this.
NSLog(@"%@", [AVAudioSession sharedInstance].availableInputs[0].dataSources);
"<AVAudioSessionDataSourceDescription: 0x145afb00, ID = 1835216945; name = Bottom>",
"<AVAudioSessionDataSourceDescription: 0x145b1870, ID = 1835216946; name = Front>",
"<AVAudioSessionDataSourceDescription: 0x145b3650, ID = 1835216947; name = Back>"
Now you can set your preferred data source.
AVAudioSessionPortDescription *port = [AVAudioSession sharedInstance].availableInputs[0];
for (AVAudioSessionDataSourceDescription *source in port.dataSources) {
if ([source.dataSourceName isEqualToString:@"Back"]) {
[port setPreferredDataSource:source error:nil];
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With