Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class AudioBufferSourceNode
- Object
- AudioNode
- AudioScheduledSourceNode
- AudioBufferSourceNode
Plays AudioData, the Web Audio AudioBufferSourceNode. Its output has the
data’s channel count. Data at another sample rate is resampled with linear
interpolation.
OfflineAudioContext audio = new OfflineAudioContext(2, 44100, 44100);
AudioData clip = audio.createBuffer(1, 44100, 44100); // or decodeAudioData
AudioBufferSourceNode src = audio.createBufferSource();
src.setBuffer(clip);
src.getPlaybackRate().setValue(1.5f);
src.connect(audio.getDestination());
src.start(audio.getCurrentTime() + 0.1);Methods
public AudioParam getPlaybackRate() | The speed factor, 1 by default; negative plays backwards. |
public AudioParam getDetune() | A detune in cents, combined with the playback rate; a control rate parameter. |
public AudioData getBuffer() | The audio played. |
public void setBuffer(AudioData buffer) | Sets the audio to play. |
public boolean isLoop() | Whether playback loops between getLoopStart() and getLoopEnd(). |
public void setLoop(boolean loop) | Turns looping on or off. |
public double getLoopStart() | The start of the loop in seconds of the data. |
public void setLoopStart(double loopStart) | Sets the start of the loop. |
public double getLoopEnd() | The end of the loop in seconds of the data; 0 (the default), or any value not after the start, means the end of the data. |
public void setLoopEnd(double loopEnd) | Sets the end of the loop. |
public void start(double when, double offset) | Starts playing at when from offset seconds into the data. |
public void start(double when, double offset, double duration) | Starts playing at when from offset seconds into the data, for duration seconds of the data (loops included). |
Inherited methods
From AudioScheduledSourceNode
start, start, stop, stop, setOnEnded
Method details
getPlaybackRate
public AudioParam getPlaybackRate()The speed factor, 1 by default; negative plays backwards. A control rate
parameter.
Returns
the parameter
getDetune
public AudioParam getDetune()A detune in cents, combined with the playback rate; a control rate
parameter.
Returns
the parameter
getBuffer
public AudioData getBuffer()The audio played.
Returns
the data, or null
setBuffer
public void setBuffer(AudioData buffer)Sets the audio to play. It can be set once; a source without data plays
one channel of silence.
Parameters
bufferAudioData- the data
isLoop
public boolean isLoop()Whether playback loops between
getLoopStart() and getLoopEnd().Returns
true when looping
setLoop
public void setLoop(boolean loop)Turns looping on or off.
Parameters
loopboolean- true to loop
getLoopStart
public double getLoopStart()The start of the loop in seconds of the data.
Returns
seconds
setLoopStart
public void setLoopStart(double loopStart)Sets the start of the loop.
Parameters
loopStartdouble- seconds of the data
getLoopEnd
public double getLoopEnd()The end of the loop in seconds of the data; 0 (the default), or any value
not after the start, means the end of the data.
Returns
seconds
setLoopEnd
public void setLoopEnd(double loopEnd)Sets the end of the loop.
Parameters
loopEnddouble- seconds of the data
start
public void start(double when, double offset)Starts playing at
when from offset seconds into the data.Parameters
whendouble- context time in seconds
offsetdouble- where in the data to start
start
public void start(double when, double offset, double duration)Starts playing at
when from offset seconds into the data, for
duration seconds of the data (loops included).Parameters
whendouble- context time in seconds
offsetdouble- where in the data to start, 0 or more
durationdouble- how much of the data to play, more than 0