AudioContext Class
An audio context that renders its graph in real time (https://webaudio.github.io/web-audio-api/#AudioContext). There is no audio device: the audio is rendered and discarded, at the pace of the clock of the event loop (DomEventLoop.TimeProvider), so that the time of the context progresses as in a browser.
public sealed class AudioContext : BaseAudioContextRemarks
The rendering runs in timer tasks of the event loop of the window of the context: a task renders the render quanta whose time has elapsed. A context is allowed to start: it starts running after its construction. A context created by .NET code without window does not render (its time does not progress), but its state changes.
See also
- Inheritance
BaseAudioContextAudioContext
Constructors
| Name | Description |
|---|---|
| AudioContext(AudioContextOptions?) | Creates a realtime context, which starts running. |
AudioContext(AudioContextOptions?)
AudioContext.csCreates a realtime context, which starts running.
public AudioContext(AudioContextOptions? contextOptions = null)Parameters
contextOptionsAudioContextOptions?
Exceptions
DomException- The sample rate or the render quantum size is not supported (a
NotSupportedError), or the document is not fully active (anInvalidStateError).
See also
Properties
| Name | Description |
|---|---|
| BaseLatency | Gets the latency in seconds of the processing of the audio by the context (the latency of the hint, rounded to render quanta). |
| OnError | Gets or sets the event handler of the error event. |
| OnSinkChange | Gets or sets the event handler of the sinkchange event. |
| OutputLatency | Gets the latency in seconds of the audio output: 0, as there is no audio device. |
| PlaybackStats | Gets the statistics of the playback. |
| SinkId | Gets the audio output device: the identifier of a device (the empty string for the default device), or an AudioSinkInfo. |
BaseLatency
AudioContext.csGets the latency in seconds of the processing of the audio by the context (the latency of the hint, rounded to render quanta).
public double BaseLatency { get; }OnError
AudioContext.csGets or sets the event handler of the error event.
Property value
See also
OnSinkChange
AudioContext.csGets or sets the event handler of the sinkchange event.
Property value
See also
OutputLatency
AudioContext.csGets the latency in seconds of the audio output: 0, as there is no audio device.
public double OutputLatency { get; }Property value
See also
PlaybackStats
AudioContext.csGets the statistics of the playback.
public AudioPlaybackStats PlaybackStats { get; }SinkId
AudioContext.csGets the audio output device: the identifier of a device (the empty string for the default device), or an AudioSinkInfo.
public StringOrAudioSinkInfo SinkId { get; }Property value
See also
Methods
| Name | Description |
|---|---|
| Close() | Closes the context: the rendering stops, and the context cannot be resumed. |
| GetOutputTimestamp() | Returns the time of the last rendered frame, and the time of the performance timeline at which it is output (both 0 before the first render quantum). |
| Resume() | Resumes the rendering suspended by AudioContext.Suspend. |
| SetSinkId(StringOrAudioSinkOptions) | Changes the audio output device: the empty string for the default device, or the options of a sink without device. |
| Suspend() | Suspends the rendering: the time of the context stops progressing. |
Close()
AudioContext.csGetOutputTimestamp()
AudioContext.csReturns the time of the last rendered frame, and the time of the performance timeline at which it is output (both 0 before the first render quantum).
public AudioTimestamp GetOutputTimestamp()Resume()
AudioContext.csResumes the rendering suspended by AudioContext.Suspend.
public Task Resume()SetSinkId(StringOrAudioSinkOptions)
AudioContext.csChanges the audio output device: the empty string for the default device, or the options of a sink without device.
public Task SetSinkId(StringOrAudioSinkOptions sinkId)Parameters
sinkIdStringOrAudioSinkOptions
Returns
Task A task completed once the device is changed: failed with a NotAllowedError when the speaker-selection feature is not allowed, or a NotFoundError for an unknown device.