fourier-transform

1.1.2 • Public • Published

fourier-transform stable Build Status

Minimalistic and efficient FFT implementation for 2n-size inputs. Includes regular and asm.js versions.

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 * (/ 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))

To use asm.js version, require as require('fourier-transform/asm'). That is ~35% faster.

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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.2
    2,970
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.1.2
    2,970
  • 1.1.1
    1
  • 1.0.2
    1
  • 1.0.1
    1
  • 1.0.0
    1

Package Sidebar

Install

npm i fourier-transform

Weekly Downloads

2,386

Version

1.1.2

License

MIT

Last publish

Collaborators

  • mikolalysenko
  • dfcreative
  • yoshuawuyts
  • hughsk
  • planeshifter
  • rreusser