Skip to content

Commit

Permalink
Updates (#1575)
Browse files Browse the repository at this point in the history
  • Loading branch information
saudsami authored Jul 6, 2024
1 parent 40c5aa3 commit fbd459a
Show file tree
Hide file tree
Showing 8 changed files with 286 additions and 186 deletions.
23 changes: 15 additions & 8 deletions shared/video-sdk/develop/voice-effects/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,26 @@ import NotAvailable from '@docs/shared/common/not-available.mdx'

## Understand the tech

With <Vpd k="SDK" /> you can implement voice modifying effects such as chat beautifier, singing beautifier, and voice changer. These are gaining popularity in social interaction and entertainment scenarios. To help you quickly integrate voice effects into your project, <Vpd k="SDK" /> provides pre-configured effects. You can choose from the following types:
Voice effects are gaining popularity in social interaction and entertainment scenarios. To help you quickly integrate voice effects into your project, <Vpd k="SDK" /> provides pre-configured effects. Choose from the following effects:

* **Preset voice beautifiers**: Chat beautifier, singing beautifier, and timbre transformation.
* **Voice beautifiers**
* Voice beautifier for Chat: Beautify the voice in chat scenarios according to the characteristics of male and female voices without changing the original voice recognition.
* Singing beautifier: Beautify the singing voice according to male and female voice characteristics while retaining the original character of the singing voice.
* Timbre shift: Fine-tune the timbre of a vocal in a specific direction.

* **Preset audio effects**: Voice changer, style transformation, room acoustics, and pitch correction.
* **Sound effects**
* Style sound effects: For songs of a specific style, make the singing and accompaniment more compatible.
* Spatial shaping: Create a spatial atmosphere through spatial reverberation effects. Make the vocals seem to come from a specific source.
* Electronic sound effects: Adjust the pitch of the vocals to perfectly match the key and pitch of the accompaniment for an electronic sound effect.

* **Preset voice conversion**: Changing the original voice to make it unrecognizable.
* **Voice changer**
* Basic voice changing: Make the voice more neutral, sweet, or stable while retain a certain degree of voice recognition.
* Advanced voice changing: Dramatically change the human voice to realize voices of uncle, girl, Hulk, etc.

* **Voice formant modification**: Changing the voice timbre by adjusting the formant ratio.
* **Custom vocal effects**
If the preset effects don't meet your needs, manually adjust the vocal pitch, equalization, and reverb effects to achieve a customized effect.

* **Customized audio effects**: Controlling the voice pitch, equalization, and reverberation.

Try the [Online Demo](https://www.agora.io/en/audio-demo?_gl=1*skmawq*_ga*MjA2MzYxMjY4Mi4xNzAzMDczMjA1*_ga_BFVGG7E02W*MTcwNzgwOTIyNS4xOC4xLjE3MDc4MTA2OTAuMC4wLjA) to experience different voice effects.
Try the [Online Demo](https://web-cdn.agora.io/marketing/audio_en_v3.html) to experience different voice effects.

## Prerequisites

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,108 +2,133 @@

### Set audio scenario and audio profile

For optimal audio quality, configure `RtcEngineConfig` to set an audio scenario and call `setAudioProfile` to specify an audio profile:
For optimal audio quality, take the following steps:

- Call <Link to="{{Global.API_REF_ANDROID_ROOT}}/class_irtcengine.html#api_irtcengine_setaudioscenario">setAudioScenario</Link> to set the audio scenario to high-quality `AUDIO_SCENARIO_GAME_STREAMING`.
- Call <Link to="{{Global.API_REF_ANDROID_ROOT}}/class_irtcengine.html#api_irtcengine_setaudioprofile2">setAudioProfile</Link> to set the audio encoding properties to high-quality encoding:

- For mono transmission, set the profile to `AUDIO_PROFILE_MUSIC_HIGH_QUALITY`.
- For stereo transmission, set the profile to `AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO`

```java
// Set mAudioScenario in RtcEngineConfig to AUDIO_SCENARIO_GAME_STREAMING
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.GAME_STREAMING);
// Create the RtcEngine object
mRtcEngine = RtcEngine.create(config);

// Call setAudioProfile to set the scene to AUDIO_PROFILE_MUSIC_HIGH_QUALITY or AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO
// Set the audio scenario
mRtcEngine.setAudioScenario(Constants.AudioScenario.getValue(Constants.AudioScenario.GAME_STREAMING));
// Set the audio encoding properties
mRtcEngine.setAudioProfile(Constants.AudioProfile.getValue(Constants.AudioProfile.MUSIC_HIGH_QUALITY_STEREO));
```

### Enhance voice with voice effects
### Voice beautifiers

Enhance the characteristics of male and female voices while preserving the inherent identity of the original voice. The following code snippets demonstrate how to enable different voice beautifiers:
Call `setAudioEffectPreset` to set music style, space shaping, electronic music, and other effects.

* Enhance the character and charm of male voices with the 'Magnetic' vocal effect. Be cautious when applying this setting to female voices, as it may lead to distortion:
- Chat voice beautifier

```java
// Set the vocal effect to magnetic. This enumeration only applies to beautifying male voices
// When used to beautify female voices, it will cause distortion
// Set the vocal effect to magnetic (for male voices)
mRtcEngine.setVoiceBeautifierPreset(Constants.CHAT_BEAUTIFIER_MAGNETIC);
// Turn off the vocal effect

// Turn off the effect
mRtcEngine.setVoiceBeautifierPreset(Constants.VOICE_BEAUTIFIER_OFF);
```

* Optimize the singing voice for musical scenarios:
- Singing voice beautifier

```java
// Beautify a male singing voice. Do not use for female voice
// Example 1: Set male voice effect
// Set the singing voice preset to beautify the male voice and add a small room reverberation effect
mRtcEngine.setVoiceBeautifierPreset(Constants.SINGING_BEAUTIFIER);
// Turn off the vocal effect
// Turn off the effect
mRtcEngine.setVoiceBeautifierPreset(Constants.VOICE_BEAUTIFIER_OFF);

// Beautify a female singing voice
// Example 2: Set female voice effect
// Call the setVoiceBeautifierParameters method to beautify the female voice and add hall reverberation effect
mRtcEngine.setVoiceBeautifierParameters(Constants.SINGING_BEAUTIFIER, 2, 3);
// Turn off the vocal effect
// Turn off the effect
mRtcEngine.setVoiceBeautifierPreset(Constants.VOICE_BEAUTIFIER_OFF);
```

* Transform the vocal richness with the 'Vibrant' timbre transformation effect:
* Tone change

```java
// Set the timbre transformation effect. Default vocal effect is 'thick'
// Set the timbre to thick
mRtcEngine.setVoiceBeautifierPreset(Constants.TIMBRE_TRANSFORMATION_VIGOROUS);
// Turn off the vocal effect
// Turn off the effect
mRtcEngine.setVoiceBeautifierPreset(Constants.VOICE_BEAUTIFIER_OFF);
```

* Enrich audio with the 'Hulk' effect:

```java
// Default vocal effect is 'Hulk'
mRtcEngine.setAudioEffectPreset(Constants.VOICE_CHANGER_EFFECT_HULK);
// Turn off the vocal effect
mRtcEngine.setAudioEffectPreset(Constants.AUDIO_EFFECT_OFF);
```
### Sound effects

* Enhance vocal characteristics with 'Pop' style:
Call `setAudioEffectPreset` to set music style, space shaping, electronic music and other effects.

* Music Style

```java
// Default vocal effect is 'Pop'
// Set the style to pop
mRtcEngine.setAudioEffectPreset(Constants.STYLE_TRANSFORMATION_POPULAR);
// Turn off vocal effects
// Turn off the effect
mRtcEngine.setAudioEffectPreset(Constants.AUDIO_EFFECT_OFF);
```

* Simulate karaoke room acoustics with the 'KTV' effect:
* Space shaping

```java
// Default vocal effect is 'KTV'
// Set the space shaping effect to KTV
mRtcEngine.setAudioEffectPreset(Constants.ROOM_ACOUSTICS_KTV);
// Turn off vocal effects
// Turn off the effect
mRtcEngine.setAudioEffectPreset(Constants.AUDIO_EFFECT_OFF);
```

* Apply electronic sound correction to a natural minor key with a pitch of C:
* Electronic sound effects

```java
// Set electronic sound to a natural minor key with a pitch of C
// Example 1: Use the preset pitch adjustment method to achieve the electronic music sound effect
// The preset is based on the natural major key with the tonic pitch of C, and corrects the actual pitch of the audio
mRtcEngine.setAudioEffectPreset(Constants.PITCH_CORRECTION);
// Turn off vocal effects
// Turn off the effect
mRtcEngine.setAudioEffectPreset(Constants.AUDIO_EFFECT_OFF);

// Example 2: Adjust the basic mode and tonic pitch to achieve the electronic music sound effect
// Call setAudioEffectParameters to adjust the basic mode of the tone to the natural minor key and the tonic pitch to D
mRtcEngine.setAudioEffectParameters(Constants.PITCH_CORRECTION, 2, 6);
// Turn off the effect
mRtcEngine.setAudioEffectPreset(Constants.AUDIO_EFFECT_OFF);
```

* Default voice change effect for a more neutral voice:
### Voice change effects

To implement basic voice-changing effects, call the `setAudioEffectPreset` method. For advanced voice-changing effects, use the `setVoiceConversionPreset` method.

* Basic voice changer

```java
// Default voice change effect to a more neutral voice
// Set the voice change effect to a more neutral voice
mRtcEngine.setVoiceConversionPreset(Constants.VOICE_CHANGER_NEUTRAL);
// Turn off vocal effects
// Turn off the effect
mRtcEngine.setVoiceConversionPreset(Constants.VOICE_CONVERSION_OFF);
```

* Fine-tune vocal output parameters, including pitch, equalization, and reverberation effects. Transform a human voice into the distinctive sound of your choice by adjusting parameter values manually:
* Advanced voice changer

```java
// Set the vocal effect to 'Hulk'
mRtcEngine.setAudioEffectPreset(Constants.VOICE_CHANGER_EFFECT_HULK);
// Turn off the effect
mRtcEngine.setAudioEffectPreset(Constants.AUDIO_EFFECT_OFF);
```

### Custom audio effects

Call `setLocalVoicePitch`, `setLocalVoiceEqualization`, and `setLocalVoiceReverb` to fine-tune vocal output parameters, including pitch, equalization, and reverberation effects. The following example shows you how to transform a human voice into the voice of the Hulk by manually setting parameter values:

```java
double pitch = 0.5;
mRtcEngine.setLocalVoicePitch(pitch);
// Set the center frequency of the local vocal equalization band
// The first parameter is the spectrum sub-band index, with values in [0, 9], representing 10 frequency bands (31, 62, 125, 250, 500, 1000, 2000, 4000, 8000, 16000 Hz)
// The second parameter is the gain value of each frequency interval, with values in [-15, 15] dB (default is 0)

// Set the center frequency of the local voice equalization band
// The first parameter is the spectrum sub-band index, the value range is [0,9], representing 10 frequency bands, and the corresponding center frequencies are [31,62,125,250,500,1000,2000,4000,8000,16000] Hz
// The second parameter is the gain value of each frequency interval, the value range is [-15,15], the unit is dB, the default value is 0
mRtcEngine.setLocalVoiceEqualization(Constants.AUDIO_EQUALIZATION_BAND_FREQUENCY.fromInt(0), -15);
mRtcEngine.setLocalVoiceEqualization(Constants.AUDIO_EQUALIZATION_BAND_FREQUENCY.fromInt(1), 3);
mRtcEngine.setLocalVoiceEqualization(Constants.AUDIO_EQUALIZATION_BAND_FREQUENCY.fromInt(2), -9);
Expand All @@ -114,20 +139,20 @@ Enhance the characteristics of male and female voices while preserving the inher
mRtcEngine.setLocalVoiceEqualization(Constants.AUDIO_EQUALIZATION_BAND_FREQUENCY.fromInt(7), -2);
mRtcEngine.setLocalVoiceEqualization(Constants.AUDIO_EQUALIZATION_BAND_FREQUENCY.fromInt(8), -1);
mRtcEngine.setLocalVoiceEqualization(Constants.AUDIO_EQUALIZATION_BAND_FREQUENCY.fromInt(9), 1);
// Original vocal intensity (dry signal), values in [-20, 10] dB

// Original voice intensity or dry signal, value range [-20,10], unit is dB
mRtcEngine.setLocalVoiceReverb(Constants.AUDIO_REVERB_TYPE.fromInt(0), 10);
// Early reflection signal strength (wet signal), values in [-20, 10] dB

// Early reflection signal intensity or wet signal, value range [-20,10], unit is dB
mRtcEngine.setLocalVoiceReverb(Constants.AUDIO_REVERB_TYPE.fromInt(1), 7);
// Room size required for the reverberation effect, values in [0, 100]

// The room size for the required reverberation effect. Generally, the larger the room, the stronger the reverberation effect. Value range: [0,100]
mRtcEngine.setLocalVoiceReverb(Constants.AUDIO_REVERB_TYPE.fromInt(2), 6);
// Initial delay length of the wet signal, values in [0, 200] ms

// Initial delay length of wet signal, value range: [0,200], unit: ms
mRtcEngine.setLocalVoiceReverb(Constants.AUDIO_REVERB_TYPE.fromInt(3), 124);
// Continuous intensity of the reverberation effect, values in [0, 100]

// The continuous strength of reverberation effect, value range: [0,100], the larger the value, the stronger the reverberation effect
mRtcEngine.setLocalVoiceReverb(Constants.AUDIO_REVERB_TYPE.fromInt(4), 78);
```

Expand Down
Loading

0 comments on commit fbd459a

Please sign in to comment.