The Alibaba Real-Time Communication (ARTC) software development kit (SDK) provides real-time sound effects, such as voice change, reverberation, and voice beautification. During audio and video calls, you can call the APIs to add rich sound effects to the local voice and enhance the interactive entertainment experience.
Feature introduction
Developers can quickly enable sound effects by calling the relevant APIs:
Voice change: Changes the human voice to create effects, such as the voice of an elder, a boy, or a girl.
Reverberation: Creates a specific spatial atmosphere, making the voice sound as if it is coming from a particular venue.
Voice beautification: Fine-tunes the timbre of the human voice in specific ways, such as making it sound magnetic or fresh.
Custom voice effects: In addition to the preset sound effect modes, you can create custom voice effects. You can call the relevant interfaces to adjust the pitch, reverberation, and equalization of the voice.
Sample source code
ARTC provides an open-source sample project. You can download the project or view the source code at the following locations:
Configure voice change, reverberation, and voice beautification on Android: Android/ARTCExample/BasicUsage/src/main/java/com/aliyun/artc/api/basicusage/VoiceChange/VoiceChangeActivity.java
Configure voice change, reverberation, and voice beautification on iOS: iOS/ARTCExample/BasicUsage/VoiceChange/VoiceChangeVC.swift
Prerequisites
Before you set the video configuration, ensure that the following prerequisites are met:
Create an ApsaraVideo Real-time Communication application using a valid Alibaba Cloud account. For more information, see Create an application. Then, obtain the App ID and App Key from the Management Console.
Integrate the ARTC SDK into your project and implement basic real-time audio and video features. For more information about SDK integration, see Download/Integrate SDKs. For more information about implementing audio and video calls, see Implement an audio and video call.
Implementation
This section describes how to call the relevant interfaces in your project to implement various sound effects.
Voice change
You can call the setAudioEffectVoiceChangerMode interface to set a voice change effect. This effect can make a voice sound like that of an elder, a boy, or a girl. Each sound effect corresponds to an enumeration value. The available voice change modes are as follows:
Voice change effect mode | Enumeration value |
Off |
|
Elder |
|
Boy |
|
Girl |
|
Robot |
|
Devil |
|
KTV |
|
Echo |
|
Dialect |
|
Roar |
|
Electronic |
|
Phonograph |
|
Android
/* The preset voice change mode. */
mAliRtcEngine.setAudioEffectVoiceChangerMode(mode);iOS
/* The preset voice change mode. */
self.rtcEngine?.setAudioEffectVoiceChangerMode(mode)Windows
/* The preset voice change mode. */
mAliRtcEngine->SetAudioEffectVoiceChangerMode(mode);Reverberation
You can call the setAudioEffectReverbMode interface to implement reverberation effects. These effects create a specific spatial atmosphere, making the voice sound as if it is coming from a particular venue. The related enumeration values are as follows:
Reverberation mode | Enumeration value |
Reverberation off |
|
Vocal I |
|
Vocal II |
|
Bathhouse |
|
Small bright room |
|
Small dark room |
|
Medium room |
|
Large room |
|
Church hall |
|
Android
/* The preset reverberation mode. */
mAliRtcEngine.setAudioEffectReverbMode(mode);
/* You can also specify the mode by configuring parameters. */iOS
/* The preset reverberation mode. */
self.rtcEngine?.setAudioEffectReverbMode(mode)Windows
/* The preset reverberation mode. */
mAliRtcEngine->SetAudioEffectReverbMode(mode);
/* You can also specify the mode by configuring parameters. */Voice beautification
You can call the setAudioEffectBeautifyMode interface to implement voice beautification. Two preset modes are supported: magnetic and fresh.
Voice beautification mode | Enumeration value |
Magnetic |
|
Fresh |
|
Android
/* The preset voice beautification mode. */
mAliRtcEngine.setAudioEffectBeautifyMode(mode);
/* You can also specify the mode by configuring parameters. */iOS
/* The preset voice beautification mode. */
self.rtcEngine?.setAudioEffectBeautifyMode(mode)Windows
/* The preset voice beautification mode. */
mAliRtcEngine->SetAudioEffectBeautifyMode(mode);
/* You can also specify the mode by configuring parameters. */Custom voice effects
If the preset sound effects do not meet your requirements, you can call the following interfaces to adjust the voice's pitch, equalization, and reverberation parameters. This lets you create custom voice effects.
The relevant interfaces are as follows:
setAudioEffectPitchValue(value): Sets the pitch parameter.value: The value range is [0.5, 2.0]. A value of 1.0 indicates that the pitch is unchanged. A value less than 1.0 lowers the pitch. A value greater than 1.0 raises the pitch.
setAudioEffectReverbParamType(type, value): Sets reverberation effect parameters. This interface must be called aftersetAudioEffectReverbMode.type: The reverberation parameter type. For more information, see AliRtcAudioEffectReverbParamType.value: The reverberation parameter value. Different types of reverberation parameters have different value ranges. For more information, see AliRtcAudioEffectReverbParamType.
setAudioEffectEqualizationParam: Sets equalizer parameters. This interface must be called aftersetAudioEffectBeautifyMode.bandIndex: The number of equalizer bands. The value range is [0, 9], which represents 10 frequency bands: 31, 62, 125, 250, 500, 1000, 2000, 4000, 8000, and 16000 Hz.gain: The equalizer gain. The value ranges from -15 dB to 15 dB. The default value is 0.
Android
// Set the pitch. The value range is [0.5, 2.0]. A value of 1.0 indicates that the pitch is unchanged. A value less than 1.0 lowers the pitch. A value greater than 1.0 raises the pitch.
mAliRtcEngine.setAudioEffectPitchValue(1.5);
// Sample code for setting reverberation 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);
// Sample code for setting voice beautification parameters.
mAliRtcEngine.setAudioEffectBeautifyMode(AliRtcEngine.AliRtcAudioEffectBeautifyMode.AliRtcSdk_AudioEffect_Beautify_Magnetic);
mAliRtcEngine.setAudioEffectEqualizationParam(AliRtcEngine.AliRtcAudioEffectEqualizationBandFrequency.AliRtcSdk_AudioEffect_EqualizationBand1K, 5); iOS
// Set the pitch. The value range is [0.5, 2.0]. A value of 1.0 indicates that the pitch is unchanged. A value less than 1.0 lowers the pitch. A value greater than 1.0 raises the pitch.
let pitch = 1.5
self.rtcEngine?.setAudioEffectPitchValue(pitch)
// Sample code for setting reverberation parameters. This must be called after setAudioEffectReverbMode.
self.rtcEngine?.setAudioEffectReverbMode(.large_Room)
self.rtcEngine?.setAudioEffectReverbParamType(.room_Size, value: 50)
// Sample code for setting voice beautification parameters.
self.rtcEngine?.setAudioEffectBeautifyMode(.vigorous)
self.rtcEngine?.setAudioEffectEqualizationParam(.band1K, gain: 5)