2013-03-26 114 views
2

我正在使用Apple的CoreAudio框架来录制我的麦克风Feed。自动增益控制似乎是默认启用:https://developer.apple.com/library/mac/#documentation/AudioUnit/Reference/AudioUnitPropertiesReference/Reference/reference.html以编程方式关闭VoiceProcessingIO AGC

kAUVoiceIOProperty_VoiceProcessingEnableAGC 
Indicates whether automatic gain control is enabled (any nonzero value) or disabled (a value of 0). Automatic gain control is enabled by default. 
Value is a read/write UInt32 valid on the global audio unit scope. 
Available in OS X v10.7 and later. 
Declared in AudioUnitProperties.h. 

如何编程关闭AGC在CoreAudio的?

回答

2

假设你正在使用AUVoiceProcessor音频单元称为voiceProcessor

UInt32 turnOff = 0; 
AudioUnitSetProperty(voiceProcessor, 
        kAUVoiceIOProperty_VoiceProcessingEnableAGC, 
        kAudioUnitScope_Global, 
        0, 
        &turnOff, 
        sizeof(turnOff)); 

快速的解释:这是什么东西做的是音频单元上的财产设置为0,在这种情况下禁用AGC。音频单元通常具有两组可控值,称为属性参数。您可以相应地使用AudioUnitSetProperty()/AudioUnitGetProperty()AudioUnitSetParameter()/AudioUnitGetParameter()来设置/获取这些值。

注意:您应该检查AudioUnitSetProperty()返回的代码OSStatus(如果没有错误,它将等于noErr)。

+0

AudioUnitSetProperty已弃用,还有其他方法吗? https://developer.apple.com/reference/audiounit/1653800-audio_unit_component_services? – zevarito 2016-11-24 14:18:09

+2

@zevarito我没有看到它被弃用,但仍然失败 - 返回OSStatus'k Audio Unit Err_Invalid Property'。有什么建议么? – beebcon 2017-03-24 00:26:46