Introduction

High-fidelity audio is essential for professional audio scenarios, such as for podcasts and singing competitions. For example, podcasts require stereo and high-fidelity audio. High-fidelity audio refers to an audio profile with a sample rate of 48 Hz and a bitrate of 192 Kbps.

To obtain high-fidelity audio during real-time communications, you can choose the appropriate audio profile based on the audio quality, channel, and scenario.

Implementation

Before setting the audio profile, ensure that you have implemented the basic real-time communication functions in your project. For details, see Start a Call or Start a Live Broadcast.

The Agora SDK provides the setAudioProfile method to set the appropriate audio profile according to the scenario. This method has two parameters:

Parameters Description
profile Sets the sample rate, bitrate, encoding mode, and the number of channels.
  • AgoraAudioProfileDefault(0): The default audio profile. In the Communication profile, the default value is AgoraAudioProfileSpeechStandard(1). In the Live-broadcast profile, the default value is AgoraAudioProfileMusicStandard(2).
  • AgoraAudioProfileSpeechStandard(1): A sample rate of 32 kHz, audio encoding, mono, and a bitrate of up to 18 Kbps.
  • AgoraAudioProfileMusicStandard(2): A sample rate of 48 kHz, music encoding, mono, and a bitrate of up to 48 Kbps.
  • AgoraAudioProfileMusicStandardStereo(3): A sample rate of 48 kHz, music encoding, stereo, and a bitrate of up to 56 Kbps.
  • AgoraAudioProfileMusicHighQuality(4): A sample rate of 48 kHz, music encoding, mono, and a bitrate of up to 128 Kbps.
  • AgoraAudioProfileMusicHighQualityStereo(5): A sample rate of 48 kHz, music encoding, stereo, and a bitrate of up to 192 Kbps.
  • scenario Sets the audio scenario. For example, entertainment, education, or live gaming. The Agora SDK optimizes the noise control and audio quality based on the scenarios.
  • AgoraAudioScenarioDefault(0): The default scenario.
  • AgoraAudioScenarioChatRoomEntertainment(1): The entertainment scenario, supporting voice during gameplay.
  • AgoraAudioScenarioEducation(2): The education scenario, prioritizing smoothness and stability.
  • AgoraAudioScenarioGameStreaming(3): The live gaming scenario, enabling the gaming audio effects in the speaker mode in a live broadcast scenario. Choose this scenario for high-fidelity music playback.
  • AgoraAudioScenarioShowRoom(4): The showroom scenario, optimizing the audio quality with external professional equipment.
  • AgoraAudioScenarioChatRoomGaming(5): The gaming scenario.
  • API call sequence

    The following diagram shows how to set the audio profile:

    Parameters and applications

    You can set the profile and scenario parameters based on the requirements of different applications, such as the audio quality and the audio player.

    Parameters Applications Options
    profile High-fidelity audio
  • MusicHighQuality
  • MusicHighQualityStereo
  • Standard audio
  • MusicStandard
  • MusicStandardStereo
  • No requirement for audio quality
  • Default
  • SpeechStandard
  • scenario Prioritize the audio quality and effects GameStreaming
    Frequently mute/unmute the microphone ChatRoomEntertainment
    External audio player ShowRoom
    Gaming noise reduction ChatRoomGaming
    Stable transmission quality Default

    You can also set the profile and scenario parameters based on different applications.

    Applications profile scenario Features
    One-to-one classroom Default Default Prioritizes the call quality with smooth transmission and high-fidelity audio.
    Battle royale game SpeechStandard ChatRoomGaming Noise reduction and transmits the voice only. Reduces the transmission rate and suitable for multiplayer games.
    Murder mystery game MusicStandard ChatRoomEntertainment High-fidelity audio encoding and decoding. No volume or audio quality change when you mute/unmute the microphone.
    KTV MusicHighQuality GameStreaming High-fidelity audio and effects. Adapts to the high-fidelity audio application.
    Podcast MusicHighQualityStereo ShowRoom High-fidelity audio and stereo panning. Support for professional audio hardware.
    Music education MusicStandardStereo GameStreaming Prioritizes audio quality. Suitable for transmitting live external audio effects.
    Collaborative teaching MusicStandardStereo ChatRoomEntertainment High-fidelity audio and effects. No volume or audio quality change when you mute/unmute the microphone.

    Sample code

    // swift
    // Gaming
    agoraKit.setAudioProfile(.speechStandard, scenario: .chatRoomGaming)
    // Entertainment
    agoraKit.setAudioProfile(.musicStandard, scenario: .chatRoomEntertainment)
    // KTV
    agoraKit.setAudioProfile(.musicHighQuality, scenario: .chatRoomEntertainment)
    // FM high-fidelity
    agoraKit.setAudioProfile(.musicHighQuality, scenario: .gameStreaming)
    // objective-c
    // Gaming
    [agoraKit setAudioProfile: AgoraAudioProfileSpeechStandard scenario: AgoraAudioScenarioChatRoomGaming];
    // Entertainment
    [agoraKit setAudioProfile: AgoraAudioProfilemusicStandard, scenario: AgoraAudioScenarioChatRoomEntertainment];
    // KTV
    [agoraKit setAudioProfile: AgoraAudioProfileMusicHighQuality, scenario: AgoraAudioScenarioChatRoomEntertainment];
    // FM high-fidelity
    [agoraKit setAudioProfile: AgoraAudioProfilemusicHighQuality, scenario: AgoraAudioScenarioGameStreaming]

    API reference

    Considerations

    Call this method before calling the joinChannelByToken method.

    When you set the volume of a device, you can set either the in-call volume or the media volume.

    • You can set the in-call volume during an audio or video call.
    • You can set the media volume when you play video, games, or background music.

    The differences between the two types of volumes are as follows:

    • The in-call volume features acoustic echo cancellation, and should always be set above 0.
    • The media volume features a higher audio quality, and can be set as 0.

    The audio scenarios in the setAudioProfile method use different volume settings.

    Audio scenario Volume setting
    GameStreaming All users use the media volume.
    Default
  • In the Communication profile, all users use the in-call volume.
  • In the Live-broadcast profile, the hosts use the in-call volume, while the audience use the media volume.
  • Education
    ShowRoom
    ChatRoomEntertainment All users use the in-call volume.
    ChatRoomGaming All users use the in-call volume.

    Given the system restrictions, the media volume can be set as 0, but not the in-call volume. Therefore, if you want to adjust the volume to 0, ensure that you set an audio scenario that uses the media volume.