ActionScript 3: Multiple MP3s with visualizer
The past day or two I’ve spent trying to figure out how to get multiple, different MP3s to display some visualization for Sprites that represent them. computeSpectrum was obviously out of the question. I then turned to Sound.extract() to see if that could help me.
Not knowing all the intricacies of that method (I haven’t touched Flash in about five years – no lie), I beat my head against a wall until I discovered that it’s meant for dynamic audio (creation)… the sample data event wasn’t firing for me – because I had loaded an MP3 into each sound. Hmm.
I was overlooking something quite simple. SoundChannel has left and right peak values. I could poll those with a Timer, normalize for panning, and apply those values to a Sprite with scaling – to generally pulse the thing to show activity. I didn’t really need to get the spectrum data because I wasn’t going to use it that way.
So sometimes it’s the easy route that gets overlooked for a more complicated, more satisfying solution. Granted, I’m still happy – but wouldn’t it be nice if somehow computeSpectrum was added somehow to SoundChannel?