OfflineAudioContext Class

An audio context that renders its graph to AudioBuffer objects as fast as possible (https://webaudio.github.io/web-audio-api/#OfflineAudioContext), deterministically.

public sealed class OfflineAudioContext : BaseAudioContext

Remarks

The rendering runs in tasks of the event loop of the window of the context: startRendering() returns before the rendering starts, and the promise is resolved by a task once the buffer is rendered. A context created by .NET code without window renders synchronously.

See also

Inheritance
BaseAudioContext OfflineAudioContext

Constructors

NameDescription
OfflineAudioContext(OfflineAudioContextOptions)Creates an offline context.
OfflineAudioContext(uint, uint, float)Creates an offline context that renders a buffer of a number of channels, a length and a sample rate.

OfflineAudioContext overloads

OfflineAudioContext(OfflineAudioContextOptions)

OfflineAudioContext.cs

Creates an offline context.

public OfflineAudioContext(OfflineAudioContextOptions contextOptions)
Parameters
contextOptions OfflineAudioContextOptions
Exceptions
DomException
An option is not supported (a NotSupportedError), or the document is not fully active (an InvalidStateError).
See also

OfflineAudioContext(uint, uint, float)

OfflineAudioContext.cs

Creates an offline context that renders a buffer of a number of channels, a length and a sample rate.

public OfflineAudioContext(uint numberOfChannels, uint length, float sampleRate)
Parameters
numberOfChannels uint
length uint
sampleRate float
Exceptions
DomException
An argument is not supported (a NotSupportedError), or the document is not fully active (an InvalidStateError).
See also

Properties

NameDescription
LengthGets the length of the rendering in sample frames, or null for a rendering of undefined length.
OnCompleteGets or sets the event handler of the complete event.

Gets the length of the rendering in sample frames, or null for a rendering of undefined length.

public uint? Length { get; }

Gets or sets the event handler of the complete event.

public Action<Event>? OnComplete { get; set; }

Methods

NameDescription
Close()Closes the context: the rendering stops.
Resume()Resumes the rendering suspended by OfflineAudioContext.Suspend.
StartRendering(uint?)Starts the rendering of a buffer: the remaining frames of the context, or a chunk of frames (rounded up to a multiple of the render quantum size).
Suspend(double)Schedules a suspension of the rendering at a time (rounded up to a render quantum boundary).

Closes the context: the rendering stops.

public Task Close()

StartRendering(uint?)

OfflineAudioContext.cs

Starts the rendering of a buffer: the remaining frames of the context, or a chunk of frames (rounded up to a multiple of the render quantum size).

public Task<AudioBuffer> StartRendering(uint? chunkSize = null)

Parameters

chunkSize uint?
The number of frames to render, or null.

Returns

Task<AudioBuffer> A task completed with the rendered buffer.

See also

Suspend(double)

OfflineAudioContext.cs

Schedules a suspension of the rendering at a time (rounded up to a render quantum boundary).

public Task Suspend(double suspendTime)