Configure audio encoding

Updated

Configure audio encoding properties and scenarios for Voice Calling apps.

Audio quality requirements vary with application use-case. For example, in professional use-cases such as radio stations and singing competitions, users are particularly sensitive to audio quality. In such cases, support for dual-channel and high-quality sound is required. High-quality sound means setting a high sampling rate and a high bitrate to achieve realistic audio. Voice SDK enables you to configure audio encoding properties to meet such requirements.

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

Understand the tech

Voice SDK uses default encoding parameters and a default audio scenario that are suitable for most common applications. If the default settings do not meet your needs, refer to the examples in the implementation section to set appropriate audio encoding properties and an application scenario.

Prerequisites

Ensure that you have implemented the SDK quickstart in your project.

Implementation

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

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

Customizing audio encoding properties

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

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

This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.

For more audio settings, see Achieve high audio quality.

Frequently asked questions

API reference