The AudioContext() constructor creates a new AudioContext object which represents an audio-processing graph, built from audio modules linked together, each represented by an AudioNode.


new AudioContext();
new AudioContext(options);


options Optional
An object based on the AudioContextOptions dictionary that contains zero or more optional properties to configure the new context (see dictionary for details of the available properties).

Return value

The newly constructed AudioContext instance.


The specified sampleRate isn't supported by the context.

Usage notes

The specification doesn't go into a lot of detail about things like how many audio contexts a user agent should support, or minimum or maximum latency requirements (if any), so these details can vary from browser to browser. Be sure to check the values if they matter to you.

In particular, the specification doesn't indicate a maximum or minimum number of audio contexts that must be able to be open at the same time, so this is left up to the browser implementations to decide.

Google Chrome

Per-tab audio context limitation in Chrome

Prior to version 66 Google Chrome only supported up to six audio contexts per tab at a time.

Non-standard exceptions in Chrome

If the value of the latencyHint  property isn't valid, Chrome throws a TypeError exception with the message "The provided value '...' is not a valid enum value of type AudioContextLatencyCategory".


This example creates a new AudioContext for interactive audio (optimizing for latency) and a sample rate of 44.1kHz.

var AudioContext = window.AudioContext || window.webkitAudioContext;

var audioCtx = new AudioContext({
  latencyHint: 'interactive',
  sampleRate: 44100,


Specification Status Comment
Web Audio API
The definition of 'AudioContext()' in that specification.
Working Draft Initial definition.

Browser compatibility

BCD tables only load in the browser

See also