Configure voice change, reverberation, and voice beautification
The ARTC SDK lets you apply real-time voice effects — voice change, reverb, and beautification — to local audio during RTC calls.
Features
Enable these audio effects by calling the relevant APIs:
-
Voice change: Alter the voice to sound like an elder, boy, or girl.
-
Reverberation: Add spatial reverb to simulate a specific venue.
-
Voice beautification: Fine-tune voice timbre to a style such as Magnetic or Fresh.
-
Custom voice effect: Adjust pitch, reverb, and equalizer settings beyond the presets to create custom effects.
Sample code
Download the open-source sample project or view the source code:
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 begin:
-
You have an Alibaba Cloud account and an RTC application (Create an application). Obtain the App ID and App Key from the Application Management console.
-
You have integrated the SDK (Download and integrate the SDK) and implemented a basic RTC call (Implement an audio and video call).
Implementation
Call the following APIs to apply audio effects in your project.
Voice change
Call the setAudioEffectVoiceChangerMode method to apply a voice change effect. Each mode maps to an enumeration value:
|
Voice change mode |
Enumeration |
|
Off |
|
|
Elder |
|
|
Boy |
|
|
Girl |
|
|
Robot |
|
|
Devil |
|
|
KTV |
|
|
Echo |
|
|
Dialect |
|
|
Roar |
|
|
Electronic |
|
|
Phonograph |
|
Android
// Set the preset voice change mode.
mAliRtcEngine.setAudioEffectVoiceChangerMode(mode);
iOS
// Set the preset voice change mode.
self.rtcEngine?.setAudioEffectVoiceChangerMode(mode)
Mac
// Set the preset voice change mode.
[self.rtcEngine setAudioEffectVoiceChangerMode:mode];
Windows
// Set the preset voice change mode.
mAliRtcEngine->SetAudioEffectVoiceChangerMode(mode);
Reverberation
Call the setAudioEffectReverbMode method to simulate a specific venue with spatial reverb. Available modes:
|
Reverberation mode |
Enumeration |
|
Off |
|
|
Vocal I |
|
|
Vocal II |
|
|
Bathroom |
|
|
Small bright room |
|
|
Small dark room |
|
|
Medium room |
|
|
Large room |
|
|
Church hall |
|
Android
// Set the preset reverberation mode.
mAliRtcEngine.setAudioEffectReverbMode(mode);
// You can also configure the effect by using parameters.
iOS
// Set the preset reverberation mode.
self.rtcEngine?.setAudioEffectReverbMode(mode)
Mac
// Set the preset reverberation mode.
[self.engine setAudioEffectReverbMode:selectMode];
Windows
// Set the preset reverberation mode.
mAliRtcEngine->SetAudioEffectReverbMode(mode);
// You can also configure the effect by using parameters.
Voice beautification
Call the setAudioEffectBeautifyMode method to apply voice beautification. Two modes are available: Magnetic and Fresh.
|
Voice beautification mode |
Enumeration |
|
Magnetic |
|
|
Fresh |
|
Android
// Set the preset voice beautification mode.
mAliRtcEngine.setAudioEffectBeautifyMode(mode);
// You can also configure the effect by using parameters.
iOS
// Set the preset voice beautification mode.
self.rtcEngine?.setAudioEffectBeautifyMode(mode)
Mac
// Set the preset voice beautification mode.
[self.engine setAudioEffectBeautifyMode:selectMode];
Windows
// Set the preset voice beautification mode.
mAliRtcEngine->SetAudioEffectBeautifyMode(mode);
// You can also configure the effect by using parameters.
Custom voice effect
If preset effects are insufficient, adjust pitch, equalizer, and reverb parameters to create custom voice effects.
Available methods:
-
setAudioEffectPitchValue(value): Sets the voice pitch.-
value: Pitch value. Range: [0.5, 2.0]. Default: 1.0 (no change). Values below 1.0 lower the pitch; values above 1.0 raise it.
-
-
setAudioEffectReverbParamType(type, value): Sets a reverb parameter. Call this aftersetAudioEffectReverbMode.-
type: The reverb parameter type. AliRtcAudioEffectReverbParamType. -
value: The reverb parameter value. Ranges vary by type. AliRtcAudioEffectReverbParamType.
-
-
setAudioEffectEqualizationParam(bandIndex, gain): Sets an equalizer parameter. Call this aftersetAudioEffectBeautifyMode.-
bandIndex: Equalizer band index. Range: [0, 9], corresponding to 31, 62, 125, 250, 500, 1000, 2000, 4000, 8000, and 16000 Hz. -
gain: Band gain in dB. Range: [-15, 15]. Default: 0.
-
Android
// Set the pitch. The value ranges from 0.5 to 2.0. The default is 1.0.
// A value less than 1.0 lowers the pitch, and a value greater than 1.0 raises it.
mAliRtcEngine.setAudioEffectPitchValue(1.5);
// To set custom reverb parameters, you must first set a reverb mode.
// Example: Set the mode to Large Room, then adjust the room size.
mAliRtcEngine.setAudioEffectReverbMode(AliRtcEngine.AliRtcAudioEffectReverbMode.AliRtcSdk_AudioEffect_Reverb_Large_Room);
mAliRtcEngine.setAudioEffectReverbParamType(AliRtcEngine.AliRtcAudioEffectReverbParamType.AliRtcSdk_AudioEffect_Reverb_Room_Size, 50);
// To set custom equalizer parameters, you must first set a voice beautification mode.
// Example: Set the mode to Magnetic, then adjust the gain of a specific band.
mAliRtcEngine.setAudioEffectBeautifyMode(AliRtcEngine.AliRtcAudioEffectBeautifyMode.AliRtcSdk_AudioEffect_Beautify_Magnetic);
mAliRtcEngine.setAudioEffectEqualizationParam(AliRtcEngine.AliRtcAudioEffectEqualizationBandFrequency.AliRtcSdk_AudioEffect_EqualizationBand1K, 5);
iOS
// Set the pitch. The value ranges from 0.5 to 2.0. The default is 1.0.
// A value less than 1.0 lowers the pitch, and a value greater than 1.0 raises it.
let pitch = 1.5
self.rtcEngine?.setAudioEffectPitchValue(pitch)
// To set custom reverb parameters, you must first set a reverb mode.
// Example: Set the mode to Large Room, then adjust the room size.
self.rtcEngine?.setAudioEffectReverbMode(.large_Room)
self.rtcEngine?.setAudioEffectReverbParamType(.room_Size, value: 50)
// To set custom equalizer parameters, you must first set a voice beautification mode.
// Example: Set the mode to Magnetic, then adjust the gain of a specific band.
self.rtcEngine?.setAudioEffectBeautifyMode(.magnetic)
self.rtcEngine?.setAudioEffectEqualizationParam(.band1K, gain: 5)
Mac
// Set the pitch. The value ranges from 0.5 to 2.0. The default is 1.0.
// A value less than 1.0 lowers the pitch, and a value greater than 1.0 raises it.
int pitch = 1.5;
[self.rtcEngine setAudioEffectPitchValue:pitch];
// To set custom reverb parameters, you must first set a reverb mode.
// Example: Set the mode to Large Room, then adjust the room size.
[self.rtcEngine setAudioEffectReverbMode:AliRtcAudioEffectReverb_Large_Room];
[self.rtcEngine setAudioEffectReverbParamType:AliRtcAudioEffectReverb_Room_Size value:50.0];
// To set custom equalizer parameters, you must first set a voice beautification mode.
// Example: Set the mode to Magnetic, then adjust the gain of a specific band.
[self.rtcEngine setAudioEffectBeautifyMode:AliRtcAudioEffectBeautify_Magnetic];
[self.rtcEngine setAudioEffectEqualizationParam:AliRtcAudioEffectEqualizationBand1K gain:5.0];
Windows
// Set the pitch. The value ranges from 0.5 to 2.0. The default is 1.0.
// A value less than 1.0 lowers the pitch, and a value greater than 1.0 raises it.
mAliRtcEngine->SetAudioEffectPitchValue(1.5);
// To set custom reverb parameters, you must first set a reverb mode.
// Example: Set the mode to Large Room, then adjust the room size.
mAliRtcEngine->SetAudioEffectReverbMode(AliEngineAudioEffectReverbMode::AliEngineAudioEffectReverb_Large_Room);
mAliRtcEngine->SetAudioEffectReverbParamType(AliEngineAudioEffectReverbParamType::AliEngineAudioEffectReverbParamType_Room_Size, 50.0f);
// To set custom equalizer parameters, you must first set a voice beautification mode.
// Example: Set the mode to Magnetic, then adjust the gain of a specific band.
mAliRtcEngine->SetAudioEffectBeautifyMode(AliEngineAudioEffectBeautifyMode::AliEngineAudioEffectBeautify_Magnetic);
mAliRtcEngine->SetAudioEffectEqualizationParam(AliEngineAudioEffectEqualizationBandFrequency::AliEngineAudioEffectEqualizationBandFrequency_Band1K, 5.0f);