# Configure audio encoding (/en/realtime-media/broadcast-streaming/build/control-audio-and-devices/configure-audio-encoding)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

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.

<_PlatformTabsGroup groupMode="structured" canonicalPlatform="web" platforms="[&#x22;android&#x22;,&#x22;ios&#x22;,&#x22;macos&#x22;,&#x22;web&#x22;,&#x22;windows&#x22;,&#x22;electron&#x22;,&#x22;flutter&#x22;,&#x22;react-native&#x22;,&#x22;unity&#x22;,&#x22;unreal&#x22;,&#x22;blueprint&#x22;]" showTabs="true">
  <_PlatformPanel platform="android">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="android" />

    This article shows you how to use Video SDK to configure appropriate audio encoding properties and application scenarios in your app.

    ## Understand the tech [#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 [#prerequisites]

    Ensure that you have implemented the [SDK quickstart](../../index) in your project.

    ## Implementation [#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:

    | API                             | Description                                                                                                                |
    | :------------------------------ | :------------------------------------------------------------------------------------------------------------------------- |
    | `create(config.mAudioScenario)` | While creating an `RtcEngine` instance, set the audio application scenario. The default value is `AUDIO_SCENARIO_DEFAULT`. |
    | `setAudioProfile(profile)`      | You can set audio encoding properties before or after joining a channel.                                                   |
    | `setAudioScenario`              | 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 [#1-on-1-interactive-teaching]

    This use-case requires ensuring call quality and smooth transmission. Add the following code to your project:

    <CodeBlockTabs defaultValue="java">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="java">
          Java
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="kotlin">
          Kotlin
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="java">
        ```java
        // Create the RtcEngine instance with a specific audio application scenario
        config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.DEFAULT);
        engine = RtcEngine.create(config);

        // Define the audio encoding settings
        RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_DEFAULT);
        ```
      </CodeBlockTab>

      <CodeBlockTab value="kotlin">
        ```kotlin
        // Create the RtcEngine instance with a specific audio application scenario
        config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.DEFAULT)
        engine = RtcEngine.create(config)

        // Define the audio encoding settings
        RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_DEFAULT)
        ```
      </CodeBlockTab>
    </CodeBlockTabs>

    ### Gaming voice chat [#gaming-voice-chat]

    This use-case requires the transmission of clear human voice with minimal background noise and at a low bitrate. Agora recommends the following settings:

    <CodeBlockTabs defaultValue="java">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="java">
          Java
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="kotlin">
          Kotlin
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="java">
        ```java
        // Create the RtcEngine instance with a specific audio application scenario
        config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.CHATROOM);
        engine = RtcEngine.create(config);

        // Define the audio encoding settings
        RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_SPEECH_STANDARD);
        ```
      </CodeBlockTab>

      <CodeBlockTab value="kotlin">
        ```kotlin
        // Create the RtcEngine instance with a specific audio application scenario
        config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.CHATROOM)
        engine = RtcEngine.create(config)

        // Define the audio encoding settings
        RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_SPEECH_STANDARD)
        ```
      </CodeBlockTab>
    </CodeBlockTabs>

    ### Scripted role play [#scripted-role-play]

    This use-case requires good sound expression, and no volume or sound quality change when switching microphones. Agora recommends the following settings:

    <CodeBlockTabs defaultValue="java">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="java">
          Java
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="kotlin">
          Kotlin
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="java">
        ```java
        // Create the RtcEngine instance with a specific audio application scenario
        config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.CHATROOM);
        engine = RtcEngine.create(config);

        // Define the audio encoding settings
        RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_STANDARD);
        ```
      </CodeBlockTab>

      <CodeBlockTab value="kotlin">
        ```kotlin
        // Create the RtcEngine instance with a specific audio application scenario
        config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.CHATROOM)
        engine = RtcEngine.create(config)

        // Define the audio encoding settings
        RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_STANDARD)
        ```
      </CodeBlockTab>
    </CodeBlockTabs>

    ### KTV [#ktv]

    KTV generally requires high sound quality and good expressiveness for music and singing. Use the following code in your project:

    <CodeBlockTabs defaultValue="java">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="java">
          Java
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="kotlin">
          Kotlin
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="java">
        ```java
        // Create the RtcEngine instance with a specific audio application scenario
        config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.GAME_STREAMING);
        engine = RtcEngine.create(config);

        // Define the audio encoding settings
        RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_HIGH_QUALITY);
        ```
      </CodeBlockTab>

      <CodeBlockTab value="kotlin">
        ```kotlin
        // Create the RtcEngine instance with a specific audio application scenario
        config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.GAME_STREAMING)
        engine = RtcEngine.create(config)

        // Define the audio encoding settings
        RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_HIGH_QUALITY)
        ```
      </CodeBlockTab>
    </CodeBlockTabs>

    ### Voice radio [#voice-radio]

    Voice radio generally uses professional audio equipment. It requires high sound quality and stereo. Use the following code in your project:

    <CodeBlockTabs defaultValue="java">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="java">
          Java
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="kotlin">
          Kotlin
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="java">
        ```java
        // Create the RtcEngine instance with a specific audio application scenario
        config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.GAME_STREAMING);
        engine = RtcEngine.create(config);

        // Set the required audio encoding properties
        RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO);
        ```
      </CodeBlockTab>

      <CodeBlockTab value="kotlin">
        ```kotlin
        // Create the RtcEngine instance with a specific audio application scenario
        config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.GAME_STREAMING)
        engine = RtcEngine.create(config)

        // Set the required audio encoding properties
        RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO)
        ```
      </CodeBlockTab>
    </CodeBlockTabs>

    ### Music teaching [#music-teaching]

    This use-case requires high sound quality, and support for the transmission of speaker-played sound effects. Agora recommends the following settings:

    <CodeBlockTabs defaultValue="java">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="java">
          Java
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="kotlin">
          Kotlin
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="java">
        ```java
        // Create the RtcEngine instance with a specific audio application scenario
        config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.GAME_STREAMING);
        engine = RtcEngine.create(config);

        // Define the audio encoding settings
        RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_STANDARD_STEREO);
        ```
      </CodeBlockTab>

      <CodeBlockTab value="kotlin">
        ```kotlin
        // Create the RtcEngine instance with a specific audio application scenario
        config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.GAME_STREAMING)
        engine = RtcEngine.create(config)

        // Define the audio encoding settings
        RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_STANDARD_STEREO)
        ```
      </CodeBlockTab>
    </CodeBlockTabs>

    ### Dual-teacher classroom [#dual-teacher-classroom]

    This use-case requires high sound quality with rich sound effects, and no volume or sound quality change when switching microphones. Agora recommends the following settings:

    <CodeBlockTabs defaultValue="java">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="java">
          Java
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="kotlin">
          Kotlin
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="java">
        ```java
        // Create the RtcEngine instance with a specific audio application scenario
        config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.CHATROOM);
        engine = RtcEngine.create(config);

        // Define the audio encoding settings
        RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_STANDARD_STEREO);
        ```
      </CodeBlockTab>

      <CodeBlockTab value="kotlin">
        ```kotlin
        // Create the RtcEngine instance with a specific audio application scenario
        config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.CHATROOM)
        engine = RtcEngine.create(config)

        // Define the audio encoding settings
        RtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_STANDARD_STEREO)
        ```
      </CodeBlockTab>
    </CodeBlockTabs>

    ## Reference [#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](/en/realtime-media/video/build/enhance-the-audio-experience/best-practices-sound-quality).

    ### Frequently asked questions [#frequently-asked-questions]

    * [What is the difference between the in-call volume and the media volume?](/en/api-reference/faq/integration/system_volume)

    ### Sample projects [#sample-projects]

    Agora offers the following open-source sample project for setting audio encoding properties and application scenario for your reference.

    * [JoinChannelAudio](https://github.com/AgoraIO/API-Examples/blob/main/Android/APIExample/app/src/main/java/io/agora/api/example/examples/basic/JoinChannelAudio.java)

    ### API reference [#api-reference]

    * [`create` \[2/2\]](https://api-ref.agora.io/en/video-sdk/android/4.x/API/class_irtcengine.html#api_irtcengine_initialize)
    * [`setAudioProfile` \[2/2\]](https://api-ref.agora.io/en/video-sdk/android/4.x/API/class_irtcengine.html#api_irtcengine_setaudioprofile2)
    * [`setAudioScenario`](https://api-ref.agora.io/en/video-sdk/android/4.x/API/class_irtcengine.html#api_irtcengine_setaudioscenario)

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="ios">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="ios" />

    This article shows you how to use Video SDK to configure appropriate audio encoding properties and application scenarios in your app.

    ## Understand the tech [#understand-the-tech-1]

    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 [#prerequisites-1]

    Ensure that you have implemented the [SDK quickstart](../../index) in your project.

    ## Implementation [#implementation-1]

    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:

    | API                                            | Description                                                                                                                                  |
    | :--------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------- |
    | `sharedEngineWithConfig(config.audioScenario)` | While creating an `AgoraRtcEngineKit` instance, set up the audio application scenario. The default value is `AgoraAudioScenarioHighDefault`. |
    | `setAudioProfile(profile)`                     | You can set audio encoding properties before or after joining a channel.                                                                     |
    | `setAudioScenario`                             | 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 [#1-on-1-interactive-teaching-1]

    This use-case requires ensuring call quality and smooth transmission. Add the following code to your project:

    ```swift
    // Create the AgoraRtcEngineKit instance with a specific audio application scenario
    var scenario:AgoraAudioScenario = .default
    config.audioScenario = audioScenario
    agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)

    // Define the audio encoding settings
    var profile:AgoraAudioProfile = .default
    agoraKit.setAudioProfile(audioProfile)
    ```

    ### Gaming voice chat [#gaming-voice-chat-1]

    This use-case requires the transmission of clear human voice with minimal background noise and at a low bitrate. Agora recommends the following settings:

    ```swift
    // Create the AgoraRtcEngineKit instance with a specific audio application scenario
    var scenario:AgoraAudioScenario = .chatRoom
    config.audioScenario = audioScenario
    agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)

    // Define the audio encoding settings
    var profile:AgoraAudioProfile = .speechStandard
    agoraKit.setAudioProfile(audioProfile)
    ```

    ### Scripted role play [#scripted-role-play-1]

    This use-case requires good sound expression, and no volume or sound quality change when switching microphones. Agora recommends the following settings:

    ```swift
    // Create the AgoraRtcEngineKit instance with a specific audio application scenario
    var scenario:AgoraAudioScenario = .chatRoom
    config.audioScenario = audioScenario
    agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)

    // Define the audio encoding settings
    var profile:AgoraAudioProfile = .musicStandard
    agoraKit.setAudioProfile(audioProfile)
    ```

    ### KTV [#ktv-1]

    KTV generally requires high sound quality and good expressiveness for music and singing. Use the following code in your project:

    ```swift
    // Create the AgoraRtcEngineKit instance with a specific audio application scenario
    var scenario:AgoraAudioScenario = .gameStreaming
    config.audioScenario = audioScenario
    agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)

    // Define the audio encoding settings
    var profile:AgoraAudioProfile = .musicHighQuality
    agoraKit.setAudioProfile(audioProfile)
    ```

    ### Voice radio [#voice-radio-1]

    Voice radio generally uses professional audio equipment. It requires high sound quality and stereo. Use the following code in your project:

    ```swift
    // Create the AgoraRtcEngineKit instance with a specific audio application scenario
    var scenario:AgoraAudioScenario = .gameStreaming
    config.audioScenario = audioScenario
    agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)

    // Set the required audio encoding properties
    var profile:AgoraAudioProfile = .musicHighQualityStereo
    agoraKit.setAudioProfile(audioProfile)
    ```

    ### Music teaching [#music-teaching-1]

    This use-case requires high sound quality, and support for the transmission of speaker-played sound effects. Agora recommends the following settings:

    ```swift
    // Create the AgoraRtcEngineKit instance with a specific audio application scenario
    var scenario:AgoraAudioScenario = .gameStreaming
    config.audioScenario = audioScenario
    agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)

    // Define the audio encoding settings
    var profile:AgoraAudioProfile = .musicStandardStereo
    agoraKit.setAudioProfile(audioProfile)
    ```

    ### Dual-teacher classroom [#dual-teacher-classroom-1]

    This use-case requires high sound quality with rich sound effects, and no volume or sound quality change when switching microphones. Agora recommends the following settings:

    ```swift
    // Create the AgoraRtcEngineKit instance with a specific audio application scenario
    var audioScenario:AgoraAudioScenario = .chatRoom
    config.audioScenario = audioScenario
    agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)

    // Define the audio encoding settings
    var profile:AgoraAudioProfile = .musicStandardStereo
    agoraKit.setAudioProfile(audioProfile)
    ```

    <CalloutContainer type="info">
      <CalloutDescription>
        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.
      </CalloutDescription>
    </CalloutContainer>

    ## Reference [#reference-1]

    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](/en/realtime-media/video/build/enhance-the-audio-experience/best-practices-sound-quality).

    ### Frequently asked questions [#frequently-asked-questions-1]

    * [What is the difference between the in-call volume and the media volume?](/en/api-reference/faq/integration/system_volume)

    ### Sample projects [#sample-projects-1]

    Agora offers the following open-source sample project for setting audio encoding properties and application scenario functions for your reference.

    * [JoinChannelAudio](https://github.com/AgoraIO/API-Examples/tree/main/iOS/APIExample/APIExample/Examples/Basic/JoinChannelAudio)

    ### API reference [#api-reference-1]

    * [`sharedEngine(with: config, delegate)`](https://api-ref.agora.io/en/video-sdk/ios/4.x/documentation/agorartckit/agorartcenginekit/sharedengine\(with\:delegate:\))
    * [`AgoraRtcEngineConfig`](https://api-ref.agora.io/en/video-sdk/ios/4.x/documentation/agorartckit/agorartcengineconfig)
    * [`setAudioProfile`](https://api-ref.agora.io/en/video-sdk/ios/4.x/documentation/agorartckit/agorartcenginekit/setaudioprofile\(_:\))
    * [`setAudioScenario`](https://api-ref.agora.io/en/video-sdk/ios/4.x/documentation/agorartckit/agorartcenginekit/setaudioscenario\(_:\))

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="macos">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="macos" />

    This article shows you how to use Video SDK to configure appropriate audio encoding properties and application scenarios in your app.

    ## Understand the tech [#understand-the-tech-2]

    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 [#prerequisites-2]

    Ensure that you have implemented the [SDK quickstart](../../index) in your project.

    ## Implementation [#implementation-2]

    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:

    | API                                            | Description                                                                                                                                  |
    | :--------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------- |
    | `sharedEngineWithConfig(config.audioScenario)` | While creating an `AgoraRtcEngineKit` instance, set up the audio application scenario. The default value is `AgoraAudioScenarioHighDefault`. |
    | `setAudioProfile(profile)`                     | You can set audio encoding properties before or after joining a channel.                                                                     |
    | `setAudioScenario`                             | 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 [#1-on-1-interactive-teaching-2]

    This use-case requires ensuring call quality and smooth transmission. Add the following code to your project:

    ```swift
    // Create the AgoraRtcEngineKit instance with a specific audio application scenario
    var scenario:AgoraAudioScenario = .default
    config.audioScenario = audioScenario
    agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)

    // Define the audio encoding settings
    var profile:AgoraAudioProfile = .default
    agoraKit.setAudioProfile(audioProfile)
    ```

    ### Gaming voice chat [#gaming-voice-chat-2]

    This use-case requires the transmission of clear human voice with minimal background noise and at a low bitrate. Agora recommends the following settings:

    ```swift
    // Create the AgoraRtcEngineKit instance with a specific audio application scenario
    var scenario:AgoraAudioScenario = .chatRoom
    config.audioScenario = audioScenario
    agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)

    // Define the audio encoding settings
    var profile:AgoraAudioProfile = .speechStandard
    agoraKit.setAudioProfile(audioProfile)
    ```

    ### Scripted role play [#scripted-role-play-2]

    This use-case requires good sound expression, and no volume or sound quality change when switching microphones. Agora recommends the following settings:

    ```swift
    // Create the AgoraRtcEngineKit instance with a specific audio application scenario
    var scenario:AgoraAudioScenario = .chatRoom
    config.audioScenario = audioScenario
    agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)

    // Define the audio encoding settings
    var profile:AgoraAudioProfile = .musicStandard
    agoraKit.setAudioProfile(audioProfile)
    ```

    ### KTV [#ktv-2]

    KTV generally requires high sound quality and good expressiveness for music and singing. Use the following code in your project:

    ```swift
    // Create the AgoraRtcEngineKit instance with a specific audio application scenario
    var scenario:AgoraAudioScenario = .gameStreaming
    config.audioScenario = audioScenario
    agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)

    // Define the audio encoding settings
    var profile:AgoraAudioProfile = .musicHighQuality
    agoraKit.setAudioProfile(audioProfile)
    ```

    ### Voice radio [#voice-radio-2]

    Voice radio generally uses professional audio equipment. It requires high sound quality and stereo. Use the following code in your project:

    ```swift
    // Create the AgoraRtcEngineKit instance with a specific audio application scenario
    var scenario:AgoraAudioScenario = .gameStreaming
    config.audioScenario = audioScenario
    agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)

    // Set the required audio encoding properties
    var profile:AgoraAudioProfile = .musicHighQualityStereo
    agoraKit.setAudioProfile(audioProfile)
    ```

    ### Music teaching [#music-teaching-2]

    This use-case requires high sound quality, and support for the transmission of speaker-played sound effects. Agora recommends the following settings:

    ```swift
    // Create the AgoraRtcEngineKit instance with a specific audio application scenario
    var scenario:AgoraAudioScenario = .gameStreaming
    config.audioScenario = audioScenario
    agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)

    // Define the audio encoding settings
    var profile:AgoraAudioProfile = .musicStandardStereo
    agoraKit.setAudioProfile(audioProfile)
    ```

    ### Dual-teacher classroom [#dual-teacher-classroom-2]

    This use-case requires high sound quality with rich sound effects, and no volume or sound quality change when switching microphones. Agora recommends the following settings:

    ```swift
    // Create the AgoraRtcEngineKit instance with a specific audio application scenario
    var audioScenario:AgoraAudioScenario = .chatRoom
    config.audioScenario = audioScenario
    agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)

    // Define the audio encoding settings
    var profile:AgoraAudioProfile = .musicStandardStereo
    agoraKit.setAudioProfile(audioProfile)
    ```

    ## Reference [#reference-2]

    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](/en/realtime-media/video/build/enhance-the-audio-experience/best-practices-sound-quality).

    ### Frequently asked questions [#frequently-asked-questions-2]

    * [What is the difference between the in-call volume and the media volume?](/en/api-reference/faq/integration/system_volume)

    ### Sample projects [#sample-projects-2]

    Agora offers the following open-source sample project for setting audio encoding properties and application scenario functions for your reference.

    * [JoinChannelAudio](https://github.com/AgoraIO/API-Examples/tree/main/macOS/APIExample/Examples/Basic/JoinChannelAudio)

    ### API reference [#api-reference-2]

    * [`sharedEngine(with: config, delegate)`](https://api-ref.agora.io/en/video-sdk/macos/4.x/documentation/agorartckit/agorartcenginekit/sharedengine\(with\:delegate:\))
    * [`AgoraRtcEngineConfig`](https://api-ref.agora.io/en/video-sdk/macos/4.x/documentation/agorartckit/agorartcengineconfig)
    * [`setAudioProfile`](https://api-ref.agora.io/en/video-sdk/macos/4.x/documentation/agorartckit/agorartcenginekit/setaudioprofile\(_:\))
    * [`setAudioScenario`](https://api-ref.agora.io/en/video-sdk/macos/4.x/documentation/agorartckit/agorartcenginekit/setaudioscenario\(_:\))

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="web">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="web" />

    This article shows you how to use Video SDK to configure appropriate audio encoding properties and application scenarios in your app.

    ## Understand the tech [#understand-the-tech-3]

    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 [#prerequisites-3]

    Ensure that you have implemented the [SDK quickstart](../../index) in your project.

    ## Implementation [#implementation-3]

    The Agora Web SDK offers the following three methods to create local audio tracks:

    * `createMicrophoneAudioTrack`
    * `createBufferSourceAudioTrack`
    * `createCustomAudioTrack`

    You can adjust the audio encoding configuration by modifying the `encoderConfig` parameter in these methods. `encoderConfig` supports the following two settings:

    * Use the audio encoding properties preset by the SDK.
    * A custom object with various audio encoding parameters.

    ### Using preset audio encoding properties [#using-preset-audio-encoding-properties]

    ```javascript
    AgoraRTC.createMicrophoneAudioTrack({
     encoderConfig: "high_quality_stereo",
    }).then(/**...**/);
    ```

    ### Customizing audio encoding properties [#customizing-audio-encoding-properties]

    ```javascript
    AgoraRTC.createMicrophoneAudioTrack({
     encoderConfig: {
      sampleRate: 48000,
      stereo: true,
      bitrate: 128,
     },
    }).then(/**...**/);
    ```

    ### Development considerations [#development-considerations]

    Set the audio encoding properties before calling the `AgoraRTCClient.publish` method to publish the audio track. Once the audio track is published, its audio encoding properties cannot be modified.

    ## Reference [#reference-3]

    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](/en/realtime-media/video/build/enhance-the-audio-experience/best-practices-sound-quality).

    ### Frequently asked questions [#frequently-asked-questions-3]

    * [What is the difference between the in-call volume and the media volume?](/en/api-reference/faq/integration/system_volume)

    ### API reference [#api-reference-3]

    * [`createMicrophoneAudioTrack`](https://api-ref.agora.io/en/video-sdk/web/4.x/interfaces/iagorartc.html#createmicrophoneaudiotrack)
    * [`createBufferSourceAudioTrack`](https://api-ref.agora.io/en/video-sdk/web/4.x/interfaces/iagorartc.html#createbuffersourceaudiotrack)
    * [`createCustomAudioTrack`](https://api-ref.agora.io/en/video-sdk/web/4.x/interfaces/iagorartc.html#createcustomaudiotrack)

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="windows">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="windows" />

    This article shows you how to use Video SDK to configure appropriate audio encoding properties and application scenarios in your app.

    ## Understand the tech [#understand-the-tech-4]

    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 [#prerequisites-4]

    Ensure that you have implemented the [SDK quickstart](../../index) in your project.

    ## Implementation [#implementation-4]

    This section explains how to set audio encoding properties and application scenarios for common applications.

    | API                                 | Description                                                                                                                        |
    | :---------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------- |
    | `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.                                                           |
    | `setAudioScenario`                  | Audio 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 [#1-on-1-interactive-teaching-3]

    The 1-to-1 interactive teaching use-case requires ensuring call quality and smooth transmission. Add the following code to your project:

    ```cpp
    // 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-3]

    KTV mainly requires high sound quality and good expressiveness for music and singing. Add the following code to your project:

    ```cpp
    // 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-3]

    Voice radio generally uses professional audio equipment, mainly requiring high sound quality and stereo. Add the following code to your project:

    ```cpp
    // 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 [#music-teaching-3]

    This use-case requires high sound quality, and support for the transmission of speaker-played sound effects. Agora recommends the following settings:

    ```cpp
    // 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 [#reference-4]

    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](/en/realtime-media/video/build/enhance-the-audio-experience/best-practices-sound-quality).

    ### Frequently asked questions [#frequently-asked-questions-4]

    * [What is the difference between the in-call volume and the media volume?](/en/api-reference/faq/integration/system_volume)

    ### Sample projects [#sample-projects-3]

    Agora offers the following open-source sample project for setting audio encoding properties and application scenario functions for your reference.

    * [AudioProfile](https://github.com/AgoraIO/API-Examples/tree/main/windows/APIExample/APIExample/Advanced/AudioProfile)

    ### API reference [#api-reference-4]

    * [`initialize`](https://api-ref.agora.io/en/video-sdk/cpp/4.x/API/class_irtcengine.html#api_irtcengine_initialize)
    * [`setAudioProfile` \[2/2\]](https://api-ref.agora.io/en/video-sdk/cpp/4.x/API/class_irtcengine.html#api_irtcengine_setaudioprofile2)
    * [`setAudioScenario`](https://api-ref.agora.io/en/video-sdk/cpp/4.x/API/class_irtcengine.html#api_irtcengine_setaudioscenario)

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="electron">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="electron" />

    This article shows you how to use Video SDK to configure appropriate audio encoding properties and application scenarios in your app.

    ## Understand the tech [#understand-the-tech-5]

    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 [#prerequisites-5]

    Ensure that you have implemented the [SDK quickstart](../../index) in your project.

    ## Implementation [#implementation-5]

    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:

    | API                                    | Description                                                                                                                      |
    | :------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------- |
    | `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 [#1-on-1-interactive-teaching-4]

    This use-case requires ensuring call quality and smooth transmission. Add the following code to your project:

    ```typescript
    // 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);
    ```

    ### KTV [#ktv-4]

    KTV generally requires high sound quality and good expressiveness for music and singing. Use the following code in your project:

    ```typescript
    // 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);
    ```

    ### Voice radio [#voice-radio-4]

    Voice radio generally uses professional audio equipment. It requires high sound quality and stereo. Use the following code in your project:

    ```typescript
    // 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);
    ```

    ### Music teaching [#music-teaching-4]

    This use-case requires high sound quality, and support for the transmission of speaker-played sound effects. Agora recommends the following settings:

    ```typescript
    // 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);
    ```

    ## Reference [#reference-5]

    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](/en/realtime-media/video/build/enhance-the-audio-experience/best-practices-sound-quality).

    ### Frequently asked questions [#frequently-asked-questions-5]

    * [What is the difference between the in-call volume and the media volume?](/en/api-reference/faq/integration/system_volume)

    ### Sample projects [#sample-projects-4]

    Agora offers the following open-source sample projects for setting audio encoding properties and application scenario functions for your reference.

    * [JoinChannelAudio](https://github.com/AgoraIO-Extensions/Electron-SDK/blob/main/example/src/renderer/examples/basic/JoinChannelAudio/JoinChannelAudio.tsx)

    ### API reference [#api-reference-5]

    * [`initialize`](https://api-ref.agora.io/en/video-sdk/electron/4.x/API/class_irtcengine.html#api_irtcengine_initialize)
    * [`setAudioProfile`](https://api-ref.agora.io/en/video-sdk/electron/4.x/API/class_irtcengine.html#api_irtcengine_setaudioprofile)
    * [`setAudioScenario`](https://api-ref.agora.io/en/video-sdk/electron/4.x/API/class_irtcengine.html#api_irtcengine_setaudioscenario)

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="flutter">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="flutter" />

    This article shows you how to use Video SDK to configure appropriate audio encoding properties and application scenarios in your app.

    ## Understand the tech [#understand-the-tech-6]

    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 [#prerequisites-6]

    Ensure that you have implemented the [SDK quickstart](../../index) in your project.

    ## Implementation [#implementation-6]

    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:

    | API                                  | Description                                                                                                                     |
    | :----------------------------------- | :------------------------------------------------------------------------------------------------------------------------------ |
    | `initialize(context.audioScenario)`  | While initializing an `RtcEngine` instance, set up the audio application scenario. The default value is `audioScenarioDefault`. |
    | `setAudioProfile(profile, scenario)` | 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 [#1-on-1-interactive-teaching-5]

    This use-case requires ensuring call quality and smooth transmission. Add the following code to your project:

    ```dart
    // Initialize the IRtcEngine instance with a specific audio application scenario
    RtcEngineContext context;
    context.audioScenario = AudioScenarioType.audioScenarioDefault;
    await rtcEngine.initialize(context);

    // Define the audio encoding settings
    await rtcEngine.setAudioProfile(AudioProfileType.audioProfileDefault);
    ```

    ### KTV [#ktv-5]

    KTV generally requires high sound quality and good expressiveness for music and singing. Use the following code in your project:

    ```dart
    // Initialize the IRtcEngine instance with a specific audio application scenario
    RtcEngineContext context;
    context.audioScenario = AudioScenarioType.audioScenarioGameStreaming;
    await rtcEngine.initialize(context);

    // Define the audio encoding settings
    await rtcEngine.setAudioProfile(AudioProfileType.audioScenarioGameStreaming);
    ```

    ### Voice radio [#voice-radio-5]

    Voice radio generally uses professional audio equipment. It requires high sound quality and stereo. Use the following code in your project:

    ```dart
    // Initialize the IRtcEngine instance with a specific audio application scenario
    RtcEngineContext context;
    context.audioScenario = AudioProfileType.audioScenarioChorus;
    await rtcEngine.initialize(context);

    // Define the audio encoding settings
    await rtcEngine.setAudioProfile(AudioProfileType.audioScenarioChorus);
    ```

    ### Music teaching [#music-teaching-5]

    This use-case requires high sound quality, and support for the transmission of speaker-played sound effects. Agora recommends the following settings:

    ```dart
    // Initialize the IRtcEngine instance with a specific audio application scenario
    RtcEngineContext context;
    context.audioScenario = AudioProfileType.audioScenarioMeeting;
    await rtcEngine.initialize(context);

    // Define the audio encoding settings
    await rtcEngine.setAudioProfile(AudioProfileType.audioScenarioMeeting);
    ```

    <CalloutContainer type="info">
      <CalloutDescription>
        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.
      </CalloutDescription>
    </CalloutContainer>

    ## Reference [#reference-6]

    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](/en/realtime-media/video/build/enhance-the-audio-experience/best-practices-sound-quality).

    ### Frequently asked questions [#frequently-asked-questions-6]

    * [What is the difference between the in-call volume and the media volume?](/en/api-reference/faq/integration/system_volume)

    ### API reference [#api-reference-6]

    * [`initialize`](https://api-ref.agora.io/en/video-sdk/flutter/6.x/API/class_irtcengine.html#api_irtcengine_initialize)
    * [`setAudioProfile`](https://api-ref.agora.io/en/video-sdk/flutter/6.x/API/class_irtcengine.html#api_irtcengine_setaudioprofile)
    * [`setAudioScenario`](https://api-ref.agora.io/en/video-sdk/flutter/6.x/API/class_irtcengine.html#api_irtcengine_setaudioscenario)

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="react-native">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="react-native" />

    This article shows you how to use Video SDK to configure appropriate audio encoding properties and application scenarios in your app.

    ## Understand the tech [#understand-the-tech-7]

    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 [#prerequisites-7]

    Ensure that you have implemented the [SDK quickstart](../../index) in your project.

    ## Implementation [#implementation-7]

    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:

    | API                                    | Description                                                                                                                      |
    | :------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------- |
    | `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 [#1-on-1-interactive-teaching-6]

    This use-case requires ensuring call quality and smooth transmission. Add the following code to your project:

    ```typescript
    // 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);
    ```

    ### KTV [#ktv-6]

    KTV generally requires high sound quality and good expressiveness for music and singing. Use the following code in your project:

    ```typescript
    // 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);
    ```

    ### Voice radio [#voice-radio-6]

    Voice radio generally uses professional audio equipment. It requires high sound quality and stereo. Use the following code in your project:

    ```typescript
    // 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);
    ```

    ### Music teaching [#music-teaching-6]

    This use-case requires high sound quality, and support for the transmission of speaker-played sound effects. Agora recommends the following settings:

    ```typescript
    // 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);
    ```

    <CalloutContainer type="info">
      <CalloutDescription>
        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.
      </CalloutDescription>
    </CalloutContainer>

    ## Reference [#reference-7]

    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](/en/realtime-media/video/build/enhance-the-audio-experience/best-practices-sound-quality).

    ### Frequently asked questions [#frequently-asked-questions-7]

    * [What is the difference between the in-call volume and the media volume?](/en/api-reference/faq/integration/system_volume)

    ### API reference [#api-reference-7]

    * [`initialize`](https://api-ref.agora.io/en/video-sdk/react-native/4.x/API/class_irtcengine.html#api_irtcengine_initialize)
    * [`setAudioProfile`](https://api-ref.agora.io/en/video-sdk/react-native/4.x/API/class_irtcengine.html#api_irtcengine_setaudioprofile)
    * [`setAudioScenario`](https://api-ref.agora.io/en/video-sdk/react-native/4.x/API/class_irtcengine.html#api_irtcengine_setaudioscenario)

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="unity">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="unity" />

    This article shows you how to use Video SDK to configure appropriate audio encoding properties and application scenarios in your game.

    ## Understand the tech [#understand-the-tech-8]

    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 [#prerequisites-8]

    Ensure that you have implemented the [SDK quickstart](../../index) in your project.

    ## Implementation [#implementation-8]

    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:

    | API                                    | Description                                                                                                                        |
    | :------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------- |
    | `Initialize(RtcEngineContext context)` | While initializing an `IRtcEngine` instance, set up the audio application scenario. The default value is `AUDIO_SCENARIO_DEFAULT`. |
    | `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 [#1-on-1-interactive-teaching-7]

    This use-case requires ensuring call quality and smooth transmission. Add the following code to your project:

    ```csharp
    // Initialize the IRtcEngine instance with a specific audio application scenario
    RtcEngineContext context = new RtcEngineContext();
    context.audioScenario = AUDIO_SCENARIO_TYPE.AUDIO_SCENARIO_DEFAULT;
    RtcEngine.Initialize(context);

    // Define the audio encoding settings
    RtcEngine.SetAudioProfile(AUDIO_PROFILE_TYPE.AUDIO_PROFILE_DEFAULT);
    ```

    ### KTV [#ktv-7]

    KTV generally requires high sound quality and good expressiveness for music and singing. Use the following code in your project:

    ```csharp
    // Initialize the IRtcEngine instance with a specific audio application scenario
    RtcEngineContext context = new RtcEngineContext();
    context.audioScenario = AUDIO_SCENARIO_TYPE.AUDIO_SCENARIO_GAME_STREAMING;
    RtcEngine.Initialize(context);

    // Define the audio encoding settings
    RtcEngine.SetAudioProfile(AUDIO_PROFILE_TYPE.AUDIO_PROFILE_MUSIC_HIGH_QUALITY);
    ```

    ### Voice radio [#voice-radio-7]

    Voice radio generally uses professional audio equipment. It requires high sound quality and stereo. Use the following code in your project:

    ```csharp
    // Initialize the IRtcEngine instance with a specific audio application scenario
    RtcEngineContext context = new RtcEngineContext();
    context.audioScenario = AUDIO_SCENARIO_TYPE.AUDIO_SCENARIO_GAME_STREAMING;
    RtcEngine.Initialize(context);

    // Define the audio encoding settings
    RtcEngine.SetAudioProfile(AUDIO_PROFILE_TYPE.AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO);
    ```

    ### Music teaching [#music-teaching-7]

    This use-case requires high sound quality, and support for the transmission of speaker-played sound effects. Agora recommends the following settings:

    ```csharp
    // Initialize the IRtcEngine instance with a specific audio application scenario
    RtcEngineContext context = new RtcEngineContext();
    context.audioScenario = AUDIO_SCENARIO_TYPE.AUDIO_SCENARIO_GAME_STREAMING;
    RtcEngine.Initialize(context);

    // Define the audio encoding settings
    RtcEngine.SetAudioProfile(AUDIO_PROFILE_TYPE.AUDIO_PROFILE_MUSIC_STANDARD_STEREO);
    ```

    <CalloutContainer type="info">
      <CalloutDescription>
        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 `AUDIO_SCENARIO_GAME_STREAMING(3)`. In this scenario, the SDK switches to media volume to address the issue.
      </CalloutDescription>
    </CalloutContainer>

    ## Reference [#reference-8]

    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](/en/realtime-media/video/build/enhance-the-audio-experience/best-practices-sound-quality).

    ### Frequently asked questions [#frequently-asked-questions-8]

    * [What is the difference between the in-call volume and the media volume?](/en/api-reference/faq/integration/system_volume)

    ### API reference [#api-reference-8]

    * [`Initialize`](https://api-ref.agora.io/en/video-sdk/unity/4.x/API/class_irtcengine.html#api_irtcengine_initialize)
    * [`SetAudioProfile` \[2/2\]](https://api-ref.agora.io/en/video-sdk/unity/4.x/API/class_irtcengine.html#api_irtcengine_setaudioprofile2)
    * [`SetAudioScenario`](https://api-ref.agora.io/en/video-sdk/unity/4.x/API/class_irtcengine.html#api_irtcengine_setaudioscenario)

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="unreal">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="unreal" />

    This article shows you how to use Video SDK to configure appropriate audio encoding properties and application scenarios in your game.

    ## Understand the tech [#understand-the-tech-9]

    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 [#prerequisites-9]

    Ensure that you have implemented the [SDK quickstart](../../index) in your project.

    ## Implementation [#implementation-9]

    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:

    | API                                 | Description                                                                                                                        |
    | :---------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------- |
    | `initialize(context.audioScenario)` | While initializing an `IRtcEngine` instance, set up the audio application scenario. The default value is `AUDIO_SCENARIO_DEFAULT`. |
    | `setAudioProfile(profile)`          | You can set audio encoding properties before or after joining a channel.                                                           |
    | `setAudioScenario`                  | 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 [#1-on-1-interactive-teaching-8]

    This use-case requires ensuring call quality and smooth transmission. Add the following code to your project:

    ```cpp
    // 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-8]

    KTV generally requires high sound quality and good expressiveness for music and singing. Use the following code in your project:

    ```cpp
    // 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-8]

    Voice radio generally uses professional audio equipment. It requires high sound quality and stereo. Use the following code in your project:

    ```cpp
    // 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 [#music-teaching-8]

    This use-case requires high sound quality, and support for the transmission of speaker-played sound effects. Agora recommends the following settings:

    ```cpp
    // 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);
    ```

    <CalloutContainer type="info">
      <CalloutDescription>
        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 `AUDIO_SCENARIO_GAME_STREAMING(3)`. In this scenario, the SDK switches to media volume to address the issue.
      </CalloutDescription>
    </CalloutContainer>

    ## Reference [#reference-9]

    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](/en/realtime-media/video/build/enhance-the-audio-experience/best-practices-sound-quality).

    ### Frequently asked questions [#frequently-asked-questions-9]

    * [What is the difference between the in-call volume and the media volume?](/en/api-reference/faq/integration/system_volume)

    ### Sample projects [#sample-projects-5]

    Agora offers an open-source sample project for your reference.

    * [GitHub](https://github.com/AgoraIO-Extensions/Agora-Unreal-RTC-SDK/tree/main/Agora-Unreal-SDK-CPP-Example)

    ### API reference [#api-reference-9]

    * [`initialize`](https://api-ref.agora.io/en/video-sdk/unreal-engine/4.x/API/class_irtcengine.html#api_irtcengine_initialize)
    * [`setAudioProfile` \[2/2\]](https://api-ref.agora.io/en/video-sdk/unreal-engine/4.x/API/class_irtcengine.html#api_irtcengine_setaudioprofile2)
    * [`setAudioScenario`](https://api-ref.agora.io/en/video-sdk/unreal-engine/4.x/API/class_irtcengine.html#api_irtcengine_setaudioscenario)

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="blueprint">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="blueprint" />

    This article shows you how to use Video SDK to configure appropriate audio encoding properties and application scenarios in your game.

    ## Understand the tech [#understand-the-tech-10]

    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 [#prerequisites-10]

    Ensure that you have implemented the [SDK quickstart](../../index) in your project.

    ## Implementation [#implementation-10]

    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:

    | API                                  | Description                                                                                                                        |
    | :----------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------- |
    | `Initialize(context.audioScenario)`  | While initializing an `IRtcEngine` instance, set up the audio application scenario. The default value is `AUDIO_SCENARIO_DEFAULT`. |
    | `SetAudioProfile(profile, scenario)` | You can set audio encoding properties before or after joining a channel.                                                           |
    | `SetAudioScenario`                   | You can set an application scenario before or after joining a channel.                                                             |

    ### Set audio encoding properties [#set-audio-encoding-properties]

    This subsection describes how to call `SetAudioProfile` to set audio encoding properties.

    1. Create UMG

    Create a **ComboBoxString** (dropdown list) widget, named **CBS\_Audio\_Profile**, where you can select the audio encoding properties as needed. The default option is **AUDIO\_PROFILE\_DEFAULT**, with other options detailed in [EAUDIO\_PROFILE\_TYPE](https://api-ref.agora.io/en/video-sdk/blueprint/4.x/API/enum_audioscenariotype.html), as shown in the image below:

    ![ConfigureAudioEncodingBlueprint](https://assets-docs.agora.io/images/video-sdk/configure_audio_encoding_implementation_blueprint-1.png)

    2. Bind UI event

    Create a **Bind Event to On Selection Changed node**, connecting the **CBS\_Audio\_Profile** widget and the **OnSetAudioProfile** callback. Selecting different audio encoding properties in the **CBS\_Audio\_Profile** dropdown list triggers the **OnSetAudioProfile** callback, as shown in the image below:

    ![ConfigureAudioEncodingBlueprint](https://assets-docs.agora.io/images/video-sdk/configure_audio_encoding_implementation_blueprint-2.png)

    3. Implement callback function

    Create the **OnSetAudioProfile** callback function, configuring the following parameters:

    | Input parameter | Data type | Parameter description                                                                                                                          |
    | :-------------- | :-------- | :--------------------------------------------------------------------------------------------------------------------------------------------- |
    | `SelectedItem`  | String    | The selected audio encoding property option.                                                                                                   |
    | `SelectionType` | Enum      | The type of selection information, see [ESelectInfo](https://docs.unrealengine.com/4.26/en-US/API/Runtime/SlateCore/Types/ESelectInfo__Type/). |

    When this callback is triggered, the selected audio encoding property is passed into **SetAudioProfile** as a profile parameter, and the method is executed to complete the setting, as shown in the image below:

    ![ConfigureAudioEncodingBlueprint](https://assets-docs.agora.io/images/video-sdk/configure_audio_encoding_implementation_blueprint-3.png)

    ### Set up audio application scenarios [#set-up-audio-application-scenarios]

    This subsection explains how to call **SetAudioScenario** to set audio application scenarios.

    1. Create UMG

    Create a **ComboBoxString** (dropdown list) widget, named **CBS\_Audio\_Scenario**, where you select the audio application scenarios as needed. The default option is **AUDIO\_SCENARIO\_DEFAULT**, with other options detailed in [EAUDIO\_SCENARIO\_TYPE](https://api-ref.agora.io/en/video-sdk/blueprint/4.x/API/enum_audioscenariotype.html), as shown in the image below:

    ![ConfigureAudioEncodingBlueprint](https://assets-docs.agora.io/images/video-sdk/configure_audio_encoding_implementation_blueprint-4.png)

    2. Bind UI Event

    Create a **Bind Event to On Selection Changed** node, connecting the **CBS\_Audio\_Scenario** widget and the **OnSetAudioScenario** callback. Selecting different audio application scenarios in the **CBS\_Audio\_Scenario** dropdown list triggers the **OnSetAudioScenario** callback, as shown in the image below:

    ![ConfigureAudioEncodingBlueprint](https://assets-docs.agora.io/images/video-sdk/configure_audio_encoding_implementation_blueprint-5.png)

    3. Implement callback function

    Create the **OnSetAudioScenario** callback function, configuring the following parameters:

    | Input Parameter | Data Type | Parameter Description                                                                                                                          |
    | :-------------- | :-------- | :--------------------------------------------------------------------------------------------------------------------------------------------- |
    | `SelectedItem`  | String    | The selected audio encoding property option.                                                                                                   |
    | `SelectionType` | Enum      | The type of selection information, see [ESelectInfo](https://docs.unrealengine.com/4.26/en-US/API/Runtime/SlateCore/Types/ESelectInfo__Type/). |

    When this callback is triggered, the selected audio application scenario is passed to **SetAudioScenario** as scenario parameter, and the method is executed to complete the setting, as shown in the image below:

    ![ConfigureAudioEncodingBlueprint](https://assets-docs.agora.io/images/video-sdk/configure_audio_encoding_implementation_blueprint-6.png)

    ### Recommended settings [#recommended-settings]

    The recommended settings for audio encoding properties and audio application scenarios for common applications are as follows:

    | Common applications                                                                                                                 | Audio encoding properties                 | Audio application scenario      |
    | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- | ------------------------------- |
    | **1-on-1 interactive teaching**: Requires ensuring call quality and smooth transmission.                                            | `AUDIO_PROFILE_DEFAULT`                   | `AUDIO_SCENARIO_DEFAULT`        |
    | **KTV**: Requires high sound quality and good music and vocal performance.                                                          | `AUDIO_PROFILE_MUSIC_HIGH_QUALITY`        | `AUDIO_SCENARIO_GAME_STREAMING` |
    | **Voice radio**: Typically uses professional audio equipment. Requires high sound quality and stereo.                               | `AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO` | `AUDIO_SCENARIO_GAME_STREAMING` |
    | **Music teaching**: Requires high sound quality and support for the transmission of speaker-played sound effects to the remote end. | `AUDIO_PROFILE_MUSIC_STANDARD_STEREO`     | `AUDIO_SCENARIO_GAME_STREAMING` |

    <CalloutContainer type="info">
      <CalloutDescription>
        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 `AUDIO_SCENARIO_GAME_STREAMING(3)`. In this scenario, the SDK switches to media volume to address the issue.
      </CalloutDescription>
    </CalloutContainer>

    ## Reference [#reference-10]

    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](/en/realtime-media/video/build/enhance-the-audio-experience/best-practices-sound-quality).

    ### Frequently asked questions [#frequently-asked-questions-10]

    * [What is the difference between the in-call volume and the media volume?](/en/api-reference/faq/integration/system_volume)

    ### Sample projects [#sample-projects-6]

    Agora offers the following open-source sample projects for setting audio encoding properties and application scenario functions for your reference.

    * [Agora-Unreal-SDK-Blueprint-Example](https://github.com/AgoraIO-Extensions/Agora-Unreal-RTC-SDK/tree/main/Agora-Unreal-SDK-Blueprint-Example)
    * [JoinChannelAudio](https://github.com/AgoraIO-Extensions/Agora-Unreal-RTC-SDK/tree/main/Agora-Unreal-SDK-Blueprint-Example/Content/API-Example/Basic/JoinChannelAudio)

    ### API reference [#api-reference-10]

    * [`initialize`](https://api-ref.agora.io/en/video-sdk/blueprint/4.x/API/class_irtcengine.html#api_irtcengine_initialize)
    * [`setAudioProfile` \[2/2\]](https://api-ref.agora.io/en/video-sdk/blueprint/4.x/API/class_irtcengine.html#api_irtcengine_setaudioprofile2)
    * [`setAudioScenario`](https://api-ref.agora.io/en/video-sdk/blueprint/4.x/API/class_irtcengine.html#api_irtcengine_setaudioscenario)

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>
</_PlatformTabsGroup>
