8989import io .agora .rtc2 .RtcEngineConfig ;
9090import io .agora .rtc2 .proxy .LocalAccessPointConfiguration ;
9191
92+ /**
93+ * The type Voice effects.
94+ */
9295@ Example (
9396 index = 4 ,
9497 group = ADVANCED ,
@@ -106,7 +109,7 @@ public class VoiceEffects extends BaseFragment implements View.OnClickListener,
106109 private EditText et_channel ;
107110 private Button join ;
108111 private Spinner audioProfile , audioScenario ,
109- chatBeautifier , timbreTransformation , voiceChanger , styleTransformation , roomAcoustics , pitchCorrection , _pitchModeOption , _pitchValueOption , voiceConversion , ainsMode ,
112+ chatBeautifier , timbreTransformation , voiceChanger , styleTransformation , roomAcoustics , pitchCorrection , _pitchModeOption , _pitchValueOption , voiceConversion , ainsMode , voiceAITuner ,
110113 customBandFreq , customReverbKey ;
111114 private ViewGroup _voice3DLayout , _pitchModeLayout , _pitchValueLayout ;
112115 private SeekBar _voice3DCircle , customPitch , customBandGain , customReverbValue , customVoiceFormant ;
@@ -154,6 +157,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
154157 _pitchValueOption = view .findViewById (R .id .audio_pitch_value_option );
155158 voiceConversion = view .findViewById (R .id .audio_voice_conversion );
156159 ainsMode = view .findViewById (R .id .audio_ains_mode );
160+ voiceAITuner = view .findViewById (R .id .voice_ai_tuner );
157161
158162 chatBeautifier .setOnItemSelectedListener (this );
159163 timbreTransformation .setOnItemSelectedListener (this );
@@ -166,6 +170,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
166170 _pitchModeOption .setOnItemSelectedListener (this );
167171 _pitchValueOption .setOnItemSelectedListener (this );
168172 ainsMode .setOnItemSelectedListener (this );
173+ voiceAITuner .setOnItemSelectedListener (this );
169174
170175 // Customize Voice Effects Layout
171176 customPitch = view .findViewById (R .id .audio_custom_pitch ); // engine.setLocalVoicePitch()
@@ -205,6 +210,7 @@ private void resetControlLayoutByJoined() {
205210 _pitchValueLayout .setVisibility (View .GONE );
206211 voiceConversion .setEnabled (joined );
207212 ainsMode .setEnabled (joined );
213+ voiceAITuner .setEnabled (joined );
208214
209215 customPitch .setEnabled (joined );
210216 customBandFreq .setEnabled (joined );
@@ -238,30 +244,30 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
238244 }
239245 try {
240246 RtcEngineConfig config = new RtcEngineConfig ();
241- /**
247+ /*
242248 * The context of Android Activity
243249 */
244250 config .mContext = context .getApplicationContext ();
245- /**
251+ /*
246252 * The App ID issued to you by Agora. See <a href="https://docs.agora.io/en/Agora%20Platform/token#get-an-app-id"> How to get the App ID</a>
247253 */
248254 config .mAppId = getString (R .string .agora_app_id );
249- /** Sets the channel profile of the Agora RtcEngine.
255+ /* Sets the channel profile of the Agora RtcEngine.
250256 CHANNEL_PROFILE_COMMUNICATION(0): (Default) The Communication profile.
251257 Use this profile in one-on-one calls or group calls, where all users can talk freely.
252258 CHANNEL_PROFILE_LIVE_BROADCASTING(1): The Live-Broadcast profile. Users in a live-broadcast
253259 channel have a role as either broadcaster or audience. A broadcaster can both send and receive streams;
254260 an audience can only receive streams.*/
255261 config .mChannelProfile = Constants .CHANNEL_PROFILE_LIVE_BROADCASTING ;
256- /**
262+ /*
257263 * IRtcEngineEventHandler is an abstract class providing default implementation.
258264 * The SDK uses this class to report to the app on SDK runtime events.
259265 */
260266 config .mEventHandler = iRtcEngineEventHandler ;
261267 config .mAudioScenario = Constants .AudioScenario .getValue (Constants .AudioScenario .DEFAULT );
262- config .mAreaCode = ((MainApplication )getActivity ().getApplication ()).getGlobalSettings ().getAreaCode ();
268+ config .mAreaCode = ((MainApplication ) getActivity ().getApplication ()).getGlobalSettings ().getAreaCode ();
263269 engine = RtcEngine .create (config );
264- /**
270+ /*
265271 * This parameter is for reporting the usages of APIExample to agora background.
266272 * Generally, it is not necessary for you to set this parameter.
267273 */
@@ -288,7 +294,7 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
288294 @ Override
289295 public void onDestroy () {
290296 super .onDestroy ();
291- /** leaveChannel and Destroy the RtcEngine instance*/
297+ /*leaveChannel and Destroy the RtcEngine instance*/
292298 if (engine != null ) {
293299 engine .leaveChannel ();
294300 }
@@ -312,15 +318,14 @@ public void onClick(View v) {
312318 AndPermission .with (this ).runtime ().permission (
313319 Permission .Group .STORAGE ,
314320 Permission .Group .MICROPHONE
315- ).onGranted (permissions ->
316- {
321+ ).onGranted (permissions -> {
317322 // Permissions Granted
318323 joinChannel (channelId );
319324 }).start ();
320325 } else {
321326 joined = false ;
322327 resetControlLayoutByJoined ();
323- /** After joining a channel, the user must call the leaveChannel method to end the
328+ /*After joining a channel, the user must call the leaveChannel method to end the
324329 * call before joining another channel. This method returns 0 if the user leaves the
325330 * channel and releases all resources related to the call. This method call is
326331 * asynchronous, and the user has not exited the channel when the method call returns.
@@ -389,21 +394,21 @@ private int getPitch2Value(String str) {
389394 * Users that input the same channel name join the same channel.
390395 */
391396 private void joinChannel (String channelId ) {
392- /** In the demo, the default is to enter as the anchor.*/
397+ /*In the demo, the default is to enter as the anchor.*/
393398 engine .setClientRole (Constants .CLIENT_ROLE_BROADCASTER );
394399 // audio config
395400 engine .setAudioProfile (
396401 Constants .AudioProfile .getValue (Constants .AudioProfile .valueOf (audioProfile .getSelectedItem ().toString ())),
397402 Constants .AudioScenario .getValue (Constants .AudioScenario .valueOf (audioScenario .getSelectedItem ().toString ()))
398403 );
399404
400- /** Please configure accessToken in the string_config file.
405+ /*Please configure accessToken in the string_config file.
401406 * A temporary token generated in Console. A temporary token is valid for 24 hours. For details, see
402407 * https://docs.agora.io/en/Agora%20Platform/token?platform=All%20Platforms#get-a-temporary-token
403408 * A token generated at the server. This applies to scenarios with high-security requirements. For details, see
404409 * https://docs.agora.io/en/cloud-recording/token_server_java?platform=Java*/
405410 TokenUtils .gen (requireContext (), channelId , 0 , accessToken -> {
406- /** Allows a user to join a channel.
411+ /* Allows a user to join a channel.
407412 if you do not specify the uid, we will generate the uid for you*/
408413
409414 ChannelMediaOptions option = new ChannelMediaOptions ();
@@ -588,7 +593,7 @@ public void onItemSelected(AdapterView<?> parent, View view, int position, long
588593
589594 for (Spinner spinner : voiceBeautifierSpinner ) {
590595 if (spinner != parent ) {
591- if (spinner .getSelectedItemPosition () != 0 ){
596+ if (spinner .getSelectedItemPosition () != 0 ) {
592597 spinner .setTag ("reset" );
593598 spinner .setSelection (0 );
594599 }
@@ -605,33 +610,33 @@ public void onItemSelected(AdapterView<?> parent, View view, int position, long
605610
606611 for (Spinner spinner : audioEffectSpinner ) {
607612 if (spinner != parent ) {
608- if (spinner .getSelectedItemPosition () != 0 ){
613+ if (spinner .getSelectedItemPosition () != 0 ) {
609614 spinner .setTag ("reset" );
610615 spinner .setSelection (0 );
611616 }
612617 }
613618 }
614619
615- _voice3DLayout .setVisibility (audioEffectPreset == ROOM_ACOUSTICS_3D_VOICE ? View .VISIBLE : View .GONE );
620+ _voice3DLayout .setVisibility (audioEffectPreset == ROOM_ACOUSTICS_3D_VOICE ? View .VISIBLE : View .GONE );
616621 _pitchModeLayout .setVisibility (audioEffectPreset == PITCH_CORRECTION ? View .VISIBLE : View .GONE );
617622 _pitchValueLayout .setVisibility (audioEffectPreset == PITCH_CORRECTION ? View .VISIBLE : View .GONE );
618623 return ;
619624 }
620625
621- if (parent == voiceConversion ){
626+ if (parent == voiceConversion ) {
622627 String item = parent .getSelectedItem ().toString ();
623628 engine .setVoiceConversionPreset (getVoiceConversionValue (item ));
624629 return ;
625630 }
626631
627632
628- if (parent == _pitchModeOption || parent == _pitchValueOption ){
633+ if (parent == _pitchModeOption || parent == _pitchValueOption ) {
629634 int effectOption1 = getPitch1Value (_pitchModeOption .getSelectedItem ().toString ());
630635 int effectOption2 = getPitch2Value (_pitchValueOption .getSelectedItem ().toString ());
631636 engine .setAudioEffectParameters (PITCH_CORRECTION , effectOption1 , effectOption2 );
632637 }
633638
634- if (parent == ainsMode ){
639+ if (parent == ainsMode ) {
635640 boolean enable = position > 0 ;
636641 /*
637642 The AI noise suppression modes:
@@ -644,6 +649,12 @@ public void onItemSelected(AdapterView<?> parent, View view, int position, long
644649 */
645650 engine .setAINSMode (enable , position - 1 );
646651 }
652+
653+ if (parent == voiceAITuner ) {
654+ boolean enable = position > 0 ;
655+ String item = parent .getSelectedItem ().toString ();
656+ engine .enableVoiceAITuner (enable , enable ? Constants .VOICE_AI_TUNER_TYPE .valueOf (item ) : Constants .VOICE_AI_TUNER_TYPE .VOICE_AI_TUNER_MATURE_MALE );
657+ }
647658 }
648659
649660 private int getVoiceConversionValue (String label ) {
@@ -672,7 +683,7 @@ private int getVoiceConversionValue(String label) {
672683 return VOICE_CHANGER_DARTH_VADER ;
673684 case "VOICE_CHANGER_IRON_LADY" :
674685 return VOICE_CHANGER_IRON_LADY ;
675- case "VOICE_CHANGER_SHIN_CHAN" :
686+ case "VOICE_CHANGER_SHIN_CHAN" :
676687 return VOICE_CHANGER_SHIN_CHAN ;
677688 case "VOICE_CHANGER_GIRLISH_MAN" :
678689 return VOICE_CHANGER_GIRLISH_MAN ;
@@ -807,11 +818,11 @@ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
807818 if (!fromUser ) {
808819 return ;
809820 }
810- if (seekBar == _voice3DCircle ){
821+ if (seekBar == _voice3DCircle ) {
811822 int cicle = (int ) (1 + 59 * progress * 1.0f / seekBar .getMax ());
812823 // [1,60], 10 default
813824 engine .setAudioEffectParameters (ROOM_ACOUSTICS_3D_VOICE , cicle , 0 );
814- }else if (seekBar == customPitch ){
825+ } else if (seekBar == customPitch ) {
815826 double pitch = 0.5 + 1.5 * progress * 1.0f / seekBar .getMax ();
816827 // pitch: [0.5,2.0], 1.0 default
817828 engine .setLocalVoicePitch (pitch );
@@ -827,11 +838,11 @@ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
827838 // AUDIO_REVERB_ROOM_SIZE(2):[0, 100] dB
828839 // AUDIO_REVERB_WET_DELAY(3):Wet signal, [0, 200] ms
829840 // AUDIO_REVERB_STRENGTH(4): [0, 100]
830- if (reverbKey == Constants .AUDIO_REVERB_TYPE .AUDIO_REVERB_DRY_LEVEL || reverbKey == Constants .AUDIO_REVERB_TYPE .AUDIO_REVERB_WET_LEVEL ){
841+ if (reverbKey == Constants .AUDIO_REVERB_TYPE .AUDIO_REVERB_DRY_LEVEL || reverbKey == Constants .AUDIO_REVERB_TYPE .AUDIO_REVERB_WET_LEVEL ) {
831842 value = (int ) (-20 + 30 * progress * 1.0f / seekBar .getMax ());
832- }else if (reverbKey == Constants .AUDIO_REVERB_TYPE .AUDIO_REVERB_WET_DELAY ){
843+ } else if (reverbKey == Constants .AUDIO_REVERB_TYPE .AUDIO_REVERB_WET_DELAY ) {
833844 value = (int ) (200 * progress * 1.0f / seekBar .getMax ());
834- }else {
845+ } else {
835846 value = (int ) (100 * progress * 1.0f / seekBar .getMax ());
836847 }
837848 engine .setLocalVoiceReverb (reverbKey , value );
0 commit comments