Audio 3A Processing
Function Overview
During real-time video calls, you can perform 3A processing on audio, mainly including AEC (Acoustic Echo Cancellation), AGC (Automatic Gain Control), and ANS (Active Noise Suppression), to improve call quality and user experience.
- AEC (Acoustic Echo Cancellation): Filters captured audio data to reduce echoes 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, keeping the volume stable.
- ANS (Active Noise Suppression): Identifies and eliminates background noise in the sound. After enabling this feature, the voice can be clearer.
Download Sample Source Code
Please refer to Download Sample Source Code to get the source code.
For related source code, please check the files in the "src/Examples/AdvancedAudioProcessing/AEC_ANS_AGC" directory.
Default Configuration and Recommended Configuration
The default configuration and recommended configuration for audio 3A processing in the SDK are as follows:
| Parameter Name | Parameter Description | Default Configuration | Recommended Configuration |
|---|---|---|---|
| AEC | Turn on/off acoustic echo cancellation. | Before this parameter is called, the SDK internally automatically determines whether to use AEC. Once this parameter is called, the SDK no longer makes automatic judgments. | In general usage scenarios, it is recommended not to modify this configuration and keep the default. |
| AGC | Turn on/off automatic gain control. | Before this parameter is called, the SDK internally automatically determines whether to use AGC. Once this parameter is called, the SDK no longer makes automatic judgments. |
|
| ANS | Turn on/off noise suppression. | Before this parameter is called, the SDK internally automatically determines whether to use ANS. Once this parameter is called, the SDK no longer makes automatic judgments. | In general usage scenarios, it is recommended not to modify this configuration and keep the default. |
Prerequisites
Before using audio 3A processing, ensure that:
- You have created a project in the ZEGOCLOUD Console and applied for a valid AppID and Server address. For details, please refer to Console - Project Information.
- You have integrated the ZEGO Express SDK into your project and implemented basic stream publishing and playing functionality. For details, please refer to Quick Start - Integration and Quick Start - Implementation.
Usage Steps
Call the createZegoStream interface to create a ZegoLocalStream instance object localStream, and configure 3A switches through the camera video data capture method.
When capturing source data through camera and microphone, use the "ANS", "AGC", and "AEC" parameters in the ZegoCaptureMicrophone object to set noise suppression, automatic gain, and echo cancellation switches respectively. "true" means on, "false" means off.
- When creating a stream, you can only select one configuration mode from "camera", "screen", and "custom".
- By default, the SDK determines whether to enable "ANS", "AGC", and "AEC" processing based on the browser's default capabilities. Unless there are special circumstances, it is recommended that developers keep the default configuration.
const zg = new ZegoExpressEngine(appID, server);
// The following configuration turns off 3A. Unless there are special circumstances, it is recommended that developers keep the default configuration
option = {
camera: {
video: true,
audio: {
ANS: false,
AGC: false,
AEC: false
}
}
}
const localStream = await zg.createZegoStream(option)If you need to configure 3A processing during stream publishing after creating a stream, you can use setAudioConfig to modify it.
