phase A: reduction law found (affine in dB), canon unchanged; keep RT_DUMP tooling

- Effective reduction is affine in dB(lvl): x_exp2 = -0.6646 - 0.05877*dB
  (mask ~ 0.8*lvl^-0.354, gamma ~= decomp 0.344); tones +-0.13 dB over 42 dB
- Pre-IIR calibrated variant (X0=1.8/S=0.11): TOTAL 2.633 vs HEAD 2.286;
  wins t1kq/t1k/al/comb, loses res/dual -> gate fails, canon stays LUT
- Grid search (X0,S,floor,CMAX) on validated trajectory model: no scalar
  law of the family fits tone+noise simultaneously (res tension)
- Refuted: high-bin/IIR3-backward propagation, direct-affine bypass,
  positive floors, ceilings
- Kept opt-in instrumentation RT_DUMP_BIN / RT_DUMP_ALL for Step 7 capture
- Docs: NOTES_LEVEL 21d, BITEXACT_PLAN s.0 note, roadmap, AGENTS
This commit is contained in:
2026-08-21 19:29:21 +03:00
parent 702b74e297
commit 3e5085e06d
5 changed files with 136 additions and 1 deletions
+50
View File
@@ -121,6 +121,13 @@ static void process_band_structural(
mask_out[k] = static_cast<float>(std::exp2(-static_cast<double>(band_level[k])) * f6f8[k]);
}
// RT_DUMP_BIN debug: capture pre-warp mask (opt-in, no cost when unset).
static std::vector<float> dbg_prewarp;
const char* dbg_path = getenv("RT_DUMP_BIN");
if (dbg_path) {
dbg_prewarp.assign(mask_out, mask_out + nbin);
}
fn529fe0::combine_acc(acc.data(), band_level.data(), f6f8.data(),
kRTAtt, kRTRel, nfft);
@@ -154,6 +161,49 @@ static void process_band_structural(
for (size_t k = 0; k < nfft; k++) {
mask_out[k] = mask_out[k] * (fVar30 * 1.0f) + (1.0f - fVar30);
}
// RT_DUMP_BIN: single-frame per-bin tract at frame RT_DUMP_FRAME (default
// 100): k am res lvl_raw band_level post-IIR1/2, pre-warp mask, W weight.
if (dbg_path && !dbg_prewarp.empty()) {
static int dbg_frames = 0;
int dbg_target = 100;
if (const char* fs = getenv("RT_DUMP_FRAME")) dbg_target = atoi(fs);
if (dbg_frames++ != dbg_target) return;
FILE* df = fopen(dbg_path, "wb");
if (df) {
fprintf(df, "# fc=%g q=%g sens=%g rp=%.6f\n", band.fc, band.q, band.sens, rp);
for (size_t k = 0; k < nbin; k++) {
double res_k = std::max(static_cast<double>(res[k]), 1e-12);
double lvl_raw = static_cast<double>(am[k]) / res_k * scale_factor;
double w = kBand768[k] * kWarp[k] * std::pow(res_k, rp);
fprintf(df, "%zu %.9g %.9g %.9g %.9g %.9g %.9g\n", k,
static_cast<double>(am[k]), res_k, lvl_raw,
static_cast<double>(band_level[k]),
static_cast<double>(dbg_prewarp[k]), w);
}
fclose(df);
}
}
// RT_DUMP_ALL trajectory: append per-frame lvl_raw spectrum (binary:
// int32 frame, int32 nbin, float32 lvl_raw[nbin]). Single-band cases only.
// Detector path is law-independent -> one capture serves offline law fits.
if (const char* ap = getenv("RT_DUMP_ALL")) {
static FILE* af = fopen(ap, "ab");
if (af) {
static int aframe = 0;
int32_t hdr[2] = {static_cast<int32_t>(aframe++),
static_cast<int32_t>(nbin)};
fwrite(hdr, sizeof(int32_t), 2, af);
for (size_t k = 0; k < nbin; k++) {
double res_k = std::max(static_cast<double>(res[k]), 1e-12);
float lv = static_cast<float>(
static_cast<double>(am[k]) / res_k * scale_factor);
fwrite(&lv, sizeof(float), 1, af);
}
fflush(af);
}
}
}
} // namespace