P1.3: integrate FFT-conv stage (build_fir_from_window step5 memcpy + fir_from_mask + overlap-save conv) with captured WIN_WINDOW; fftconv_check confirms FIR=window[2048:4096]={0.8->1.0}

This commit is contained in:
2026-08-19 23:25:21 +03:00
parent 42316efa71
commit 8b8895f68a
4 changed files with 162 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
#pragma once
#include <cstddef>
#include <cstdint>
#include <vector>
#include <complex>
#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<double>* fir,
const std::complex<double>* 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