Minimalistic and efficient FFT implementation
JavaScript
Latest commit b316b59 Jan 23, 2017 @dfcreative dfcreative Reduce size
Permalink
Failed to load latest commit information.
lib Add fft-asm tests Jan 23, 2017
.gitignore Init May 13, 2016
benchmark.js Reduce size Jan 23, 2017
benchmark.md Add fft-asm tests Jan 23, 2017
index.js Break wrong tests Jan 23, 2017
package.json Add fft-asm tests Jan 23, 2017
process.md Prepare to remove readme May 14, 2016
readme.md Shorten description Jun 6, 2016
test.js Visualize tests Jan 23, 2017

readme.md

fourier-transform stable

Minimalistic and efficient FFT implementation for 2n-size inputs.

npm install fourier-transform

var ft = require('fourier-transform');
var db = require('decibels');

var frequency = 440;
var size = 1024;
var sampleRate = 44100;
var waveform = new Float32Array(size);
for (var i = 0; i < size; i++) {
    waveform[i] = Math.sin(frequency * Math.PI * 2 * (i / sampleRate));
}

//get normalized magnitudes for frequencies from 0 to 22050 with interval 44100/1024 ≈ 43Hz
var spectrum = ft(waveform);

//convert to decibels
var decibels = spectrum.map((value) => db.fromGain(value))

Thanks

To all the existing fft packages, without them this one would not be possible. Special thanks to @corbanbrook for the most efficient implementation in dsp.js. This package is based on dsp.js RFFT, which is based on RealFFT.

Contribute

If you find it slow, difficult or broken, please post an issue. If you have ideas or know-hows for better implementation - PR’s are welcome.

Related