Audio 3A Processing
Feature Overview
In real-time audio and video calls or live streaming, you can perform 3A processing on audio, mainly including AEC (Acoustic Echo Cancelling), AGC (Automatic Gain Control), and ANS (Active Noise Control), to improve the quality of calls or live streaming and user experience.
- AEC (Acoustic Echo Cancellation): Filter the captured audio data to reduce echo in the audio.
- AGC (Automatic Gain Control): After enabling this feature, 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 feature, the 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 improve the fidelity of human voice and music sound quality in music scenarios. If users need a more aggressive noise suppression strategy, they can use the Scenario-Based AI Noise Suppression feature.
If you need to use the music scenario detection capability, please contact ZEGOCLOUD Technical Support for special packaging and configuration.
Example Source Code Download
Please refer to Download Example Source Code to get the source code.
For related source code, please check the files in the "/ZegoExpressExample/AdvancedAudioProcessing/src/main/java/im/zego/advancedaudioprocessing/audio3a" directory.
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 acoustic 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 acoustic echo cancellation when using headphones. | Not 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 it. |
| setAECMode | Set acoustic echo cancellation mode. | ZegoAECMode.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, the SDK 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. | ZegoANSMode.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 ZEGOCLOUD 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 and video streaming functionality. 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, startPreview, createMediaPlayer, createAudioEffectPlayer, and createRealTimeSequentialDataManager to take effect.
Developers can complete echo cancellation related settings according to the following steps:
-
Call the enableAEC interface to enable acoustic echo cancellation. After enabling this feature, the SDK will filter the captured audio data to reduce echo in the audio.
-
(Optional) Developers can call the enableHeadphoneAEC interface to set whether to enable acoustic echo cancellation when using headphones.
-
After enabling acoustic echo cancellation, developers can call the setAECMode interface to set the acoustic echo cancellation mode. The SDK supports the following three acoustic echo cancellation modes:
Enumeration Value Description ZegoAECMode.AGGRESSIVE Aggressive echo cancellation, which may obviously affect sound quality, but echo will be eliminated very cleanly. ZegoAECMode.MEDIUM Moderate echo cancellation, which may slightly affect sound quality a little bit, but residual echo will be less. ZegoAECMode.SOFT Comfortable echo cancellation, which basically will not affect the sound quality of the sound. There may sometimes be a little residual echo, but it will not affect normal listening.
Express SDK supports AI echo cancellation, which further improves the fidelity of human voice on the basis of effectively eliminating echo. If you need to use the AI echo cancellation feature, please contact ZEGOCLOUD Technical Support for special packaging first.
Taking setting moderate echo cancellation as an example:
// Enable AEC
engine.enableAEC(true);
// Enable AEC when using headphones
engine.enableHeadphoneAEC(true);
// Set AEC mode to ZegoAECMode.MEDIUM
engine.setAECMode(ZegoAECMode.MEDIUM);Set AGC (Automatic Gain Control)
enableAGC needs to be called before startPublishingStream, startPlayingStream, startPreview, createMediaPlayer, createAudioEffectPlayer, and createRealTimeSequentialDataManager to take effect.
Call the enableAGC interface to enable automatic gain control. After enabling this feature, 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, createAudioEffectPlayer, and createRealTimeSequentialDataManager 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 feature, the 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 noise such as typing on keyboards and tapping on tables.
-
After enabling noise suppression, developers can call the setANSMode interface to set the noise suppression mode. The default value is "ZegoANSMode.MEDIUM". The SDK supports the following noise suppression modes:
Enumeration Value Description ZegoANSMode.AGGRESSIVE Aggressive noise suppression, which may obviously damage sound quality, but has a very good noise suppression effect. ZegoANSMode.MEDIUM (Default value) Moderate noise suppression, which may damage some sound quality, but has a good noise suppression effect. ZegoANSMode.SOFT Light noise suppression, which basically will not damage sound quality, but will leave some noise. WarningExpress SDK supports AI mode noise suppression, and provides three modes: lightweight mode, balanced mode, and low latency mode. On the basis of eliminating steady-state noise, it effectively eliminates transient noise, such as keyboards, coughing, wind, car horns, etc. For details, please refer to Scenario-Based AI Noise Suppression.
-
(Optional) Enable music detection. Please contact ZEGOCLOUD Technical Support to configure and enable the music detection feature.
Taking setting light noise suppression as an example:
// Enable ANS
engine.enableANS(true);
// Enable transient noise suppression
engine.enableTransientANS(true);
// Set ANS mode to ZegoANSMode.SOFT
engine.setANSMode(ZegoANSMode.SOFT);