Giter Site home page Giter Site logo

jsfft's Introduction

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.

jsfft's People

Contributors

dntj avatar hughrawlinson avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.