Class 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);
-
Method Summary
Modifier and TypeMethodDescriptionThe audio played.A detune in cents, combined with the playback rate; a control rate parameter.doubleThe 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.doubleThe start of the loop in seconds of the data.The speed factor, 1 by default; negative plays backwards.booleanisLoop()Whether playback loops betweengetLoopStart()andgetLoopEnd().voidSets the audio to play.voidsetLoop(boolean loop) Turns looping on or off.voidsetLoopEnd(double loopEnd) Sets the end of the loop.voidsetLoopStart(double loopStart) Sets the start of the loop.voidstart(double when, double offset) Starts playing atwhenfromoffsetseconds into the data.voidstart(double when, double offset, double duration) Starts playing atwhenfromoffsetseconds into the data, fordurationseconds of the data (loops included).Methods inherited from class AudioScheduledSourceNode
setOnEnded, start, start, stop, stopMethods inherited from class AudioNode
connect, connect, connect, connect, disconnect, disconnect, disconnect, disconnect, disconnect, getChannelCount, getChannelCountMode, getChannelInterpretation, getContext, getNumberOfInputs, getNumberOfOutputs, setChannelCount, setChannelCountMode, setChannelInterpretation
-
Method Details
-
getPlaybackRate
The speed factor, 1 by default; negative plays backwards. A control rate parameter.
Returns
the parameter
-
getDetune
A detune in cents, combined with the playback rate; a control rate parameter.
Returns
the parameter
-
getBuffer
The audio played.
Returns
the data, or null
-
setBuffer
Sets the audio to play. It can be set once; a source without data plays one channel of silence.
Parameters
buffer: the data
-
isLoop
public boolean isLoop() -
setLoop
public void setLoop(boolean loop) Turns looping on or off.
Parameters
loop: 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
loopStart: 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
loopEnd: seconds of the data
-
start
public void start(double when, double offset) Starts playing at
whenfromoffsetseconds into the data.Parameters
-
when: context time in seconds -
offset: where in the data to start
-
-
start
public void start(double when, double offset, double duration) Starts playing at
whenfromoffsetseconds into the data, fordurationseconds of the data (loops included).Parameters
-
when: context time in seconds -
offset: where in the data to start, 0 or more -
duration: how much of the data to play, more than 0
-
-