2.0.11 • Published 2 years ago

@signalprocessing/transforms v2.0.11

Weekly downloads
103
License
MIT
Repository
github
Last release
2 years ago

Install

npm install @signalprocessing/transforms

Usage

This module can be both imported as commonJS or ES module.

  • Fast Fourier Transform ( fft )

  • Inverse Fast Fourier Transform ( ifft )

This functions implement fast Fourier transform and inverse fast Fourier transform of any given real or complex signal.

FFT of real signal: let [realFFTCoeffcients, imaginaryFFTCoeffcients] = fft(realSignal).

FFT of complex signal: let [realFFTCoeffcients, imaginaryFFTCoeffcients] = fft(realPartofSignal, imaginaryPartofSignal).

IFFT of any signal: let [realPartofSignal, imaginaryPartofSignal] = ifft(realFFTCoeffcients, imaginaryFFTCoeffcients).

Note: If imaginaryFFTCoeffcients is not present for the ifft function, then you must artifically create imaginaryFFTCoeffcients array of all zeros with the same size of realFFTCoeffcients array.

If you have the signal A, then you should get ifff(fft(A)) == A with some numerical difference.

//Example

//import fft
let fft=require("@signalprocessing/transforms").fft

//import ifft 
let ifft=require("@signalprocessing/transforms").ifft

//Sampling rate
let Fs = 1000;

//Sampling period
let T = 1 / Fs;

//Length of signal
let L = 1500;

//Time data
let t = Array.from({ length: L }, (x, i) => i * T);

//A real signal containing a 30 Hz sinusoid of amplitude 0.5 and a 100 Hz sinusoid of amplitude 1.
let realSignal = Array.from(t, (x, i) => 0.5 * Math.sin(2 * Math.PI * 30 * x) + Math.sin(2 * Math.PI * 100 * x));

//Compute the fast Fourier transform of the signal.
let [realFFTCoeffcients, imaginaryFFTCoeffcients] = fft(realSignal);

//Compute the inverse fast Fourier transform of the signal.
let [nRealSignal,nImagSignal] = ifft(realFFTCoeffcients,imaginaryFFTCoeffcients)

License

MIT

2.0.11

2 years ago

2.0.7

2 years ago

2.0.9

2 years ago

2.0.10

2 years ago

2.0.8

2 years ago

2.0.6

3 years ago

2.0.3

3 years ago

2.0.5

3 years ago

2.0.4

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.1

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.0

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago