AGC API Structure Definitions

AGC_FRAME_ADVANCE

Length of the frame of data on which the AGC will operate.

AGC_META_DATA_NO_VAD

If the application has no VAD, adapt_on_vad must be disabled in the configuration. This pre-processor definition can be assigned to the vad_flag in agc_meta_data_t in that situation to make it clear in the code that there is no VAD.

AGC_META_DATA_NO_AEC

If the application has no AEC, lc_enabled must be disabled in the configuration. This pre-processor definition can be assigned to the aec_ref_power and aec_corr_factor in agc_meta_data_t in that situation to make it clear in the code that there is no AEC.

struct agc_config_t
#include <agc_api.h>

AGC configuration structure.

This structure contains configuration settings that can be changed to alter the behaviour of the AGC instance.

Members with the “lc_” prefix are parameters for the Loss Control feature.

Public Members

int adapt

Boolean to enable AGC adaption; if enabled, the gain to apply will adapt based on the peak of the input frame and the upper/lower threshold parameters.

int adapt_on_vad

Boolean to enable adaption based on the VAD meta-data; if enabled, adaption will always be performed when voice activity is detected. This must be disabled if the application doesn’t have a VAD.

int soft_clipping

Boolean to enable soft-clipping of the output frame.

float_s32_t gain

The current gain to be applied, not including loss control.

float_s32_t max_gain

The maximum gain allowed when adaption is enabled.

float_s32_t min_gain

The minimum gain allowed when adaption is enabled.

float_s32_t upper_threshold

The upper limit for the gained peak of the frame when adaption is enabled.

float_s32_t lower_threshold

The lower limit for the gained peak of the frame when adaption is enabled.

float_s32_t gain_inc

Factor by which to increase the gain during adaption.

float_s32_t gain_dec

Factor by which to decrease the gain during adaption.

int lc_enabled

Boolean to enable loss control. This must be disabled if the application doesn’t have an AEC.

int lc_n_frame_far

Number of frames required to consider far-end audio active.

int lc_n_frame_near

Number of frames required to consider near-end audio active.

float_s32_t lc_corr_threshold

Threshold for far-end correlation above which to indicate far-end activity only.

float_s32_t lc_bg_power_gamma

Gamma coefficient for estimating the power of the far-end background noise.

float_s32_t lc_gamma_inc

Factor by which to increase the loss control gain when less than target value.

float_s32_t lc_gamma_dec

Factor by which to decrease the loss control gain when greater than target value.

float_s32_t lc_far_delta

Delta multiplier used when only far-end activity is detected.

float_s32_t lc_near_delta

Delta multiplier used when only near-end activity is detected.

float_s32_t lc_near_delta_far_active

Delta multiplier used when both near-end and far-end activity is detected.

float_s32_t lc_gain_max

Loss control gain to apply when near-end activity only is detected.

float_s32_t lc_gain_double_talk

Loss control gain to apply when double-talk is detected.

float_s32_t lc_gain_silence

Loss control gain to apply when silence is detected.

float_s32_t lc_gain_min

Loss control gain to apply when far-end activity only is detected.

struct agc_state_t
#include <agc_api.h>

AGC state structure.

This structure holds the current state of the AGC instance and members are updated each time that agc_process_frame() runs. Many of these members are exponentially-weighted moving averages (EWMA) which influence the adaption of the AGC gain or the loss control feature. The user should not directly modify any of these members, except the config.

Public Members

agc_config_t config

The current configuration of the AGC. Any member of this configuration structure can be modified and that change will take effect on the next run of agc_process_frame().

float_s32_t x_slow

EWMA of the frame peak, which is used to identify the overall trend of a rise or fall in the input signal.

float_s32_t x_fast

EWMA of the frame peak, which is used to identify a rise or fall in the peak of frame.

float_s32_t x_peak

EWMA of x_fast, which is used when adapting to the agc_config_t::upper_threshold.

int lc_t_far

Timer counting down until enough frames with far-end activity have been processed.

int lc_t_near

Timer counting down until enough frames with near-end activity have been processed.

float_s32_t lc_near_power_est

EWMA of estimates of the near-end power.

float_s32_t lc_far_power_est

EWMA of estimates of the far-end power.

float_s32_t lc_near_bg_power_est

EWMA of estimates of the power of near-end background noise.

float_s32_t lc_gain

Loss control gain applied on top of the AGC gain in agc_config_t.

float_s32_t lc_far_bg_power_est

EWMA of estimates of the power of far-end background noise.

float_s32_t lc_corr_val

EWMA of the far-end correlation for detecting double-talk.

struct agc_meta_data_t
#include <agc_api.h>

AGC meta data structure.

This structure holds meta-data about the current frame to be processed, and must be updated to reflect the current frame before calling agc_process_frame().

Public Members

int vad_flag

Boolean to indicate the detection of voice activity in the current frame.

float_s32_t aec_ref_power

The power of the most powerful reference channel.

float_s32_t aec_corr_factor

Correlation factor between the microphone input and the AEC’s estimated microphone signal.