Audio 3A Processing
Feature Overview
During real-time audio/video calls or live streaming, 3A processing can be performed on audio, mainly including AEC (Acoustic Echo Cancellation), AGC (Automatic Gain Control), and ANS (Active Noise Suppression), 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 feature, the SDK can automatically adjust microphone volume to adapt to near and far sound pickup, maintaining stable volume.
- ANS (Noise Suppression): Identify background noise in sound and eliminate it. After enabling this feature, human voice can be clearer. At the same time, you can enable music scenario detection to identify communication and music scenarios in real time without consumption, and further fidelity the sound quality of human voice and music in music scenarios. If users need more aggressive noise reduction strategies, they can use the Scenario-based AI Noise Reduction feature.
To use the music scenario detection capability, please contact ZEGO Technical Support for special packaging and configuration.
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 will automatically determine whether to use AEC. Once this function is called, the SDK will no longer automatically determine. | In general usage scenarios, it is recommended not to modify this configuration and keep the default. |
| enableHeadphoneAEC | Whether to enable echo cancellation when using headphones. | Enabled. | In ordinary voice chat or gaming scenarios, it is recommended to enable this feature. In other cases, it is generally not necessary to enable. |
| 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 will automatically determine whether to use AGC. Once this function is called, it will no longer automatically determine. |
|
| enableANS | Turn on/off noise suppression. | Before calling this function, the SDK will automatically determine whether to use ANS. Once this function is called, it will no longer automatically determine. | 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 the ZEGO Console and applied for a valid AppID and AppSign. For details, please refer to Console - Project Information.
- You have integrated the ZEGO Express SDK in your project and implemented basic audio/video streaming functions. For details, please refer to Quick Start - Integration and Quick Start - Implementation.
Usage Steps
Set AEC (Acoustic Echo Cancellation)
enableAEC, enableHeadphoneAEC, and setAECMode all need to be called before startPublishingStream, startPlayingStream, and startPreview interfaces 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 feature is enabled, the SDK will filter the collected audio data to reduce echoes in the audio.
-
(Optional) Developers can call the enableHeadphoneAEC interface to set whether to enable echo cancellation when using headphones.
-
After enabling echo cancellation, developers can call the setAECMode interface to set the echo cancellation mode. The SDK supports the following three echo cancellation modes:
Enumeration Value Description Aggressive Aggressive echo cancellation, may significantly affect sound quality, but echoes will be eliminated very cleanly. Medium Moderate echo cancellation, may slightly affect sound quality a little bit, but residual echoes will be less. Soft Comfortable echo cancellation, echo cancellation basically will not affect the sound quality of the sound, may sometimes leave a little echo, but will not affect normal listening.
Taking setting moderate echo cancellation as an example:
// Enable AEC
this.engine.enableAEC(true)
// Enable AEC when using headphones
this.engine.enableHeadphoneAEC(true)
// Set AEC mode to Medium
this.engine.setAECMode(ZegoAECMode.Medium)Set AGC (Automatic Gain Control)
enableAGC needs to be called before startPublishingStream, startPlayingStream, and startPreview interfaces to take effect.
Call the enableAGC interface to enable automatic gain control. After this feature is enabled, the SDK can automatically adjust microphone volume to adapt to near and far sound pickup, maintaining stable volume.
// Enable AGC
this.engine.enableAGC(true)Set ANS (Noise Suppression)
enableANS, enableTransientANS, and setANSMode all need to be called before startPublishingStream, startPlayingStream, and startPreview interfaces to take effect.
Developers can complete noise suppression related settings according to the following steps:
-
Call the enableANS interface to enable noise suppression. After this feature is enabled, human voice can be clearer.
-
(Optional) Developers can call the enableTransientANS interface to set whether to enable transient noise suppression. Transient noise suppression is used to suppress transient noises such as typing on keyboards, tapping tables, etc.
-
After enabling noise suppression, developers can call the setANSMode interface to set the noise suppression mode.
The SDK supports the following four noise suppression modes:
Enumeration Value Description Aggressive Aggressive noise suppression, may significantly damage sound quality, but has good noise reduction effects. Medium Moderate noise suppression, may damage some sound quality, but has good noise reduction effects. Soft Light noise suppression, basically will not damage sound quality, but will leave some noise. AI AI mode noise suppression, will cause great damage to music, can be used to process non-steady-state noise, but cannot be used for sound source processing that needs to collect background sound. For details, please refer to Scenario-based AI Noise Reduction.
Taking setting moderate noise suppression as an example:
// Enable ANS
this.engine.enableANS(true)
// Enable transient noise suppression
this.engine.enableTransientANS(true)
// Set ANS mode to ZegoANSModeMedium
this.engine.setANSMode(ZegoANSMode.Medium)- (Optional) Enable music detection. Please contact ZEGO Technical Support to configure and enable the music detection feature.
