Class Fft
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
sizeint
Properties
Size
Number of points.
public int Size { get; }
Property Value
Methods
Forward(Span<Complex>)
Forward transform in place (length must equal Size).
public void Forward(Span<Complex> data)
Parameters
GetWindow(WindowFunction)
Window coefficients of the given kind for this size.
public ReadOnlySpan<float> GetWindow(WindowFunction kind)
Parameters
kindWindowFunction
Returns
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
samplesReadOnlySpan<float>magnitudesDbSpan<float>windowWindowFunctionfloorDbfloat