Package Exports
- signalsmith-js-fft
- signalsmith-js-fft/fft.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (signalsmith-js-fft) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
JS FFT
This is a simple JavaScript FFT implementation for power-of-2-sizes, including Real FFTs.
How to use
In the browser:
<script src="fft.js"></script>
<script>
// Classes are defined in the global namespace
var fft = new FFT(256); // Complex FFT
var rfft = new RFFT(256); // Real FFT
</script>In Node:
let ssfft = require('signalsmith-js-fft');
let FFT = ssfft.FFT, RFFT = ssfft.RFFT;Complex FFTs
For complex FFTs, the inputs and outputs are complex-interleaved (i.e. [real0, imag0, real1, imag1, ...]), so the arrays should be twice the FFT size.
var fft = new FFT(256);
//
var waveform = new Float64Array(512), spectrum = new Float64Array(512);
fft.fft(waveform, spectrum); // forward FFT
fft.ifft(spectrum, waveform); // round-trip is scaled by 256Real FFTs
For real-valued FFTs, the Nyquist result is packed into the imaginary part of bin 0, so the arrays are exactly the FFT size.
var rfft = new RFFT(256);
var waveform = new Float64Array(256), spectrum = new Float64Array(256);
rfft.fft(waveform, spectrum); // forward FFT
rfft.ifft(spectrum, waveform); // round-trip is scaled by 256License
The licence is MIT License - but we're flexible, so get in touch if you need anything else.