Badass JavaScript

A showcase of awesome JavaScript that pushes the boundaries of what's possible on the web, by @devongovett.

FLAC.js, Aurora, and the Future of Web Audio

June 15th 2012

I don’t often toot my own horn on this blog, but I thought this was worth a mention.  Over at Official.fm Labs, we just released FLAC.js our JavaScript FLAC audio decoder, and Aurora.js, our framework to make building JS audio decoders easier.  Check out our blog post over there for more detailed info and the demo here, but the quick story is that we think the Web Audio API is a really important addition to web browsers because it allows us to build some never before possible applications in the browser.

While the HTML5 Audio tag is nice, the truth is that browsers support widely different codecs, and encoding multiple versions of some audio you want to embed is really unacceptable.  We want to make this better, so we’ve been writing audio codecs in JavaScript (including JSMad, ALAC.js, and now FLAC.js) using the low-level Web Audio API to get audio data to the hardware.  Until recently, there were multiple audio APIs in browsers, but a few weeks ago, the Web Audio API was chosen for the standardization path in the W3C.  This is good news, because it means that we have a single API that all browsers can support, and it is even already in iOS 6 (albeit broken in the first beta)!

Because we think this is important, not just for audio playback, but for a whole new breed of audio applications in the browser such as Garageband-esque apps, DJ apps, and audio editors, we have been working on a nice little framework called Aurora.js to help make building audio decoders and applications in the browser a little less daunting.  Aurora handles common tasks for you such as dealing with binary data, and the decoding pipeline from source to demuxer to decoder, and finally to the audio hardware itself by abstracting browser audio APIs.

If you’re interested in extending Aurora with your own demuxers and decoders (and we would love if you did), we’ve been working on documentation for the framework.  We’re already working on an AAC decoder, and would love to see an Ogg Vorbis decoder and anything else the community comes up with.

JavaScript has become super powerful, and just the fact that we can decode audio in the browser at less than 5% CPU is incredible.  I can’t wait to see the amazing audio apps that come out of this!