2013-03-26 111 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