Skip to content

Commit

Permalink
Merge tag '4.4.0' into dev/HarmonyOS_NEXT-Beta
Browse files Browse the repository at this point in the history
  • Loading branch information
weileifrank committed Sep 29, 2024
2 parents 69cf36f + 3e4a874 commit b04801a
Show file tree
Hide file tree
Showing 202 changed files with 11,916 additions and 2,457 deletions.
2 changes: 1 addition & 1 deletion Android/APIExample-Audio/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'com.android.application'

def localSdkPath= "${rootProject.projectDir.absolutePath}/../../sdk"
def agoraSdkVersion = '4.3.2'
def agoraSdkVersion = '4.4.0'

android {
compileSdkVersion 32
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@
import io.agora.rtc2.RtcEngineConfig;
import io.agora.rtc2.proxy.LocalAccessPointConfiguration;

/**
* The type Voice effects.
*/
@Example(
index = 4,
group = ADVANCED,
Expand All @@ -106,7 +109,7 @@ public class VoiceEffects extends BaseFragment implements View.OnClickListener,
private EditText et_channel;
private Button join;
private Spinner audioProfile, audioScenario,
chatBeautifier, timbreTransformation, voiceChanger, styleTransformation, roomAcoustics, pitchCorrection, _pitchModeOption, _pitchValueOption, voiceConversion, ainsMode,
chatBeautifier, timbreTransformation, voiceChanger, styleTransformation, roomAcoustics, pitchCorrection, _pitchModeOption, _pitchValueOption, voiceConversion, ainsMode, voiceAITuner,
customBandFreq, customReverbKey;
private ViewGroup _voice3DLayout, _pitchModeLayout, _pitchValueLayout;
private SeekBar _voice3DCircle, customPitch, customBandGain, customReverbValue, customVoiceFormant;
Expand Down Expand Up @@ -154,6 +157,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
_pitchValueOption = view.findViewById(R.id.audio_pitch_value_option);
voiceConversion = view.findViewById(R.id.audio_voice_conversion);
ainsMode = view.findViewById(R.id.audio_ains_mode);
voiceAITuner = view.findViewById(R.id.voice_ai_tuner);

chatBeautifier.setOnItemSelectedListener(this);
timbreTransformation.setOnItemSelectedListener(this);
Expand All @@ -166,6 +170,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
_pitchModeOption.setOnItemSelectedListener(this);
_pitchValueOption.setOnItemSelectedListener(this);
ainsMode.setOnItemSelectedListener(this);
voiceAITuner.setOnItemSelectedListener(this);

// Customize Voice Effects Layout
customPitch = view.findViewById(R.id.audio_custom_pitch); // engine.setLocalVoicePitch()
Expand Down Expand Up @@ -205,6 +210,7 @@ private void resetControlLayoutByJoined() {
_pitchValueLayout.setVisibility(View.GONE);
voiceConversion.setEnabled(joined);
ainsMode.setEnabled(joined);
voiceAITuner.setEnabled(joined);

customPitch.setEnabled(joined);
customBandFreq.setEnabled(joined);
Expand Down Expand Up @@ -238,30 +244,30 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
}
try {
RtcEngineConfig config = new RtcEngineConfig();
/**
/*
* The context of Android Activity
*/
config.mContext = context.getApplicationContext();
/**
/*
* 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>
*/
config.mAppId = getString(R.string.agora_app_id);
/** Sets the channel profile of the Agora RtcEngine.
/* Sets the channel profile of the Agora RtcEngine.
CHANNEL_PROFILE_COMMUNICATION(0): (Default) The Communication profile.
Use this profile in one-on-one calls or group calls, where all users can talk freely.
CHANNEL_PROFILE_LIVE_BROADCASTING(1): The Live-Broadcast profile. Users in a live-broadcast
channel have a role as either broadcaster or audience. A broadcaster can both send and receive streams;
an audience can only receive streams.*/
config.mChannelProfile = Constants.CHANNEL_PROFILE_LIVE_BROADCASTING;
/**
/*
* IRtcEngineEventHandler is an abstract class providing default implementation.
* The SDK uses this class to report to the app on SDK runtime events.
*/
config.mEventHandler = iRtcEngineEventHandler;
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.DEFAULT);
config.mAreaCode = ((MainApplication)getActivity().getApplication()).getGlobalSettings().getAreaCode();
config.mAreaCode = ((MainApplication) getActivity().getApplication()).getGlobalSettings().getAreaCode();
engine = RtcEngine.create(config);
/**
/*
* This parameter is for reporting the usages of APIExample to agora background.
* Generally, it is not necessary for you to set this parameter.
*/
Expand All @@ -288,7 +294,7 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
@Override
public void onDestroy() {
super.onDestroy();
/**leaveChannel and Destroy the RtcEngine instance*/
/*leaveChannel and Destroy the RtcEngine instance*/
if (engine != null) {
engine.leaveChannel();
}
Expand All @@ -312,15 +318,14 @@ public void onClick(View v) {
AndPermission.with(this).runtime().permission(
Permission.Group.STORAGE,
Permission.Group.MICROPHONE
).onGranted(permissions ->
{
).onGranted(permissions -> {
// Permissions Granted
joinChannel(channelId);
}).start();
} else {
joined = false;
resetControlLayoutByJoined();
/**After joining a channel, the user must call the leaveChannel method to end the
/*After joining a channel, the user must call the leaveChannel method to end the
* call before joining another channel. This method returns 0 if the user leaves the
* channel and releases all resources related to the call. This method call is
* asynchronous, and the user has not exited the channel when the method call returns.
Expand Down Expand Up @@ -389,21 +394,21 @@ private int getPitch2Value(String str) {
* Users that input the same channel name join the same channel.
*/
private void joinChannel(String channelId) {
/**In the demo, the default is to enter as the anchor.*/
/*In the demo, the default is to enter as the anchor.*/
engine.setClientRole(Constants.CLIENT_ROLE_BROADCASTER);
// audio config
engine.setAudioProfile(
Constants.AudioProfile.getValue(Constants.AudioProfile.valueOf(audioProfile.getSelectedItem().toString())),
Constants.AudioScenario.getValue(Constants.AudioScenario.valueOf(audioScenario.getSelectedItem().toString()))
);

/**Please configure accessToken in the string_config file.
/*Please configure accessToken in the string_config file.
* A temporary token generated in Console. A temporary token is valid for 24 hours. For details, see
* https://docs.agora.io/en/Agora%20Platform/token?platform=All%20Platforms#get-a-temporary-token
* A token generated at the server. This applies to scenarios with high-security requirements. For details, see
* https://docs.agora.io/en/cloud-recording/token_server_java?platform=Java*/
TokenUtils.gen(requireContext(), channelId, 0, accessToken -> {
/** Allows a user to join a channel.
/* Allows a user to join a channel.
if you do not specify the uid, we will generate the uid for you*/

ChannelMediaOptions option = new ChannelMediaOptions();
Expand Down Expand Up @@ -588,7 +593,7 @@ public void onItemSelected(AdapterView<?> parent, View view, int position, long

for (Spinner spinner : voiceBeautifierSpinner) {
if (spinner != parent) {
if(spinner.getSelectedItemPosition() != 0){
if (spinner.getSelectedItemPosition() != 0) {
spinner.setTag("reset");
spinner.setSelection(0);
}
Expand All @@ -605,33 +610,33 @@ public void onItemSelected(AdapterView<?> parent, View view, int position, long

for (Spinner spinner : audioEffectSpinner) {
if (spinner != parent) {
if(spinner.getSelectedItemPosition() != 0){
if (spinner.getSelectedItemPosition() != 0) {
spinner.setTag("reset");
spinner.setSelection(0);
}
}
}

_voice3DLayout.setVisibility(audioEffectPreset == ROOM_ACOUSTICS_3D_VOICE ? View.VISIBLE: View.GONE);
_voice3DLayout.setVisibility(audioEffectPreset == ROOM_ACOUSTICS_3D_VOICE ? View.VISIBLE : View.GONE);
_pitchModeLayout.setVisibility(audioEffectPreset == PITCH_CORRECTION ? View.VISIBLE : View.GONE);
_pitchValueLayout.setVisibility(audioEffectPreset == PITCH_CORRECTION ? View.VISIBLE : View.GONE);
return;
}

if(parent == voiceConversion){
if (parent == voiceConversion) {
String item = parent.getSelectedItem().toString();
engine.setVoiceConversionPreset(getVoiceConversionValue(item));
return;
}


if(parent == _pitchModeOption || parent == _pitchValueOption){
if (parent == _pitchModeOption || parent == _pitchValueOption) {
int effectOption1 = getPitch1Value(_pitchModeOption.getSelectedItem().toString());
int effectOption2 = getPitch2Value(_pitchValueOption.getSelectedItem().toString());
engine.setAudioEffectParameters(PITCH_CORRECTION, effectOption1, effectOption2);
}

if(parent == ainsMode){
if (parent == ainsMode) {
boolean enable = position > 0;
/*
The AI noise suppression modes:
Expand All @@ -644,6 +649,12 @@ public void onItemSelected(AdapterView<?> parent, View view, int position, long
*/
engine.setAINSMode(enable, position - 1);
}

if (parent == voiceAITuner) {
boolean enable = position > 0;
String item = parent.getSelectedItem().toString();
engine.enableVoiceAITuner(enable, enable ? Constants.VOICE_AI_TUNER_TYPE.valueOf(item) : Constants.VOICE_AI_TUNER_TYPE.VOICE_AI_TUNER_MATURE_MALE);
}
}

private int getVoiceConversionValue(String label) {
Expand Down Expand Up @@ -672,7 +683,7 @@ private int getVoiceConversionValue(String label) {
return VOICE_CHANGER_DARTH_VADER;
case "VOICE_CHANGER_IRON_LADY":
return VOICE_CHANGER_IRON_LADY;
case "VOICE_CHANGER_SHIN_CHAN":
case "VOICE_CHANGER_SHIN_CHAN":
return VOICE_CHANGER_SHIN_CHAN;
case "VOICE_CHANGER_GIRLISH_MAN":
return VOICE_CHANGER_GIRLISH_MAN;
Expand Down Expand Up @@ -807,11 +818,11 @@ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (!fromUser) {
return;
}
if(seekBar == _voice3DCircle){
if (seekBar == _voice3DCircle) {
int cicle = (int) (1 + 59 * progress * 1.0f / seekBar.getMax());
// [1,60], 10 default
engine.setAudioEffectParameters(ROOM_ACOUSTICS_3D_VOICE, cicle, 0);
}else if(seekBar == customPitch){
} else if (seekBar == customPitch) {
double pitch = 0.5 + 1.5 * progress * 1.0f / seekBar.getMax();
// pitch: [0.5,2.0], 1.0 default
engine.setLocalVoicePitch(pitch);
Expand All @@ -827,11 +838,11 @@ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
// AUDIO_REVERB_ROOM_SIZE(2):[0, 100] dB
// AUDIO_REVERB_WET_DELAY(3):Wet signal, [0, 200] ms
// AUDIO_REVERB_STRENGTH(4): [0, 100]
if(reverbKey == Constants.AUDIO_REVERB_TYPE.AUDIO_REVERB_DRY_LEVEL || reverbKey == Constants.AUDIO_REVERB_TYPE.AUDIO_REVERB_WET_LEVEL){
if (reverbKey == Constants.AUDIO_REVERB_TYPE.AUDIO_REVERB_DRY_LEVEL || reverbKey == Constants.AUDIO_REVERB_TYPE.AUDIO_REVERB_WET_LEVEL) {
value = (int) (-20 + 30 * progress * 1.0f / seekBar.getMax());
}else if(reverbKey == Constants.AUDIO_REVERB_TYPE.AUDIO_REVERB_WET_DELAY){
} else if (reverbKey == Constants.AUDIO_REVERB_TYPE.AUDIO_REVERB_WET_DELAY) {
value = (int) (200 * progress * 1.0f / seekBar.getMax());
}else {
} else {
value = (int) (100 * progress * 1.0f / seekBar.getMax());
}
engine.setLocalVoiceReverb(reverbKey, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private static void gen(String appId, String certificate, String channelName, in
}

Request request = new Request.Builder()
.url("https://test-toolbox.bj2.agoralab.co/v1/token/generate")
.url("https://service.agora.io/toolbox-global/v1/token/generate")
.addHeader("Content-Type", "application/json")
.post(RequestBody.create(postBody.toString(), null))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,29 @@

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:gravity="center_vertical">

<TextView
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text="Voice AI Tuner"
android:textColor="@android:color/black" />

<androidx.appcompat.widget.AppCompatSpinner
android:id="@+id/voice_ai_tuner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:entries="@array/voice_ai_tuner"
android:spinnerMode="dropdown" />

</LinearLayout>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
14 changes: 14 additions & 0 deletions Android/APIExample-Audio/app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,18 @@
<item>AINS_MODE_AGGRESSIVE</item>
<item>AINS_MODE_ULTRALOWLATENCY</item>
</string-array>

<string-array name="voice_ai_tuner">
<item>OFF</item>
<item>VOICE_AI_TUNER_MATURE_MALE</item>
<item>VOICE_AI_TUNER_FRESH_MALE</item>
<item>VOICE_AI_TUNER_ELEGANT_FEMALE</item>
<item>VOICE_AI_TUNER_SWEET_FEMALE</item>
<item>VOICE_AI_TUNER_WARM_MALE_SINGING</item>
<item>VOICE_AI_TUNER_GENTLE_FEMALE_SINGING</item>
<item>VOICE_AI_TUNER_HUSKY_MALE_SINGING</item>
<item>VOICE_AI_TUNER_WARM_ELEGANT_FEMALE_SINGING</item>
<item>VOICE_AI_TUNER_POWERFUL_MALE_SINGING</item>
<item>VOICE_AI_TUNER_DREAMY_FEMALE_SINGING</item>
</string-array>
</resources>
4 changes: 4 additions & 0 deletions Android/APIExample-Audio/cloud_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
# cache gradle to /tmp/.gradle
ls ~/.gradle || (mkdir -p /tmp/.gradle && ln -s /tmp/.gradle ~/.gradle && touch ~/.gradle/ln_$(date "+%y%m%d%H") && ls ~/.gradle)

#change android maven to china repos
sed -ie "s#google()#maven { url \"https\://maven.aliyun.com/repository/public\" }\n google()#g" settings.gradle
sed -ie "s#https://services.gradle.org/distributions#https://mirrors.cloud.tencent.com/gradle#g" gradle/wrapper/gradle-wrapper.properties

## config appId
sed -i -e "s#YOUR APP ID#${APP_ID}#g" app/src/main/res/values/string_configs.xml
sed -i -e "s#YOUR APP CERTIFICATE##g" app/src/main/res/values/string_configs.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ class CustomVideoRenderRender(
0,
0,
viewportWidth,
viewportHeight
viewportHeight,
0
)
} catch (exception: NullPointerException) {
Log.e(TAG, "skip empty buffer!")
Expand Down
Loading

0 comments on commit b04801a

Please sign in to comment.