SoundData: Facilitating Audio Visualization Experiments
March 31st, 2008 : Nik RowellUPDATE: I’ve discovered a serious flaw in this class… I plan to refactor things soon – stay tuned.
In an effort to simplify audio visualization experiments with ActionScript 3.0, I’ve developed a SoundData class. The class’s main attraction is centered around the flash.media.SoundMixer.computeSpectrum() method, but it also provides additional control over playback, including startSound(), stopSound() and toggle() methods. The class also allows manipulation over volume and panning.
Using the class in an experiment is a piece of cake. Simply instantiate it with the URL to the mp3 file you’d like to stream, and a few optional parameters:
import com.nikrowell.media.SoundData;
var sound:SoundData = new SoundData("myTrack.mp3", true, 0.9);
Begin playing the sound:
sound.startSound();
And obtain the spectrum data or other properties as needed:
sound.compute(true);
var float:Number = sound.read(200, 50);
sound.volume = 0.75;
A few important notes:
- Although the
SoundData.panhas been implemented, this version currently has unexpected results when combined with thecompute()andread() - There is not yet control over buffering or preloading, making animations more prone to choppy starts.
- Values passed to the
panandvolumesetter methods must be normalized. Passing 48 to the the volume will default to 1 (100%), and not 48%.
You can View the documentation or email me/add a comment for the source code - I'd love to see what you come up with!
Stay tuned for my first experiment with the new class - it will likely be a spin off of my previous post
Tags: ActionScript, Code, Downloads, Object-Oriented-Programming












April 17th, 2008 at 11:30 pm
[...] had every intention of using my recently released SoundData class in an experiment with Papervision3D. I got pretty far: Picked out a good Armin Van Buuren track, [...]