public sealed class FftA fast Fourier transform of a fixed power-of-two size.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Two effects need this and neither could exist without it. A convolution reverb against a one-second impulse response is 48 000 multiply-accumulates per sample done directly — about two thousand times more work than a machine has — and the transform is what turns it into a multiply per bin. A spectrum analyser is the transform and nothing else.
An object rather than a static method, because the tables are the point. The twiddle factors and the bit-reversal permutation depend only on the size, so they are computed once and the transform itself allocates nothing and calls no transcendental function. A static Fft.Transform(span) would have to rebuild them every block.
Radix-2, iterative, decimation in time. The textbook one. Radix-4 is about a third faster and twice the code; a split-radix is faster still and is a research project. The profile that would justify either does not exist yet, and this is not where a game's audio budget goes.
Complex in, complex out, even for real signals. Audio is real, so half the input is zeroes and half the output is the mirror of the other half — a real-input transform would be twice as fast for the same answer. That optimisation is owed and is deliberately not taken yet: it doubles the index arithmetic, and index arithmetic is where a transform goes quietly wrong.
Fields and properties (1)
public int SizeHow many points it transforms.
Methods (4)
public Fft(int size)A transform of a size.
public void Forward(Span<float> real, Span<float> imaginary)Transforms in place, time to frequency.
public void Inverse(Span<float> real, Span<float> imaginary)Transforms in place, frequency to time.
public static int NextSize(int value)The smallest power of two at least as large as a value.
Used by (6)
- ConvolutionReverbEffectVixen.Audio
- FftTestsVixen.Audio.Tests
- PitchVocoderEffectVixen.Audio
- RealFftVixen.Audio
- RealFftTestsVixen.Audio.Tests
- SpectrumAnalyzerEffectVixen.Audio