BaseAudioContext Class
The base of the audio contexts (https://webaudio.github.io/web-audio-api/#BaseAudioContext): a graph of AudioNode objects rendered in blocks of sample frames (render quanta) to its BaseAudioContext.Destination, with a time that starts at 0 and advances as the graph is rendered.
public abstract class BaseAudioContext : EventTargetRemarks
The graph is rendered on the thread of the event loop of the window of the context, never concurrently with its scripts. A context created by .NET code without window renders when its methods are called.
See also
- Inheritance
EventTargetBaseAudioContext
Properties
| Name | Description |
|---|---|
| AudioWorklet | Gets the worklet of the AudioWorkletProcessor classes of the context. |
| CurrentTime | Gets the time of the context in seconds: the time of the next sample frame to render. |
| Destination | Gets the node to which the audio of the graph is rendered. |
| Listener | Gets the listener of the spatialization of the PannerNode objects. |
| OnStateChange | Gets or sets the event handler of the statechange event. |
| RenderQuantumSize | Gets the number of sample frames of a render quantum. |
| SampleRate | Gets the sample rate of the context in Hz. |
| State | Gets the state of the context. |
AudioWorklet
BaseAudioContext.csGets the worklet of the AudioWorkletProcessor classes of the context.
public AudioWorklet AudioWorklet { get; }Property value
Exceptions
InvalidOperationException- The context was created by .NET code without window: there is no script engine.
See also
CurrentTime
BaseAudioContext.csGets the time of the context in seconds: the time of the next sample frame to render.
public double CurrentTime { get; }Property value
See also
Destination
BaseAudioContext.csGets the node to which the audio of the graph is rendered.
public AudioDestinationNode Destination { get; }Listener
BaseAudioContext.csGets the listener of the spatialization of the PannerNode objects.
public AudioListener Listener { get; }Property value
See also
OnStateChange
BaseAudioContext.csGets or sets the event handler of the statechange event.
RenderQuantumSize
BaseAudioContext.csGets the number of sample frames of a render quantum.
public uint RenderQuantumSize { get; }Property value
See also
SampleRate
BaseAudioContext.csState
BaseAudioContext.csMethods
| Name | Description |
|---|---|
| CreateAnalyser() | Creates a node that provides the time-domain and frequency-domain data of its input. |
| CreateBiquadFilter() | Creates a second-order filter. |
| CreateBuffer(uint, uint, float) | Creates a buffer of silence. |
| CreateBufferSource() | Creates a node that plays an AudioBuffer. |
| CreateChannelMerger(uint) | Creates a node that combines its inputs into the channels of its output. |
| CreateChannelSplitter(uint) | Creates a node whose outputs are the channels of its input. |
| CreateConstantSource() | Creates a node that outputs a constant value. |
| CreateConvolver() | Creates a node that convolves its input with an impulse response. |
| CreateDelay(double) | Creates a node that delays its input. |
| CreateDynamicsCompressor() | Creates a dynamics compressor. |
| CreateGain() | Creates a node that multiplies its input by a gain. |
| CreateIIRFilter(IReadOnlyList<double>, IReadOnlyList<double>) | Creates a general infinite impulse response filter. |
| CreateOscillator() | Creates a source of a periodic waveform. |
| CreatePanner() | Creates a node that spatializes its input relative to the listener. |
| CreatePeriodicWave(IReadOnlyList<float>, IReadOnlyList<float>, PeriodicWaveConstraints?) | Creates a periodic waveform from the coefficients of its Fourier series. |
| CreateScriptProcessor(uint, uint, uint) | Creates a node that processes its input with the audioprocess events (deprecated). |
| CreateStereoPanner() | Creates a node that pans its input in a stereo image. |
| CreateWaveShaper() | Creates a node that applies a distortion curve to its input. |
| DecodeAudioData(ReadOnlyMemory<byte>) | Decodes an audio file to an AudioBuffer at the sample rate of the context: WAV (integer PCM of 8 to 32 bits, floats, A-law and µ-law) or FLAC. |
| DecodeAudioDataArray(object, DecodeSuccessCallback?, DecodeErrorCallback?) | Decodes an audio file (WAV or FLAC) for the scripts, and detaches its ArrayBuffer: use BaseAudioContext.DecodeAudioData in .NET code. |
CreateAnalyser()
BaseAudioContext.csCreates a node that provides the time-domain and frequency-domain data of its input.
public AnalyserNode CreateAnalyser()CreateBiquadFilter()
BaseAudioContext.csCreates a second-order filter.
public BiquadFilterNode CreateBiquadFilter()CreateBuffer(uint, uint, float)
BaseAudioContext.csCreates a buffer of silence.
public AudioBuffer CreateBuffer(uint numberOfChannels, uint length, float sampleRate)Parameters
Returns
See also
CreateBufferSource()
BaseAudioContext.csCreates a node that plays an AudioBuffer.
public AudioBufferSourceNode CreateBufferSource()CreateChannelMerger(uint)
BaseAudioContext.csCreates a node that combines its inputs into the channels of its output.
public ChannelMergerNode CreateChannelMerger(uint numberOfInputs = 6U)CreateChannelSplitter(uint)
BaseAudioContext.csCreates a node whose outputs are the channels of its input.
public ChannelSplitterNode CreateChannelSplitter(uint numberOfOutputs = 6U)CreateConstantSource()
BaseAudioContext.csCreates a node that outputs a constant value.
public ConstantSourceNode CreateConstantSource()CreateConvolver()
BaseAudioContext.csCreates a node that convolves its input with an impulse response.
public ConvolverNode CreateConvolver()CreateDelay(double)
BaseAudioContext.csCreates a node that delays its input.
CreateDynamicsCompressor()
BaseAudioContext.csCreates a dynamics compressor.
public DynamicsCompressorNode CreateDynamicsCompressor()CreateGain()
BaseAudioContext.csCreates a node that multiplies its input by a gain.
public GainNode CreateGain()CreateIIRFilter(IReadOnlyList<double>, IReadOnlyList<double>)
BaseAudioContext.csCreates a general infinite impulse response filter.
public IIRFilterNode CreateIIRFilter(IReadOnlyList<double> feedforward, IReadOnlyList<double> feedback)CreateOscillator()
BaseAudioContext.csCreates a source of a periodic waveform.
public OscillatorNode CreateOscillator()CreatePanner()
BaseAudioContext.csCreates a node that spatializes its input relative to the listener.
public PannerNode CreatePanner()CreatePeriodicWave(IReadOnlyList<float>, IReadOnlyList<float>, PeriodicWaveConstraints?)
BaseAudioContext.csCreates a periodic waveform from the coefficients of its Fourier series.
public PeriodicWave CreatePeriodicWave(IReadOnlyList<float> real, IReadOnlyList<float> imag, PeriodicWaveConstraints? constraints = null)Parameters
realIReadOnlyList<float>imagIReadOnlyList<float>constraintsPeriodicWaveConstraints?
Returns
Exceptions
DomException- The arrays have different lengths, or a length less than 2 (an
IndexSizeError).
See also
CreateScriptProcessor(uint, uint, uint)
BaseAudioContext.csCreates a node that processes its input with the audioprocess events (deprecated).
public ScriptProcessorNode CreateScriptProcessor(uint bufferSize = 0U, uint numberOfInputChannels = 2U, uint numberOfOutputChannels = 2U)Parameters
bufferSizeuint- The number of frames of the buffers of the events (a power of two from 256 to 16384), or 0 to let the implementation choose.
numberOfInputChannelsuint- The number of channels of the input.
numberOfOutputChannelsuint- The number of channels of the output.
Returns
Exceptions
DomException- An argument is out of its range (an
IndexSizeError), or the buffer size is not a multiple of the render quantum size (aNotSupportedError).
See also
CreateStereoPanner()
BaseAudioContext.csCreates a node that pans its input in a stereo image.
public StereoPannerNode CreateStereoPanner()CreateWaveShaper()
BaseAudioContext.csCreates a node that applies a distortion curve to its input.
public WaveShaperNode CreateWaveShaper()DecodeAudioData(ReadOnlyMemory<byte>)
BaseAudioContext.csDecodes an audio file to an AudioBuffer at the sample rate of the context: WAV (integer PCM of 8 to 32 bits, floats, A-law and µ-law) or FLAC.
public Task<AudioBuffer> DecodeAudioData(ReadOnlyMemory<byte> audioData)Parameters
audioDataReadOnlyMemory<byte>
Returns
Task<AudioBuffer> A task completed with the buffer, or failed with a DomException: an EncodingError when the file cannot be decoded, an InvalidStateError when the document is not fully active.
See also
DecodeAudioDataArray(object, DecodeSuccessCallback?, DecodeErrorCallback?)
BaseAudioContext.csDecodes an audio file (WAV or FLAC) for the scripts, and detaches its ArrayBuffer: use BaseAudioContext.DecodeAudioData in .NET code.
public Task<AudioBuffer> DecodeAudioDataArray(object audioData, DecodeSuccessCallback? successCallback = null, DecodeErrorCallback? errorCallback = null)Parameters
audioDataobjectsuccessCallbackDecodeSuccessCallback?errorCallbackDecodeErrorCallback?