The iPhone 5 has 3 mics. Can I change from which one I'm recording?

对着背影说爱祢 提交于 2020-01-01 12:33:31

问题


The iPhone 5 has 3 microphones, according to its product presentation:

After looking through the website of iFixit and others I now know where the bottom microphone is and I've identified the one on the back, right next to the camera.

There should be another one on the front, at the top, but I can't see it, so I assume it's behind the earpiece/receiver opening. (Is this correct?)

I would like to record from two different microphones while the iPhone 5 is lying on it's back. (So the rear mic is out of the question).

My question:

Is there some way I can record from both mics at the same time and separately (i.e. in stereo, like some Windows Phone 8 Lumia phones let you do it)? If not, is there a method that I can use to switch between the microphones, e.g. first record from the one at the bottom of the iPhone, then execute some code to switch to the one at the top?

Your tips will be much appreciated.


回答1:


// set up the audio session
NSError *error = nil;

AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:&error];
[audioSession setActive:YES error:&error];

if (error != nil) { NSLog(error); }


// all available inputs
NSArray* inputs = [audioSession availableInputs];

// Locate the port corresponding to the built-in microphone
for (AVAudioSessionPortDescription* port in inputs)
{
    if ([port.portType isEqualToString:AVAudioSessionPortBuiltInMic])
    {
        [self setBuiltInMicPort:port];
        break;
    }
}

// list all microphones
for (AVAudioSessionDataSourceDescription *micType in [audioSession inputDataSources]) {
    NSLog(@"%@ -- %@ -- %@ -- %@", micType.dataSourceID, micType.dataSourceName, micType.location, micType.orientation );

    if ([micType.orientation isEqualToString:@"Front"]) // or @"Back" or @"Bottom"
    {
        [micType setPreferredPolarPattern:AVAudioSessionPolarPatternOmnidirectional error:&error]; // optional
        [self.builtInMicPort setPreferredDataSource:micType error:&error];   
    }
}

This is basic example how to select different built-in microphones in the iPhone. Please keep in mind that the number of microphones differs: iPhone 5 and later has three microphones while previous generations have only two microphones (no back mic).

For more information read Apples Technical Q&A.




回答2:


I've just verified that Skype switches to the top microphone when using the front camera. Now I only need to verify that I can switch quickly between the top and bottom microphone by starting video capturing from the front camera and then stopping it again.



来源:https://stackoverflow.com/questions/20600839/the-iphone-5-has-3-mics-can-i-change-from-which-one-im-recording

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!