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 |
---|---|
initialize(context.audioScenario) |
Sets the audio scenario when you create the IRtcEngine 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 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
RtcEngineContext context;
context.audioScenario = AUDIO_SCENARIO_DEFAULT
m_rtcEngine->initialize(context);
// Set the audio profile
m_rtcEngine->setAudioProfile(AUDIO_PROFILE_DEFAULT);
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
RtcEngineContext context;
context.audioScenario = AUDIO_SCENARIO_HIGH_DEFINITION
m_rtcEngine->initialize(context);
// Set the audio profile
m_rtcEngine->setAudioProfile(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
RtcEngineContext context;
context.audioScenario = AUDIO_SCENARIO_HIGH_DEFINITION
m_rtcEngine->initialize(context);
// Set the audio profile
m_rtcEngine->setAudioProfile(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
RtcEngineContext context;
context.audioScenario = AUDIO_SCENARIO_HIGH_DEFINITION
m_rtcEngine->initialize(context);
// Set the audio profile
m_rtcEngine->setAudioProfile(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.
initialize
setAudioProfile
[1/2]setAudioProfile
[2/2]