logo
On this page

Voice Changer/Reverb/Stereo


Introduction

  • Voice Changer: By changing the user's pitch, the output sound is perceptually different from the original sound, achieving various effects such as male voice changing to female voice.
  • Reverb: Through special processing of sound, creates reverb effects for different environments, making the sound appear as if emitted in scenarios such as concert halls, large churches, etc.
  • Reverb Echo: Through special processing of sound, can be combined with voice changer and reverb to achieve various customized sound effects, such as ethereal, robot sounds.
  • Virtual Stereo: Through in-depth use of dual-channel technology, virtually simulates the positional angles of sound sources, achieving effects such as stereo, 3D audio, sound positioning, etc.

In scenarios such as live streaming, voice chat rooms, and KTV rooms, to increase fun and interactivity, players can use voice changers for fun, use reverb to enhance the atmosphere, and use stereo to make sound more three-dimensional. ZegoExpress SDK provides various preset voice changer, reverb, reverb echo, and stereo effects. Developers can flexibly set the sound they want. If they need to preview, they can enable in-ear monitoring for testing.

You can experience the SDK's preset human voice effects through the Audio Effect DEMO provided by ZEGO.

Note

This function is only effective for sound captured by the SDK. Developers can dynamically adjust voice changer, reverb, reverb echo, and virtual stereo during calls or live streaming.

Example Source Code Download

Please refer to Download Example Source Code.

For related source code, please check files in the /ZegoExpressExample/src/AudioProcess directory.

Prerequisites

Usage Steps

Voice Changer

Set Preset Voice Changer

Call the setVoiceChangerPreset method to use SDK preset voice changer effects.

The ZegoVoiceChangerPreset preset voice changer effects are as follows. Developers can choose according to their needs:

Type NamePreset ValueDescriptionVoice Changer Type
NONE0No voice changer-
MEN_TO_CHILD1Male voice to child voiceVoice changer
MEN_TO_WOMEN2Male voice to female voiceVoice changer
WOMEN_TO_CHILD3Female voice to child voiceVoice changer
WOMEN_TO_MEN4Female voice to male voiceVoice changer
FOREIGNER5Foreigner sound effectVoice changer
OPTIMUS_PRIME6Optimus Prime sound effectVoice changer
ANDROID7Robot sound effectVoice changer
ETHEREAL8Ethereal sound effectTimbre transformation
MALE_MAGNETIC9Magnetic maleRoom beautification
FEMALE_FRESH10Fresh femaleRoom beautification
MAJOR_C11C Major key electric soundElectric sound effect
MINOR_A12A Minor key electric soundElectric sound effect
HARMONIC_MINOR13Harmonic Minor electric soundElectric sound effect
FEMALE_ENERGETIC14Energetic female sound effectRoom beautification
RICH_NESS15Rich sound effectRoom beautification
MUFFLED16Muffled sound effectRoom beautification
ROUNDNESS17Mellow sound effectRoom beautification
FALSETTO18Falsetto sound effectRoom beautification
FULLNESS19Full sound effectRoom beautification
CLEAR20Clear sound effectRoom beautification
HIGHLY_RESONANT21High-pitched sound effectRoom beautification
LOUD_CLEAR22Loud and clear sound effectRoom beautification
MINIONS23Minions sound effectVoice changer
AUTOBOT30Transformer sound effectVoice changer
OUT_OF_POWER31Out of power sound effectVoice changer

The following example code takes male voice changing to child voice as an example:

ZegoExpressSDK::getEngine()->setVoiceChangerPreset(ZEGO_VOICE_CHANGER_PRESET_MEN_TO_CHILD);

Set Custom Voice Changer

If the SDK preset voice changer effects cannot meet your needs, developers can call the ZegoVoiceChangerParam method to set custom voice changer through the pitch parameter pitch. The value range of this parameter is [-8.0, 8.0]. The larger the value, the sharper the sound. The default value is 0.0 (i.e., no voice changer).

ZegoVoiceChangerParam param;
param.pitch = 2.0f;
ZegoExpressSDK::getEngine()->setVoiceChangerParam(param);

Reverb

Set Preset Reverb

Call setReverbPreset to set reverb through preset enumerations.

The ZegoReverbPreset preset reverb effects are as follows. Developers can choose according to their needs:

