iPhone 上的 Core Audio - 有什么方法可以改变麦克风增益(扬声器麦克风或耳机麦克风)?

发布于 2024-09-03 05:21:02 字数 1693 浏览 6 评论 0原文

经过多次搜索后,答案似乎是否定的,但我想在放弃之前我应该​​在这里问一下。对于我正在从事的一个包括录音的项目,当路由是外部麦克风+扬声器和耳机麦克风+耳机时,输入电平听起来都有点安静。有谁确切知道是否可以通过编程方式更改 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

萌化 2024-09-10 05:21:02

增益是音频单元的一个属性。

我还没有尝试过,但你应该能够做到 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

望她远 2024-09-10 05:21:02

增益控制是自动的,平均值始终是被视为“最佳”的水平。您可以通过混音器路由输入来控制音量,但我认为它可能会削波。

上开始使用 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

瘫痪情歌 2024-09-10 05:21:02

对于 iOS 5.0 及更高版本,您现在可以将 AudioSession 模式设置为 kAudioSessionMode_Measurement。

kAudioSessionMode_Measurement

适用于希望最小化系统提供的信号处理对输入和/或输出音频信号的影响的应用。

您可以在 Core Audio 中设置 AudioSession 模式,如下所示:

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

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

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:

UInt32 mode = kAudioSessionMode_Measurement;
AudioSessionSetProperty(kAudioSessionProperty_Mode, sizeof(mode), &mode)
灵芸 2024-09-10 05:21:02

从 iOS 5 开始,您可以按如下方式设置全局模拟输入增益设置

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);
}

As of iOS 5, you can set the global analog input gain setting 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);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文