Firefox Tomorrow

web api interface

AudioContext

View on MDN ↗

The AudioContext interface represents an audio-processing graph built from audio modules linked together, each represented by an AudioNode.

An audio context controls both the creation of the nodes it contains and the execution of the audio processing, or decoding. You need to create an AudioContext before you do anything else, as everything happens inside a context. It’s recommended to create one AudioContext and reuse it instead of initializing a new one each time, and it’s OK to use a single AudioContext for several different audio sources and pipeline concurrently.

Constructor

Instance properties

Also inherits properties from its parent interface, BaseAudioContext.

  • baseLatency Read only
    • : Returns the number of seconds of processing latency incurred by the AudioContext passing the audio from the AudioDestinationNode to the audio subsystem.
  • outputLatency Read only
    • : Returns an estimation of the output latency of the current audio context.
  • playbackStats Read only Experimental
    • : Returns an AudioPlaybackStats object providing access to duration, underrun, and latency statistics for the AudioContext.
  • sinkId Read only Experimental
    • : Returns the sink ID of the current output audio device.

Instance methods

Also inherits methods from its parent interface, BaseAudioContext.

Events

  • sinkchange Experimental
    • : Fired when the output audio device (and therefore, the sinkId) has changed.

Examples

Basic audio context declaration:

const audioCtx = new AudioContext();

const oscillatorNode = audioCtx.createOscillator();
const gainNode = audioCtx.createGain();
const finish = audioCtx.destination;
// etc.

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.

See also