AudioParams
Audio data format.
public class AudioParams { public int sample_rate { set; get; } public int channels { set; get; } public RAW_AUDIO_FRAME_OP_MODE_TYPE mode { set; get; } public int samples_per_call { set; get; } public AudioParams() { sample_rate = 0; channels = 0; mode = RAW_AUDIO_FRAME_OP_MODE_TYPE.RAW_AUDIO_FRAME_OP_MODE_READ_ONLY; samples_per_call = 0; } public AudioParams(int samplerate, int channel, RAW_AUDIO_FRAME_OP_MODE_TYPE type, int samplesPerCall) { sample_rate = samplerate; channels = channel; mode = type; samples_per_call = samplesPerCall; } };
You can pass the AudioParams object in the following APIs to set the audio data format for the corresponding callback:
- SetRecordingAudioFrameParameters: Sets the audio data format for the OnRecordAudioFrame callback.
- SetPlaybackAudioFrameParameters: Sets the audio data format for the OnPlaybackAudioFrame callback.
- SetMixedAudioFrameParameters: Sets the audio data format for the OnMixedAudioFrame callback.
- SetEarMonitoringAudioFrameParameters: Sets the audio data format for the OnEarMonitoringAudioFrame callback.
Attention:
- 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).
Attributes
- sample_rate
- The audio sample rate (Hz), which can be set as one of the following values:
- 8000.
- (Default) 16000.
- 32000.
- 44100
- 48000
- channels
- The number of audio channels, which can be set as either of the following values:
- 1: (Default) Mono.
- 2: Stereo.
- mode
- The use mode of the audio data. See RAW_AUDIO_FRAME_OP_MODE_TYPE.
- samples_per_call
- The number of samples, such as 1024 for the media push.