Table of Contents

Class AudioBufferSourceNode

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The AudioBufferSourceNode interface is an AudioScheduledSourceNode which represents an audio source consisting of in-memory audio data, stored in an AudioBuffer.

[Value("AudioBufferSourceNode")]
public class AudioBufferSourceNode : AudioScheduledSourceNode
Inheritance
AudioBufferSourceNode
Inherited Members

Remarks

This interface 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 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 Start(Number, Number, Number), 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 AudioBuffers 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 AudioScheduledSourceNodestop are allowed. The most recent call replaces the previous one, if the AudioBufferSourceNode has not already reached the end of the buffer.

The AudioBufferSourceNode takes the content of an AudioBuffer and m

-Using the Web Audio API
-Web Audio API

See also on MDN

Constructors

AudioBufferSourceNode()

public AudioBufferSourceNode()

AudioBufferSourceNode(BaseAudioContext, AudioBufferSourceOptions)

The AudioBufferSourceNode()
constructor creates a new AudioBufferSourceNode object instance.

public AudioBufferSourceNode(BaseAudioContext context, AudioBufferSourceOptions options = null)

Parameters

context BaseAudioContext
options AudioBufferSourceOptions

Remarks

Properties

Buffer

The buffer property of the AudioBufferSourceNode interface provides the ability to play back audio using an AudioBuffer as the source of the sound data.

[Value("buffer")]
public AudioBuffer? Buffer { get; set; }

Property Value

AudioBuffer

An AudioBuffer which contains the data representing the sound which the
node will play.

Remarks

If the buffer property is set to the value null, the node
generates a single channel containing silence (that is, every sample is 0).

-Using the Web Audio API
-Web Audio API

See also on MDN

Detune

The detune property of the
AudioBufferSourceNode interface is a k-rate AudioParam
representing detuning of oscillation in cents.

[Value("detune")]
public AudioParam Detune { get; }

Property Value

AudioParam

A k-rate AudioParam
whose value indicates the detuning of oscillation in cents.

NOTE
Though the AudioParam returned is read-only, the
value it represents is not.

Remarks

For example, values of +100 and -100 detune the source up or down by one semitone,
while +1200 and -1200 detune it up or down by one octave.

-Using the Web Audio API
-Web Audio API

See also on MDN

Loop

The loop property of the AudioBufferSourceNode
interface is a Boolean indicating if the audio asset must be replayed when the end of
the AudioBuffer is reached.

[Value("loop")]
public bool Loop { get; set; }

Property Value

bool

A Boolean which is true if looping is enabled; otherwise, the value is
false.When looping is enabled, the sound begins playing at the time specified as the start
point when Start(Number, Number, Number) is called. When the
time specified by the LoopEnd property
is reached, playback continues at the time specified by
LoopStart

Remarks

The loop property's default value is false.

-Web Audio API
-Using the Web Audio API
-AudioBufferSourceNode

See also on MDN

LoopEnd

The loopEnd property of the AudioBufferSourceNode
interface 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 LoopStart property.
This is only used if the Loop property is
true.

[Value("loopEnd")]
public Number LoopEnd { get; set; }

Property Value

Number

A floating-point number indicating the offset, in seconds, into the audio buffer at
which each loop will loop return to the beginning of the loop (that is, the current play
time gets reset to LoopStart). This property is
only used if the Loop property is
true.The default value is 0.

Remarks

LoopStart

The loopStart property of the AudioBufferSourceNode interface is a floating-point value indicating, in seconds, where in the AudioBuffer the restart of the play must happen.

[Value("loopStart")]
public Number LoopStart { get; set; }

Property Value

Number

A floating-point number indicating the offset, in seconds, into the audio buffer at
which each loop should begin during playback. This value is only used when the
Loop parameter is true.

Remarks

The loopStart property's default value is 0.

-Web Audio API
-Using the Web Audio API

See also on MDN

PlaybackRate

The playbackRate property of
the AudioBufferSourceNode interface Is a k-rate AudioParam that
defines the speed at which the audio asset will be played.

[Value("playbackRate")]
public AudioParam PlaybackRate { get; }

Property Value

AudioParam

An AudioParam whose Value is a
floating-point value indicating the playback rate of the audio as a decimal proportion
of the original sampling rate.Consider a sound buffer containing audio sampled at 44.1 kHz (44,100 samples per
second). Let's see what a few values of playbackRate do:

Remarks

A value of 1.0 indicates it should play at the same speed as its sampling rate,
values less than 1.0 cause the sound to play more slowly, while values greater than
1.0 result in audio playing faster than normal. The default value is 1.0.
When set to another value, the AudioBufferSourceNode resamples the audio
before sending it to the output.

-Using the Web Audio API
-Web Audio API

See also on MDN

Methods

Start(Number, Number, Number)

The start() method of the AudioBufferSourceNode
Interface is used to schedule playback of the audio data contained in the buffer, or
to begin playback immediately.

[Value("start")]
public GlobalObject.Undefined Start(Number when = null, Number offset = null, Number duration = null)

Parameters

when Number
offset Number
duration Number

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks