Voice Changer/Reverb/Stereo
Feature Overview
In live streaming, audio chat room, and Karaoke room scenarios, to increase fun and interactivity, users can use voice changers for entertainment, 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 desired sound. If you need to preview, you can enable headphone monitor for testing.
- Voice Changer: By changing the user's pitch, the output sound is perceptually different from the original sound, achieving various effects such as male to female voice.
- Reverb: Through special processing of sound, create reverb effects of different environments, making the sound as if it were emitted in concert halls, cathedrals, and other scenes.
- Reverb Echo: Through special processing of sound, can be combined with voice changer and reverb to achieve various custom sound effects, such as ethereal, robot sounds.
- Virtual Stereo: Through deep use of dual-channel technology, virtually create various position angles of sound sources, achieving stereo, 3D surround sound, sound positioning, and other effects.
You can experience the SDK's preset vocal effects through the Audio Effects DEMO provided by ZEGO.
This function only applies to sounds captured by the SDK. Developers can dynamically adjust voice changer, reverb, reverb echo, and virtual stereo during calls or live streaming.
Prerequisites
Before using voice changer/reverb/stereo, please ensure that you have implemented basic audio/video publishing and playing functions in your project. For details, please refer to Quick Start - Integration.
Usage Steps
Voice Changer
There are two ways to set voice changer: preset voice changer and custom voice changer.
Set Preset Voice Changer
If you need to set custom voice changer, please refer to Set Custom Voice Changer.
Call the setVoiceChangerPreset method to use SDK's preset voice changer effects.
ZegoVoiceChangerPreset preset voice changer effects are as follows. Developers can choose according to needs:
| Type Name | Preset Value | Description | Voice Changer Type |
|---|---|---|---|
| NONE | 0 | No voice changer | - |
| MEN_TO_CHILD | 1 | Male to child voice | Voice changer |
| MEN_TO_WOMEN | 2 | Male to female voice | Voice changer |
| WOMEN_TO_CHILD | 3 | Female to child voice | Voice changer |
| WOMEN_TO_MEN | 4 | Female 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 electronic music | Electronic music effect |
| MINOR_A | 12 | A minor electronic music | Electronic music effect |
| HARMONIC_MINOR | 13 | Harmonic minor electronic music | Electronic music effect |
| FEMALE_ENERGETIC | 14 | Energetic female effect | Room beautification |
| RICH_NESS | 15 | Rich effect | Room beautification |
| MUFFLED | 16 | Muffled effect | Room beautification |
| ROUNDNESS | 17 | Round effect | Room beautification |
| FALSETTO | 18 | Falsetto effect | Room beautification |
| FULLNESS | 19 | Full effect | Room beautification |
| CLEAR | 20 | Clear effect | Room beautification |
| HIGHLY_RESONANT | 21 | High-pitched effect | Room beautification |
| LOUD_CLEAR | 22 | Loud and clear effect | Room beautification |
| MINIONS | 23 | Minions sound effect | Voice changer |
| AUTOBOT | 30 | Autobot sound effect | Voice changer |
| OUT_OF_POWER | 31 | Out of power effect | Voice changer |
To use the Autobot and OutOfPower voice changer effects, please contact technical support for custom SDK packaging.
The following example code uses male to child voice as an example:
ZegoExpressSDK::getEngine()->setVoiceChangerPreset(ZEGO_VOICE_CHANGER_PRESET_MEN_TO_CHILD);Set Custom Voice Changer
If you need to set preset voice changer, please refer to Set Preset Voice Changer.
If the SDK's preset voice changer effects cannot meet requirements, developers can call the ZegoVoiceChangerParam method and set custom voice changer through the pitch parameter pitch. The value range of this parameter is [-12.0, 12.0]. The larger the value, the sharper the sound. The default value is "0.0" (i.e., no voice changer).
For version 2.18.0 and earlier, the value range is [-8.0, 8.0].
ZegoVoiceChangerParam param;
param.pitch = 2.0f;
ZegoExpressSDK::getEngine()->setVoiceChangerParam(param);Reverb
There are two ways to set reverb: preset reverb and custom reverb.
Set Preset Reverb
If you need to set custom reverb, please refer to Set Custom Reverb.
Call setReverbPreset to set reverb through preset enumeration.
ZegoReverbPreset preset reverb effects are as follows. Developers can choose according to needs:
| Type Name | Preset Value | Description | Reverb Type |
|---|---|---|---|
| NONE | 0 | None | - |
| SOFT_ROOM | 1 | Small 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 sound quality flaws | Spatial shaping |
| POPULAR | 8 | Popular | Music style |
| ROCK | 9 | Rock | Music style |
| VOCAL_CONCERT | 10 | Vocal concert | Spatial shaping |
| GRAMO_PHONE | 11 | Gramophone | Spatial shaping |
| ENHANCED_KTV | 12 | Enhanced KTV, more focused and brighter KTV vocal effects, suitable for ordinary and professional users | Spatial shaping |
The following example code uses large room mode as an example:
ZegoExpressSDK::getEngine()->setReverbPreset(ZEGO_REVERB_PRESET_LARGE_ROOM);Set Custom Reverb
If you need to set preset reverb, please refer to Set Preset Reverb.
If the SDK's preset reverb types cannot meet requirements, developers can call the ZegoReverbAdvancedParam method and set relevant parameters in combination 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; // Wet signal only
reverbParam.wetGain = 5.0; // Wet signal gain(dB), value range [-20.0, 10.0]
reverbParam.dryGain = 5.0; // Dry signal gain(dB), value range [-20.0, 10.0]
reverbParam.toneLow = 80.0; // Low frequency attenuation, default is no attenuation (100%)
reverbParam.toneHigh = 80.0; // High frequency attenuation, default is no attenuation (100%)
reverbParam.preDelay = 20.0; // Initial delay time(ms). Value range [0, 200]
reverbParam.stereoWidth = 0.0; // Stereo width (percentage), default value is 0%
ZegoExpressSDK::getEngine()->setReverbAdvancedParam(reverbParam);After setting custom reverb parameters, the preset reverb effect set when enabling reverb will become invalid. If you want to use SDK preset parameters again, you can use the setReverbPreset preset enumeration method to set.
Reverb Echo
Call the setReverbEchoParam method and set relevant parameters in combination to achieve the reverb echo effects developers need (for detailed parameter descriptions, please refer to the API documentation).
The following example code uses achieving ethereal effect as an example:
ZegoReverbEchoParam echoParamEthereal;
echoParamEthereal.inGain = 0.8; // Gain of input audio signal, value range [0.0, 1.0]
echoParamEthereal.outGain = 1.0; // Gain of output audio signal, value range [0.0, 1.0]
echoParamEthereal.numDelays = 7; // Number of echoes, value range [0, 7]
echoParamEthereal.delay = {230, 460, 690, 920, 1150, 1380, 1610}; // Delays of echo signals respectively
echoParamEthereal.decay = {0.41f, 0.18f, 0.08f, 0.03f, 0.009f, 0.003f, 0.001f}; // Decay coefficients of echo signals respectively
ZegoExpressSDK::getEngine()->setReverbEchoParam(echoParamEthereal);Virtual Stereo
Set Publish Stream Audio Channel Count
If you need to enable virtual stereo functionality, you must call the setAudioConfig method before publishing stream to set audio encoding channels to Stereo dual channel (default is Mono single channel).
The following example uses preset enumeration to construct ZegoAudioConfig and sets it to dual channel:
ZegoAudioConfig audioConfig = ZegoAudioConfig(ZEGO_AUDIO_CONFIG_PRESET_STANDARD_QUALITY_STEREO);
ZegoExpressSDK::getEngine()->setAudioConfig(audioConfig);Set Virtual Stereo Parameters
After setting audio encoding channels to dual channel, call the enableVirtualStereo method and set the sound source angle of virtual stereo through the enable parameter to have stereo effect. The angle range is 0 ~ 180. Generally, it can be set to 90 degrees (i.e., straight ahead).
The following example enables virtual stereo and sets the angle to 90 degrees:
ZegoExpressSDK::getEngine()->enableVirtualStereo(true, 90);