This interface represents a set of AudioNode objects and their connections. It allows for arbitrary routing of signals to the AudioDestinationNode (what the user ultimately hears). Nodes are created from the context and are then connected together. In most use cases, only a single AudioContext is used per document. An AudioContext is constructed as follows:
var context = new AudioContext();
The number of AudioBufferSourceNodes that are currently playing.
An AudioDestinationNode with a single input representing the final destination for all audio (to be rendered to the audio hardware). All AudioNodes actively rendering audio will directly or indirectly connect to destination.
An AudioListener which is used for 3D spatialization.
The sample rate (in sample-frames per second) at which the AudioContext handles audio. It is assumed that all AudioNodes in the context run at this rate. In making this assumption, sample-rate converters or "varispeed" processors are not supported in real-time processing.
Creates a AnalyserNode.
Creates a BiquadFilterNode representing a second order filter which can be configured as one of several common filter types.
Creates an AudioBuffer of the given size. The audio data in the buffer will be zero-initialized (silent). An exception will be thrown if the numberOfChannels or sampleRate are out-of-bounds.
how many channels the buffer will have. An implementation must support at least 32 channels.
the size of the buffer in sample-frames.
the sample-rate of the linear PCM audio data in the buffer in sample-frames per second. An implementation must support sample-rates in at least the range 22050 to 96000.
Creates an AudioBuffer given the audio file data contained in the ArrayBuffer. The ArrayBuffer can, for example, be loaded from an XMLHttpRequest's response attribute after setting the responseType to "arraybuffer". Audio file data can be in any of the formats supported by the audio element. The following steps must be performed:
the audio file data (for example from a .wav file).
if a mixdown to mono will be performed. Normally, this would not be set.
Creates an AudioBufferSourceNode.
Creates an ChannelMergerNode representing a channel merger. An exception will be thrown for invalid parameter values.
the number of inputs. Values of up to 32 must be supported. If not specified, then 6 will be used.
Creates an ChannelSplitterNode representing a channel splitter. An exception will be thrown for invalid parameter values.
the number of outputs. Values of up to 32 must be supported. If not specified, then 6 will be used.
Creates a ConvolverNode.
Creates a DelayNode representing a variable delay line. The initial default delay time will be 0 seconds.
the maximum delay time in seconds allowed for the delay line. If specified, this value must be greater than zero and less than three minutes or a NOT_SUPPORTED_ERR exception will be thrown.
Creates a DynamicsCompressorNode.
Creates a GainNode.
Creates a MediaElementAudioSourceNode given an HTMLMediaElement. As a consequence of calling this method, audio playback from the HTMLMediaElement will be re-routed into the processing graph of the AudioContext.
Creates a MediaStreamAudioSourceNode given a MediaStream. As a consequence of calling this method, audio playback from the MediaStream will be re-routed into the processing graph of the AudioContext.
Creates an OscillatorNode.
Creates an PannerNode.
the buffer size in units of sample-frames. It must be one of the following values: 256, 512, 1024, 2048, 4096, 8192, 16384. This value controls how frequently the onaudioprocess event handler is called and how many sample-frames need to be processed each call. Lower values for bufferSize will result in a lower (better) latency. Higher values will be necessary to avoid audio breakup and glitches. The value chosen must carefully balance between latency and audio quality.
(defaults to 2) the number of channels for this node's input. Values of up to 32 must be supported.
(defaults to 2) the number of channels for this node's output. Values of up to 32 must be supported.
Creates a WaveShaperNode representing a non-linear distortion.
Creates a WaveTable representing a waveform containing arbitrary harmonic content. The real and imag parameters must be of type Float32Array of equal lengths greater than zero and less than or equal to 4096 or an exception will be thrown. These parameters specify the Fourier coefficients of a Fourier series representing the partials of a periodic waveform. The created WaveTable will be used with an OscillatorNode and will represent a normalized time-domain waveform having maximum absolute peak value of 1. Another way of saying this is that the generated waveform of an OscillatorNode will have maximum peak value at 0dBFS. Conveniently, this corresponds to the full-range of the signal values used by the Web Audio API. Because the WaveTable will be normalized on creation, the real and imag parameters represent relative values.
an array of cosine terms (traditionally the A terms). In audio terminology, the first element (index 0) is the DC-offset of the periodic waveform and is usually set to zero. The second element (index 1) represents the fundamental frequency. The third element represents the first overtone, and so on.
an array of sine terms (traditionally the B terms). The first element (index 0) should be set to zero (and will be ignored) since this term does not exist in the Fourier series. The second element (index 1) represents the fundamental frequency. The third element represents the first overtone, and so on.
The following steps must be performed: