Agora Java API Reference for Android
Public Member Functions | Public Attributes | List of all members
io.agora.rtc2.audio.AudioParams Class Reference

Audio data format. More...

Public Member Functions

 AudioParams (int sampleRate, int channelCnt, int mode, int samplesPerCall)
 
int getSampleRate ()
 
int getChannel ()
 
int getMode ()
 
int getSamplesPerCall ()
 
String toString ()
 

Public Attributes

int sampleRate = 0
 
int channel = 0
 
int mode = Constants.RAW_AUDIO_FRAME_OP_MODE_READ_ONLY
 
int samplesPerCall = 0
 

Detailed Description

Audio data format.

You can pass the AudioParams object in the following APIs to set the audio data format for the corresponding callback:

Note
  • The SDK calculates the sampling interval through the samplesPerCall, sampleRate, and channel parameters in AudioParams, and triggers the onRecordAudioFrame, onPlaybackAudioFrame, onMixedAudioFrame, and onEarMonitoringAudioFrame callbacks according to the sampling interval.
  • Sample interval (sec) = samplePerCall /( sampleRate × channel ).
  • Ensure that the sample interval ≥ 0.01 (s).

Member Data Documentation

◆ sampleRate

int io.agora.rtc2.audio.AudioParams.sampleRate = 0

The audio sample rate (Hz), which can be set as one of the following values:

  • 8000.
  • (Default) 16000.
  • 32000.
  • 44100
  • 48000

◆ channel

int io.agora.rtc2.audio.AudioParams.channel = 0

The number of audio channels, which can be set as either of the following values:

  • 1: (Default) Mono.
  • 2: Stereo.

◆ mode

int io.agora.rtc2.audio.AudioParams.mode = Constants.RAW_AUDIO_FRAME_OP_MODE_READ_ONLY

The use mode of the audio data, which can be set as either of the following values:

  • RAW_AUDIO_FRAME_OP_MODE_READ_ONLY (0): Read-only mode, For example, when users acquire the data with the Agora SDK, then start the media push.
  • RAW_AUDIO_FRAME_OP_MODE_READ_WRITE (2): Read and write mode, For example, when users have their own audio-effect processing module and perform some voice pre-processing, such as a voice change.

◆ samplesPerCall

int io.agora.rtc2.audio.AudioParams.samplesPerCall = 0

The number of samples, such as 1024 for the media push.