Generating Sound with the Web Audio API

19 March 2011

The nascent Web Audio API is a neat addition to the HTML5 (6?) landscape. It opens the door to realtime audio synthesis directly in JavaScript, something that is currently only possible using Flash.

It’s easy to use. The following code generates a simple sine wave:

If you're running a build of Safari or Chromium with support for the API (available here), running the example and clicking “play” will produce a lovely tone.