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.
Quick Jump
- Methods
-
- wrap(ByteBuffer buffer,int sampleType,long presentationTimeUs)
- wrap(ByteBuffer buffer,int sampleType,int channelCount,long presentationTimeUs)
- allocate(int capacity,int sampleType,ByteOrder byteOrder,long presentationTimeUs)
- allocate(int capacity,int sampleType,int channelCount,ByteOrder byteOrder,long presentationTimeUs)
- capacity()
- limit()
- limit(int newLimit)
- position()
- position(int newPosition)
- get()
- get(int index)
- put(double sample)
- put(int index,double sample)
- getByteBuffer()
- getBytes()
- getPresentationTimeUs()
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.
limit()
Returns the number of samples in the buffer per channel.
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.
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.
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.
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