There is smth new I would like to share with Flash community: ASFFT Project. Well project is too loud name as far as it is only small library that allows users to decompose images using Fast Fourier Transform in to Real and Imaginary parts. But if you dig more in to the title you will find lots of amazing possibilities it brings to you. The problem is that it is pretty slow and can’t be used on processing video frames for example but it is fast enough to do different image manipulations without freezing Flash Player.
The lib will contain 2 classes “FFT2D” and “FFT”. First one is to work with two dimensional data mostly presented as images. The second one is for streaming (or not) one dimensional data. Usually used in sound signal manipulations/transformation.
At this very moment only FFT2D class available. I will add one dimensional FFT class in near future.
Simple demo example of FFT usage
Project page at Google Code



Did you code the algorithm from scratch or have you found a way to use the native fourier transform in the SoundMixer.computeSpectrum()?
this one has nothing to do with SoundMixer.computeSpectrum(). It is written from scratch to use the power of Alchemy for extreme data analyze. Currently available class is FFT2D that is 2 dimensional (image based) FFT computation.
Nice work. I just noticed the C code in there. I’ve only ever heard of FFT being used for sounds, didn’t realise it could be used for image manipulation.
J
you are my hero.
this can be sooooo useful.
keep up!
How does it compare to http://rest-term.com/archives/1345/ ?
This is excellent work. Regarding a 1D FFT: SoundMixer.computeSpectrum(true) has baffled me for months. Its output has a quality that I’ve never been able to replicate. If your FFT1D offering does the trick– which seems likely, after looking at FFT2D– you’ll effectively be freeing the whole community from the inadequacies of computeSpectrum.
Thanks in advance.
@makc u can easily compare it. as for the first look this one supported RGB data. and i think this version is faster
well yes, that operates on Vector.-s, not pixels, but it makes sense in case anyone wants to run it on anything else than images.
Vector.{Number}-s that was
@makc if you read my post and look trough the source u would see that this one used not only for pixels but also for vectors and ByteArrays and simply gives you a chance to reuse Pixel bender filters for data re-processing. and that along with this class also 1D version is coming soon with ability to work with simple 1d data such as sound signal.
yep, I looked at http://code.google.com/p/in-spirit/source/browse/trunk/projects/ASFFT/src/ru/inspirit/math/FFT2D.as but only noticed initFromXXXBitmap() at first. I assume setDataVector() is general-purpose one?
@makc not really. as for me the best source is ByteArray as far as it can be used to combine Pixel Bender usage as filter processor. u also can work via BitmapData object
say, can you help me with this bit of code:
re = new Vector. (w * w, true);
im = re.concat ();
var fftTest2:FFT2D = new FFT2D;
fftTest2.setDataVector (re, FFT2D.REAL_RAW_DATA);
fftTest2.setDataVector (im, FFT2D.IMAGINARY_FFT_DATA);
fftTest2.forwardFFT ();
re = fftTest2.getDataVector (FFT2D.REAL_FFT_DATA);
trace (re.length); // traces 0
what did I miss?
@makc well u have to init instance first. init(width, height, numChannels);
u also dont need to set fftTest2.setDataVector (im, FFT2D.IMAGINARY_FFT_DATA); for the transform to work.
Thanks. But:
[Fault] exception, information=RangeError: Error #1125: The index 10000 is out of range 10000.
Fault, setDataVector() at FFT2D.as:317
@makc can u send me the full code u use to produce this error.
here you go http://pastebin.com/1n959Kxv
@makc i assume the problem is cause Lib required data to fill the allocated buffer. so u should pass the buffer of required length not the one u just randomly selected
humm, what is required length?
btw, it magically works on powers of two, e.g. for w=512 I have:
time: 3011 ms
time: 579 ms <- yours
@makc i corrected your code there. from 255 to 256. cause this is the power of 2 of provided 255 by you. so Lib created buffer of 256×256 and required u to fill it.
there was also code completion error, IMAGINARY_FFT_DATA instead of IMAGINARY_RAW_DATA. any way, I am getting 3.5 to 5.5 times faster times
Eugene can you be more precise in when the fft class will be available?
Love your work!
Also anxiously awaiting the FFT implementation. Any idea when that will be up??
Thanks man!
Amazing work! I would be fantastic if you could explain a bit more about the FFT classes you have for sound in a blog post. I know you have some sample code on your google code site, but explaining the methods a bit more would be most helpful. I am checking out FFTSpectrumAnalyzer class specifically. Thanks man, you’re doing great work and benefiting the community big time!
To add to the above post in the FFTSpectrumAnalyzer, just a little background on these methods: initLogarithmicAverages, initLinearAverages and analyzeSpectrum. Thanks again! I will keep digging as well.