Raw audio data.

public class AudioFrame {
  public ByteBuffer buffer;
  public int sampleRataHz;
  public int bytesPerSample;
  public int channelNums;
  public int samplesPerChannel;
  public long timestamp;

  public AudioFrame(ByteBuffer buffer, int sampleRataHz, int bytesPerSample, int channelNums,
      int samplesPerChannel, long timestamp) {
    this.sampleRataHz = sampleRataHz;
    this.bytesPerSample = bytesPerSample;
    this.channelNums = channelNums;
    this.samplesPerChannel = samplesPerChannel;
    this.timestamp = timestamp;
    this.buffer = buffer;

  public ByteBuffer getByteBuffer() {
    return buffer;

  public int getBytesPerSample() {
    return bytesPerSample;

  public int getChannelNums() {
    return channelNums;

  public int getSampleRataHz() {
    return sampleRataHz;

  public int getSamplesPerChannel() {
    return samplesPerChannel;

  public long getTimestamp() {
    return timestamp;

  public String toString() {
    return "AudioFrame{sampleRataHz=" + sampleRataHz + ", bytesPerSample=" + bytesPerSample
        + ", channelNums=" + channelNums + ", samplesPerChannel=" + samplesPerChannel
        + ", timestamp=" + timestamp + '}';


The number of samples per channel in the audio frame.
The number of bytes per sample. For PCM, this parameter is generally set to 16 bits (2 bytes).
The number of audio channels (the data are interleaved if it is stereo).
  • 1: Mono.
  • 2: Stereo.
The number of samples per channel in the audio frame.

The data buffer of the audio frame. When the audio frame uses a stereo channel, the data buffer is interleaved.

The size of the data buffer is as follows: buffer = samples × channels × bytesPerSample.

The timestamp (ms) of the audio frame.