How it works
Everything happens inside an AudioContext, where you connect nodes into a graph: sources (an oscillator, a decoded sound file, a microphone stream), processing nodes (volume, filters, delay, reverb, stereo panning, compression) and a destination, usually the speakers. An AnalyserNode exposes frequency and waveform data for visualisers, and AudioWorklet runs custom processing code on the audio thread, so busy page scripts do not interrupt the sound.
It is lower level than an audio element, which is enough for simply playing a file. Browsers only let a page start sound after a user gesture such as a click, so an AudioContext begins suspended until then. Libraries such as Tone.js (music and synthesis) and Howler.js (game and interface sounds) build on it.
Web Audio API pricing
Related terms
More in Media and documents
Video and audio