Hi I'm working on a program to analyze sound files and I need to do a DFT on a 1 second array which often is 44100 samples.
So what I need is a 1D FFT algorithm working on arbitrary length, i.e. not a power of 2.
Any ideas?
Hi I'm working on a program to analyze sound files and I need to do a DFT on a 1 second array which often is 44100 samples.
So what I need is a 1D FFT algorithm working on arbitrary length, i.e. not a power of 2.
Any ideas?
The https://en.wikipedia.org/wiki/Cooley%E2%80%93Tukey_FFT_algorithm is USUALLY used for binary splits, but actually handles arbitrary factorizations. As long as your number factorizes completely into small numbers (yours is 2*2*3*3*5*5*7*7
) this will give a fairly efficient FFT. (See the General Factorizations section.)
There are other FFT algorithms known that can handle arbitrary sizes, but they are much slower (though better than naive). See https://en.wikipedia.org/wiki/Chirp_Z-transform#Bluestein.27s_algorithm for one.
http://www.nayuki.io/page/free-small-fft-in-multiple-languages has implementations of the general Cooley-Tukey FFT algorithm in a number of languages, including JavaScript. It doesn't do an efficient implementation for arbitrary primes, but you don't have any large ones to deal with.