AudioFrame
Raw audio data.
public class AudioFrame { public ByteBuffer buffer; public int sampleRataHz; public int bytesPerSample; public int channelNums; public int samplesPerChannel; public long timestamp; @CalledByNative 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; } @CalledByNative public ByteBuffer getByteBuffer() { return buffer; } @CalledByNative public int getBytesPerSample() { return bytesPerSample; } @CalledByNative public int getChannelNums() { return channelNums; } @CalledByNative public int getSampleRataHz() { return sampleRataHz; } @CalledByNative public int getSamplesPerChannel() { return samplesPerChannel; } @CalledByNative public long getTimestamp() { return timestamp; } @Override public String toString() { return "AudioFrame{sampleRataHz=" + sampleRataHz + ", bytesPerSample=" + bytesPerSample + ", channelNums=" + channelNums + ", samplesPerChannel=" + samplesPerChannel + ", timestamp=" + timestamp + '}'; } }
Attributes
- samplesPerChannel
- The number of samples per channel in the audio frame.
- bytesPerSample
- The number of bytes per sample. For PCM, this parameter is generally set to 16 bits (2 bytes).
- channelNums
-
The number of audio channels (the data are interleaved if it is stereo).
- 1: Mono.
- 2: Stereo.
- sampleRataHz
- The number of samples per channel in the audio frame.
- buffer
-
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
. - timestamp
- The timestamp (ms) of the audio frame.