The Alibaba Real-Time Communication (ARTC) software development kit (SDK) provides real-time sound effects, such as voice changer, reverb, and beautification. You can call APIs during audio and video calls to add various sound effects to the local audio stream, which enhances the interactive entertainment experience.
Feature overview
Developers can quickly enable sound effects by calling the relevant APIs:
Voice changer: Changes the user's voice to sound like an old man, a boy, or a girl.
Reverb: Creates a specific spatial atmosphere, making the voice sound as if it is coming from a particular venue.
Beautification: Fine-tunes the timbre of a voice to make it sound more magnetic or fresh.
Custom voice effects: In addition to the preset sound effect modes, you can call APIs to adjust the pitch, reverb, and equalization of a voice to create custom effects.
Sample code
ARTC provides an open source sample project for your reference. You can download the project or view the source code. The sample code is located in the following files:
Set voice changer, reverb, and beautification effects on Android: Android/ARTCExample/BasicUsage/src/main/java/com/aliyun/artc/api/basicusage/VoiceChange/VoiceChangeActivity.java
Set voice changer, reverb, and beautification effects on iOS: iOS/ARTCExample/BasicUsage/VoiceChange/VoiceChangeVC.swift
Prerequisites
Before you set the video configuration, you must meet the following requirements:
You have a valid Alibaba Cloud account and have created an ApsaraVideo Real-time Communication application. For more information, see Create an application. You can obtain the App ID and App Key from the Application Management console.
You have integrated the ARTC SDK into your project and implemented basic real-time audio and video features. For more information about SDK integration, see Download and integrate the SDK. For more information about implementing audio and video calls, see Implement an audio and video call.
Implementation
This section describes how to call the required APIs in your project to implement various sound effects.
Voice changer
You can call the setAudioEffectVoiceChangerMode API to set a voice changer effect. This API can change a voice to sound like an old man, a boy, or a girl. Each sound effect corresponds to an enumeration value. The available voice changer modes are as follows:
Voice changer mode | Enumeration value |
Off |
|
Old man |
|
Boy |
|
Girl |
|
Robot |
|
Devil |
|
KTV |
|
Echo |
|
Dialect |
|
Howl |
|
Electronic music |
|
Phonograph |
|
Android
/* Preset voice changer mode */
mAliRtcEngine.setAudioEffectVoiceChangerMode(mode);iOS
/* Preset voice changer mode */
self.rtcEngine?.setAudioEffectVoiceChangerMode(mode)Windows
/* Preset voice changer mode */
mAliRtcEngine->SetAudioEffectVoiceChangerMode(mode);Reverb
You can call the setAudioEffectReverbMode API to implement reverb effects. Reverb creates a specific spatial atmosphere, making the voice sound as if it is coming from a particular venue. The available reverb modes and their corresponding enumeration values are as follows:
Reverb mode | Enumeration value |
Reverb off |
|
Vocal I |
|
Vocal II |
|
Bathroom |
|
Small room bright |
|
Small room dark |
|
Medium room |
|
Large room |
|
Church hall |
|
Android
/* Preset reverb mode */
mAliRtcEngine.setAudioEffectReverbMode(mode);
/* You can also set parameters. */iOS
/* Preset reverb mode */
self.rtcEngine?.setAudioEffectReverbMode(mode)Windows
/* Preset reverb mode */
mAliRtcEngine->SetAudioEffectReverbMode(mode);
/* You can also set parameters. */Beautification
You can call the setAudioEffectBeautifyMode API to implement voice beautification. Two preset modes are supported: magnetic and fresh.
Beautification mode | Enumeration value |
Magnetic |
|
Fresh |
|
Android
/* Preset beautification mode */
mAliRtcEngine.setAudioEffectBeautifyMode(mode);
/* You can also set parameters. */iOS
/* Preset beautification mode */
self.rtcEngine?.setAudioEffectBeautifyMode(mode)Windows
/* Preset beautification mode */
mAliRtcEngine->SetAudioEffectBeautifyMode(mode);
/* You can also set parameters. */Custom voice effects
If the preset sound effects do not meet your requirements, you can call the following APIs to adjust the pitch, equalization, and reverb parameters to create custom voice effects.
The following APIs are available:
setAudioEffectPitchValue(value): Sets the pitch parameter.value: Specifies the pitch. The value range is [0.5, 2.0]. A value of 1.0 indicates the original pitch. A value less than 1.0 lowers the pitch, and a value greater than 1.0 raises the pitch.
setAudioEffectReverbParamType(type, value): Sets the reverb effect parameters. This must be called aftersetAudioEffectReverbMode.type: The reverb parameter type. For more information, see AliRtcAudioEffectReverbParamType.value: The reverb parameter value. Different reverb parameter types have different value ranges. For more information, see AliRtcAudioEffectReverbParamType.
setAudioEffectEqualizationParam: Sets the equalizer parameters. This must be called aftersetAudioEffectBeautifyMode.bandIndex: The equalizer band index. The value range is 0 to 9, representing the 10 frequency bands: [31, 62, 125, 250, 500, 1000, 2000, 4000, 8000, 16000] Hz.gain: The equalizer gain value. The value range is -15 dB to 15 dB. The default value is 0.
Android
// Set the pitch. The range is [0.5, 2.0]. 1.0 means the pitch is unchanged. A value less than 1.0 lowers the pitch, and a value greater than 1.0 raises the pitch.
mAliRtcEngine.setAudioEffectPitchValue(1.5);
// Example of setting reverb parameters. This must be called after setAudioEffectReverbMode.
mAliRtcEngine.setAudioEffectReverbMode(AliRtcEngine.AliRtcAudioEffectReverbMode.AliRtcSdk_AudioEffect_Reverb_Large_Room);
mAliRtcEngine.setAudioEffectReverbParamType(AliRtcEngine.AliRtcAudioEffectReverbParamType.AliRtcSdk_AudioEffect_Reverb_Room_Size, 50);
// Example of setting beautification parameters.
mAliRtcEngine.setAudioEffectBeautifyMode(AliRtcEngine.AliRtcAudioEffectBeautifyMode.AliRtcSdk_AudioEffect_Beautify_Magnetic);
mAliRtcEngine.setAudioEffectEqualizationParam(AliRtcEngine.AliRtcAudioEffectEqualizationBandFrequency.AliRtcSdk_AudioEffect_EqualizationBand1K, 5); iOS
// Set the pitch. The range is [0.5, 2.0]. 1.0 means the pitch is unchanged. A value less than 1.0 lowers the pitch, and a value greater than 1.0 raises the pitch.
let pitch = 1.5
self.rtcEngine?.setAudioEffectPitchValue(pitch)
// Example of setting reverb parameters. This must be called after setAudioEffectReverbMode.
self.rtcEngine?.setAudioEffectReverbMode(.large_Room)
self.rtcEngine?.setAudioEffectReverbParamType(.room_Size, value: 50)
// Example of setting beautification parameters.
self.rtcEngine?.setAudioEffectBeautifyMode(.vigorous)
self.rtcEngine?.setAudioEffectEqualizationParam(.band1K, gain: 5)