This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for the proper prefixes to use in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the spec changes.
The Web Audio API is an API designed to manipulate and play audio assets on a Web page or application.
The API has been designed to allow modular routing. Basic audio operations are performed by audio nodes that are linked together to form an audio routing graphs. Inside a same context, several sources are supported, with different kind of channel layout. This modular design allows for great flexibility and for the creation of complex audio functions and of dynamic effects.
Audio nodes are linked via their inputs and outputs. Each input or output is composed of several channels representing a specific audio layout. Though mono, stereo, quad and 5.1 audio layouts are supported, any discrete layouts are supported.
Sources of audio can be very various: it can be generated directly in JavaScript by a specific audio node, like an oscillator, a custom function, or even a simple array of data, it can be linked to an HTML media element, like <video> or <audio>, or it can come from a WebRTC MediaStream, that is from a local device camera or even from a distant computer.
Timing is controlled with high precision, to the sample, and very low latency: it allows for carefully definition of events required by drum machines or sequencers.
The Web Audio API also allows to control how the audio are spatialized: using a system based on a source-listener model, it allows to controls the panning model to be used, automatically deals with distance-induced attenuation, or doppler shift induced by a moving source, or listener.
Reference
AnalyserNodeAudioBufferAudioBufferSourceNodeAudioContextAudioDestinationNodeAudioListenerAudioNodeAudioParamaudioprocess(event)AudioProcessingEventBiquadFilterNodeChannelMergerNodeChannelSplitterNodecomplete(event)ConvolverNodeDelayNodeDynamicsCompressorNodeended(event)GainNodeMediaElementAudioSourceNodeMediaStreamAudioDestinationNodeMediaStreamAudioSourceNodeOfflineAudioCompletionEventOfflineAudioContextOscillatorNodePannerNodeScriptProcessorNodeWaveShaperNodeWaveTable
Tutorials
- Using the Web Audio API
- Getting Started with the Web Audio API (but describes a WebKit-only non-standard implementation)
- Mixing Positional Audio and WebGL
- Developing Game Audio with the Web Audio API
Specifications
| Specification | Status | Comment |
|---|---|---|
| Web Audio API | Working Draft |
Browser compatibility
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
|---|---|---|---|---|---|
| Basic support | (Yes)webkit | Activated on Nightly only | Not supported | Not supported | 6 webkit |
| Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|
| Basic support | ? | Activated on Nightly only | Not supported | Not supported | 6 webkit |
Mozilla Developer Network