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 AgoraAudioProfileDefault
profile and the AgoraAudioScenarioDefault
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 |
---|---|
sharedEngineWithConfig(config.audioScenario) |
Sets the audio scenario when you create the AgoraRtcEngineKit instance. The default value is AgoraAudioScenarioDefault . |
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 ViewController.swift
of your project.
AgoraAudioScenarioChatRoom
scenario applies to iOS only.For the one-to-one classroom that requires the call quality with smooth transmission, add the following code to your project:
// Swift
// Set the audio scenario when you create the AgoraRtcEngineKit instance
var audioScenario:AgoraAudioScenario = .default
config.audioScenario = audioScenario
agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
// Set the audio profile
var audioProfile:AgoraAudioProfile = .default
agoraKit.setAudioProfile(audioProfile)
This scenario mainly requires voice clarity, no noise, and a lower bitrate. Agora recommends the following settings:
// Swift
// Set the audio scenario when you create the AgoraRtcEngineKit instance
var audioScenario:AgoraAudioScenario = .chatRoom
config.audioScenario = audioScenario
agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
// Set the audio profile
var audioProfile:AgoraAudioProfile = .speechStandard
agoraKit.setAudioProfile(audioProfile)
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:
// Swift
// Set the audio scenario when you create the AgoraRtcEngineKit instance
var audioScenario:AgoraAudioScenario = .chatRoom
config.audioScenario = audioScenario
agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
// Set the audio profile
var audioProfile:AgoraAudioProfile = .musicStandard
agoraKit.setAudioProfile(audioProfile)
For the KTV that requires high-fidelity audio and a high performance to music or singing voice, add the following code to your project:
// Swift
// Set the audio scenario when you create the AgoraRtcEngineKit instance
var audioScenario:AgoraAudioScenario = .highdefinition
config.audioScenario = audioScenario
agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
// Set the audio profile
var audioProfile:AgoraAudioProfile = .musichighquality
agoraKit.setAudioProfile(audioProfile)
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:
// Swift
// Set the audio scenario when you create the AgoraRtcEngineKit instance
var audioScenario:AgoraAudioScenario = .highdefinition
config.audioScenario = audioScenario
agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
// Set the audio profile
var audioProfile:AgoraAudioProfile = .musichighqualitystereo
agoraKit.setAudioProfile(audioProfile)
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:
// Swift
// Set the audio scenario when you create the AgoraRtcEngineKit instance
var audioScenario:AgoraAudioScenario = .highdefinition
config.audioScenario = audioScenario
agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
// Set the audio profile
var audioProfile:AgoraAudioProfile = .musicStandardStereo
agoraKit.setAudioProfile(audioProfile)
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:
// Swift
// Set the audio scenario when you create the AgoraRtcEngineKit instance
var audioScenario:AgoraAudioScenario = .chatRoom
config.audioScenario = audioScenario
agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
// Set the audio profile
var audioProfile:AgoraAudioProfile = .musicStandardStereo
agoraKit.setAudioProfile(audioProfile)
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.
On iOS, 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 AgoraAudioScenarioDefault
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 AgoraAudioScenarioHighDefinition
, AgoraAudioScenarioGameStreaming
, or AgoraAudioScenarioChorus
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 AgoraAudioScenarioChatRoom
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 |