Standalone AGC (auto gain control) in WebRtc appli

2019-08-06 03:00发布

问题:

I'm trying to create a standalone AGC using WebRtc library. (Input - wav file, output - wav file with adjusted gain). But at this time I have some problems with this issue.

I'm trying to use functions which are declared in gain_control.h file. When I'm using WebRtcAgc_Process(....) I obtain constant gain, which applies to whole signal, but not nonlinear gain which depends from input signal magnitude.

May be I should use another functions for my purpose? How can I implement AGC via WebRTC library?

回答1:

The AGC's main purpose is to provide a recommended system mic volume which the user is expected to set through the OS. If you would like to apply a purely digital gain, you can configure it in one of two modes (from modules/audio_processing/include/audio_processing.h, but gain_control.h has analogous modes):

// Adaptive mode intended for situations in which an analog volume control
// is unavailable. It operates in a similar fashion to the adaptive analog
// mode, but with scaling instead applied in the digital domain. As with
// the analog mode, it additionally uses a digital compression stage.
kAdaptiveDigital,

// Fixed mode which enables only the digital compression stage also used by
// the two adaptive modes.
//
// It is distinguished from the adaptive modes by considering only a
// short time-window of the input signal. It applies a fixed gain through
// most of the input level range, and compresses (gradually reduces gain
// with increasing level) the input signal at higher levels. This mode is
// preferred on embedded devices where the capture signal level is
// predictable, so that a known gain can be applied.
kFixedDigital

You can set these through WebRtcAgc_Init(), though unless you need to avoid the overhead, I'd recommend just using the AudioProcessing class.



回答2:

refer to http://osxr.org/android/source/external/webrtc/src/modules/audio_processing/agc/interface/gain_control.h#0133

The gain adjustments are done only during 0135 * active periods of speech. The input speech length can be either 10ms or 0136 * 20ms and the output is of the same length.

quick overview of webrtcage_process

int WebRtcAgc_Process(void* agcInst,
                    const WebRtc_Word16* inNear,
                    const WebRtc_Word16* inNear_H,
                     WebRtc_Word16 samples,
                     WebRtc_Word16* out,
                     WebRtc_Word16* out_H,
                     WebRtc_Word32 inMicLevel,
                     WebRtc_Word32* outMicLevel,
                     WebRtc_Word16 echo,
                     WebRtc_UWord8* saturationWarning);