Type NamePreset ValueDescriptionReverb Type
NONE0None-
SOFT_ROOM1Soft RoomSpatial shaping
LARGE_ROOM2Large RoomSpatial shaping
CONCERT_HALL3Concert HallSpatial shaping
VALLEY4ValleySpatial shaping
RECORDING_STUDIO5Recording StudioSpatial shaping
BASEMENT6BasementSpatial shaping
KTV7KTV, suitable for users with obvious timbre flawsSpatial shaping
POPULAR8PopMusical style
ROCK9RockMusical style
VOCAL_CONCERT10Vocal ConcertSpatial shaping
GRAMO_PHONE11GramophoneSpatial shaping
ENHANCED_KTV12Enhanced KTV, more focused and better KTV vocal effects, suitable for ordinary and professional usersSpatial shaping

The following example code takes large room mode as an example:

ZegoExpressSDK::getEngine()->setReverbPreset(ZEGO_REVERB_PRESET_LARGE_ROOM);

Set Custom Reverb

If the SDK preset reverb types cannot meet your needs, developers can call the ZegoReverbAdvancedParam method and combine settings through related parameters to achieve the reverb effects developers need (for detailed parameter descriptions, please refer to the API documentation).

ZegoReverbAdvancedParam reverbParam;
reverbParam.damping = 50.0; // Reverb damping
reverbParam.reverberance = 50.0; // Reverberation
reverbParam.roomSize = 50.0; // Room size
reverbParam.wetOnly = false;
reverbParam.wetGain = 5.0;
reverbParam.dryGain = 5.0;
reverbParam.toneLow = 80.0;
reverbParam.toneHigh = 80.0;
reverbParam.preDelay = 20.0;
reverbParam.stereoWidth = 0.0;
ZegoExpressSDK::getEngine()->setReverbAdvancedParam(reverbParam);
Warning

After setting custom reverb parameters, the preset reverb effects set when enabling reverb will become invalid. If you want to use SDK preset parameters again, you can use the setReverbPreset preset enumeration method from version 4.2.1 to set.

Reverb Echo

Call the setReverbEchoParam method and combine settings through related parameters to achieve the reverb echo effects developers need (for detailed parameter descriptions, please refer to the API documentation).

The following example code takes achieving an ethereal effect as an example:

ZegoReverbEchoParam echoParamEthereal;
echoParamEthereal.inGain = 0.8;
echoParamEthereal.outGain = 1.0;
echoParamEthereal.numDelays = 7;
echoParamEthereal.delay = {230, 460, 690, 920, 1150, 1380, 1610};
echoParamEthereal.decay = {0.41f, 0.18f, 0.08f, 0.03f, 0.009f, 0.003f, 0.001f};
ZegoExpressSDK::getEngine()->setReverbEchoParam(echoParamEthereal);

Virtual Stereo

Set Publishing Stream Audio Channel Count

If you need to enable virtual stereo functionality, you must first call the setAudioConfig method before publishing to set the audio encoding channel to Stereo dual channel (default is Mono single channel).

The following example sets it to dual channel through preset enumeration to construct ZegoAudioConfig :

ZegoAudioConfig audioConfig = ZegoAudioConfig(ZEGO_AUDIO_CONFIG_PRESET_STANDARD_QUALITY_STEREO);
ZegoExpressSDK::getEngine()->setAudioConfig(audioConfig);

Set Virtual Stereo Parameters

After setting the audio encoding channel to dual channel, call the enableVirtualStereo method, use the enable parameter to enable virtual stereo, and set the virtual stereo sound source angle through the angle parameter to achieve stereo effects. The angle range is 0~180. Generally, it can be set to 90 degrees (i.e., directly in front).

The following example enables virtual stereo and sets the angle to 90 degrees:

ZegoExpressSDK::getEngine()->enableVirtualStereo(true, 90);

API Reference List

MethodDescription
setVoiceChangerPreset Set voice changer through preset enumeration
ZegoVoiceChangerParam Voice changer parameter
setReverbPreset Set reverb through preset enumeration
ZegoReverbAdvancedParam Audio reverb advanced parameters
setReverbEchoParam Set reverb echo effect
setAudioConfig Set audio configuration
enableVirtualStereo Set virtual stereo

Previous

Audio 3A Processing

Next

Audio Mixing