What Is the Web Audio API?
The Web Audio API uses the XMLHttpRequest()
functionality of the web browser to load a sound as an array of binary
bytes that is decoded into an audio buffer and then used to play your
sound. An audio buffer is a memory-resident copy of your sound. It
remains in memory, and you can access it as many times and as often as
you like without the need to make multiple copies, using up precious
memory. There is no need to create multiple copies of an audio object, as we did in earlier examples.
Using the Web Audio API promises to one day be the most efficient way to
play audio clips in games and applications.
Note
The Web Audio API specifies that it should be used for short sounds and audio clips, but music and longer audio should be streamed with the Audio element.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access