Class: Fft

Fft

Compute the Fast Fourier Transform of an incomming signal.

Fft implementation by Nayuki.

support standalone usage

Constructor

new Fft(options)

Parameters:
Name Type Description
options Object

Override default parameters.

Properties
Name Type Attributes Default Description
size Number <optional>
1024

Size of the fft, should be a power of 2. If the frame size of the incomming signal is lower than this value, it is zero padded to match the fft size.

window String <optional>
'none'

Name of the window applied on the incomming signal. Available windows are: 'none', 'hann', 'hanning', 'hamming', 'blackman', 'blackmanharris', 'sine', 'rectangle'.

mode String <optional>
'magnitude'

Type of the output (magnitude or power)

norm String <optional>
'auto'

Type of normalization applied on the output. Possible values are 'auto', 'none', 'linear', 'power'. When set to auto, a linear normalization is applied on the magnitude spectrum, while a power normalization is applied on the power spectrum.

Source:
To Do:
  • - check if 'rectangle' and 'none' windows are not redondant.
  • - check default values for all params.
Example
import * as lfo from 'waves-lfo/client';

// assuming an `audioBuffer` exists
const source = new lfo.source.AudioInBuffer({ audioBuffer });

const slicer = new lfo.operator.Slicer({
  frameSize: 256,
});

const fft = new lfo.operator.Fft({
  mode: 'power',
  window: 'hann',
  norm: 'power',
  size: 256,
});

source.connect(slicer);
slicer.connect(fft);
source.start();

// > outputs 129 bins containing the values of the power spectrum (including
// > DC and Nyuist frequencies).

Methods

inputSignal(signal) → {Array}

Use the Fft operator in standalone mode (i.e. outside of a graph).

Parameters:
Name Type Description
signal Array

Input values.

Source:
Returns:
  • Fft of the input signal.
Type
Array
Example
const fft = new lfo.operator.Fft({ size: 512, window: 'hann' });
// mandatory for use in standalone mode
fft.initStream({ frameSize: 256, frameType: 'signal' });
fft.inputSignal(signal);