How to modify the configuration of audio 3A processing?
During real-time audio and video calls, 3A processing can be performed on audio, which mainly includes AEC (Acoustic Echo Cancelling), AGC (Automatic Gain Control), and ANS (Active Noise Control), to improve call quality and user experience.
- AEC (Echo Cancellation): Filter the collected audio data to reduce echo in the audio.
- AGC (Automatic Gain Control): After enabling this function, the SDK can automatically adjust the microphone volume, adapt to near and far sound pickup, and maintain stable volume.
- ANS (Noise Suppression): Identify and eliminate background noise in the sound. After enabling this function, the human voice can be clearer.
We provide example source code for your reference. Please check the files in the "/ZegoExpressExample/Examples/AdvancedAudioProcessing/AECANSAGC" directory in the code.
The following documentation examples (code, API interfaces, documentation links, etc.) are all based on iOS.
Operation Steps
Before using audio 3A processing, please ensure:
- Integrated ZEGO Express SDK in the project and implemented basic real-time audio and video functions. For details, please refer to Quick Start - Integrate and Quick Start - Implement Video Call.
- Created a project in ZEGOCLOUD Console and applied for a valid AppID and AppSign. For details, please refer to "Project Information" in Console - Project Management.
Set AEC (Echo Cancellation)
enableAEC, enableHeadphoneAEC, and setAECMode must be called before startPublishingStream, startPlayingStream, startPreview, createMediaPlayer, and createAudioEffectPlayer to be effective.
Developers can complete echo cancellation 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 echo 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:
| Enum Value | Description |
|---|---|
| ZegoAECModeAggressive | Aggressive echo cancellation, which may significantly affect sound quality, but the echo will be eliminated very cleanly. |
| ZegoAECModeMedium | Moderate echo cancellation, which may slightly affect sound quality, but residual echo will be less. |
| ZegoAECModeSoft | Comfortable echo cancellation, which basically does not affect sound quality, and may sometimes leave a little echo, but will not affect normal listening. |
Taking setting moderate echo cancellation as an example:
// Enable AEC
[[ZegoExpressEngine sharedEngine] enableAEC:YES];
// Enable AEC when using headphones
[[ZegoExpressEngine sharedEngine] enableHeadphoneAEC:YES];
// Set AEC mode to ZegoAECModeMedium
[[ZegoExpressEngine sharedEngine] setAECMode:ZegoAECModeMedium];Set AGC (Automatic Gain Control)
enableAGC must be called before startPublishingStream, startPlayingStream, startPreview, createMediaPlayer, and createAudioEffectPlayer to be effective.
Call the enableAGC interface to enable automatic gain control. After this function is enabled, the SDK can automatically adjust the microphone volume, adapt to near and far sound pickup, and maintain stable volume.
// Enable AGC
[[ZegoExpressEngine sharedEngine] enableAGC:YES];Set ANS (Noise Suppression)
enableANS, enableTransientANS, and setANSMode must be called before startPublishingStream, startPlayingStream, startPreview, createMediaPlayer, and createAudioEffectPlayer to be effective.
Developers can complete noise suppression settings according to the following steps:
-
Call the enableANS interface to enable noise suppression. After this function is enabled, 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 keyboard tapping and table tapping.
-
After enabling noise suppression, developers can call the setANSMode interface to set the noise suppression mode. The default value is "ZegoANSModeMedium".
The SDK supports the following three noise suppression modes:
| Enum Value | Description |
|---|---|
| ZegoANSModeAggressive | Aggressive noise suppression, which may significantly damage sound quality, but has a good noise reduction effect. |
| ZegoANSModeMedium | Moderate noise suppression, which may damage some sound quality, but has a good noise reduction effect. |
| ZegoANSModeSoft | Light noise suppression, which basically does not damage sound quality, but will leave some noise. |
Taking setting moderate noise suppression as an example:
// Enable ANS
[[ZegoExpressEngine sharedEngine] enableANS:YES];
// Enable transient noise suppression
[[ZegoExpressEngine sharedEngine] enableTransientANS:YES];
// Set ANS mode to ZegoANSModeMedium
[[ZegoExpressEngine sharedEngine] setANSMode:ZegoANSModeMedium];Recommended Configuration
The default and recommended configuration of audio 3A processing in the SDK are as follows:
| Interface Name | Interface Description | Default Configuration | Recommended Configuration |
|---|---|---|---|
| enableAEC | Enable/disable echo cancellation | Default is Yes, but will be disabled in call mode. | 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 | Yes | In ordinary voice chat or game sessions, it is recommended to enable this function. In other cases, it is generally not necessary to enable it. |
| setAECMode | Set echo cancellation mode | ZegoAECModeAggressive (aggressive echo cancellation) | In general usage scenarios, it is recommended not to modify this configuration and keep the default. |
| enableAGC | Enable/disable automatic gain control | Yes |
|
| enableANS | Enable/disable noise suppression | Yes | In general usage scenarios, it is recommended not to modify this configuration and keep the default. |
| setANSMode | Set audio noise suppression mode | ZegoANSModeMedium (moderate noise suppression) | In general usage scenarios, it is recommended not to modify this configuration and keep the default. |
