Web Audio API

Last Updated : 4 Feb, 2026

The Web Audio API is a powerful JavaScript API used to create, process, and control audio directly in the browser. It enables real-time audio effects, analysis, and advanced sound manipulation for web applications.

  • Used for playing, recording, and manipulating audio
  • Supports real-time audio processing
  • Allows audio effects like echo, reverb, and filters
  • Works with audio from files, microphones, or streams
  • Commonly used in music apps, games, and voice-based features.
Syntax: var latency = audioCtx.outputLatency;

[Example]: Creates an AudioContext and logs the audio output latency to the browser console.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>
        AudioContext outputLatency property
    </title>
</head>

<body>
    <center>
        <h1 style="color:green">
        GeeksforGeeks
        </h1>
        <h2>AudioContext outputLatency property</h2>
    </center>
</body>

</html>
JavaScript
const audioCtx = new AudioContext();
console.log(audioCtx.outputLatency);
  • Creates a new AudioContext instance.
  • Accesses the outputLatency property.
  • Prints the output latency value in the console.
Return Value: A double value is returned in seconds.
Comment