Introduction
To promote audio quality and user experience, ZEGOCLOUD provides the ability to process audio with 3A technologies, including AEC, AGC, and ANS.
- AEC (Acoustic Echo Cancellation): A method of removing the echo from the audio signal captured by the microphone. After this feature is enabled, the SDK will filter the collected audio data to remove the echo.
- AGC (Automatic Gain Control): A feature that automatically adjusts the receiver's audio gain (volume). After this feature is enabled, the sound will be amplified, but the sound quality will be affected to some extent.
- ANS (Active Noise Control): A set of audio technologies that actively cancel the ambient noise. Enabling this feature will make your voice clearer.
Prerequisites
Before you begin, make sure you complete the following steps:
- Create a project in ZEGOCLOUD Admin Console, and get the AppID of your project.
- The ZEGO Express SDK has been integrated into the project. For details, see Integration and Implementation.
Set up audio 3A processing
Set up the AEC (Acoustic Echo Cancellation)
To implement the AEC feature, do the following:
To enable the AEC feature, call the
enableAEC
method.Optional: To enable the AEC feature for the headphones scenario, call the
enableHeadphoneAEC
method.To set the AEC mode, call the
setAECMode
mode.
The following sample code is used for setting the AEC to the medium mode (ZegoAECMode.MEDIUM
):
// Enable the AEC feature.
engine.enableAEC(true);
// Enable the AEC when using headphones.
engine.enableHeadphoneAEC(true);
// Set the AEC to medium mode (ZegoAECMode.MEDIUM).
engine.setAECMode(ZegoAECMode.MEDIUM);
Set up the AGC (Automatic Gain Control)
To enable the AGC, call the enableAGC
method. After this function is turned on, the SDK can automatically adjust the Microphone Volume to adapt to near and far sound pickups and keep the Volume stable.
// Enable the AGC feature.
engine.enableAGC(true);
Set up the ANS (Active Noise Control)
To implement the ANS feature, do the following:
To enable the ANS feature, call the
enableANS
method.Optional: To control or cancel the transient noise, call the
enableTransientANS
method. This feature can be used to suppress the noise of typing keyboard, table, etc.To set or adjust the ANS mode, call the
setANSMode
method. The SDK uses medium mode (ZegoANSMode.MEDIUM
) by default.
The following sample code is used for setting the ANS to the soft mode (ZegoANSMode.SOFT
):
// Enable the ANS feature.
engine.enableANS(true);
// Enable the transient ANS feature to control the transient noise.
engine.enableTransientANS(true);
// Set the ANS to soft mode (ZegoANSMode.SOFT).
engine.setANSMode(ZegoANSMode.SOFT);
Recommended configurations for 3A
The default and recommended configurations for audio 3A processing in the SDK are as follows:
Method | Description | Default config | Recommended config |
---|---|---|---|
enableAEC |
Enable/Disable the AEC feature. | True | We recommend you use the default settings for general scenarios. |
enableHeadphoneAEC |
Enable the AEC for the headphone scenario. | False | We recommend you enable this for chatting or playing games in groups. |
setAECMode |
Set the AEC mode. | ZegoAECMode.AGGRESSIVE (Aggressive mode) | We recommend you use the default settings for general scenarios. |
enableAGC |
Enable/Disable the AGC feature. | True |
|
enableANS |
Enable/Disable the ANS feature. | True | We recommend you use the default settings for general scenarios. |
setANSMode |
Set the ANS mode. | ZegoANSMode.MEDIUM (Medium mode) | We recommend you use the default settings for general scenarios. |
Top comments (1)
Really interesting.
Thanks for sharing!