Firefox finally supports Web Audio, but there's still some way to go

Aug 20, 2013 18:46 GMT  ·  By

Firefox is finally getting support for the Web Audio API. The advanced audio processing API has been a WebKit-exclusive for more than a year, but developers should finally be able to start thinking about supporting multiple platforms in their Web Audio apps.

Nobody likes to have to write more code than necessary, but most developers should be glad to be able to reach more people than before.

But it's not a good idea to get too excited yet. While Chrome has had support for the feature for more than a year, the Web Audio API is still prefixed. What's more, since the API itself is not finalized, knowing what feature works and how in what browser is tricky.

Mozilla doesn't use a prefixed version, since, like the Blink team, it has decided to stop that practice. But Firefox's support for the Web Audio API is still behind Chrome's with more features, changes and improvements on their way.

Fortunately, it is possible to write standards-compliant and relative future-proof Web Audio code today, as Mozilla explains. An important trick is to use the AudioContext-MonkeyPatch that uses unprefixed aliases for the prefixed properties and should enable developers to write code that works almost everywhere.

That takes care of the different naming and some minor changes in the implementation, but won't help if the features are missing from the browser so, if you want code that runs today in all browsers, make sure to avoid certain functionality.

"Ensure that your project doesn't use node types that are not implemented yet in Firefox: MediaStreamAudioSourceNode, MediaElementAudioSourceNode and OscillatorNode," Mozilla explains.

"If i'’s using, for example, OscillatorNode, you will have to wait until it is supported, or maybe, if you're really eager, hack in some replacement using ScriptProcessorNode, which allows you to write a node with callbacks that get called periodically, so that your JavaScript code generates or processes audio," it adds.