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

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.
  • AUDIO_PROFILE_DEFAULT(0): The default audio profile. In the Communication profile, the default value is AUDIO_PROFILE_SPEECH_STANDARD(1). In the Live-broadcast profile, the default value is AUDIO_PROFILE_MUSIC_STANDARD(2).
  • AUDIO_PROFILE_SPEECH_STANDARD(1): A sample rate of 32 kHz, audio encoding, mono, and a bitrate of up to 18 Kbps.
  • AUDIO_PROFILE_MUSIC_STANDARD(2): A sample rate of 48 kHz, music encoding, mono, and a bitrate of up to 48 Kbps.
  • AUDIO_PROFILE_MUSIC_STANDARD_STEREO(3): A sample rate of 48 kHz, music encoding, stereo, and a bitrate of up to 56 Kbps.
  • AUDIO_PROFILE_MUSIC_HIGH_QUALITY(4): A sample rate of 48 kHz, music encoding, mono, and a bitrate of up to 128 Kbps.
  • AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(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.
  • AUDIO_SCENARIO_DEFAULT(0): The default scenario.
  • AUDIO_SCENARIO_CHATROOM_ENTERTAINMENT(1): The entertainment scenario, supporting voice during gameplay.
  • AUDIO_SCENARIO_EDUCATION(2): The education scenario, prioritizing smoothness and stability.
  • AUDIO_SCENARIO_GAME_STREAMING(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.
  • AUDIO_SCENARIO_SHOWROOM(4): The showroom scenario, optimizing the audio quality with external professional equipment.
  • AUDIO_SCENARIO_CHATROOM_GAMING(5): The gaming scenario.
  • 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
  • MUSIC_HIGH_QUALITY
  • MUSIC_HIGH_QUALITY_STEREO
  • Standard audio
  • MUSIC_STANDARD
  • MUSIC_STANDARD_STEREO
  • No requirement for audio quality
  • DEFAULT
  • SPEECH_STANDARD
  • scenario Prioritize the audio quality and effects GAME_STREAMING
    Frequently mute/unmute the microphone CHATROOM_ENTERTAINMENT
    External audio player SHOWROOM
    Gaming noise reduction CHATROOM_GAMING
    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 SPEECH_STANDARD CHATROOM_GAMING Noise reduction and transmits the voice only. Reduces the transmission rate and suitable for multiplayer games.
    Murder mystery game MUSIC_STANDARD CHATROOM_
    ENTERTAINMENT
    High-fidelity audio encoding and decoding. No volume or audio quality change when you mute/unmute the microphone.
    KTV MUSIC_HIGH_
    QUALITY
    GAME_STREAMING High-fidelity audio and effects. Adapts to the high-fidelity audio application.
    Podcast MUSIC_HIGH_
    QUALITY_STEREO
    SHOWROOM High-fidelity audio and stereo panning. Support for professional audio hardware.
    Music education MUSIC_STANDARD_
    STEREO
    GAME_STREAMING Prioritizes audio quality. Suitable for transmitting live external audio effects.
    Collaborative teaching MUSIC_STANDARD_
    STEREO
    CHATROOM_
    ENTERTAINMENT
    High-fidelity audio and effects. No volume or audio quality change when you mute/unmute the microphone.

    Sample Code

    // FM high-fidelity
    rtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO, Constants.AUDIO_SCENARIO_SHOWROOM);
    
    // Gaming
    rtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_SPEECH_STANDARD, Constants.AUDIO_SCENARIO_CHATROOM_GAMING);
    
    // Entertainment
    rtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_STANDARD, Constants.AUDIO_SCENARIO_CHATROOM_ENTERTAINMENT);
    
    // KTV
    rtcEngine.setAudioProfile(Constants.AUDIO_AUDIO_PROFILE_MUSIC_HIGH_QUALITY, Constants.AUDIO_SCENARIO_CHATROOM_ENTERTAINMENT);

    API Reference

    Considerations

    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
    GAME_STREAMING 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
    CHATROOM_ENTERTAINMENT All users use the in-call volume.
    CHATROOM_GAMING 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.