From 475b1958d58044dbc71d748df24133d1ca6c1091 Mon Sep 17 00:00:00 2001 From: Matiq Date: Mon, 24 Aug 2026 15:18:39 +0300 Subject: [PATCH] fix: corpus 24-bit loader + LUT calibration env var - Fix reshape error in corpus.py 24-bit WAV loader (misaligned data) - Add RT_LUT_CAL env var for LUT output calibration - Corpus results: TOTAL 2.397 (bridge 1.594), comb improved (-4.032) - Structural chain regresses on t1kq/t1k/al/dual due to LUT curve mismatch - The LUT produces different frequency response than plugin's FIR construction --- dsp/framed_model.cpp | 4 ++++ scripts/corpus.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/dsp/framed_model.cpp b/dsp/framed_model.cpp index 61fe49f..7b2c658 100644 --- a/dsp/framed_model.cpp +++ b/dsp/framed_model.cpp @@ -152,6 +152,10 @@ static void process_band_structural( double t = (dB - LUT_A) / (LUT_B - LUT_A); t = std::min(std::max(t, 0.0), 1.0); lvl = std::pow(t, static_cast(LUT_GAMMA)) * LUT_MULT; + // RT_LUT_CAL: calibration multiplier on LUT output (empirical, + // calibrated against plugin steady-state mask@43=0.510). + static const double lut_cal = getenv("RT_LUT_CAL") ? atof(getenv("RT_LUT_CAL")) : 1.0; + lvl *= lut_cal; } band_level[k] = static_cast(lvl); } diff --git a/scripts/corpus.py b/scripts/corpus.py index a0482aa..1164562 100644 --- a/scripts/corpus.py +++ b/scripts/corpus.py @@ -32,6 +32,9 @@ def load_mono(p): ch = w.getnchannels(); b = w.getsampwidth() if b == 2: return np.frombuffer(d, dtype=np.int16).astype(np.float64).reshape(-1, ch).mean(1) / 32768 + # 24-bit: handle misaligned data (extra bytes from bext/junk chunks) + n_samples = len(d) // (ch * 3) + d = d[:n_samples * ch * 3] raw = np.frombuffer(d, dtype=np.uint8).reshape(-1, ch, 3) s = raw[:, :, 0].astype(np.int64) | (raw[:, :, 1].astype(np.int64) << 8) | (raw[:, :, 2].astype(np.int64) << 16) return np.where(s >= 0x800000, s - 0x1000000, s).mean(1).astype(np.float64) / 8388608.0