Need help with jsfft?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

dntj
244 Stars 35 Forks MIT License 54 Commits 0 Opened issues

Description

Small, efficient Javascript FFT implementation

Services available

!
?

Need anything else?

Contributors list

jsfft

Small, efficient Javascript FFT implementation for node or the browser.

Usage

JSFFT ships with ComplexArray which can be operated on:

const fft = require('jsfft');

// Use the in-place mapper to populate the data. const data = new fft.ComplexArray(512).map((value, i, n) => { value.real = (i > n/3 && i < 2*n/3) ? 1 : 0; });

Including the fft module attaches FFT methods to ComplexArray. FFT and InvFFT perform in-place transforms on the underlying data:

const frequencies = data.FFT();
// Implement a low-pass filter using the in-place mapper.
frequencies.map((frequency, i, n) => {
  if (i > n/5 && i < 4*n/5) {
    frequency.real = 0;
    frequency.imag = 0;
  }
});

Alternatively, frequency-space filters can be implemented via the frequencyMap:

const filtered = data.frequencyMap((frequency, i, n) => {
  if (i > n/5 && i < 4*n/5) {
    frequency.real = 0;
    frequency.imag = 0;
  }
});

Conventions

JSFFT uses the normalization convention that is symmetric between the forward and reverse transform. With

N
data points, the transform is normalized by a factor of
√N
:
           1   N-1       2πik/N
fft(k) =   -    ∑  f(j) 𝐞
          √N   j=0

Other Implementations

DSP is a full featured Digital Signal Processing library in JS which includes a JS FFT implementation.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.