Class thl::dsp::fft::RealFft#
-
class RealFft#
The FFT of a real signal of a power-of-two size, on the backend the build chose.
forward(): size() real samples to num_bins() = size() / 2 + 1 bins, X[k] = sum over n of x[n] · e^(-2πi·k·n / N), unscaled (as numpy.fft.rfft): a sine of amplitude A at bin k reads |X[k]| = A · N / 2. Bin 0 (DC) and bin N / 2 (Nyquist) are real. inverse(): the bins back to size() samples, scaled by 1 / N, so inverse(forward(x)) is x. The imaginary parts of bins 0 and N / 2 are ignored.
The backend is a build option (TANH_FFT_BACKEND): pffft on every platform, or Apple’s Accelerate on macOS and iOS; backend_name() says which. Both give the same bins.
Threads: prepare() allocates (not on the audio thread); forward() and inverse() are real-time safe and use the object’s own buffers, so one object serves one thread at a time.
Public Functions
-
RealFft()#
-
~RealFft()#
-
bool prepare(size_t size)#
Sets up the transform of
sizesamples (is_valid_size()).False, and unprepared, for any other size or if the backend cannot set it up.
-
void forward(std::span<const float> time, std::span<std::complex<float>> bins)#
time(size() samples) tobins(num_bins()).
-
void inverse(std::span<const std::complex<float>> bins, std::span<float> time)#
bins(num_bins()) totime(size() samples), scaled by 1 / size().
-
RealFft()#