Monday, February 22, 2010

Dynamic Sound in Actionscript

Sounds in actionscript, especially the dynamically generated are some sort of black art that few get to master. I had to sample dynamically some sounds due to some self-imposed strict file size constraints.
You can check the final product here: www.mankies.info/xentrics

The basic idea is that a sound object, aside from loading the usual mp3 file, uses a call back function to sample the wavelet and fill a buffer of at least 2048 samples. This requires FP10 as far. You can check it out here

In the game
Apart from the reverberating engine before full-thrust takes over, you'll be able to tune in to two sounds, a splash when the ship hits the water and a jet sound when the ship goes super sonic.

Instead of copy pasting less sensible code lines into this blog, I edited the sound generating functions so that they can be sensible to create an intelligible graph.

Waveforms: Click to view details







Noise source on wonderfl.net
Splash source on wonderfl.net