public class AudioBuffer extends Object
MediaManager.getAudioBuffer(java.lang.String, boolean, int)
method.| Modifier and Type | Class and Description |
|---|---|
static interface |
AudioBuffer.AudioBufferCallback
A callback that can be registered to receive notifications when the contents of the
AudioBuffer is changed.
|
| Constructor and Description |
|---|
AudioBuffer(int maxSize)
Creates a new AudioBuffer with the given maximum size.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCallback(AudioBuffer.AudioBufferCallback l)
Adds a callback to be notified when the contents of this buffer are changed.
|
void |
copyFrom(AudioBuffer source)
Copies data into the buffer from the given source buffer.
|
void |
copyFrom(int sampleRate,
int numChannels,
float[] source)
Copies data from the source array into this buffer.
|
void |
copyFrom(int sampleRate,
int numChannels,
float[] source,
int offset,
int len)
Copies data from the source array (in the given range) into the buffer.
|
void |
copyTo(AudioBuffer dest)
Copies data to another audio buffer.
|
void |
copyTo(float[] dest)
Copies data from this buffer to the given float array.
|
void |
copyTo(float[] dest,
int offset)
Copies data from this buffer to the given float array.
|
void |
downSample(int targetSampleRate)
Downsamples the buffer to the given rate.
|
int |
getMaxSize()
Gets the maximum size of the buffer.
|
int |
getNumChannels() |
int |
getSampleRate() |
int |
getSize()
The current size of the buffer.
|
void |
removeCallback(AudioBuffer.AudioBufferCallback l)
Removes a callback from the audio buffer.
|
public AudioBuffer(int maxSize)
maxSize - The maximum size of the buffer.public void copyFrom(AudioBuffer source)
AudioBuffer.AudioBufferCallback.frameReceived(com.codename1.media.AudioBuffer)
method.source - The source buffer to copy from.public void copyFrom(int sampleRate,
int numChannels,
float[] source)
AudioBuffer.AudioBufferCallback.frameReceived(com.codename1.media.AudioBuffer)
method.source - public void copyFrom(int sampleRate,
int numChannels,
float[] source,
int offset,
int len)
AudioBuffer.AudioBufferCallback.frameReceived(com.codename1.media.AudioBuffer)
method.source - The source array to copy data from.offset - The offset in the source array to begin copying from.len - The length of the range to copy.public void copyTo(AudioBuffer dest)
dest - The destination audio buffer.public void copyTo(float[] dest)
dest - The destination float array to copy to.public void copyTo(float[] dest,
int offset)
dest - The destination float array.offset - The offset in the destination array to start copying to.public int getSize()
public int getMaxSize()
public void addCallback(AudioBuffer.AudioBufferCallback l)
l - The AudioBufferCallbackpublic void removeCallback(AudioBuffer.AudioBufferCallback l)
l - The callback to remove.public int getSampleRate()
public int getNumChannels()
public void downSample(int targetSampleRate)
getSize() and getSampleRate().
Note: This should only be called inside the AudioBuffer callback since it is
modifying the contents of the buffer.targetSampleRate - The new target rate.