For AI agents: see the complete documentation index at /llms.txt.
Configure audio encoding
Updated
Configure audio encoding properties and scenarios for Video Calling apps.
Audio quality requirements vary with application use-case. For example, in professional use-cases such as radio stations and singing competitions, users are particularly sensitive to audio quality. In such cases, support for dual-channel and high-quality sound is required. High-quality sound means setting a high sampling rate and a high bitrate to achieve realistic audio. Video SDK enables you to configure audio encoding properties to meet such requirements.
This article shows you how to use Video SDK to configure appropriate audio encoding properties and application scenarios in your app.
Understand the tech
Video SDK uses default encoding parameters and a default audio scenario that are suitable for most common applications. If the default settings do not meet your needs, refer to the examples in the implementation section to set appropriate audio encoding properties and an application scenario.
Prerequisites
Ensure that you have implemented the SDK quickstart in your project.
Implementation
This section shows you how to set audio encoding properties and application scenarios for common applications. You use the following APIs to configure audio encoding:
| API | Description |
|---|---|
create(config.mAudioScenario) | While creating an RtcEngine instance, set the audio application scenario. The default value is AUDIO_SCENARIO_DEFAULT. |
setAudioProfile(profile) | You can set audio encoding properties before or after joining a channel. |
setAudioScenario | You can set an application scenario before or after joining a channel. |
Refer to the following examples to choose the most appropriate settings for your application.
1-on-1 interactive teaching
This use-case requires ensuring call quality and smooth transmission. Add the following code to your project:
// Create the RtcEngine instance with a specific audio application scenario
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.DEFAULT);
engine = RtcEngine.create(config);
// Define the audio encoding settings
RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_DEFAULT);// Create the RtcEngine instance with a specific audio application scenario
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.DEFAULT)
engine = RtcEngine.create(config)
// Define the audio encoding settings
RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_DEFAULT)Gaming voice chat
This use-case requires the transmission of clear human voice with minimal background noise and at a low bitrate. Agora recommends the following settings:
// Create the RtcEngine instance with a specific audio application scenario
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.CHATROOM);
engine = RtcEngine.create(config);
// Define the audio encoding settings
RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_SPEECH_STANDARD);// Create the RtcEngine instance with a specific audio application scenario
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.CHATROOM)
engine = RtcEngine.create(config)
// Define the audio encoding settings
RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_SPEECH_STANDARD)Scripted role play
This use-case requires good sound expression, and no volume or sound quality change when switching microphones. Agora recommends the following settings:
// Create the RtcEngine instance with a specific audio application scenario
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.CHATROOM);
engine = RtcEngine.create(config);
// Define the audio encoding settings
RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_STANDARD);// Create the RtcEngine instance with a specific audio application scenario
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.CHATROOM)
engine = RtcEngine.create(config)
// Define the audio encoding settings
RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_STANDARD)KTV
KTV generally requires high sound quality and good expressiveness for music and singing. Use the following code in your project:
// Create the RtcEngine instance with a specific audio application scenario
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.GAME_STREAMING);
engine = RtcEngine.create(config);
// Define the audio encoding settings
RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_HIGH_QUALITY);// Create the RtcEngine instance with a specific audio application scenario
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.GAME_STREAMING)
engine = RtcEngine.create(config)
// Define the audio encoding settings
RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_HIGH_QUALITY)Voice radio
Voice radio generally uses professional audio equipment. It requires high sound quality and stereo. Use the following code in your project:
// Create the RtcEngine instance with a specific audio application scenario
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.GAME_STREAMING);
engine = RtcEngine.create(config);
// Set the required audio encoding properties
RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO);// Create the RtcEngine instance with a specific audio application scenario
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.GAME_STREAMING)
engine = RtcEngine.create(config)
// Set the required audio encoding properties
RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO)Music teaching
This use-case requires high sound quality, and support for the transmission of speaker-played sound effects. Agora recommends the following settings:
// Create the RtcEngine instance with a specific audio application scenario
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.GAME_STREAMING);
engine = RtcEngine.create(config);
// Define the audio encoding settings
RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_STANDARD_STEREO);// Create the RtcEngine instance with a specific audio application scenario
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.GAME_STREAMING)
engine = RtcEngine.create(config)
// Define the audio encoding settings
RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_STANDARD_STEREO)Dual-teacher classroom
This use-case requires high sound quality with rich sound effects, and no volume or sound quality change when switching microphones. Agora recommends the following settings:
// Create the RtcEngine instance with a specific audio application scenario
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.CHATROOM);
engine = RtcEngine.create(config);
// Define the audio encoding settings
RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_STANDARD_STEREO);// Create the RtcEngine instance with a specific audio application scenario
config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.CHATROOM)
engine = RtcEngine.create(config)
// Define the audio encoding settings
RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_STANDARD_STEREO)Reference
This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.
For more audio settings, see Achieve high audio quality.
Frequently asked questions
Sample projects
Agora offers the following open-source sample project for setting audio encoding properties and application scenario for your reference.
API reference
This article shows you how to use Video SDK to configure appropriate audio encoding properties and application scenarios in your app.
Understand the tech
Video SDK uses default encoding parameters and a default audio scenario that are suitable for most common applications. If the default settings do not meet your needs, refer to the examples in the implementation section to set appropriate audio encoding properties and an application scenario.
Prerequisites
Ensure that you have implemented the SDK quickstart in your project.
Implementation
This section shows you how to set audio encoding properties and application scenarios for common applications. You use the following APIs to configure audio encoding:
| API | Description |
|---|---|
sharedEngineWithConfig(config.audioScenario) | While creating an AgoraRtcEngineKit instance, set up the audio application scenario. The default value is AgoraAudioScenarioHighDefault. |
setAudioProfile(profile) | You can set audio encoding properties before or after joining a channel. |
setAudioScenario | You can set an application scenario before or after joining a channel. |
Refer to the following examples to choose the most appropriate settings for your application.
1-on-1 interactive teaching
This use-case requires ensuring call quality and smooth transmission. Add the following code to your project:
// Create the AgoraRtcEngineKit instance with a specific audio application scenario
var scenario:AgoraAudioScenario = .default
config.audioScenario = audioScenario
agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
// Define the audio encoding settings
var profile:AgoraAudioProfile = .default
agoraKit.setAudioProfile(audioProfile)Gaming voice chat
This use-case requires the transmission of clear human voice with minimal background noise and at a low bitrate. Agora recommends the following settings:
// Create the AgoraRtcEngineKit instance with a specific audio application scenario
var scenario:AgoraAudioScenario = .chatRoom
config.audioScenario = audioScenario
agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
// Define the audio encoding settings
var profile:AgoraAudioProfile = .speechStandard
agoraKit.setAudioProfile(audioProfile)Scripted role play
This use-case requires good sound expression, and no volume or sound quality change when switching microphones. Agora recommends the following settings:
// Create the AgoraRtcEngineKit instance with a specific audio application scenario
var scenario:AgoraAudioScenario = .chatRoom
config.audioScenario = audioScenario
agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
// Define the audio encoding settings
var profile:AgoraAudioProfile = .musicStandard
agoraKit.setAudioProfile(audioProfile)KTV
KTV generally requires high sound quality and good expressiveness for music and singing. Use the following code in your project:
// Create the AgoraRtcEngineKit instance with a specific audio application scenario
var scenario:AgoraAudioScenario = .gameStreaming
config.audioScenario = audioScenario
agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
// Define the audio encoding settings
var profile:AgoraAudioProfile = .musicHighQuality
agoraKit.setAudioProfile(audioProfile)Voice radio
Voice radio generally uses professional audio equipment. It requires high sound quality and stereo. Use the following code in your project:
// Create the AgoraRtcEngineKit instance with a specific audio application scenario
var scenario:AgoraAudioScenario = .gameStreaming
config.audioScenario = audioScenario
agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
// Set the required audio encoding properties
var profile:AgoraAudioProfile = .musicHighQualityStereo
agoraKit.setAudioProfile(audioProfile)Music teaching
This use-case requires high sound quality, and support for the transmission of speaker-played sound effects. Agora recommends the following settings:
// Create the AgoraRtcEngineKit instance with a specific audio application scenario
var scenario:AgoraAudioScenario = .gameStreaming
config.audioScenario = audioScenario
agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
// Define the audio encoding settings
var profile:AgoraAudioProfile = .musicStandardStereo
agoraKit.setAudioProfile(audioProfile)Dual-teacher classroom
This use-case requires high sound quality with rich sound effects, and no volume or sound quality change when switching microphones. Agora recommends the following settings:
// Create the AgoraRtcEngineKit instance with a specific audio application scenario
var audioScenario:AgoraAudioScenario = .chatRoom
config.audioScenario = audioScenario
agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
// Define the audio encoding settings
var profile:AgoraAudioProfile = .musicStandardStereo
agoraKit.setAudioProfile(audioProfile)Due to iOS system limitations, some audio routes cannot be recognized in call volume mode. Therefore, if you need to use an external sound card, it is recommended to set the audio application scene to the high-quality scenario AudioScenarioGameStreaming(3). In this scenario, the SDK switches to media volume to address the issue.
Reference
This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.
For more audio settings, see Achieve high audio quality.
Frequently asked questions
Sample projects
Agora offers the following open-source sample project for setting audio encoding properties and application scenario functions for your reference.
API reference
This article shows you how to use Video SDK to configure appropriate audio encoding properties and application scenarios in your app.
Understand the tech
Video SDK uses default encoding parameters and a default audio scenario that are suitable for most common applications. If the default settings do not meet your needs, refer to the examples in the implementation section to set appropriate audio encoding properties and an application scenario.
Prerequisites
Ensure that you have implemented the SDK quickstart in your project.
Implementation
This section shows you how to set audio encoding properties and application scenarios for common applications. You use the following APIs to configure audio encoding:
| API | Description |
|---|---|
sharedEngineWithConfig(config.audioScenario) | While creating an AgoraRtcEngineKit instance, set up the audio application scenario. The default value is AgoraAudioScenarioHighDefault. |
setAudioProfile(profile) | You can set audio encoding properties before or after joining a channel. |
setAudioScenario | You can set an application scenario before or after joining a channel. |
Refer to the following examples to choose the most appropriate settings for your application.
1-on-1 interactive teaching
This use-case requires ensuring call quality and smooth transmission. Add the following code to your project:
// Create the AgoraRtcEngineKit instance with a specific audio application scenario
var scenario:AgoraAudioScenario = .default
config.audioScenario = audioScenario
agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
// Define the audio encoding settings
var profile:AgoraAudioProfile = .default
agoraKit.setAudioProfile(audioProfile)Gaming voice chat
This use-case requires the transmission of clear human voice with minimal background noise and at a low bitrate. Agora recommends the following settings:
// Create the AgoraRtcEngineKit instance with a specific audio application scenario
var scenario:AgoraAudioScenario = .chatRoom
config.audioScenario = audioScenario
agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
// Define the audio encoding settings
var profile:AgoraAudioProfile = .speechStandard
agoraKit.setAudioProfile(audioProfile)Scripted role play
This use-case requires good sound expression, and no volume or sound quality change when switching microphones. Agora recommends the following settings:
// Create the AgoraRtcEngineKit instance with a specific audio application scenario
var scenario:AgoraAudioScenario = .chatRoom
config.audioScenario = audioScenario
agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
// Define the audio encoding settings
var profile:AgoraAudioProfile = .musicStandard
agoraKit.setAudioProfile(audioProfile)KTV
KTV generally requires high sound quality and good expressiveness for music and singing. Use the following code in your project:
// Create the AgoraRtcEngineKit instance with a specific audio application scenario
var scenario:AgoraAudioScenario = .gameStreaming
config.audioScenario = audioScenario
agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
// Define the audio encoding settings
var profile:AgoraAudioProfile = .musicHighQuality
agoraKit.setAudioProfile(audioProfile)Voice radio
Voice radio generally uses professional audio equipment. It requires high sound quality and stereo. Use the following code in your project:
// Create the AgoraRtcEngineKit instance with a specific audio application scenario
var scenario:AgoraAudioScenario = .gameStreaming
config.audioScenario = audioScenario
agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
// Set the required audio encoding properties
var profile:AgoraAudioProfile = .musicHighQualityStereo
agoraKit.setAudioProfile(audioProfile)Music teaching
This use-case requires high sound quality, and support for the transmission of speaker-played sound effects. Agora recommends the following settings:
// Create the AgoraRtcEngineKit instance with a specific audio application scenario
var scenario:AgoraAudioScenario = .gameStreaming
config.audioScenario = audioScenario
agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
// Define the audio encoding settings
var profile:AgoraAudioProfile = .musicStandardStereo
agoraKit.setAudioProfile(audioProfile)Dual-teacher classroom
This use-case requires high sound quality with rich sound effects, and no volume or sound quality change when switching microphones. Agora recommends the following settings:
// Create the AgoraRtcEngineKit instance with a specific audio application scenario
var audioScenario:AgoraAudioScenario = .chatRoom
config.audioScenario = audioScenario
agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
// Define the audio encoding settings
var profile:AgoraAudioProfile = .musicStandardStereo
agoraKit.setAudioProfile(audioProfile)Reference
This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.
For more audio settings, see Achieve high audio quality.
Frequently asked questions
Sample projects
Agora offers the following open-source sample project for setting audio encoding properties and application scenario functions for your reference.
API reference
This article shows you how to use Video SDK to configure appropriate audio encoding properties and application scenarios in your app.
Understand the tech
Video SDK uses default encoding parameters and a default audio scenario that are suitable for most common applications. If the default settings do not meet your needs, refer to the examples in the implementation section to set appropriate audio encoding properties and an application scenario.
Prerequisites
Ensure that you have implemented the SDK quickstart in your project.
Implementation
The Agora Web SDK offers the following three methods to create local audio tracks:
createMicrophoneAudioTrackcreateBufferSourceAudioTrackcreateCustomAudioTrack
You can adjust the audio encoding configuration by modifying the encoderConfig parameter in these methods. encoderConfig supports the following two settings:
- Use the audio encoding properties preset by the SDK.
- A custom object with various audio encoding parameters.
Using preset audio encoding properties
AgoraRTC.createMicrophoneAudioTrack({
encoderConfig: "high_quality_stereo",
}).then(/**...**/);Customizing audio encoding properties
AgoraRTC.createMicrophoneAudioTrack({
encoderConfig: {
sampleRate: 48000,
stereo: true,
bitrate: 128,
},
}).then(/**...**/);Development considerations
Set the audio encoding properties before calling the AgoraRTCClient.publish method to publish the audio track. Once the audio track is published, its audio encoding properties cannot be modified.
Reference
This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.
For more audio settings, see Achieve high audio quality.
Frequently asked questions
API reference
This article shows you how to use Video SDK to configure appropriate audio encoding properties and application scenarios in your app.
Understand the tech
Video SDK uses default encoding parameters and a default audio scenario that are suitable for most common applications. If the default settings do not meet your needs, refer to the examples in the implementation section to set appropriate audio encoding properties and an application scenario.
Prerequisites
Ensure that you have implemented the SDK quickstart in your project.
Implementation
This section explains how to set audio encoding properties and application scenarios for common applications.
| API | Description |
|---|---|
initialize(context.audioScenario) | While initializing an IRtcEngine instance, set up the audio application scenario. The default value is AUDIO_SCENARIO_DEFAULT. |
setAudioProfile(profile) | Audio encoding properties can be set before and after joining a channel. |
setAudioScenario | Audio application scenarios can be set before and after joining the channel. |
You can add the following sample code to your project.
1-on-1 interactive teaching
The 1-to-1 interactive teaching use-case requires ensuring call quality and smooth transmission. Add the following code to your project:
// Initialize the IRtcEngine instance with a specific audio application scenario
RtcEngineContext context;
context.audioScenario = AUDIO_SCENARIO_DEFAULT;
m_rtcEngine->initialize(context);
// Define the audio encoding settings
m_rtcEngine->setAudioProfile(AUDIO_PROFILE_DEFAULT);KTV
KTV mainly requires high sound quality and good expressiveness for music and singing. Add the following code to your project:
// Initialize the IRtcEngine instance with a specific audio application scenario
RtcEngineContext context;
context.audioScenario = AUDIO_SCENARIO_GAME_STREAMING;
m_rtcEngine->initialize(context);
// Define the audio encoding settings
m_rtcEngine->setAudioProfile(AUDIO_PROFILE_MUSIC_HIGH_QUALITY);Voice radio
Voice radio generally uses professional audio equipment, mainly requiring high sound quality and stereo. Add the following code to your project:
// Initialize the IRtcEngine instance with a specific audio application scenario
RtcEngineContext context;
context.audioScenario = AUDIO_SCENARIO_GAME_STREAMING;
m_rtcEngine->initialize(context);
// Define the audio encoding settings
m_rtcEngine->setAudioProfile(AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO);Music teaching
This use-case requires high sound quality, and support for the transmission of speaker-played sound effects. Agora recommends the following settings:
// Initialize the IRtcEngine instance with a specific audio application scenario
RtcEngineContext context;
context.audioScenario = AUDIO_SCENARIO_GAME_STREAMING;
m_rtcEngine->initialize(context);
// Define the audio encoding settings
m_rtcEngine->setAudioProfile(AUDIO_PROFILE_MUSIC_STANDARD_STEREO);Reference
This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.
For more audio settings, see Achieve high audio quality.
Frequently asked questions
Sample projects
Agora offers the following open-source sample project for setting audio encoding properties and application scenario functions for your reference.
API reference
This article shows you how to use Video SDK to configure appropriate audio encoding properties and application scenarios in your app.
Understand the tech
Video SDK uses default encoding parameters and a default audio scenario that are suitable for most common applications. If the default settings do not meet your needs, refer to the examples in the implementation section to set appropriate audio encoding properties and an application scenario.
Prerequisites
Ensure that you have implemented the SDK quickstart in your project.
Implementation
This section shows you how to set audio encoding properties and application scenarios for common applications. You use the following APIs to configure audio encoding:
| API | Description |
|---|---|
initialize(RtcEngineContext context) | While initializing an IRtcEngine instance, set up the audio application scenario. The default value is AudioScenarioDefault. |
setAudioProfile(profile) | You can set audio encoding properties before or after joining a channel. |
setAudioScenario(scenario) | You can set an application scenario before or after joining a channel. |
Refer to the following examples to choose the most appropriate settings for your application.
1-on-1 interactive teaching
This use-case requires ensuring call quality and smooth transmission. Add the following code to your project:
// Initialize the IRtcEngine instance with a specific audio application scenario
const engine = createAgoraRtcEngine();
engine.initialize({
appId,
...,
audioScenario: AudioScenarioType.AudioScenarioDefault,
});
// Define the audio encoding settings
engine.setAudioProfile(AudioProfileType.AudioProfileDefault);KTV
KTV generally requires high sound quality and good expressiveness for music and singing. Use the following code in your project:
// Initialize the IRtcEngine instance with a specific audio application scenario
const engine = createAgoraRtcEngine();
engine.initialize({
appId,
...,
audioScenario: AudioScenarioType.AudioScenarioDefault,
});
// Define the audio encoding settings
engine.setAudioProfile(AudioProfileType.AudioProfileMusicHighQuality);Voice radio
Voice radio generally uses professional audio equipment. It requires high sound quality and stereo. Use the following code in your project:
// Initialize the IRtcEngine instance with a specific audio application scenario
const engine = createAgoraRtcEngine();
engine.initialize({
appId,
...,
audioScenario: AudioScenarioType.AudioScenarioGameStreaming,
});
// Define the audio encoding settings
engine.setAudioProfile(AudioProfileType.AudioProfileMusicHighQualityStereo);Music teaching
This use-case requires high sound quality, and support for the transmission of speaker-played sound effects. Agora recommends the following settings:
// Initialize the IRtcEngine instance with a specific audio application scenario
const engine = createAgoraRtcEngine();
engine.initialize({
appId,
...,
audioScenario: AudioScenarioType.AudioScenarioDefault,
});
// Define the audio encoding settings
engine.setAudioProfile(AudioProfileType.AudioProfileMusicStandardStereo);Reference
This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.
For more audio settings, see Achieve high audio quality.
Frequently asked questions
Sample projects
Agora offers the following open-source sample projects for setting audio encoding properties and application scenario functions for your reference.
API reference
This article shows you how to use Video SDK to configure appropriate audio encoding properties and application scenarios in your app.
Understand the tech
Video SDK uses default encoding parameters and a default audio scenario that are suitable for most common applications. If the default settings do not meet your needs, refer to the examples in the implementation section to set appropriate audio encoding properties and an application scenario.
Prerequisites
Ensure that you have implemented the SDK quickstart in your project.
Implementation
This section shows you how to set audio encoding properties and application scenarios for common applications. You use the following APIs to configure audio encoding:
| API | Description |
|---|---|
initialize(context.audioScenario) | While initializing an RtcEngine instance, set up the audio application scenario. The default value is audioScenarioDefault. |
setAudioProfile(profile, scenario) | You can set audio encoding properties before or after joining a channel. |
setAudioScenario(scenario) | You can set an application scenario before or after joining a channel. |
Refer to the following examples to choose the most appropriate settings for your application.
1-on-1 interactive teaching
This use-case requires ensuring call quality and smooth transmission. Add the following code to your project:
// Initialize the IRtcEngine instance with a specific audio application scenario
RtcEngineContext context;
context.audioScenario = AudioScenarioType.audioScenarioDefault;
await rtcEngine.initialize(context);
// Define the audio encoding settings
await rtcEngine.setAudioProfile(AudioProfileType.audioProfileDefault);KTV
KTV generally requires high sound quality and good expressiveness for music and singing. Use the following code in your project:
// Initialize the IRtcEngine instance with a specific audio application scenario
RtcEngineContext context;
context.audioScenario = AudioScenarioType.audioScenarioGameStreaming;
await rtcEngine.initialize(context);
// Define the audio encoding settings
await rtcEngine.setAudioProfile(AudioProfileType.audioScenarioGameStreaming);Voice radio
Voice radio generally uses professional audio equipment. It requires high sound quality and stereo. Use the following code in your project:
// Initialize the IRtcEngine instance with a specific audio application scenario
RtcEngineContext context;
context.audioScenario = AudioProfileType.audioScenarioChorus;
await rtcEngine.initialize(context);
// Define the audio encoding settings
await rtcEngine.setAudioProfile(AudioProfileType.audioScenarioChorus);Music teaching
This use-case requires high sound quality, and support for the transmission of speaker-played sound effects. Agora recommends the following settings:
// Initialize the IRtcEngine instance with a specific audio application scenario
RtcEngineContext context;
context.audioScenario = AudioProfileType.audioScenarioMeeting;
await rtcEngine.initialize(context);
// Define the audio encoding settings
await rtcEngine.setAudioProfile(AudioProfileType.audioScenarioMeeting);Due to iOS system limitations, some audio routes cannot be recognized in call volume mode. Therefore, if you need to use an external sound card, it is recommended to set the audio application scene to the high-quality scenario audioScenarioGameStreaming(3). In this scenario, the SDK switches to media volume to address the issue.
Reference
This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.
For more audio settings, see Achieve high audio quality.
Frequently asked questions
API reference
This article shows you how to use Video SDK to configure appropriate audio encoding properties and application scenarios in your app.
Understand the tech
Video SDK uses default encoding parameters and a default audio scenario that are suitable for most common applications. If the default settings do not meet your needs, refer to the examples in the implementation section to set appropriate audio encoding properties and an application scenario.
Prerequisites
Ensure that you have implemented the SDK quickstart in your project.
Implementation
This section shows you how to set audio encoding properties and application scenarios for common applications. You use the following APIs to configure audio encoding:
| API | Description |
|---|---|
initialize(RtcEngineContext context) | While initializing an IRtcEngine instance, set up the audio application scenario. The default value is AudioScenarioDefault. |
setAudioProfile(profile) | You can set audio encoding properties before or after joining a channel. |
setAudioScenario(scenario) | You can set an application scenario before or after joining a channel. |
Refer to the following examples to choose the most appropriate settings for your application.
1-on-1 interactive teaching
This use-case requires ensuring call quality and smooth transmission. Add the following code to your project:
// Initialize the IRtcEngine instance with a specific audio application scenario
const engine = createAgoraRtcEngine();
engine.initialize({
appId,
...,
audioScenario: AudioScenarioType.AudioScenarioDefault,
});
// Define the audio encoding settings
engine.setAudioProfile(AudioProfileType.AudioProfileDefault);KTV
KTV generally requires high sound quality and good expressiveness for music and singing. Use the following code in your project:
// Initialize the IRtcEngine instance with a specific audio application scenario
const engine = createAgoraRtcEngine();
engine.initialize({
appId,
...,
audioScenario: AudioScenarioType.AudioScenarioDefault,
});
// Define the audio encoding settings
engine.setAudioProfile(AudioProfileType.AudioProfileMusicHighQuality);Voice radio
Voice radio generally uses professional audio equipment. It requires high sound quality and stereo. Use the following code in your project:
// Initialize the IRtcEngine instance with a specific audio application scenario
const engine = createAgoraRtcEngine();
engine.initialize({
appId,
...,
audioScenario: AudioScenarioType.AudioScenarioGameStreaming,
});
// Define the audio encoding settings
engine.setAudioProfile(AudioProfileType.AudioProfileMusicHighQualityStereo);Music teaching
This use-case requires high sound quality, and support for the transmission of speaker-played sound effects. Agora recommends the following settings:
// Initialize the IRtcEngine instance with a specific audio application scenario
const engine = createAgoraRtcEngine();
engine.initialize({
appId,
...,
audioScenario: AudioScenarioType.AudioScenarioDefault,
});
// Define the audio encoding settings
engine.setAudioProfile(AudioProfileType.AudioProfileMusicStandardStereo);Due to iOS system limitations, some audio routes cannot be recognized in call volume mode. Therefore, if you need to use an external sound card, it is recommended to set the audio application scene to the high-quality scenario AudioScenarioGameStreaming(3). In this scenario, the SDK switches to media volume to address the issue.
Reference
This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.
For more audio settings, see Achieve high audio quality.
Frequently asked questions
API reference
This article shows you how to use Video SDK to configure appropriate audio encoding properties and application scenarios in your game.
Understand the tech
Video SDK uses default encoding parameters and a default audio scenario that are suitable for most common applications. If the default settings do not meet your needs, refer to the examples in the implementation section to set appropriate audio encoding properties and an application scenario.
Prerequisites
Ensure that you have implemented the SDK quickstart in your project.
Implementation
This section shows you how to set audio encoding properties and application scenarios for common applications. You use the following APIs to configure audio encoding:
| API | Description |
|---|---|
Initialize(RtcEngineContext context) | While initializing an IRtcEngine instance, set up the audio application scenario. The default value is AUDIO_SCENARIO_DEFAULT. |
SetAudioProfile(profile) | You can set audio encoding properties before or after joining a channel. |
SetAudioScenario(scenario) | You can set an application scenario before or after joining a channel. |
Refer to the following examples to choose the most appropriate settings for your application.
1-on-1 interactive teaching
This use-case requires ensuring call quality and smooth transmission. Add the following code to your project:
// Initialize the IRtcEngine instance with a specific audio application scenario
RtcEngineContext context = new RtcEngineContext();
context.audioScenario = AUDIO_SCENARIO_TYPE.AUDIO_SCENARIO_DEFAULT;
RtcEngine.Initialize(context);
// Define the audio encoding settings
RtcEngine.SetAudioProfile(AUDIO_PROFILE_TYPE.AUDIO_PROFILE_DEFAULT);KTV
KTV generally requires high sound quality and good expressiveness for music and singing. Use the following code in your project:
// Initialize the IRtcEngine instance with a specific audio application scenario
RtcEngineContext context = new RtcEngineContext();
context.audioScenario = AUDIO_SCENARIO_TYPE.AUDIO_SCENARIO_GAME_STREAMING;
RtcEngine.Initialize(context);
// Define the audio encoding settings
RtcEngine.SetAudioProfile(AUDIO_PROFILE_TYPE.AUDIO_PROFILE_MUSIC_HIGH_QUALITY);Voice radio
Voice radio generally uses professional audio equipment. It requires high sound quality and stereo. Use the following code in your project:
// Initialize the IRtcEngine instance with a specific audio application scenario
RtcEngineContext context = new RtcEngineContext();
context.audioScenario = AUDIO_SCENARIO_TYPE.AUDIO_SCENARIO_GAME_STREAMING;
RtcEngine.Initialize(context);
// Define the audio encoding settings
RtcEngine.SetAudioProfile(AUDIO_PROFILE_TYPE.AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO);Music teaching
This use-case requires high sound quality, and support for the transmission of speaker-played sound effects. Agora recommends the following settings:
// Initialize the IRtcEngine instance with a specific audio application scenario
RtcEngineContext context = new RtcEngineContext();
context.audioScenario = AUDIO_SCENARIO_TYPE.AUDIO_SCENARIO_GAME_STREAMING;
RtcEngine.Initialize(context);
// Define the audio encoding settings
RtcEngine.SetAudioProfile(AUDIO_PROFILE_TYPE.AUDIO_PROFILE_MUSIC_STANDARD_STEREO);Due to iOS system limitations, some audio routes cannot be recognized in call volume mode. Therefore, if you need to use an external sound card, it is recommended to set the audio application scene to the high-quality scenario AUDIO_SCENARIO_GAME_STREAMING(3). In this scenario, the SDK switches to media volume to address the issue.
Reference
This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.
For more audio settings, see Achieve high audio quality.
Frequently asked questions
API reference
This article shows you how to use Video SDK to configure appropriate audio encoding properties and application scenarios in your game.
Understand the tech
Video SDK uses default encoding parameters and a default audio scenario that are suitable for most common applications. If the default settings do not meet your needs, refer to the examples in the implementation section to set appropriate audio encoding properties and an application scenario.
Prerequisites
Ensure that you have implemented the SDK quickstart in your project.
Implementation
This section shows you how to set audio encoding properties and application scenarios for common applications. You use the following APIs to configure audio encoding:
| API | Description |
|---|---|
initialize(context.audioScenario) | While initializing an IRtcEngine instance, set up the audio application scenario. The default value is AUDIO_SCENARIO_DEFAULT. |
setAudioProfile(profile) | You can set audio encoding properties before or after joining a channel. |
setAudioScenario | You can set an application scenario before or after joining a channel. |
Refer to the following examples to choose the most appropriate settings for your application.
1-on-1 Interactive teaching
This use-case requires ensuring call quality and smooth transmission. Add the following code to your project:
// Initialize the IRtcEngine instance with a specific audio application scenario
RtcEngineContext context;
context.audioScenario = AUDIO_SCENARIO_DEFAULT;
m_rtcEngine->initialize(context);
// Define the audio encoding settings
m_rtcEngine->setAudioProfile(AUDIO_PROFILE_DEFAULT);KTV
KTV generally requires high sound quality and good expressiveness for music and singing. Use the following code in your project:
// Initialize the IRtcEngine instance with a specific audio application scenario
RtcEngineContext context;
context.audioScenario = AUDIO_SCENARIO_GAME_STREAMING;
m_rtcEngine->initialize(context);
// Define the audio encoding settings
m_rtcEngine->setAudioProfile(AUDIO_PROFILE_MUSIC_HIGH_QUALITY);Voice radio
Voice radio generally uses professional audio equipment. It requires high sound quality and stereo. Use the following code in your project:
// Initialize the IRtcEngine instance with a specific audio application scenario
RtcEngineContext context;
context.audioScenario = AUDIO_SCENARIO_GAME_STREAMING;
m_rtcEngine->initialize(context);
// Define the audio encoding settings
m_rtcEngine->setAudioProfile(AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO);Music teaching
This use-case requires high sound quality, and support for the transmission of speaker-played sound effects. Agora recommends the following settings:
// Initialize the IRtcEngine instance with a specific audio application scenario
RtcEngineContext context;
context.audioScenario = AUDIO_SCENARIO_GAME_STREAMING;
m_rtcEngine->initialize(context);
// Define the audio encoding settings
m_rtcEngine->setAudioProfile(AUDIO_PROFILE_MUSIC_STANDARD_STEREO);Due to iOS system limitations, some audio routes cannot be recognized in call volume mode. Therefore, if you need to use an external sound card, it is recommended to set the audio application scene to the high-quality scenario AUDIO_SCENARIO_GAME_STREAMING(3). In this scenario, the SDK switches to media volume to address the issue.
Reference
This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.
For more audio settings, see Achieve high audio quality.
Frequently asked questions
Sample projects
Agora offers an open-source sample project for your reference.
API reference
This article shows you how to use Video SDK to configure appropriate audio encoding properties and application scenarios in your game.
Understand the tech
Video SDK uses default encoding parameters and a default audio scenario that are suitable for most common applications. If the default settings do not meet your needs, refer to the examples in the implementation section to set appropriate audio encoding properties and an application scenario.
Prerequisites
Ensure that you have implemented the SDK quickstart in your project.
Implementation
This section shows you how to set audio encoding properties and application scenarios for common applications. You use the following APIs to configure audio encoding:
| API | Description |
|---|---|
Initialize(context.audioScenario) | While initializing an IRtcEngine instance, set up the audio application scenario. The default value is AUDIO_SCENARIO_DEFAULT. |
SetAudioProfile(profile, scenario) | You can set audio encoding properties before or after joining a channel. |
SetAudioScenario | You can set an application scenario before or after joining a channel. |
Set audio encoding properties
This subsection describes how to call SetAudioProfile to set audio encoding properties.
- Create UMG
Create a ComboBoxString (dropdown list) widget, named CBS_Audio_Profile, where you can select the audio encoding properties as needed. The default option is AUDIO_PROFILE_DEFAULT, with other options detailed in EAUDIO_PROFILE_TYPE, as shown in the image below:
- Bind UI event
Create a Bind Event to On Selection Changed node, connecting the CBS_Audio_Profile widget and the OnSetAudioProfile callback. Selecting different audio encoding properties in the CBS_Audio_Profile dropdown list triggers the OnSetAudioProfile callback, as shown in the image below:
- Implement callback function
Create the OnSetAudioProfile callback function, configuring the following parameters:
| Input parameter | Data type | Parameter description |
|---|---|---|
SelectedItem | String | The selected audio encoding property option. |
SelectionType | Enum | The type of selection information, see ESelectInfo. |
When this callback is triggered, the selected audio encoding property is passed into SetAudioProfile as a profile parameter, and the method is executed to complete the setting, as shown in the image below:
Set up audio application scenarios
This subsection explains how to call SetAudioScenario to set audio application scenarios.
- Create UMG
Create a ComboBoxString (dropdown list) widget, named CBS_Audio_Scenario, where you select the audio application scenarios as needed. The default option is AUDIO_SCENARIO_DEFAULT, with other options detailed in EAUDIO_SCENARIO_TYPE, as shown in the image below:
- Bind UI Event
Create a Bind Event to On Selection Changed node, connecting the CBS_Audio_Scenario widget and the OnSetAudioScenario callback. Selecting different audio application scenarios in the CBS_Audio_Scenario dropdown list triggers the OnSetAudioScenario callback, as shown in the image below:
- Implement callback function
Create the OnSetAudioScenario callback function, configuring the following parameters:
| Input Parameter | Data Type | Parameter Description |
|---|---|---|
SelectedItem | String | The selected audio encoding property option. |
SelectionType | Enum | The type of selection information, see ESelectInfo. |
When this callback is triggered, the selected audio application scenario is passed to SetAudioScenario as scenario parameter, and the method is executed to complete the setting, as shown in the image below:
Recommended settings
The recommended settings for audio encoding properties and audio application scenarios for common applications are as follows:
| Common applications | Audio encoding properties | Audio application scenario |
|---|---|---|
| 1-on-1 interactive teaching: Requires ensuring call quality and smooth transmission. | AUDIO_PROFILE_DEFAULT | AUDIO_SCENARIO_DEFAULT |
| KTV: Requires high sound quality and good music and vocal performance. | AUDIO_PROFILE_MUSIC_HIGH_QUALITY | AUDIO_SCENARIO_GAME_STREAMING |
| Voice radio: Typically uses professional audio equipment. Requires high sound quality and stereo. | AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO | AUDIO_SCENARIO_GAME_STREAMING |
| Music teaching: Requires high sound quality and support for the transmission of speaker-played sound effects to the remote end. | AUDIO_PROFILE_MUSIC_STANDARD_STEREO | AUDIO_SCENARIO_GAME_STREAMING |
Due to iOS system limitations, some audio routes cannot be recognized in call volume mode. Therefore, if you need to use an external sound card, it is recommended to set the audio application scene to the high-quality scenario AUDIO_SCENARIO_GAME_STREAMING(3). In this scenario, the SDK switches to media volume to address the issue.
Reference
This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.
For more audio settings, see Achieve high audio quality.
Frequently asked questions
Sample projects
Agora offers the following open-source sample projects for setting audio encoding properties and application scenario functions for your reference.
