AudioBufferSourceNode class abstract
The AudioBufferSourceNode
is an AudioScheduledSourceNode
which represents an audio source consisting of in-memory audio data, stored
in an AudioBuffer.
This is especially useful for playing back audio which has particularly stringent timing accuracy requirements, such as for sounds that must match a specific rhythm and can be kept in memory rather than being played from disk or the network. To play sounds which require accurate timing but must be streamed from the network or played from disk, use a AudioWorkletNode to implement its playback.
An AudioBufferSourceNode
has no inputs and exactly one output, which has
the same number of channels as the AudioBuffer
indicated by its
AudioBufferSourceNode.buffer property. If there's no buffer set—that is,
if buffer
is null
—the output contains a single channel of silence (every
sample is 0).
An AudioBufferSourceNode
can only be played once; after each call to
AudioBufferSourceNode.start, you have to create a new node if you want to
play the same sound again. Fortunately, these nodes are very inexpensive to
create, and the actual AudioBuffer
s can be reused for multiple plays of
the sound. Indeed, you can use these nodes in a "fire and forget" manner:
create the node, call start()
to begin playing the sound, and don't even
bother to hold a reference to it. It will automatically be garbage-collected
at an appropriate time, which won't be until sometime after the sound has
finished playing.
Multiple calls to AudioScheduledSourceNode.stop are allowed. The most
recent call replaces the previous one, if the AudioBufferSourceNode
has
not already reached the end of the buffer.
Number of inputs | 0 |
---|---|
Number of outputs | 1 |
Channel count | defined by the associated [AudioBuffer] |
API documentation sourced from MDN Web Docs.
- Implemented types
Constructors
Properties
- buffer ↔ AudioBuffer?
-
The
buffer
property of the AudioBufferSourceNode interface provides the ability to play back audio using an AudioBuffer as the source of the sound data.getter/setter pair - channelCount ↔ int
-
The
channelCount
property of the AudioNode represents an integer used to determine how many channels are used when up-mixing and down-mixing connections to any inputs to the node.getter/setter pairinherited - channelCountMode ↔ ChannelCountMode
-
The
channelCountMode
property of the AudioNode represents an enumerated value describing the way channels must be matched between the node's inputs and outputs.getter/setter pairinherited - channelInterpretation ↔ ChannelInterpretation
-
The
channelInterpretation
property of the AudioNode interface represents an enumerated value describing how input channels are mapped to output channels when the number of inputs/outputs is different. For example, this setting defines how a mono input will be up-mixed to a stereo or 5.1 channel output, or how a quad channel input will be down-mixed to a stereo or mono output.getter/setter pairinherited - context → BaseAudioContext
-
The read-only
context
property of the AudioNode returns the associated BaseAudioContext, that is the object representing the processing graph the node is participating in.no setterinherited - detune → AudioParam
-
The
detune
property of the AudioBufferSourceNode is a k-rate AudioParam representing detuning of oscillation in cents.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- loop ↔ bool
-
The
loop
property of the AudioBufferSourceNode is a Boolean indicating if the audio asset must be replayed when the end of the AudioBuffer is reached.getter/setter pair - loopEnd ↔ double
-
The
loopEnd
property of the AudioBufferSourceNode specifies is a floating point number specifying, in seconds, at what offset into playing the AudioBuffer playback should loop back to the time indicated by the AudioBufferSourceNode.loopStart property. This is only used if the AudioBufferSourceNode.loop property istrue
.getter/setter pair - loopStart ↔ double
-
The
loopStart
property of the AudioBufferSourceNode is a floating-point value indicating, in seconds, where in the AudioBuffer the restart of the play must happen.getter/setter pair - numberOfInputs → int
-
The
numberOfInputs
property of the AudioNode returns the number of inputs feeding the node. Source nodes are defined as nodes having anumberOfInputs
property with a value of 0.no setterinherited - numberOfOutputs → int
-
The
numberOfOutputs
property of the AudioNode returns the number of outputs coming out of the node. Destination nodes — like AudioDestinationNode — have a value of 0 for this attribute.no setterinherited - onended ↔ EventHandler
-
getter/setter pairinherited
- playbackRate → AudioParam
-
The
playbackRate
property of the AudioBufferSourceNode Is a k-rate AudioParam that defines the speed at which the audio asset will be played.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
connect(
AudioNode destinationNode, [int output, int input]) → AudioNode -
The
connect()
method of the AudioNode lets you connect one of the node's outputs to a target, which may be either anotherAudioNode
(thereby directing the sound data to the specified node). See also AudioNode.connectParaminherited -
connectParam(
AudioParam destinationParam, [int output, int input]) → void -
This is a variant of AudioNode.connect with a
DestinationParam
argument instead of anAudioNode
. Note : The W3C recommandation uses just one verb for both.inherited -
disconnect(
[AudioNode destinationParamOrOutput, int output, int input]) → void -
The
disconnect()
method of the AudioNode lets you disconnect one or more nodes from the node on which the method is called. See also AudioNode.disconnectParaminherited -
disconnectParam(
AudioParam destinationParam, [int output, int input]) → void -
This is a variant of AudioNode.disconnect with a
DestinationParam
argument instead of anAudioNode
. Note : The W3C recommandation uses just one verb for both.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
start(
[num? when, num? offset, num? duration]) → void -
The
start()
method of the AudioBufferSourceNode is used to schedule playback of the audio data contained in the buffer, or to begin playback immediately.override -
stop(
[num when]) → void -
The
stop()
method on AudioScheduledSourceNode schedules a sound to cease playback at the specified time. If no time is specified, then the sound stops playing immediately.inherited -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited