logo
Video Call
On this page

Voice Changer/Reverb/Stereo

2024-05-24

Feature Overview

In scenarios such as live streaming, voice chat rooms, and karaoke rooms, to increase fun and interactivity, players can use voice changing to be funny, use reverb to enhance the atmosphere, and use stereo to make sound more three-dimensional. ZEGOCLOUD Express SDK provides a variety of preset voice changer, reverb, and stereo effects. Developers can flexibly set the desired sound effects. If you need to preview, you can enable headphone monitoring for testing.

  • Voice Changer: By changing the user's pitch, the output sounds perceptually different from the original sound, achieving effects such as male-to-female voice conversion.
  • Reverb: Through special processing of sound, create reverb effects of different environments, making the sound as if it were in a concert hall, cathedral, and other scenes.
  • Virtual Stereo: Through deep use of dual-channel technology, virtually create different positions and angles of sound sources, achieving stereo, 3D surround sound, sound positioning, and other effects.

You can experience the SDK's preset voice effects through the Sound Effects Experience DEMO provided by ZEGOCLOUD.

Warning
  • This feature only works for audio captured by the SDK. Developers can dynamically adjust voice changer, reverb, and virtual stereo during calls or live streaming.
  • Currently, only one specific stream can be processed at a time, and multiple streams cannot be processed simultaneously.
  • Reverb, virtual stereo, voice changer, and other features cannot be enabled at the same time, otherwise the effects may be abnormal.

Prerequisites

Before using voice changer/reverb/stereo, make sure:

Usage Steps

Voice Changer

There are two ways to set voice changer: preset voice changer and custom voice changer.

Set Preset Voice Changer

Warning
  • PC Web: The voice changer feature is supported on Google Chrome 66.0, Microsoft Edge 79.0, FireFox 76.0, and Safari 14.1 and above. However, to ensure the stability of the voice changer feature, it is recommended to use the latest version of Google Chrome or Microsoft Edge browser.
  • Mobile: To ensure stability when using the voice changer feature, it is recommended to use Safari or Google Chrome 96.0 or above. Some Android WeChat browsers may experience a little current noise when using the voice changer feature.
  1. Call the createZegoStream interface to create a ZegoLocalStream media stream.
// Import voice changer module
import {VoiceChanger} from "zego-express-engine-webrtc/voice-changer";
// Needs to be called before new ZegoExpressEngine
ZegoExpressEngine.use(VoiceChanger);
// Initialize instance
const zg = new ZegoExpressEngine(appID, server);
// Create media stream
const localstream = await zg.createZegoStream();
  1. Set the voice changer effect. Call the setVoiceChangerPreset interface, pass in the media stream that needs voice changing, start voice changer processing, and complete the relevant settings for voice changer processing.

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 to child voiceVoice changer
MEN_TO_WOMEN2Male to female voiceVoice changer
WOMEN_TO_CHILD3Female to child voiceVoice changer
WOMEN_TO_MEN4Female 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 electronic musicElectronic sound effect
MINOR_A12A Minor electronic musicElectronic sound effect
HARMONIC_MINOR13Harmonic Minor electronic musicElectronic sound effect
FEMALE_ENERGETIC14Energetic female sound effectRoom beautification
RICH_NESS15Rich sound effectRoom beautification
MUFFLED16Muffled sound effectRoom beautification
ROUNDNESS17Round 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

The following example code uses "Male to child voice" as an example:

// localStream is the zego stream object created through createZegoStream
zg.setVoiceChangerPreset(1, localStream);

Set Custom Voice Changer

If the SDK's preset voice changer effects cannot meet your needs, developers can call setVoiceChangerParam with the "voiceParam" parameter value to set a custom voice changer. 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).

// localStream is the zego stream object created through createZegoStream
zg.setVoiceChangerParam(localStream, 5);

Reverb

Create Media Stream

Call the createZegoStream interface to create a ZegoLocalStream media stream. For example code, please refer to step 1 of Voice Changer.

Set Reverb Effect

Call setReverbPreset to set reverb through preset enumeration.

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

Type NamePreset ValueDescriptionReverb Type
NONE0None-
SOFT_ROOM1Small 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 brighter KTV vocal effect, suitable for ordinary and professional usersSpatial shaping

The following example code uses "Large room" mode as an example:

// localStream is the zego stream object created through createZegoStream
zg.setReverbPreset(localStream, 2);
Note

Web SDK does not support custom reverb effects for now.

Virtual Stereo

Set Streaming Audio Channel Count

If you need to enable the virtual stereo feature, you must set dual channels when creating the ZegoLocalStream media stream, that is, when calling the createZegoStream method, set ZegoStreamOptions.camera.audio.channelCount to 2 (the default is mono).

The example code creates a dual-channel pure audio media stream.

const localStream = await zg.createZegoStream({
    camera: {
        video: false,
        audio: {
            channelCount: 2
        },
    }
});

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-360. Generally, it can be set to 90 degrees (i.e., directly in front).

Note

The SDK supports omni-directional virtual stereo effects. The usage is to set the "angle" parameter to "-1".

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

zg.enableVirtualStereo(localStream, true, 90);

The following example enables omni-directional virtual stereo:

zg.enableVirtualStereo(localStream, true, -1);

FAQ

  1. On the Safari browser, why is there no stereo effect when the playing side enables microphone capture?

    When the playing side enables microphone capture, the played rendered audio will become mono effect. If you need to maintain the stereo effect when playing, the playing side should turn off microphone capture.

Previous

Audio 3A Processing

Next

Audio Mixing

On this page

Back to top