Audio 3A Processing
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.
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.
Default Configuration and Recommended Configuration
The default configuration and recommended configuration for audio 3A processing in the SDK are as follows:
| Interface Name | Interface Description | Default Configuration | Recommended Configuration |
|---|---|---|---|
| EnableAEC | Turn 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. |
| SetAECMode | Set echo cancellation mode. | Aggressive (Aggressive echo cancellation). | In general usage scenarios, it is recommended not to modify this configuration and keep the default. |
| EnableAGC | Turn 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. |
|
| EnableANS | Turn 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. |
| enableTransientANS | Turn 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. |
| SetANSMode | Set 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:
- You have created a project in ZEGOCLOUD Console and applied for valid AppID and AppSign. For details, please refer to Console - Project Information.
- You have integrated ZEGO Express SDK in the project and implemented basic audio and video streaming functions. For details, please refer to Quick Start - Integration and Quick Start - Implementation.
Usage Steps
Set AEC (Acoustic Echo Cancellation)
EnableAEC and SetAECMode both need to be called before StartPublishingStream, StartPlayingStream, StartPreview, CreateMediaPlayer, and CreateAudioEffectPlayer to take effect.
Developers can complete echo cancellation related settings according to the following steps:
-
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.
-
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 Value Description Aggressive Aggressive echo cancellation, which may significantly affect sound quality, but echoes will be eliminated very cleanly. Medium Moderate echo cancellation, which may slightly affect sound quality a little bit, but there will be fewer residual echoes. Soft Comfortable 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)
EnableAGC needs to be called before StartPublishingStream, StartPlayingStream, StartPreview, CreateMediaPlayer, and CreateAudioEffectPlayer to take effect.
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)
EnableANS, EnableTransientANS, and SetANSMode all need to be called before StartPublishingStream, StartPlayingStream, StartPreview, CreateMediaPlayer, and CreateAudioEffectPlayer to take effect.
Developers can complete noise suppression related settings according to the following steps:
-
Call the EnableANS interface to enable noise suppression. After enabling this function, the human voice will be clearer.
-
(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.
-
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 Value Description Soft Mild 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. Aggressive Aggressive noise suppression, may significantly damage sound quality, but has very good noise reduction effect. AI AI 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. -
(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);