logo
On this page

Audio 3A Processing

2025-03-05

Function Overview

During real-time audio and video calls or live streaming, audio can be processed with 3A, mainly including AEC (Acoustic Echo Cancelling), AGC (Automatic Gain Control), and ANS (Active Noise Control), to improve call or live streaming quality and user experience.

  • AEC (Acoustic Echo Cancellation): Filter collected audio data to reduce echoes in the audio.
  • AGC (Automatic Gain Control): After enabling this function, the SDK can automatically adjust the microphone volume to adapt to near and far sound pickup and keep the volume stable.
  • ANS (Noise Suppression): Identify background noise in the sound and eliminate it. After enabling this function, the human voice will be clearer.
Warning

This feature does not support running in WebGL environment.

Example Source Code Download

Please refer to Download Example Source Code to get the source code.

For related source code, please see the "Assets/ZegoExpressExample/Examples/AdvancedAudioProcessing/AEC_ANS_AGC.cs" file.

The default configuration and recommended configuration for audio 3A processing in the SDK are as follows:

Interface NameInterface DescriptionDefault ConfigurationRecommended Configuration
EnableAECTurn on/off echo cancellation.Before calling this function, the SDK internally automatically determines whether to use AEC. Once this function is called, the SDK no longer automatically determines.In general usage scenarios, it is recommended not to modify this configuration and keep the default.
SetAECModeSet echo cancellation mode.Aggressive (Aggressive echo cancellation).In general usage scenarios, it is recommended not to modify this configuration and keep the default.
EnableAGCTurn on/off automatic gain control.Before calling this function, the SDK internally automatically determines whether to use AGC. Once this function is called, it no longer automatically determines.
  • In ordinary voice chat scenarios, it is recommended to use the default configuration.
  • In music radio scenarios, it is recommended not to enable automatic gain control to restore the human voice.
  • In education scenarios, such as large classes, small classes, and 1v1, etc., it is recommended to enable automatic gain control.
EnableANSTurn on/off noise suppression.Before calling this function, the SDK internally automatically determines whether to use ANS. Once this function is called, it no longer automatically determines.In general usage scenarios, it is recommended not to modify this configuration and keep the default.
enableTransientANSTurn on/off transient noise suppression.When this function is not called, transient noise suppression is not enabled by default.In general usage scenarios, it is recommended not to modify this configuration and keep the default.
SetANSModeSet audio noise suppression mode.Medium (Moderate noise suppression).In general usage scenarios, it is recommended not to modify this configuration and keep the default.

Prerequisites

Before using audio 3A processing, please ensure:

Usage Steps

Set AEC (Acoustic Echo Cancellation)

Developers can complete echo cancellation related settings according to the following steps:

  1. Call the EnableAEC interface to enable echo cancellation. After this function is enabled, the SDK will filter the collected audio data to reduce echoes in the audio.

  2. After enabling echo cancellation, developers can set the echo cancellation mode by calling the SetAECMode interface. The SDK supports the following three echo cancellation modes:

    Enumeration ValueDescription
    AggressiveAggressive echo cancellation, which may significantly affect sound quality, but echoes will be eliminated very cleanly.
    MediumModerate echo cancellation, which may slightly affect sound quality a little bit, but there will be fewer residual echoes.
    SoftComfortable echo cancellation, echo cancellation basically does not affect the sound quality of the sound, sometimes there may be a little residual echo, but it will not affect normal listening.

Taking setting moderate echo cancellation as an example:

// Enable AEC
engine.EnableAEC(true);
// Set AEC mode to Medium
engine.SetAECMode(Medium);

Set AGC (Automatic Gain Control)

Call the EnableAGC interface to enable automatic gain control. After enabling this function, the SDK can automatically adjust the microphone volume to adapt to near and far sound pickup and keep the volume stable.

// Enable AGC
engine.EnableAGC(true);

Set ANS (Noise Suppression)

Developers can complete noise suppression related settings according to the following steps:

  1. Call the EnableANS interface to enable noise suppression. After enabling this function, the human voice will be clearer.

  2. (Optional) Developers can set whether to enable transient noise suppression by calling the EnableTransientANS interface. Transient noise suppression is used to suppress transient noise such as typing on keyboards, tapping on tables, etc.

  3. After enabling noise suppression, developers can set the noise suppression mode by calling the SetANSMode interface. The default value is "ZegoANSMode.Medium". The SDK supports the following four noise suppression modes:

    Enumeration ValueDescription
    SoftMild noise suppression, basically does not damage sound quality, but will leave some noise.
    Medium(Default value) Moderate noise suppression, may damage some sound quality, but has good noise reduction effect.
    AggressiveAggressive noise suppression, may significantly damage sound quality, but has very good noise reduction effect.
    AIAI mode noise suppression, will cause great damage to music, so it cannot be used for noise suppression of sound sources that need to collect background sound. If you need to use it, please contact technical support.
  4. (Optional) Enable music detection. Please contact ZEGOCLOUD Technical Support to configure and enable the music detection function.

Taking setting mild noise suppression as an example:

// Enable ANS
engine.EnableANS(true);
// Enable transient noise suppression
engine.EnableTransientANS(true);
// Set ANS mode to Soft
engine.SetANSMode(Soft);

Previous

Ear Monitor and Channel Settings

Next

Custom Audio Capture and Rendering

On this page

Back to top