P1.5: embed live level-tracker A[] + mask scalars into C++ (dsp/leveltrack_data.hpp); leveltrack_check sanity confirms SR=48000, A_ATTACK plateaus 0.692, attack/release=1.0

This commit is contained in:
2026-08-20 01:12:12 +03:00
parent 0e90918226
commit a49e35dc25
3 changed files with 213 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
#!/usr/bin/env python3
"""Emit dsp/leveltrack_data.hpp: live level-tracker A[] + mask scalars from
handoff/rtctx_live.json (P1.5 realtime capture, render_long.rpp preset).
"""
import json, os
HERE = os.path.dirname(os.path.abspath(__file__))
SRC = os.path.join(HERE, 'rtctx_live.json')
OUT = os.path.join(HERE, '..', 'dsp', 'leveltrack_data.hpp')
d = json.load(open(SRC))
A_attack = d['A_4c0528'] # attack smoothing (fast), 341 double
A_release = d['A_3c0510'] # release smoothing (slow), 341 double
scalars = d['scalars'] # hex-offset -> float
def fmt_doubles(a):
return ", ".join("%.17g" % v for v in a)
lines = []
lines.append("// AUTOGENERATED from P1.5 realtime capture handoff/rtctx_live.json")
lines.append("// (render_long.rpp: attack=0 release=0 selectivity=10 sharpness=10 depth=0.864).")
lines.append("// Regenerate with handoff/emit_leveltrack.py. Do not edit by hand.")
lines.append("#pragma once")
lines.append("#include <cstddef>")
lines.append("")
lines.append("namespace ltk {")
lines.append("")
lines.append("// ctx = 0x2370040, marker +0x24 == 48000.0f (internal SR).")
lines.append("constexpr float CTX_INTERNAL_SR = 48000.0f;")
lines.append("")
lines.append("// mask scalars (float) captured live:")
for off, val in scalars.items():
lines.append(f"constexpr float SCALAR{off.upper()} = {val}f;")
lines.append("")
lines.append(f"constexpr size_t LEVEL_NBINS = {len(A_attack)};")
lines.append("")
lines.append("// per-bin level-tracker IIR attack coefficients (0x4c0528):")
lines.append(f"const double A_ATTACK[{len(A_attack)}] = {{")
for i in range(0, len(A_attack), 6):
lines.append(" " + ", ".join("%.17g" % v for v in A_attack[i:i+6]) + ",")
lines.append("};")
lines.append("")
lines.append("// per-bin level-tracker IIR release coefficients (0x3c0510 == 0x2c04f8):")
lines.append(f"const double A_RELEASE[{len(A_release)}] = {{")
for i in range(0, len(A_release), 6):
lines.append(" " + ", ".join("%.17g" % v for v in A_release[i:i+6]) + ",")
lines.append("};")
lines.append("")
lines.append("} // namespace ltk")
open(OUT, 'w').write("\n".join(lines) + "\n")
print(f"wrote {OUT}: attack={len(A_attack)} release={len(A_release)} scalars={len(scalars)}")