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 explains how to set audio encoding properties and application scenarios for common applications.

APIDescription
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.
setAudioScenarioAudio 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