I'm using Apple's CoreAudio framework for recording my microphone feed. Automatic Gain Control seems to be enabled by default: https://developer.apple.com/library/mac/#documentation/AudioUnit/Reference/AudioUnitPropertiesReference/Reference/reference.html
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.
How do I programmatically turn off the AGC in CoreAudio?
Assuming you're using an AUVoiceProcessor Audio Unit called voiceProcessor
UInt32 turnOff = 0;
AudioUnitSetProperty(voiceProcessor,
kAUVoiceIOProperty_VoiceProcessingEnableAGC,
kAudioUnitScope_Global,
0,
&turnOff,
sizeof(turnOff));
Quick explanation: What this is doing is setting a property on the audio unit to 0, which in this case disables the AGC. Audio Units typically have two sets of controllable values called properties and parameters. You can set/get these values by using AudioUnitSetProperty()
/ AudioUnitGetProperty()
and AudioUnitSetParameter()
/ AudioUnitGetParameter()
accordingly.
Note: You should probably check the OSStatus
code that AudioUnitSetProperty()
returns (it'll be equal to noErr
if there wasn't an error).