Table of Contents

Class Fft

Namespace
PluginUI.Dsp
Assembly
PluginUI.dll

Radix-2 FFT with precomputed twiddles and a magnitude-spectrum helper for analyzers. One instance per size; not thread-safe (use one per thread).

public sealed class Fft
Inheritance
Fft
Inherited Members

Remarks

The butterflies run on split real / imaginary arrays with Vector<T> (4 doubles per instruction with AVX2, 2 with SSE), and the bit-reversal permutation is fused with the loading of the input.

MagnitudeSpectrum(ReadOnlySpan<float>, Span<float>, WindowFunction, float) uses the real-input algorithm: the N real samples are packed into an N/2-point complex FFT, then separated, which halves the work. The dB conversion is vectorized too.

Constructors

Fft(int)

Creates an FFT of size points (power of two, 16..65536).

public Fft(int size)

Parameters

size int

Properties

Size

Number of points.

public int Size { get; }

Property Value

int

Methods

Forward(Span<Complex>)

Forward transform in place (length must equal Size).

public void Forward(Span<Complex> data)

Parameters

data Span<Complex>

GetWindow(WindowFunction)

Window coefficients of the given kind for this size.

public ReadOnlySpan<float> GetWindow(WindowFunction kind)

Parameters

kind WindowFunction

Returns

ReadOnlySpan<float>

MagnitudeSpectrum(ReadOnlySpan<float>, Span<float>, WindowFunction, float)

Windowed magnitude spectrum in dBFS (a full-scale sine reads ≈ 0 dB): magnitudesDb receives Size / 2 bins (bin k = k × sampleRate / Size Hz).

public void MagnitudeSpectrum(ReadOnlySpan<float> samples, Span<float> magnitudesDb, WindowFunction window = WindowFunction.Hann, float floorDb = -140)

Parameters

samples ReadOnlySpan<float>
magnitudesDb Span<float>
window WindowFunction
floorDb float