Skip to content
Tone.js

FFT

class Component ↳ extends MeterBase<FFTOptions, 1>

Get the current frequency data of the connected audio source using a fast Fourier transform. Read more about FFT algorithms on [Wikipedia] (https://en.wikipedia.org/wiki/Fast_Fourier_transform).

new FFT(size?: number)

Parameters

  • size number optional

    The size of the FFT. Value must be a power of two in the range 16 to 16384.

new FFT(options?: Partial<FFTOptions>)

Parameters

↳ inherited from MeterBase

input: InputNode

The signal to be analyzed

read-only

name: string

The name of the class

Default: "FFT"

normalRange: boolean

If the output should be in decibels or normal range between 0-1. If normalRange is false, the output range will be the measured decibel value, otherwise the decibel value will be converted to the range of 0-1

↳ inherited from MeterBase

output: OutputNode

The output is just a pass through of the input

size: number

The size of analysis. This must be a power of two in the range 16 to 16384. Determines the size of the array returned by getValue (i.e. the number of frequency bins). Large FFT sizes may be costly to compute.

smoothing: number

0 represents no time averaging with the last analysis frame.

↳ inherited from MeterBase

dispose(): this

Dispose and disconnect

Returns this

getFrequencyOfIndex(index: number): number

Returns the frequency value in hertz of each of the indices of the FFT’s getValue response.

const fft = new Tone.FFT(32);
console.log([0, 1, 2, 3, 4].map(index => fft.getFrequencyOfIndex(index)));

Parameters

  • index number

Returns number

getValue(): Float32Array

Gets the current frequency data from the connected audio source. Returns the frequency data of length size as a Float32Array of decibel values.

Returns Float32Array

static

getDefaults(): FFTOptions

Returns all of the default options belonging to the class.

Returns FFTOptions