Voice Changer/Reverb/Stereo
Feature Introduction
In live streaming, voice chat rooms, and KTV rooms, to increase fun and interactivity, players can use voice changers to make fun, use reverb to enhance the atmosphere, and use stereo to make the sound more three-dimensional. ZEGO Express SDK provides a variety of preset voice changer, reverb, reverb echo, and stereo effects. Developers can flexibly set the sound they want. If they need to audition, they can enable in-ear monitoring 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 voice to female voice.
- Reverb: Through special processing of the sound, reverb effects of different environments are created, making the sound as if it were emitted in scenes such as concert halls and cathedrals.
- Reverb Echo: Through special processing of the sound, it can be combined with voice changers and reverb to achieve various custom sound effects, such as ethereal and robot sounds.
- Virtual Stereo: Through deep use of dual-channel technology, various position angles of the sound source are virtually generated to achieve stereo, 3D surround sound, sound positioning, and other effects.
You can experience the SDK's preset human voice effects through the Audio Effects Experience DEMO provided by ZEGO.
This feature is only valid for sound collected by the SDK. Developers can dynamically adjust voice changer, reverb, reverb echo, and virtual stereo during calls or live streaming.
Sample Source Code Download
Please refer to Download Sample Source Code to get the source code.
For related source code, please check the files in the "/ZegoExpressExample/Examples/AdvancedAudioProcessing/VoiceChangeReverbStereo" directory.
Prerequisites
Before using voice changer/reverb/stereo, please ensure:
- You have created a project in the ZEGOCLOUD Console and applied for a valid AppID and AppSign. For details, please refer to Console - Project Information.
- You have integrated ZEGO Express SDK in the project and implemented basic audio and video publishing and playing functions. For details, please refer to Quick Start - Integration and Quick Start - Implementation Flow.
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 the SDK's 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 | - |
| MenToChild | 1 | Male voice to child voice | Voice changer |
| MenToWomen | 2 | Male voice to female voice | Voice changer |
| WomenToChild | 3 | Female voice to child voice | Voice changer |
| WomenToMen | 4 | Female voice to male voice | Voice changer |
| Foreigner | 5 | Foreigner sound effect | Voice changer |
| OptimusPrime | 6 | Optimus Prime sound effect | Voice changer |
| Android | 7 | Robot sound effect | Voice changer |
| Ethereal | 8 | Ethereal sound effect | Timbre transformation |
| MaleMagnetic | 9 | Magnetic male | Room beautification |
| FemaleFresh | 10 | Fresh female | Room beautification |
| MajorC | 11 | C Major electric sound | Electric sound effect |
| MinorA | 12 | A Minor electric sound | Electric sound effect |
| HarmonicMinor | 13 | Harmonic Minor electric sound | Electric sound effect |
| FemaleEnergetic | 14 | Energetic female sound effect | Room beautification |
| RichNess | 15 | Rich sound effect | Room beautification |
| Muffled | 16 | Deep sound effect | Timbre transformation |
| Roundness | 17 | Round 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 |
| HighlyResonant | 21 | High-pitched sound effect | Room beautification |
| LoudClear | 22 | Loud and clear sound effect | Room beautification |
| Minions | 23 | Minion sound effect | Voice changer |
| Autobot | 30 | Autobot sound effect | Voice changer |
| OutOfPower | 31 | Out of power sound effect | Voice changer |
To use the Autobot and OutOfPower voice changer effects, please contact technical support for custom SDK packaging.
The following example code takes "Male voice to child voice" as an example:
[[ZegoExpressEngine sharedEngine] setVoiceChangerPreset:ZegoVoiceChangerPresetMenToChild];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 your needs, developers can call the setVoiceChangerParam method ZegoVoiceChangerParam to 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" (that is, no voice changer).
For version 2.18.0 and earlier, the value range is [-8.0, 8.0].
ZegoVoiceChangerParam *param = [[ZegoVoiceChangerParam alloc] init];
param.pitch = 2.0;
[[ZegoExpressEngine sharedEngine] 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 the setReverbPreset to set reverb through preset enumeration.
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 | - |
| SoftRoom | 1 | Small room | Spatial shaping |
| LargeRoom | 2 | Large room | Spatial shaping |
| ConcerHall | 3 | Concert hall | Spatial shaping |
| Valley | 4 | Valley | Spatial shaping |
| RecordingStudio | 5 | Recording studio | Spatial shaping |
| Basement | 6 | Basement | Spatial shaping |
| KTV | 7 | KTV | Spatial shaping |
| Popular | 8 | Pop | Music style |
| Rock | 9 | Rock | Music style |
| VocalConcert | 10 | Vocal concert | Spatial shaping |
| GramoPhone | 11 | Gramophone | Spatial shaping |
| EnhancedKTV | 12 | Enhanced KTV, more focused and brighter KTV human voice effects, suitable for ordinary users and professional users | Spatial shaping |
The following example code takes "Large room" mode as an example:
[[ZegoExpressEngine sharedEngine] setReverbPreset:ZegoReverbPresetLargeRoom];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 your needs, developers can call the setReverbAdvancedParam method ZegoReverbAdvancedParam to combine and set relevant parameters to achieve the reverb effects required by developers (for detailed parameter descriptions, please refer to the API documentation).
ZegoReverbAdvancedParam *reverbParam = [[ZegoReverbAdvancedParam alloc] init];
// Reverb damping
reverbParam.damping = 50.0;
// Reverberance
reverbParam.reverberance = 50.0;
// Room size
reverbParam.roomSize = 50.0;
// Wet signal only
reverbParam.wetOnly = false;
// Wet signal gain (dB), value range [-20.0, 10.0]
reverbParam.wetGain = 5.0;
// Dry signal gain (dB), value range [-20.0, 10.0]
reverbParam.dryGain = 5.0;
// Low frequency attenuation, default is no attenuation (100%)
reverbParam.toneLow = 80.0;
// High frequency attenuation, default is no attenuation (100%)
reverbParam.toneHigh = 80.0;
// Initial delay time (ms). Value range [0, 200]
reverbParam.preDelay = 20.0;
// Stereo width (percentage), default value is 0%
reverbParam.stereoWidth = 0.0;
[[ZegoExpressEngine sharedEngine] setReverbAdvancedParam:reverbParam];After setting custom reverb parameters, the preset reverb effects set when enabling reverb will become invalid. If you want to use the SDK preset parameters again, you can use the setReverbPreset preset enumeration method to set them.
Reverb Echo
Call the setReverbEchoParam method to combine and set relevant parameters to achieve the reverb echo effects required by developers (for detailed parameter descriptions, please refer to the API documentation).
The following example code takes implementing "Ethereal sound effect" as an example:
ZegoReverbEchoParam *echoParamEthereal = [[ZegoReverbEchoParam alloc] init];
// Gain of input audio signal, value range [0.0, 1.0]
echoParamEthereal.inGain = 0.8;
// Gain of output audio signal, value range [0.0, 1.0]
echoParamEthereal.outGain = 1.0;
// Number of echoes, value range [0, 7]
echoParamEthereal.numDelays = 7;
// Delays of echo signals respectively
echoParamEthereal.delay = @[@230, @460, @690, @920, @1150, @1380, @1610];
// Decay coefficients of echo signals respectively
echoParamEthereal.decay = @[@0.41f, @0.18f, @0.08f, @0.03f, @0.009f, @0.003f, @0.001f];
[[ZegoExpressEngine sharedEngine] setReverbEchoParam:echoParamEthereal];Virtual Stereo
Set publishing stream audio channel count
If you need to enable the virtual stereo feature, you must first call the setAudioConfig method before publishing stream to set the audio encoding channel to Stereo dual-channel (default is Mono mono-channel).
The example here constructs ZegoAudioConfig through preset enumeration and sets it to dual-channel.
ZegoAudioConfig *config = [ZegoAudioConfig configWithPreset:ZegoAudioConfigPresetStandardQualityStereo];
[[ZegoExpressEngine sharedEngine] setAudioConfig:config];Set virtual stereo parameters
After setting the audio encoding channel to dual-channel, call the enableVirtualStereo method, enable virtual stereo through the "enable" parameter, and set the sound source angle of virtual stereo through the "angle" parameter to have a stereo effect. The angle range is 0 to 360. Generally, it can be set to 90 degrees (that is, directly in front).
Since version 2.15.0, the SDK has newly supported all-around virtual stereo effects. The usage is to set the "angle" angle parameter to "-1".
The example here enables virtual stereo and sets the angle to 90 degrees:
[[ZegoExpressEngine sharedEngine] enableVirtualStereo:YES angle:90];The example here enables all-around virtual stereo:
[[ZegoExpressEngine sharedEngine] enableVirtualStereo:YES angle:-1];