Core Audio on iPhone - any way to change microphone gain (for mic with mic or mic for headphones)?

After a long search, the answer seems no, but I thought I would ask here before giving up. For the project I'm working on, including audio recording, the input levels sound a little quiet when the route is an external microphone + speaker, as well as earphones for headphones + earphones. Does anyone know finally whether it is possible to programmatically change the microphone gain levels on the iPhone in any part of Core Audio?

If not, is it possible that I really am not in speakerphone mode (at least with an external microphone), but I only think that I am? Here is my audio session initialization code:

OSStatus error = AudioSessionInitialize(NULL, NULL, audioQueueHelperInterruptionListener, r);

[...some error checking of the OSStatus...]

UInt32 category = kAudioSessionCategory_PlayAndRecord; // need to play out the speaker at full volume too so it is necessary to change default route below
error = AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(category), &category);
if (error) printf("couldn't set audio category!");

UInt32 doChangeDefaultRoute = 1;
error = AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, sizeof (doChangeDefaultRoute), &doChangeDefaultRoute);
if (error) printf("couldn't change default route!");

error = AudioSessionAddPropertyListener(kAudioSessionProperty_AudioRouteChange, audioQueueHelperPropListener, r);
if (error) printf("ERROR ADDING AUDIO SESSION PROP LISTENER! %d\n", (int)error);

UInt32 inputAvailable = 0;
UInt32 size = sizeof(inputAvailable);

error = AudioSessionGetProperty(kAudioSessionProperty_AudioInputAvailable, &size, &inputAvailable);
if (error) printf("ERROR GETTING INPUT AVAILABILITY! %d\n", (int)error);

error = AudioSessionAddPropertyListener(kAudioSessionProperty_AudioInputAvailable, audioQueueHelperPropListener, r);
if (error) printf("ERROR ADDING AUDIO SESSION PROP LISTENER! %d\n", (int)error);

error = AudioSessionSetActive(true); 
if (error) printf("AudioSessionSetActive (true) failed");

Thanks so much for any pointers.

+3
4

, "". , , , , .

, CoreAudio iphone

http://www.subfurther.com/blog/?p=507

+1

- Audio Unit.

, AudioUnitSetProperty " " AGC : kAUVoiceIOProperty_VoiceProcessingEnableAGC

. kAUVoiceIOProperty_BypassVoiceProcessing

+3

For iOS 5.0 and later, you can now set AudioSession mode to kAudioSessionMode_Measurement.

kAudioSessionMode_Measurement

Suitable for applications that want to minimize the impact of system signal processing on input and / or output audio signals.

You can set the AudioSession mode in Core Audio as follows:

UInt32 mode = kAudioSessionMode_Measurement;
AudioSessionSetProperty(kAudioSessionProperty_Mode, sizeof(mode), &mode)
0
source

As in iOS 5, you can set the gain of the global analog input as follows

UInt32 uInt32Size = sizeof(UInt32);
UInt32 isGainAvaiable = 0;
OSStatus status = AudioSessionGetProperty(kAudioSessionProperty_InputGainAvailable, &uInt32Size, &isGainAvaiable);
if (isGainAvaiable)
{
    Float32 gainFloat = 0.142857f; //for example...
    status = AudioSessionSetProperty(kAudioSessionProperty_InputGainScalar, sizeof(gainFloat), &gainFloat);
}
0
source

Source: https://habr.com/ru/post/1747603/


All Articles