Chris@25: fft.js Chris@25: ================================================================================ Chris@25: Chris@25: FFT in JavaScript, it works, I think. Chris@25: Chris@25: No promises, but I tested it against Wolfram Alpha once, and it was reasonably accurate. Chris@25: Chris@25: There are optimized kernels for prime factors, 2, 3, 4, so if you want high performance, use lengths that are a factor of those. Chris@25: Chris@25: Notice that the DFT is not normalized, so `ifft(fft(x)) / n ~= x` Chris@25: Chris@25: Chris@25: Usage Chris@25: --------------------------------------------------------------------------------- Chris@25: Chris@25: ```javascript Chris@25: Chris@25: /* Create a new FFT object */ Chris@25: Chris@25: var fft = new FFT.complex(n, inverse) Chris@25: Chris@25: /* Output and input should be float arrays (of the right length), type is either 'complex' (default) or 'real' */ Chris@25: fft.process(output, outputOffset, outputStride, input, inputOffset, inputStride, type) Chris@25: Chris@25: /* Or the simplified interface, which just sets the offsets to 0, and the strides to 1 */ Chris@25: fft.simple(output, input, type) Chris@25: Chris@25: ``` Chris@25: Chris@25: Chris@25: Installing via npm Chris@25: --------------------------------------------------------------------------------- Chris@25: Chris@25: You can also install via npm, the name is `fft` in the registy. Chris@25: Chris@25: Chris@25: Credits Chris@25: --------------------------------------------------------------------------------- Chris@25: Chris@25: I was too lazy to calculate the butterflies myself, so they are inspired by [kissfft](http://sourceforge.net/projects/kissfft/), which is a small library for doing discrete fourier transforms. Chris@25: