iPhone 上的 Core Audio - 有什么方法可以改变麦克风增益(扬声器麦克风或耳机麦克风)?
经过多次搜索后,答案似乎是否定的,但我想在放弃之前我应该在这里问一下。对于我正在从事的一个包括录音的项目,当路由是外部麦克风+扬声器和耳机麦克风+耳机时,输入电平听起来都有点安静。有谁确切知道是否可以通过编程方式更改 iPhone 上 Core Audio 任何部分的麦克风增益级别?
如果不是,是否有可能我并没有真正处于“免提”模式(至少使用外部麦克风),但只是认为我处于“免提”模式?这是我的音频会话初始化代码:
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");
非常感谢您的指点。
After much searching the answer seems to be no, but I thought I'd ask here before giving up. For a project I'm working on that includes recording sound, the input levels sound a little quiet both when the route is external mic + speaker and when it's headphone mic + headphones. Does anyone know definitively whether it is possible to programmatically change mic gain levels on the iPhone in any part of Core Audio?
If not, is it possible that I'm not really in "speakerphone" mode (with the external mic at least) but only think I am? Here is my audio session init 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 very much for any pointers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
增益是音频单元的一个属性。
我还没有尝试过,但你应该能够做到 AudioUnitSetProperty 并使用此属性键关闭“自动增益控制”或简称 AGC: kAUVoiceIOProperty_VoiceProcessingEnableAGC
另请参阅
kAUVoiceIOProperty_BypassVo冰处理
Gain is a property of the Audio Unit.
I haven't tried it, but you should be able to do AudioUnitSetProperty and turn off "Automatic Gain Control" or AGC for short with this property key: kAUVoiceIOProperty_VoiceProcessingEnableAGC
See also
kAUVoiceIOProperty_BypassVoiceProcessing
增益控制是自动的,平均值始终是被视为“最佳”的水平。您可以通过混音器路由输入来控制音量,但我认为它可能会削波。
上开始使用 coreAudio 的好地方
这是在 iphone http://www.subfurther 。 com/blog/?p=507
The gain control is automatic, the average will always be the level deemed 'optimal'. You could route the input thru a mixer to control the volume but i think it would probably clip.
This is a pretty good place to start with coreAudio on the iphone
http://www.subfurther.com/blog/?p=507
对于 iOS 5.0 及更高版本,您现在可以将 AudioSession 模式设置为 kAudioSessionMode_Measurement。
适用于希望最小化系统提供的信号处理对输入和/或输出音频信号的影响的应用。
您可以在 Core Audio 中设置 AudioSession 模式,如下所示:
For iOS 5.0 and later, you can now set AudioSession mode to kAudioSessionMode_Measurement.
Appropriate for applications that wish to minimize the effect of system-supplied signal processing for input and/or output audio signals.
You can set the AudioSession mode in Core Audio like this:
从 iOS 5 开始,您可以按如下方式设置全局模拟输入增益设置
As of iOS 5, you can set the global analog input gain setting as follows