#pragma once #include #include #include #include #include "fft_plan.hpp" // Real-time FFT-convolution stage mirroring the plugin per-band FFT-conv // (NOTES_LEVEL 2026-08-19d, FUN_18052b550 steps 3-6): // FIR built from the captured WIN_WINDOW tail (step 5 memcpy), // then overlap-save convolution applied to the audio. // Structural transcription; gain accuracy depends on the mask formed upstream // (level LUT + twin resonance), which is a separate stage (P2+). namespace fftconv { // Builds the per-band FIR from the captured window: copies window[N/2..N-1] // into FIR[0..N/2-1] and fills the upper half with zero (xmm9 fill), N = nfft. // Mirrors the decompiled step 5 exactly. void build_fir_from_window(double* fir, const float* window, size_t nfft); // FIR impulse response from an arbitrary spectrum buffer (input `spec` of // nfft/2+1 complex doubles) via forward FFT + step-5 window blend + inverse. void fir_from_mask(std::complex* fir, const std::complex* mask, const float* window, size_t nfft, const FFTPlan* plan); // Overlap-save convolution of `in` (frames) with real FIR `ir` (nfft samples). // out pre-sized to frames. lat: zero-pad/initial delay applied internally. void conv_overlap_save(const double* ir, size_t nfft, size_t hop, const float* in, float* out, size_t frames, const FFTPlan* plan); } // namespace fftconv