Open-source project
mdn/webaudio-examples avatar
mdn/webaudio-examples

mdn/webaudio-examples: Web Audio API Demos

Code examples that accompany the MDN Web Docs pages relating to Web Audio.

1,439 stars443 forksHTMLCC0-1.0

At a glance

What is it?
mdn/webaudio-examples is a browser-based collection for learning the Web Audio API. It covers playback, analysis, recording, filtering, spatialization, worklets, and offline rendering, but it is not a complete audio framework.
Who is it for?
Adopt this repository if you need small, readable references for Web Audio API concepts or want a starting point for an interactive browser demo. Do not treat it as a production audio engine, framework, or complete application starter because it has no package installation workflow, releases, application-level abstractions, or documented production support model.
Can I use it commercially?
Yes. CC0-1.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 20 days ago.
What is it written in?
Mainly HTML, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 23, 2026, and from our analysis. They are not legal advice.

Editorial analysis

What webaudio-examples Covers

mdn/webaudio-examples solves the problem of demonstrating individual Web Audio API capabilities in a browser. Its examples accompany the MDN Web Docs pages, so the intended audience is developers who want a concrete starting point for understanding an interface, node, method, or processing pattern. The repository is not a single application with one fixed audio workflow. It is a collection of directories, each focused on a different part of the API.

The collection includes basic playback controls. The audio-basics directory presents a retro-style boombox for playing audio, adjusting stereo panning, and changing volume. The audio-analyser directory visualizes audio-signal data obtained from an AnalyserNode. The audio-buffer directory demonstrates AudioBuffer, while audio-param covers methods associated with AudioParam.

Other directories address context lifecycle and signal processing. audiocontext-states illustrates the states property and the close(), resume(), and suspend() methods. audioworklet demonstrates AudioWorklet. compressor-example shows BaseAudioContext.createDynamicsCompressor() and DynamicsCompressorNode. The offline-audio-context and offline-audio-context-promise directories cover rendering audio into a buffer away from immediate playback.

The repository also includes media and routing examples. decode-audio-data demonstrates BaseAudioContext.decodeAudioData(), iirfilter-node covers IIRFilterNode, and media-source-buffer uses AudioContext.createMediaElementSource(). create-media-stream-destination connects a Web Audio stream to MediaRecorder and documents an Opus output example. The top-level layout also includes panner-node, spatialization, stereo-panner-node, multi-track, step-sequencer, output-timestamp, stream-source-buffer, and voice-change-o-matic, although the README excerpt does not describe every one of those directories in detail.

How Web Audio Graph Processing Appears in the Examples

The examples use the browser's Web Audio API as the processing environment. The documented examples organize browser code around audio nodes and an audio context, with connections determining how signal data moves. In the multi-track example, separate independently playable audio tracks connect to one AudioDestinationNode. This makes the example a concrete illustration of combining several sources before the final output.

The analyser example takes data from an AnalyserNode and draws a graphical representation of the audio signal. This differs from a normal media-player example because it illustrates inspecting or transforming an audio graph. The IIR filter example focuses on a processing node, while panner-node, spatialization, and stereo-panner-node are named for routing and positioning concerns. These examples are useful when a developer needs to see how browser audio processing interfaces fit together rather than merely how a file is played.

The recording example follows a different data path. AudioContext.createMediaStreamDestination() produces a stream that can be passed to a MediaRecorder instance. The README describes the example as outputting a sine wave to an Opus file. That path is useful for understanding how Web Audio output can become a recorded browser media object, but it also means the example is tied to browser media capabilities and the availability of the selected output format.

The worklet and offline-context examples show that the collection is not limited to immediate playback. AudioWorklet provides a separate processor path for audio work, while OfflineAudioContext can render audio in the background and produce a buffer. The exact source files and node wiring for each demo are stored in its directory, but the README does not describe a shared architecture, shared package setup, or common application layer.

Installing and Previewing the Audio Analyser Demo

The README documents local serving rather than installation of an npm package. Clone or obtain the repository, enter the audio-analyser directory, and start Python's built-in HTTP server. Python 3.10.12 or later is specified for this preview path.

The following commands are copied from the project instructions. The first command changes into the example directory. The second starts the local server on its default port:

bash
cd audio-analyser
python3 -m http.server

After the server starts, open the following address in a browser:

text
http://localhost:8000

The expected first use is the analyser page. The README describes a graphical visualization of an audio signal using data from an AnalyserNode. If the page does not load, confirm that the shell is inside the audio-analyser directory and that port 8000 is available. The README does not document an npm install command, a build command, automated tests, or a deployment command for this demo. It instead directs developers to a local HTTP server, with an MDN reference for serving files through other technologies.

Selecting a Demo for a Specific Web Audio Task

The directory names provide a practical selection map. Start with audio-basics when the immediate question concerns playback, stereo panning, or volume. Use audio-analyser when the goal is to inspect signal data in a drawing or visualization. For lifecycle management, audiocontext-states is the relevant reference because it names states, close(), resume(), and suspend().

