logo
On this page

How to modify the configuration of audio 3A processing?

2022-07-13
Products / Plugins:Video Call / Audio Call / Live streaming
Platform / Framework:iOS / Android / macOS / Windows

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.

Note

The following documentation examples (code, API interfaces, documentation links, etc.) are all based on iOS.

Operation Steps

Before using audio 3A processing, please ensure:

Set AEC (Echo Cancellation)

Developers can complete echo cancellation settings according to the following steps:

  1. 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.

  2. (Optional) Developers can call the enableHeadphoneAEC interface to set whether to enable echo cancellation when using headphones.

  3. 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 ValueDescription
ZegoAECModeAggressiveAggressive echo cancellation, which may significantly affect sound quality, but the echo will be eliminated very cleanly.
ZegoAECModeMediumModerate echo cancellation, which may slightly affect sound quality, but residual echo will be less.
ZegoAECModeSoftComfortable 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)

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)

Developers can complete noise suppression settings according to the following steps:

  1. Call the enableANS interface to enable noise suppression. After this function is enabled, the human voice can be clearer.

  2. (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.

  3. 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 ValueDescription
ZegoANSModeAggressiveAggressive noise suppression, which may significantly damage sound quality, but has a good noise reduction effect.
ZegoANSModeMediumModerate noise suppression, which may damage some sound quality, but has a good noise reduction effect.
ZegoANSModeSoftLight 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];

The default and recommended configuration of audio 3A processing in the SDK are as follows:

Interface NameInterface DescriptionDefault ConfigurationRecommended Configuration
enableAECEnable/disable echo cancellationDefault 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.
enableHeadphoneAECWhether to enable echo cancellation when using headphonesYesIn ordinary voice chat or game sessions, it is recommended to enable this function. In other cases, it is generally not necessary to enable it.
setAECModeSet echo cancellation modeZegoAECModeAggressive (aggressive echo cancellation)In general usage scenarios, it is recommended not to modify this configuration and keep the default.
enableAGCEnable/disable automatic gain controlYes
  • In ordinary voice chat scenarios, it is recommended to use the default configuration.
  • In music radio scenarios, it is recommended not to enable automatic gain control to restore the human voice.
  • In education scenarios, such as large classes, small classes, and 1V1, it is recommended to enable automatic gain control.
enableANSEnable/disable noise suppressionYesIn general usage scenarios, it is recommended not to modify this configuration and keep the default.
setANSModeSet audio noise suppression modeZegoANSModeMedium (moderate noise suppression)In general usage scenarios, it is recommended not to modify this configuration and keep the default.

Previous

How to resolve macOS permission issues?

Next

Why do some files fail to transcode?

On this page

Back to top