Discrete Fourier Transformation
This module have functions to compute DFT using the correlation algorithm (the simplest and easy to understand, also the slowest)
Various methods are used to obtain DFT for time domain samples including use of Simultaneous Equations using Gaussian elimination, correlation, and using the Fast Fourier Transform algorithm. The first option requires massive work even for a comparitively small number of samples. In actual practice, correlation is the preferred method if the DFT has less than about 32 points.
The function of this module is really slow, and not intended to be used in production. It has two goals:
- Educational: learn how to implement the DFT correlation algorithm
- Testing: test more complex algorithms against this to check outputs
This is part of dsp-kit
- Source:
Examples
// using dsp-kit
var dsp = require('dsp-kit')
dsp.dft('forward', signal)
dsp.dft('inverse', complexSignal)
// requiring only this module
var dft = require('dsp-dft')
dft.dft('forward', signal)
Methods
(static) dft(direction, signal, output) → {Object}
Perform a DFT using a brute force correlation algorithm
It accepts real and complex signals of any size.
It implements the mathematical function as it, without any kind of optimization, so it's the slowest algorithm possible.
This algorithm is not intended to be used in production. It's main use (apart from the educational purposes) is to check the output of more complex algorithms
Parameters:
Name | Type | Description |
---|---|---|
direction |
String | Can be 'forward' or 'inverse' |
signal |
Array | Object | The (real) signal array, or the complex signal
object |
output |
Object | (Optional) the pair of buffers |
- Source:
Returns:
the DFT output
- Type
- Object
Example
dft('forward', signal)
dft('inverse', { real: ..., imag: .... })