An audio profile includes the audio sample rate, encoding scheme, number of channels, and bitrate for the encoding audio stream; an audio scenario determines the audio performance.
Different applications require different audio profiles or scenarios. This page shows you how to set the appropriate audio profile and scenario in your app using Agora SDKs.
The SDK uses the AUDIO_PROFILE_DEFAULT
profile and the AUDIO_SCENARIO_DEFAULT
scenario by default. If the default setting does not meet your requirements, you can call the following APIs to set another audio profile or scenario:
API | Description |
---|---|
create(config.mAudioScenario) |
Sets the audio scenario when you create the RtcEngine instance. The default value is AUDIO_SCENARIO_DEFAULT . |
setAudioProfile(profile) |
Sets the audio profile either before or after joining a channel. |
setAudioProfile(profile, scenario) |
Sets the audio profile and scenario either before or after joining a channel. |
Before proceeding, ensure that you have a project that has implemented the basic real-time engagement functionality. See Start a Video Call or Start Interactive Live Streaming.
This section shows you how to set the audio profile and scenario in common applications. You can add the sample code in /app/java/com.example.<projectname>/MainActivity
of your project.
For the one-to-one classroom that requires the call quality with smooth transmission, add the following code to your project:
// Set the audio scenario when you create the RtcEngine instance
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.DEFAULT);
engine = RtcEngine.create(config);
// Set the audio profile
RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_DEFAULT);
This scenario mainly requires voice clarity, no noise, and a lower bitrate. Agora recommends the following settings:
// Set the audio scenario when you create the RtcEngine instance
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.CHATROOM);
engine = RtcEngine.create(config);
// Set the audio profile
RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_SPEECH_STANDARD);
This scenario mainly requires high audio performance, with no volume or audio quality change when users mute or unmute the microphone. Agora recommends the following settings:
// Set the audio scenario when you create the RtcEngine instance
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.CHATROOM);
engine = RtcEngine.create(config);
// Set the audio profile
RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_STANDARD);
For the KTV that requires high-fidelity audio and a high performance to music or singing voice, add the following code to your project:
// Set the audio scenario when you create the RtcEngine instance
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.HIGH_DEFINITION);
engine = RtcEngine.create(config);
// Set the audio profile
RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_HIGH_QUALITY);
For the podcast that uses professional audio hardware devices, and requires high-fidelity audio and stereo audio channels, add the following code to your project:
// Set the audio scenario when you create the RtcEngine instance
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.HIGH_DEFINITION);
engine = RtcEngine.create(config);
// Set the audio profile
RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO);
This scenario mainly requires high-fidelity audio and support for transmitting the audio effects from the local playback to remote users. Agora recommends the following settings:
// Set the audio scenario when you create the RtcEngine instance
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.HIGH_DEFINITION);
engine = RtcEngine.create(config);
// Set the audio profile
RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_STANDARD_STEREO);
This scenario mainly requires high-fidelity audio, support for rich audio effects, and no volume or audio quality change when users mute or unmute the microphone. Agora recommends the following settings:
// Set the audio scenario when you create the RtcEngine instance
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.CHATROOM);
engine = RtcEngine.create(config);
// Set the audio profile
RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_STANDARD_STEREO);
This section provides reference information you may need when setting the audio profile and scenario.
Agora provides an open-source sample project that implements setting the audio profile and scenario on GitHub. You can try the sample project and view the source code.
create
[2/2]setAudioProfile
[1/2]setAudioProfile
[2/2]The audio scenario affects the volume type. See the difference between two kinds of volume type as follows:
The following tables show the volume type according to different audio scenarios, user roles, and audio routes.
In the AUDIO_SCENARIO_DEFAULT
scenario:
Wired earphones | Speakerphone or earpiece | Bluetooth devices | |
---|---|---|---|
|
Media volume | In-call volume | In-call volume |
Single host in the interactive live streaming profile | Media volume | Media volume | In-call volume |
Audience in the interactive live streaming profile | Media volume | Media volume | Media volume |
In the AUDIO_SCENARIO_HIGH_DEFINITION
, AUDIO_SCENARIO_GAME_STREAMING
, or AUDIO_SCENARIO_CHORUS
scenario:
Wired earphones | Speakerphone or earpiece | Bluetooth devices | |
---|---|---|---|
|
Media volume | Media volume | Media volume |
Single host in the interactive live streaming profile | Media volume | Media volume | Media volume |
Audience in the interactive live streaming profile | Media volume | Media volume | Media volume |
In the AUDIO_SCENARIO_CHATROOM
scenario:
Wired earphones | Speakerphone or earpiece | Bluetooth devices | |
---|---|---|---|
|
Media volume | In-call volume | In-call volume |
Single host in the interactive live streaming profile | Media volume | In-call volume | In-call volume |
Audience in the interactive live streaming profile | Media volume | In-call volume | In-call volume |