Hey guys, long time no see.
For the past couple of weeks I’ve been wracking my brains over SoundMixer.computeSpectrum(), arguably the coolest method in ActionScript 3. It’s the one that spits out the last 256 (or so) audio samples that hit the speakers, with the option of viewing that data in the time domain (waveform) or the frequency domain (Fourier transform). It’s great for visualizing music, but its major drawback is that it only operates on global, playing audio, which means you cannot visualize different channels or preprocess the visualization.
**Sound.extract()**, a new method in Flash Player 10, gives you a Sound object’s entire waveform at any time you want; I’ve managed to line up the waveform in Sound.extract() perfectly with the waveform in SoundMixer.computeSpectrum(), so they are literally neck-in-neck. [u][url=http://rezmason.net/noodle/fft.html]In this SWF[/u] I’m drawing two lines– a blue line, which uses data from SoundMixer.computeSpectrum(), and a red line, which uses data from Sound.extract(). (The red line is drawn on top; if you can’t see the blue line, it’s because the data lines up.)
However, I’m not having nearly as much success reproducing the built-in Fourier transform, which is most important. Check this SWF out– tapping the A, B and C keys add certain tones to the waveform, and clicking toggles the view between the time domain and the frequency domain. The black line is computeSpectrum() data, and the white line is my own Fourier transform() of the Sound.extract() data. And they certainly don’t line up. I get the feeling that the built-in result is doing more than a Fourier transform, but there’s no way of knowing exactly what it’s doing.
If I do get this to work, I’ll release it like Papervision– free, use it however you want, etc. This feature should have been built into Flash 10, after all. So I would really appreciate any help on this matter.
P.S.– if anyone’s interested, I’ve put a simple Fourier transform utility here.