Documentation
ExpressVideoSDK Video Call
Documentation
Demo APP
SDK Center
API Center
FAQ
Code Market
Console
Sign Up
Log In
中文站 English
  • Documentation
  • Video Call
  • Upgrade using advanced features
  • Advanced features
  • Improve video quality
  • Audio 3A processing

Audio 3A processing

Last updated:2024-12-04 00:13

Introduction

During real-time audio and video calls or live streaming, audio can be processed using the 3A approach, which mainly includes Acoustic Echo Cancelling (AEC), Automatic Gain Control (AGC), and Active Noise Control (ANS), in order to improve the quality of the calls or live streams and enhance the user experience.

  • AEC (Acoustic Echo Cancelling): Filters the captured audio data to reduce echo in the audio.
  • AGC (Automatic Gain Control): When enabled, the SDK can automatically adjust the microphone volume to adapt to different distances, ensuring a stable volume.
  • ANS (Active Noise Control): Identifies background noise in the audio and eliminates it, making the human voice clearer. You can also enable music scene detection, which can dynamically recognize communication and music scenes in real-time without any additional consumption, further enhancing the audio quality of human voice and music. If users require more aggressive noise reduction strategies, the AI-based noise reduction in real-world scenarios feature can be used.

To use the music scene detection capability, please contact ZEGOCLOUD technical support for special packaging and configuration.

Download example source code

Please refer to Sample codes to get the source code.

The relevant source code can be found 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 Enable/disable 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 use cases, it is recommended not to modify this configuration and keep it as the default.
enableHeadphoneAEC Enable/disable acoustic echo cancellation when using headphones. Disabled. It is recommended to enable this feature for normal voice chat or game voice chat, and it is generally not necessary to enable it in other scenarios.
setAECMode Set the acoustic echo cancellation mode. ZegoAECMode.AGGRESSIVE (aggressive echo cancellation). In general use cases, it is recommended not to modify this configuration and keep it as the default.
enableAGC Enable/disable 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.
  • In normal 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.
enableANS Enable/disable noise suppression. Before calling this function, the SDK will automatically determine whether to use ANS. Once this function is called, the SDK will no longer automatically determine. In general use cases, it is recommended not to modify this configuration and keep it as the default.
enableTransientANS Enable/disable transient noise suppression. By default, transient noise suppression is disabled when this function is not called. In general use cases, it is recommended not to modify this configuration and keep it as the default.
setANSMode Set the audio noise suppression mode. ZegoANSMode.Medium (moderate noise suppression). In general use cases, it is recommended not to modify this configuration and keep it as the default.

Prerequisites

Before using audio 3A processing, please make sure:

  • A project has been created in ZEGOCLOUD Console and applied for a valid AppID and AppSign. For details, please refer to Console - How to view project information .
  • ZEGO Express SDK has been integrated into the project to implement basic real-time audio and video functions. For details, please refer to Integrate the SDK and Implement a basic video call.

Steps to use

Set AEC (Acoustic Echo Cancellation)

enableAEC, enableHeadphoneAEC, and setAECMode need to be called before startPublishingStream, startPlayingStream, startPreview, createMediaPlayer, createAudioEffectPlayer, and createRealTimeSequentialDataManager interfaces in order to take effect.

Developers can follow the steps below to configure echo cancellation:

  1. Call the enableAEC interface to enable echo cancellation. After enabling this feature, the SDK will filter the captured audio data to reduce echo.

  2. (Optional) Developers can call the enableHeadphoneAEC interface 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:

    Enumeration Description
    ZegoAECMode.AGGRESSIVE Aggressive echo cancellation, which may have a noticeable impact on audio quality, but effectively eliminates echo.
    ZegoAECMode.MEDIUM Moderate echo cancellation, which may slightly affect audio quality, but reduces residual echo.
    ZegoAECMode.SOFT Comfortable echo cancellation, which has minimal impact on audio quality and may leave a small amount of echo, but does not affect normal listening.

The Express SDK supports AI echo cancellation and provides a lightweight mode to further enhance the fidelity of human voice while effectively eliminating echo. If you need to use the AI echo cancellation feature, please contact ZEGOCLOUND technical support for special packaging.

For example, to set the echo cancellation mode to "Medium":

// 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)

To configure AGC:

enableAGC needs to be called before startPublishingStream, startPlayingStream, startPreview, createMediaPlayer, createAudioEffectPlayer, and createRealTimeSequentialDataManager interfaces in order to take effect.

Call the enableAGC interface to enable Automatic Gain Control (AGC). After enabling this feature, the SDK will automatically adjust the microphone volume to adapt to different distances, ensuring a stable volume.

// Enable AGC
engine.enableAGC(true);

Set ANS (Acoustic Noise Suppression)

To configure ANS:

enableANS, enableTransientANS, and setANSMode need to be called before startPublishingStream, startPlayingStream, startPreview, createMediaPlayer, createAudioEffectPlayer, and createRealTimeSequentialDataManager interfaces in order to take effect.

Developers can follow the steps below to configure noise suppression:

  1. Call the enableANS interface to enable noise suppression. This feature can make the human voice clearer.

  2. (Optional) Developers can call the enableTransientANS interface to enable transient noise suppression, which is used to suppress transient noises such as keyboard typing and table tapping.

  3. After enabling noise suppression, developers can call the setANSMode interface to set the noise suppression mode. The default value is "Medium". The SDK supports the following three noise suppression modes:

    Enumeration Description
    ZegoANSMode.AGGRESSIVE Aggressive noise suppression, which may significantly affect audio quality but has good noise reduction effects.
    ZegoANSMode.MEDIUM (Default) Moderate noise suppression, which may slightly affect audio quality but has good noise reduction effects.
    ZegoANSMode.SOFT Mild noise suppression, which has minimal impact on audio quality but may leave some residual noise.

    Note: The Express SDK supports AI-based noise suppression and provides two modes: ZegoANSModeAI and ZegoANSModeAI_BALANCED. These modes effectively eliminate transient noises such as keyboard typing, coughing, wind noise, and car horns, in addition to eliminating steady-state noise. For more details, please refer to AI-based noise reduction in real-world scenarios.

  4. (Optional) Enable music detection. Please contact ZEGOCLOUD technical support to configure and enable music detection. Taking setting mild 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);

Related documents

  • How to deal with the echo issue?
Page Directory
  • Free trial
  • 提交工单
    咨询集成、功能及报价等问题
    电话咨询
    400 1006 604
    Get Consulting
    Scan Wechat QR code