Choose audio-param for parameter methods, audio-buffer for AudioBuffer, and decode-audio-data for BaseAudioContext.decodeAudioData(). The repository separates source creation, buffer handling, and parameter control. That separation can help a developer avoid searching through every example when the problem is narrowly defined.

For processing, use compressor-example for DynamicsCompressorNode, iirfilter-node for IIRFilterNode, and audioworklet for AudioWorklet. The offline-audio-context directories address rendering work away from immediate playback, while multi-track shows how independently playable tracks can share one destination. create-media-stream-destination is the most specific choice for a recording pipeline because it connects Web Audio output to MediaRecorder and an Opus file.

The repository also contains examples not described in the README excerpt, including panner-node, spatialization, stereo-panner-node, step-sequencer, output-timestamp, stream-source-buffer, and voice-change-o-matic. Their names suggest relevant topics, but the README does not provide enough implementation detail to make claims about their exact behavior. Inspect the directory files before selecting one of those examples.

Limitations for Production Audio Work

The main limitation is scope. This repository provides demonstrations, not a reusable audio application framework. The README does not document a shared public API, plugin interface, package manager configuration, automated test suite, or production deployment guide. Each example may have its own HTML, JavaScript, styles, and assets, so adopting one example for a larger application can require copying and adapting directory-specific code.

There is also a browser capability boundary. Web Audio features can depend on browser implementation, user permissions, media policies, and resource availability. The recording example specifically depends on MediaRecorder and an Opus output path. The README does not promise consistent codec support across browsers, nor does it provide a compatibility matrix. An example that demonstrates an API call does not by itself establish that the same call, permission flow, or output format is available in every target browser.

The examples are intentionally small in several cases. The README calls audio-analyser very simple and describes multiple directories as simple demos. That is helpful for learning, but it can be a poor foundation for a production player requiring buffering policy, error handling, accessibility controls, telemetry, persistence, authentication, or deployment automation. Those concerns are not documented as features of this repository.

The repository is not archived, and its last push was on 2026-10-03. It has no GitHub releases. The repository layout suggests continued changes, but the README does not provide a release policy, semantic versioning scheme, changelog, or upgrade compatibility policy.

Alternatives and License Implications

A real alternative is to use the Web Audio API directly in an application-specific frontend instead of treating this repository as a framework. The difference is architectural: mdn/webaudio-examples supplies isolated, readable demonstrations tied to MDN documentation, while a direct implementation can define its own audio graph, state management, user interface, asset pipeline, error handling, and build process around the required product behavior. The repository is better when the immediate need is to understand a specific node or method; an application-specific codebase is better when audio is one component of a larger product.

Another alternative is to use a higher-level audio library or engine, but the README does not identify a particular competitor or document compatibility with one. It would therefore be misleading to claim that this repository replaces a named production tool. The practical comparison is between educational examples and an application-owned integration. The former reduces the amount of code needed to inspect one concept, but it does not supply the surrounding controls and operational behavior that a deployed application may require.

The repository license is CC0-1.0. That is a public-domain dedication intended to waive rights to the covered content, subject to the terms of the license text. It is important to distinguish the repository's license from the licenses of external browser APIs, linked documentation, codecs, audio files, or third-party code copied into an application. The README does not state that every external asset is covered by CC0-1.0, so license review should cover each example's actual files and dependencies rather than relying only on the repository-level license.

Editorial conclusion

Adopt this repository if you need small, readable references for Web Audio API concepts or want a starting point for an interactive browser demo. Do not treat it as a production audio engine, framework, or complete application starter because it has no package installation workflow, releases, application-level abstractions, or documented production support model. Verify first that the relevant example matches the browser feature you need, that its assets and dependencies are available in that directory, and that your deployment supports the permissions and codec requirements of examples such as create-media-stream-destination.

Frequently asked questions

How do I run the mdn/webaudio-examples demos locally?

Clone the repository, enter the example directory, and run Python's built-in HTTP server. The README uses audio-analyser as its example and directs the browser to http://localhost:8000.

Which mdn/webaudio-examples demo should I use for audio recording?

Use the create-media-stream-destination directory. Its documented flow uses AudioContext.createMediaStreamDestination() with MediaRecorder and shows output of a sine wave to an Opus file.

Does mdn/webaudio-examples provide a build or npm installation?

The README does not document an npm installation or build command. It presents the repository as a collection of example directories and gives a local HTTP server workflow for previewing them.

Is mdn/webaudio-examples suitable for production audio applications?

The repository presents it as code examples accompanying MDN Web Docs. The README does not document a shared application API, production deployment process, automated test suite, or compatibility policy, so its documented role is learning and experimentation.

Official sources

  1. Issues
  2. License: CC0-1.0
  3. mdn/webaudio-examples on GitHub
  4. Project website
  5. README
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/mdn-webaudio-examples.svg)](https://hysenlabs.com/projects/mdn-webaudio-examples)

Was this useful?