AudioBufferSourceNode Class

A source that plays an AudioBuffer (https://webaudio.github.io/web-audio-api/#AudioBufferSourceNode), with a playback rate, a detune, a loop, and sub-sample accurate start and stop times (the samples are linearly interpolated).

public sealed class AudioBufferSourceNode : AudioScheduledSourceNode
Inheritance
AudioScheduledSourceNode AudioBufferSourceNode

Constructors

NameDescription
AudioBufferSourceNode(BaseAudioContext, AudioBufferSourceOptions?)Creates a buffer source.

AudioBufferSourceNode(BaseAudioContext, AudioBufferSourceOptions?)

AudioBufferSourceNode.cs

Creates a buffer source.

public AudioBufferSourceNode(BaseAudioContext context, AudioBufferSourceOptions? options = null)

Properties

NameDescription
BufferGets or sets the buffer to play. A buffer can only be set once.
DetuneGets the detune of the playback in cents (k-rate).
LoopGets or sets a value indicating whether the region from AudioBufferSourceNode.LoopStart to AudioBufferSourceNode.LoopEnd is played in a loop.
LoopEndGets or sets the playhead position in seconds where the loop ends (exclusive); 0 for the end of the buffer.
LoopStartGets or sets the playhead position in seconds where the loop starts.
PlaybackRateGets the speed of the playback (k-rate).

Gets or sets the buffer to play. A buffer can only be set once.

public AudioBuffer? Buffer { get; set; }

Property value

AudioBuffer?

Exceptions

DomException
A buffer was already set (an InvalidStateError).

See also

Gets the detune of the playback in cents (k-rate).

public AudioParam Detune { get; }

Gets or sets a value indicating whether the region from AudioBufferSourceNode.LoopStart to AudioBufferSourceNode.LoopEnd is played in a loop.

public bool Loop { get; set; }

Gets or sets the playhead position in seconds where the loop ends (exclusive); 0 for the end of the buffer.

public double LoopEnd { get; set; }

Gets or sets the playhead position in seconds where the loop starts.

public double LoopStart { get; set; }

Gets the speed of the playback (k-rate).

public AudioParam PlaybackRate { get; }

Methods

NameDescription
Start(double, double?, double?)Schedules the start of the playback at a time, from a position of the buffer, for a duration of buffer content.

Start(double, double?, double?)

AudioBufferSourceNode.cs

Schedules the start of the playback at a time, from a position of the buffer, for a duration of buffer content.

public void Start(double when = 0d, double? offset = null, double? duration = null)

Parameters

when double
The time of the context when the playback starts.
offset double?
The playhead position in seconds where the playback starts.
duration double?
The duration in seconds of buffer content to play (including the loop iterations), or null to play until the end.

Exceptions

DomException
The source was already started (an InvalidStateError).

See also