Skip to content

signal.Dft.Function.dftRealSingle

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

dsp-collection / signal/Dft / dftRealSingle

Function: dftRealSingle()

function dftRealSingle(x, relativeFrequency): MutableComplex;

Computes the DFT on an array of real numbers for a single frequency.

This is a reference implementation without any optimization. It's simple to understand, but slow.

Parameters

x

ArrayLike<number>

The input values (samples).

relativeFrequency

number

A frequency relative to x.length. It represents the number of sinusoidal oscillations within x and is normally within the range 0 (for DC) to Math.floor((x.length - 1) / 2). The absolute frequency is relativeFrequency * samplingRate / x.length.

Returns

MutableComplex

A complex number that corresponds to the amplitude and phase of a sinusoidal frequency component. The amplitude can be normalized by mutliplying 1 / x.length for DC and 2 / x.length for frequencies > 0 and < x.length / 2.

Clone this wiki locally