Skip to main content
Android
iOS
macOS
Web
Windows
Electron
Flutter
React Native
React JS
Unity
Unreal Engine
Unreal (Blueprint)

Configure audio encoding

Audio quality requirements vary with application scenario. For example. in professional scenarios 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:

APIDescription
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 scenario 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);
Copy

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);
Copy

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);
Copy

Music teaching

This scenario 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);
Copy
Information

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​

vundefined