FFT
class Component ↳ extends MeterBase<FFTOptions>
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).
Constructor
Section titled “Constructor”new FFT(size?: number)Parameters
-
size
numberoptionalThe size of the FFT. Value must be a power of two in the range 16 to 16384.
new FFT(options?: Partial<FFTOptions>)Parameters
- options
Partial<FFTOptions>optional
Properties
Section titled “Properties”normalRange
Section titled “normalRange”normalRange: booleanIf 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
output
Section titled “output”↳ inherited from MeterBase
output: OutputNodeThe output is just a pass through of the input
size: numberThe 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
Section titled “smoothing”smoothing: number0 represents no time averaging with the last analysis frame.
Methods
Section titled “Methods”dispose()
Section titled “dispose()”↳ inherited from MeterBase
dispose(): thisDispose and disconnect
Returns this
getFrequencyOfIndex()
Section titled “getFrequencyOfIndex()”getFrequencyOfIndex(index: number): numberReturns 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()
Section titled “getValue()”getValue(): Float32ArrayGets the current frequency data from the connected audio source. Returns the frequency data of length size as a Float32Array of decibel values.
Returns Float32Array
getDefaults()
Section titled “getDefaults()”static
getDefaults(): FFTOptionsReturns all of the default options belonging to the class.
Returns FFTOptions
Inherited members
Section titled “Inherited members”- From
ToneWithContext: context, blockTime, sampleTime, get(), immediate(), now(), set(), toFrequency(), toSeconds(), toTicks() - From
Tone: debug, version, disposed, toString() - From
ToneAudioNode: channelCount, channelCountMode, channelInterpretation, numberOfInputs, numberOfOutputs, chain(), connect(), disconnect(), fan(), toDestination(), toMaster()