11

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 ?

Paras Joshi
  • 20,427
  • 11
  • 57
  • 70
Deepak Sharma
  • 5,577
  • 7
  • 55
  • 131

2 Answers2

1

Setting kAudioSessionProperty_Mode to kAudioSessionMode_VideoRecordingwith AudioSessionSetProperty uses the microphone nearest to the camera, which should be the back microphone. That's if you use the Audio Session Services. AVAudioSessionModeVideoRecordingif 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".

HBu
  • 559
  • 6
  • 18
1

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];
    }
}
Tony Weber
  • 124
  • 4