From e4c53480adab436fbf7deff213cdfdd4f74da6ef Mon Sep 17 00:00:00 2001 From: Matiq Date: Wed, 2 Sep 2026 22:37:09 +0300 Subject: [PATCH] audit fixes: dead conditional, DBG_CASC gate, dup loop, fft comments, blend doc - framed_model: remove `if (pool_w > 0 && !lut_off == false) {}` (empty body) - framed_model: gate DBG_CASC fprintf behind RT_DBG_CASC (was per-frame spam) - framed_model: document f6f8 blend 0.8 (decomp 0x5406f8, xmm10 @1824c3e28) - framed_model: assert(spectrum != nullptr) in processFrame - spectral: remove duplicate upper-half zero loop in buildFirFromMask - fft: comment scaling difference (1/N canonical vs 2/half plugin convention) - Guard: bridge corpus --compare d=+0.000 (exact parity) --- dsp/fft.cpp | 4 ++-- dsp/framed_model.cpp | 7 +++++-- dsp/spectral.cpp | 3 --- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dsp/fft.cpp b/dsp/fft.cpp index 77e1f3a..3581955 100644 --- a/dsp/fft.cpp +++ b/dsp/fft.cpp @@ -87,7 +87,7 @@ void execute_inverse(const FFTPlan* plan, std::complex* buf) { } for (uint32_t i = 0; i < N; i++) { - buf[i] /= N; + buf[i] /= N; // canonical 1/N normalization (inverse FFT) } } @@ -282,7 +282,7 @@ void execute_real_inverse_exact(const FFTPlan* plan, } } - // Scale by 1/(N/2) + // Scale by 2/half (= 4/N) — plugin convention, differs from canonical 1/N in execute_inverse for (uint32_t i = 0; i < half; i++) { z[i] *= 2.0 / half; } diff --git a/dsp/framed_model.cpp b/dsp/framed_model.cpp index 428df20..fdd8eb8 100644 --- a/dsp/framed_model.cpp +++ b/dsp/framed_model.cpp @@ -8,6 +8,7 @@ #include #include #include +#include namespace { @@ -151,7 +152,6 @@ static void process_band_structural( for (size_t k = 0; k < nbin; k++) lvl_in[k] = static_cast(lvl_in[k] / k_tot); } } - if (pool_w > 0 && !lut_off == false) {} if (pool_w > 0) { std::vector pooled(nbin); for (size_t k = 0; k < nbin; k++) { @@ -396,6 +396,8 @@ static void process_band_structural( band_level[nfft - 1 - k] = band_level[k]; } + // f6f8 blend: freqaxis*(1-mix) + mix*0.8 (source: decomp 0x5406f8 blend buffer, + // xmm10=0.8 @1824c3e28; mix hardcoded 1.0 → constant 0.8 pedestal) for (size_t k = 0; k < nfft; k++) { f6f8[k] = 1.0f * (1.0f - mix) + mix * 0.8f; } @@ -684,6 +686,7 @@ void FramedDetector::processFrame(const std::complex* spectrum, float* m // the slow adaptation the real plugin exhibits on sustained content. static const int env_live = getenv("RT_ENV") ? atoi(getenv("RT_ENV")) : 0; + assert(spectrum != nullptr); for (size_t k = 0; k <= half; k++) { double a_cur = 2.0 * std::abs(spectrum[k]) / wsum_; if (env_live) { @@ -724,7 +727,7 @@ void FramedDetector::processFrame(const std::complex* spectrum, float* m // Cascade computes: |audio_spectrum × twin_response| → Haar smooth → sin-peak floor // Output replaces am/res in the structural chain. static thread_local std::vector casc_curve; - fprintf(stderr, "DBG_CASC casc_on=%d nfft=%zu twin=%zu b=%zu bands=%zu\n", casc_on, nfft_, twin_resp_complex_.size(), b, bands_.size()); + if (getenv("RT_DBG_CASC")) fprintf(stderr, "DBG_CASC casc_on=%d nfft=%zu twin=%zu b=%zu bands=%zu\n", casc_on, nfft_, twin_resp_complex_.size(), b, bands_.size()); if (casc_on && nfft_ == 4096 && twin_resp_complex_.size() > b) { size_t nbin = half + 1; std::vector complex_input(2 * nbin); diff --git a/dsp/spectral.cpp b/dsp/spectral.cpp index 3419564..6798e60 100644 --- a/dsp/spectral.cpp +++ b/dsp/spectral.cpp @@ -207,9 +207,6 @@ void SpectralProcessor::buildFirFromMask(const float* mask, std::complex for (size_t i = half + 1; i < nfft; i++) { time_domain[i] = 0.0; // xmm9 = 0 zeros upper half } - for (size_t i = half + 1; i < nfft; i++) { - time_domain[i] = 0.0; - } // Step 4: opB = fwd-RFFT (th1a90): time_domain (real) → complex std::vector> freq_domain(half + 1);