Skip to content

signal.Fft.Function.fftRealSpectrum

Christian d'Heureuse edited this page Jun 7, 2026 · 2 revisions

dsp-collection / signal/Fft / fftRealSpectrum

Function: fftRealSpectrum()

function fftRealSpectrum(x, inclNyquist?): ComplexArray;

Defined in: signal/Fft.ts:237

Computes the complex spectrum of an array of real numbers. The result is the normalized lower half of the FFT.

If x.length is even, the computation is faster. And if x.length is a power of 2, it's even faster.

Parameters

x

ArrayLike<number>

The input values (samples).

inclNyquist?

boolean = false

If true and x.length is even, the value for the relative frequency x.length / 2 (Nyquist frequency, half the sample rate) is included in the output array. This is done to allow an exact re-synthesis of the original signal from the spectrum. But the Nyquist frequency component is an artifact and does not represent the phase and amplitude of that frequency. The phase is always 0. It's not possible to compute a proper value for the Nyquist frequency.

Returns

ComplexArray

An array of complex numbers that represent the spectrum of the input signal.

Clone this wiki locally