Name
analyzeSample()
Class
FFT
Description
Calculates the frequency spectrum of a given audio sample and returns an 
 array of magnitudes, one for each frequency band. The frequency associated 
 with each band of the spectrum is frequency = binIndex * sampleRate / 
 (2*numBands).
 This version is intended to be used in non-real time processing, particularly when you are
 creating an animation in non-real time and want to get the FFT for a particular chunk of an audio sample.
 For stereo samples, you can call this function once for each channel, so you can display the left and right
 fft values separately.
 The values of the resulting array show the amplitudes of pure tone 
 components contained in the signal. If the signal is a sine with an 
 amplitude of 1, the spectrum will have an absolute value of 1 (0 dB) at the 
 frequency of the sine. For complex real-world signals the spectrum values 
 will be much lower and usually don't exceed 0.05.
Syntax
FFT.analyzeSample(sample, target)FFT.analyzeSample(sample, numBands)
Parameters
sample(float[])an array of numbers that describe the waveform to be analyzedtarget(float[])array that the computed spectrum will be written to. The FFT will compute as many frequency bands as the length of this array, which must be a power of 2 (2, 4, 8, 16 etc.)
Return
float[]

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.