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.
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
- The ZEGO Express SDK has been integrated in your project and basic real-time voice functionality has been implemented. For details, please refer to Quick Start - Integration and Quick Start - Implementing Flow.
- A project has been created in the ZEGOCLOUD Console and a valid AppID and AppSign have been obtained.
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 Name | Preset Value | Description | Voice Changer Type |
|---|---|---|---|
| NONE | 0 | No voice changer | - |
| MEN_TO_CHILD | 1 | Male voice to child voice | Voice changer |
| MEN_TO_WOMEN | 2 | Male voice to female voice | Voice changer |
| WOMEN_TO_CHILD | 3 | Female voice to child voice | Voice changer |
| WOMEN_TO_MEN | 4 | Female voice to male voice | Voice changer |
| FOREIGNER | 5 | Foreigner sound effect | Voice changer |
| OPTIMUS_PRIME | 6 | Optimus Prime sound effect | Voice changer |
| ANDROID | 7 | Robot sound effect | Voice changer |
| ETHEREAL | 8 | Ethereal sound effect | Timbre transformation |
| MALE_MAGNETIC | 9 | Magnetic male | Room beautification |
| FEMALE_FRESH | 10 | Fresh female | Room beautification |
| MAJOR_C | 11 | C Major key electric sound | Electric sound effect |
| MINOR_A | 12 | A Minor key electric sound | Electric sound effect |
| HARMONIC_MINOR | 13 | Harmonic Minor electric sound | Electric sound effect |
| FEMALE_ENERGETIC | 14 | Energetic female sound effect | Room beautification |
| RICH_NESS | 15 | Rich sound effect | Room beautification |
| MUFFLED | 16 | Muffled sound effect | Room beautification |
| ROUNDNESS | 17 | Mellow sound effect | Room beautification |
| FALSETTO | 18 | Falsetto sound effect | Room beautification |
| FULLNESS | 19 | Full sound effect | Room beautification |
| CLEAR | 20 | Clear sound effect | Room beautification |
| HIGHLY_RESONANT | 21 | High-pitched sound effect | Room beautification |
| LOUD_CLEAR | 22 | Loud and clear sound effect | Room beautification |
| MINIONS | 23 | Minions sound effect | Voice changer |
| AUTOBOT | 30 | Transformer sound effect | Voice changer |
| OUT_OF_POWER | 31 | Out of power sound effect | Voice 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 Name | Preset Value | Description | Reverb Type |
|---|---|---|---|
| NONE | 0 | None | - |
| SOFT_ROOM | 1 | Soft Room | Spatial shaping |
| LARGE_ROOM | 2 | Large Room | Spatial shaping |
| CONCERT_HALL | 3 | Concert Hall | Spatial shaping |
| VALLEY | 4 | Valley | Spatial shaping |
| RECORDING_STUDIO | 5 | Recording Studio | Spatial shaping |
| BASEMENT | 6 | Basement | Spatial shaping |
| KTV | 7 | KTV, suitable for users with obvious timbre flaws | Spatial shaping |
| POPULAR | 8 | Pop | Musical style |
| ROCK | 9 | Rock | Musical style |
| VOCAL_CONCERT | 10 | Vocal Concert | Spatial shaping |
| GRAMO_PHONE | 11 | Gramophone | Spatial shaping |
| ENHANCED_KTV | 12 | Enhanced KTV, more focused and better KTV vocal effects, suitable for ordinary and professional users | Spatial 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);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
| Method | Description |
|---|---|
| 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 |
