Skip to content

fft

fft(signal): any[]

Defined in: packages/pleco-xa/src/scripts/xa-fft.js:119

Fast Fourier Transform using Cooley-Tukey algorithm (radix-2, iterative).

Zero-padding contract: this is a radix-2 transform, so inputs whose length is not already a power of 2 are zero-padded UP to the next power of 2. The returned spectrum therefore has 2**ceil(log2(N)) bins, which for a non-power-of-2 input is LONGER than the input. This padding is intentional (not a silent best-guess): pass a power-of-2-length signal to get a spectrum of exactly that length, or account for the padded length in the caller.

Non-finite policy: NaN/Infinity in the input throws with the offending index — corrupted audio is never laundered into a plausible spectrum.

any[] | Float32Array<ArrayBufferLike>

Input signal

any[]

FFT result as complex numbers; length = next power of 2 >= N