The AudioBufferSourceNode interface is an AudioScheduledSourceNode which represents an audio source consisting of in-memory audio data, stored in an AudioBuffer. It's 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.

Documentation AudioBufferSourceNode by Mozilla Contributors, licensed under CC-BY-SA 2.5.

See also:

Constructor

new(context:BaseAudioContext, ?options:Null<AudioBufferSourceOptions>)

Throws:

null

DOMError

Variables

buffer:AudioBuffer

An AudioBuffer that defines the audio asset to be played, or when set to the value null, defines a single channel of silence (in which every sample is 0.0).

read onlydetune:AudioParam

Is a k-rate AudioParam representing detuning of playback in cents. This value is compounded with playbackRate to determine the speed at which the sound is played. Its default value is 0 (meaning no detuning), and its nominal range is -∞ to ∞.

loop:Bool

A Boolean attribute indicating if the audio asset must be replayed when the end of the AudioBuffer is reached. Its default value is false.

loopEnd:Float

A floating-point number indicating the time, in seconds, at which playback of the AudioBuffer stops and loops back to the time indicated by loopStart, if loop is true. The default value is 0.

loopStart:Float

A floating-point value indicating the time, in seconds, at which playback of the AudioBuffer must begin when loop is true. Its default value is 0 (meaning that at the beginning of each loop, playback begins at the start of the audio buffer).

read onlyplaybackRate:AudioParam

An a-rate AudioParam that defines the speed factor at which the audio asset will be played, where a value of 1.0 is the sound's natural sampling rate. Since no pitch correction is applied on the output, this can be used to change the pitch of the sample. This value is compounded with detune to determine the final playback rate.

Methods

@:value({ grainOffset : 0.0, when : 0.0 })start(when:Float = 0.0, grainOffset:Float = 0.0, ?grainDuration:Float):Void

Used to schedule playback of the audio data contained in the buffer, or to begin playback immediately.

Throws:

null

DOMError

Inherited Variables

Defined by AudioScheduledSourceNode

onended:Function

A function to be called when the ended event is fired, indicating that the node has finished playing.

Defined by AudioNode

channelCount:Int

Represents an integer used to determine how many channels are used when up-mixing and down-mixing connections to any inputs to the node. Its usage and precise definition depend on the value of AudioNode.channelCountMode.

channelCountMode:ChannelCountMode

Represents an enumerated value describing the way channels must be matched between the node's inputs and outputs.

channelInterpretation:ChannelInterpretation

Represents an enumerated value describing the meaning of the channels. This interpretation will define how audio up-mixing and down-mixing will happen.

The possible values are "speakers" or "discrete".

read onlycontext:BaseAudioContext

Returns the associated BaseAudioContext, that is the object representing the processing graph the node is participating in.

read onlynumberOfInputs:Int

Returns the number of inputs feeding the node. Source nodes are defined as nodes having a numberOfInputs property with a value of 0.

read onlynumberOfOutputs:Int

Returns the number of outputs coming out of the node. Destination nodes — like AudioDestinationNode — have a value of 0 for this attribute.

Inherited Methods

Defined by AudioScheduledSourceNode

@:value({ when : 0.0 })stop(when:Float = 0.0):Void

Throws:

null

DOMError

Defined by AudioNode

@:value({ output : 0 })connect(destination:AudioParam, output:Int = 0):Void

@:value({ input : 0, output : 0 })connect(destination:AudioNode, output:Int = 0, input:Int = 0):AudioNode

Allows us to connect the output of this node to be input into another node, either as audio data or as the value of an AudioParam.

Throws:

null

DOMError

disconnect(destination:AudioParam, output:Int):Void

disconnect():Void

disconnect(output:Int):Void

disconnect(destination:AudioNode):Void

disconnect(destination:AudioNode, output:Int):Void

disconnect(destination:AudioNode, output:Int, input:Int):Void

disconnect(destination:AudioParam):Void

Allows us to disconnect the current node from another one it is already connected to.

Throws:

null

DOMError

Defined by EventTarget

addEventListener(type:String, listener:Function, ?options:EitherType<AddEventListenerOptions, Bool>, ?wantsUntrusted:Bool):Void

addEventListener(type:String, listener:EventListener, ?options:EitherType<AddEventListenerOptions, Bool>, ?wantsUntrusted:Bool):Void

Register an event handler of a specific event type on the EventTarget.

Throws:

null

DOMError

dispatchEvent(event:Event):Bool

Dispatch an event to this EventTarget.

Throws:

null

DOMError

removeEventListener(type:String, listener:Function, ?options:EitherType<EventListenerOptions, Bool>):Void

removeEventListener(type:String, listener:EventListener, ?options:EitherType<EventListenerOptions, Bool>):Void

Removes an event listener from the EventTarget.

Throws:

null

DOMError