In social and entertainment scenarios, users often need various voice effects to enhance interactive experiences. Agora provides multiple preset voice changers and reverberation effects. You can also flexibly change the users' voice, such as adjusting the pitch and setting the equalization and reverberation modes.
Use a preset voice changer option and reverberation effect
You can use one of the following preset voice changer options by calling the
- An old man's voice.
- A little boy's voice.
- A little girl's voice.
- Zhu Bajie's voice (Zhu Bajie is a character from Journey to the West who has a voice like a growling bear).
- Ethereal vocal effects.
- Hulk's voice.
// Sets to an old man's voice. mRtcEngine.setLocalVoiceChanger(VOICE_CHANGER_OLDMAN); // Sets to the user's original voice. mRtcEngine.setLocalVoiceChanger(VOICE_CHANGER_OFF);
You can use one of the following preset reverberation effects by calling the
- Pop music
- Rock music
- Pop concert
- Recording studio
// Sets the preset reverberation effect to pop music. mRtcEngine.setLocalVoiceReverbPreset(AUDIO_REVERB_POPULAR); // Turns off reverberation. mRtcEngine.setLocalVoiceReverbPreset(AUDIO_REVERB_OFF);
Customize the voice effects
You can also customize the voice effects by adjusting the voice pitch, equalization, and reverberation settings.
The following sample code shows how to change from the original voice to Hulk's voice.
// Sets the pitch. The value ranges between 0.5 and 2.0. The lower the value, the lower the pitch. The default value is 1.0, which is the original pitch. double pitch = 0.5; rtcEngine.setLocalVoicePitch(pitch); // Sets the local voice equalization. // The first parameter sets the band frequency. The value ranges between 0 and 9. Each value represents the center frequency of the band: 31, 62, 125, 250, 500, 1k, 2k, 4k, 8k, and 16k Hz // The second parameter sets the gain of each band. The value ranges between -15 and 15 dB. The default value is 0. rtcEngine.setLocalVoiceEqualization(0, -15); rtcEngine.setLocalVoiceEqualization(1, 3); rtcEngine.setLocalVoiceEqualization(2, -9); rtcEngine.setLocalVoiceEqualization(3, -8); rtcEngine.setLocalVoiceEqualization(4, -6); rtcEngine.setLocalVoiceEqualization(5, -4); rtcEngine.setLocalVoiceEqualization(6, -3); rtcEngine.setLocalVoiceEqualization(7, -2); rtcEngine.setLocalVoiceEqualization(8, -1); rtcEngine.setLocalVoiceEqualization(9, 1); // The level of the dry signal in dB. The value ranges between -20 and 10. rtcEngine.setLocalVoiceReverb(Constants.AUDIO_REVERB_DRY_LEVEL, 10); // The level of the early reflection signal (wet signal) in dB. The value ranges between -20 and 10. rtcEngine.setLocalVoiceReverb(Constants.AUDIO_REVERB_WET_LEVEL, 7); // The room size of the reverberation. A larger room size means a stronger reverberation. The value ranges between 0 and 100. rtcEngine.setLocalVoiceReverb(Constants.AUDIO_REVERB_ROOM_SIZE, 6); // The length of the initial delay of the wet signal (ms). The value ranges between 0 and 200. rtcEngine.setLocalVoiceReverb(Constants.AUDIO_REVERB_WET_DELAY, 124); // The reverberation strength. The value ranges between 0 and 100. The higher the value, the stronger the reverberation. rtcEngine.setLocalVoiceReverb(Constants.AUDIO_REVERB_STRENGTH, 78);
We provide an open-source demo project Agora-RTC-With-Voice-Changer-Android that implements voice changer and reverberation on GitHub. You can try the demo and refer to the code in
The API methods have return values. If the method call fails, the return value is < 0.