Microphone low voice recording issue when AVAudioSession mode is set to AVAudioSessionModeVideoChat

StackOverflow https://stackoverflow.com/questions/21769343

Question

As per the documentation of AVAudioSessionModeVideoChat -

When this mode is in use, the device’s tonal equalization is optimized for voice and the set of allowable audio routes is reduced to only those appropriate for video chat.

So the system reduces the default sensitivity of audio output and input routes suitable for this mode.

I'm using setMode to AVAudioSessionModeVideoChat so that app/system automatically recognizes and adapt to hardware integrations (wired and bluetooth headset) on the fly. But, it seems like setting this mode to video chat reduces the built microphone sensitivity considerably and hence sound gets recorded at low pitch. My targeted app users would be mostly in noisy atmosphere.

Is there any way to increase input and output sensitivity to maximum and at the same time leverage AVAudioSessionModeVideoChat mode?

Following is the code used for setting AudioSession in my application...

if (![[[AVAudioSession sharedInstance] category] isEqualToString:AVAudioSessionCategoryPlayAndRecord]) {
    [[AVAudioSession sharedInstance] setActive:NO error:&error];

    [[AVAudioSession sharedInstance] setActive:YES error:&error];
    NSLog(@"setActive error = %@", error);

    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:&error];
    NSLog(@"setCategory error = %@", error);

    [[AVAudioSession sharedInstance] setMode:AVAudioSessionModeVideoChat error:&error];
    NSLog(@"setMode error = %@", error);
}

Testing environment details: -

Device tested : iPad mini retina 4G and iPad 2

iOS : 7.0.3

Testing with device built in speakers and microphones.

Was it helpful?

Solution

Below is one of the possible alternative solution/approach that worked for my app targeted users. Set category with AVAudioSessionCategoryOptions that handles bluetooth headset integration and sound defaults to loud speakers.

if (![[[AVAudioSession sharedInstance] category] isEqualToString:AVAudioSessionCategoryPlayAndRecord]) {
    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:(AVAudioSessionCategoryOptionDefaultToSpeaker | AVAudioSessionCategoryOptionAllowBluetooth) error:&error];
    NSLog(@"setCategory error = %@", error);

    [[AVAudioSession sharedInstance] setActive:YES error:&error];
    NSLog(@"setActive error = %@", error);
}

Note - I had to remove AVAudioSessionModeVideoChat mode set approach since system tends to optimize the input/output system resources and thereby microphone sensitivity issue as mentioned in my question.

So far I have done some amount of testing on iPad mini and iPad 2. Still need to test on iPhones.

I hope this answer helps someone, if not me!!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top