Expand Minimize Picture-in-picture Power Device Status Voice Recognition Skip Back Skip Forward Minus Plus Play Search
Internet Explorer alert
This browser is not recommended for use with smartdevicelink.com, and may not function properly. Upgrade to a different browser to guarantee support of all features.
close alert
To Top Created with Sketch. To Top
To Bottom Created with Sketch. To Bottom
Android Documentation
SampleBuffer

Class SampleBuffer

Hierarchy

java.lang.Object

Package
com.smartdevicelink.managers.audio

Overview

Wraps a buffer of raw audio samples depending on the sample type (8 bit, 16 bit) Unifies samples into double.

Methods

wrap( ByteBuffer buffer, int sampleType, long presentationTimeUs )

Wraps a raw (mono) byte buffer to a new sample buffer.

public static com.smartdevicelink.managers.audio.SampleBuffer wrap(ByteBuffer buffer,int sampleType,long presentationTimeUs)

Method Parameters

buffer
The raw buffer to be wrapped.
sampleType
The sample type of the samples in the raw buffer.
presentationTimeUs
The presentation time of the buffer.

wrap( ByteBuffer buffer, int sampleType, int channelCount, long presentationTimeUs )

Wraps a raw byte buffer to a new sample buffer.

public static com.smartdevicelink.managers.audio.SampleBuffer wrap(ByteBuffer buffer,int sampleType,int channelCount,long presentationTimeUs)

Method Parameters

buffer
The raw buffer to be wrapped.
sampleType
The sample type of the samples in the raw buffer.
channelCount
The number of channels (1 = mono, 2 = stereo).
presentationTimeUs
The presentation time of the buffer.

allocate( int capacity, int sampleType, ByteOrder byteOrder, long presentationTimeUs )

Allocates a new sample buffer.

public static com.smartdevicelink.managers.audio.SampleBuffer allocate(int capacity,int sampleType,ByteOrder byteOrder,long presentationTimeUs)

Method Parameters

capacity
The specified sample capacity of the sample buffer.
sampleType
The sample type of the samples the buffer should store.
byteOrder
The byte order for the samples (little or big endian).
presentationTimeUs
The presentation time for the buffer.

allocate( int capacity, int sampleType, int channelCount, ByteOrder byteOrder, long presentationTimeUs )

Allocates a new sample buffer.

public static com.smartdevicelink.managers.audio.SampleBuffer allocate(int capacity,int sampleType,int channelCount,ByteOrder byteOrder,long presentationTimeUs)

Method Parameters

capacity
The specified sample capacity of the sample buffer.
sampleType
The sample type of the samples the buffer should store.
channelCount
The number of channels (1 = mono, 2 = stereo).
byteOrder
The byte order for the samples (little or big endian).
presentationTimeUs
The presentation time for the buffer.

capacity()

Returns the capacity of the buffer per channel.

public int capacity()

limit()

Returns the number of samples in the buffer per channel.

public int limit()

limit( int newLimit )

Sets the number of samples in the buffer to the new limit.

public void limit(int newLimit)

Method Parameters

newLimit
The new limit of the sample buffer.

position()

Returns the current position in the buffer per channel.

public int position()

position( int newPosition )

Sets the position of the sample buffer to the new index.

public void position(int newPosition)

Method Parameters

newPosition
The new position of the sample buffer.

get()

Returns the sample of the current position and then increments the position. The sample returned is a mixed sample getting all samples from each channel.

public double get()

get( int index )

Returns the sample from the given index in the buffer. If the buffer's channel count is > 1 the sample returned is a mixed sample getting all samples from each channel.

public double get(int index)

Method Parameters

index
The index of the sample requested.

put( double sample )

Puts a sample to the current position and increments the position.

public void put(double sample)

Method Parameters

sample
The sample to put into the buffer.

put( int index, double sample )

Puts a sample to the given index in the buffer. If the buffer's channel count is > 1 the sample will be stored in each channel at the given index.

public void put(int index,double sample)

Method Parameters

index
The index to put the sample.
sample
The sample to store in the buffer.

getByteBuffer()

Returns the raw byte buffer managed by this sample buffer.

public java.nio.ByteBuffer getByteBuffer()

getBytes()

Returns a copy of the bytes from position 0 to the current limit.

public byte getBytes()

getPresentationTimeUs()

The presentation time of this sample buffer.

public long getPresentationTimeUs()

Inherited Methods

From Class Methods
java.lang.Object getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize
View on GitHub.com
Previous Section Next Section