New this build: new audio features, including effects! As well as some long-overdue new audio features like pausing and resuming, we've also introduced a whole set of effects. Here's a demo of some of them. They can be great for atmospheric or environmental effects to add a whole new depth to your game, and others are just cool for creative use. These depend on the Web Audio API being supported by the browser. Currently it's only supported in Chrome (for desktop), node-webkit (on all platforms, since it's based on Chromium) and iOS 6+. Firefox are also actively working on it and hopefully Chrome for Android will add support soon too. In future you can check quickly for Web Audio API support using ScirraMark, a page we've set up to score the browser based on HTML5 gaming features it supports.
The advanced audio features involve adding effects and also the option of audio analysers (to get real-time frequency domain information). The actions will only work if the Advanced audio supported condition in the Audio object is true, since the condition checks for Web Audio API support. Multiple effects can be added to individual tags. Audio and signal processing are complex topics, and having prior experience in audio will allow you to make the most of these new features, but in summary the supported effects are:
- Analyser: doesn't change the audio, but can report back frequency domain data
- Compressor: automatically boost or reduce volume to even out the overall volume level
- Convolution: an advanced effect using another sound as an impulse response to process the audio. This allows for real-world locations to be recorded and the environmental sound used in your games!
- Delay: a feedback loop with a delay, making a sort of simple echo effect.
- Filter: boost or reduce certain frequencies, such as a low-pass filter (which cuts out high frequencies). Useful for simple atmospherics, treble/bass adjustment, etc.
- Flanger: delays the sound by a few milliseconds then mixes it back in with itself. By oscillating the delay time a strange sweeping effect is created
- Gain: a simple volume control, which might be useful in longer effect chains
- Phaser: phase-shifts the sound then mixes it back in with itself. By oscillating the phase shift another sweeping effect is created
- Tremolo: automatically oscillates the volume up and down, better known as amplitude modulation. Some interesting amplitude modulation effects can be created by moving the modulation frequency in to the audible range (above 20 Hz).
If advanced audio is not supported, adding effects will do nothing, so you'll just hear unprocessed audio. That means you can easily add all sorts of environmental effects, and if advanced audio is not supported the user will simply hear the unprocessed audio.
The convolution effect is especially interesting, but it requires some technical knowledge and professional equipment to properly record impulse responses. There may be libraries of pre-recorded impulse responses available somewhere, but I haven't checked. Still, the possibilities it opens for immersive audio in games is exciting!
These new features will require a fair bit of documentation, which as usual will come around the next stable release. However I might write a blog post going in to more detail, since it's a subject I'm personally very interested in, and some deeper explanation of the effects involved could be useful.
The Audio object is very complicated since it supports four separate audio engines (audio element, Web Audio API, PhoneGap media and appMobi (Intel?) sound), and the new features have made it even more so. Much of the Audio code has been revised, so please listen out for any new bugs, issues or differences, especially between different platforms.