Class AudioBuffer
boolean, int)
method.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA callback that can be registered to receive notifications when the contents of the AudioBuffer is changed. -
Constructor Summary
ConstructorsConstructorDescriptionAudioBuffer(int maxSize) Creates a new AudioBuffer with the given maximum size. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a callback to be notified when the contents of this buffer are changed.voidcopyFrom(int sampleRate, int numChannels, float[] source) Copies data from the source array into this buffer.voidcopyFrom(int sampleRate, int numChannels, float[] source, int offset, int len) Copies data from the source array (in the given range) into the buffer.voidcopyFrom(AudioBuffer source) Copies data into the buffer from the given source buffer.voidcopyTo(float[] dest) Copies data from this buffer to the given float array.voidcopyTo(float[] dest, int offset) Copies data from this buffer to the given float array.voidcopyTo(AudioBuffer dest) Copies data to another audio buffer.voiddownSample(int targetSampleRate) Downsamples the buffer to the given rate.intGets the maximum size of the buffer.intReturns
intReturns
intgetSize()The current size of the buffer.voidRemoves a callback from the audio buffer.
-
Constructor Details
-
AudioBuffer
public AudioBuffer(int maxSize) Creates a new AudioBuffer with the given maximum size.
Parameters
maxSize: The maximum size of the buffer.
-
-
Method Details
-
copyFrom
Copies data into the buffer from the given source buffer. This will trigger the callbacks'
AudioBufferCallback#frameReceived(com.codename1.media.AudioBuffer)method.Parameters
source: The source buffer to copy from.
-
copyFrom
public void copyFrom(int sampleRate, int numChannels, float[] source) Copies data from the source array into this buffer. This will trigger the callbacks'
AudioBufferCallback#frameReceived(com.codename1.media.AudioBuffer)method.Parameters
source
-
copyFrom
public 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. This will trigger the callbacks'
AudioBufferCallback#frameReceived(com.codename1.media.AudioBuffer)method.Parameters
-
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.
-
-
copyTo
Copies data to another audio buffer. This will trigger callbacks in the destination.
Parameters
dest: The destination audio buffer.
-
copyTo
public void copyTo(float[] dest) Copies data from this buffer to the given float array.
Parameters
dest: The destination float array to copy to.
-
copyTo
public void copyTo(float[] dest, int offset) Copies data from this buffer to the given float array.
Parameters
-
dest: The destination float array. -
offset: The offset in the destination array to start copying to.
-
-
getSize
public int getSize()The current size of the buffer. This value will be changed each time data is copied into the buffer to reflect the current size of the data. -
getMaxSize
public int getMaxSize()Gets the maximum size of the buffer. Trying to copy more than this amount of data into the buffer will result in an IndexOutOfBoundsException. -
addCallback
Adds a callback to be notified when the contents of this buffer are changed.
Parameters
l: The AudioBufferCallback
-
removeCallback
Removes a callback from the audio buffer.
Parameters
l: The callback to remove.
-
getSampleRate
public int getSampleRate()Returns
the sampleRate
-
getNumChannels
public int getNumChannels()Returns
the numChannels
-
downSample
public void downSample(int targetSampleRate) Downsamples the buffer to the given rate. This will change the result of
#getSize()and#getSampleRate().Note: This should only be called inside the AudioBuffer callback since it is modifying the contents of the buffer.
Parameters
targetSampleRate: The new target rate.
-