Note: this post is archived from the now closed ofmlabs.org.
We have been waiting for a flashy demo to use it in for a long while, but we decided that you have waited long enough and wired it up with a song into a streaming audio player. Thanks to fONKSQUISh for allowing us to use their songs. Update: if you use the online demo chose a FLAC file from your hard drive for playback.
The main thing is that it runs on a lot of platforms and decodes FLAC encoded audio. The decoder by itself should run on any platform that supports typed arrays, but we have only tested it on platforms that support an Audio API, like the Mozilla Audio Data API, and Google’s Web Audio API. That means that it should work in Firefox, Chrome, and Webkit with Web Audio enabled.
We hoped that we could say that it runs on the iOS 6 beta, but we’re having problems getting the Web Audio API to work reliably. However the decoder itself does appear to work. Hopefully by the time iOS 6 ships this fall, the Web Audio API will be more reliable and our codecs will begin to work on mobile devices.
The FLAC decoder is released under the LGPL license (following the original license from FFmpeg), which means that you can use it freely; however, if you modify the FLAC decoder itself, then you need to provide the source to your users.
We’ve been working on a nice little framework called Aurora.js that we have been using to write our decoders so far. 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. Aurora is designed to be easily extendible with more codecs, and that is exactly what we have been doing. JSMad was written before Aurora existed, and since then, we’ve converted it to use Aurora in the form of MP3.js. Additionally, we have ALAC.js and now FLAC.js. We have at least one more in the pipeline to release shortly!
The result of all of this, is that the Aurora framework makes it very nice to write demuxers and decoders for various container formats and codecs respectively. It also makes it easy to extract various information about the format, duration, and metadata from audio files, and includes a high level player API that, in our opinion, is easier to work with than the HTML5 Audio tag.
The Web Audio API opens up many doors to us to build amazing audio applications in the browser. Many of those applications will need to use compressed audio data, and we’ve been implementing the codecs to make that happen. Be sure to check out the demo of FLAC.js and write your own decoders using Aurora.js. We’re excited to see the amazing apps you build!