Getting Started with Web Audio API

A wonderful article that breaks down all the basics of the Web Audio API.

The Web Audio API is a high-level JavaScript API for processing and synthesizing audio in web applications. It’s created by W3C.

LINK: Getting Started with Web Audio API
LINK: Web Audio API

Code example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
var dogBarkingBuffer = null;
// Fix up prefixing
window.AudioContext = window.AudioContext || window.webkitAudioContext;
var context = new AudioContext();

function loadDogSound(url) {
var request = new XMLHttpRequest();
request.open('GET', url, true);
request.responseType = 'arraybuffer';

// Decode asynchronously
request.onload = function() {
context.decodeAudioData(request.response, function(buffer) {
dogBarkingBuffer = buffer;
}, onError);
}
request.send();
}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.