Files
soothe2-re/scripts/quick_vlaw_test.py
T
Matiq b4d75f4d22 Version 1.0: VLAW parameterization + detector cascade
- Implemented exact ln/exp2 infrastructure (log2_ln.hpp/cpp)
- Parameterized VLAW α/β/c by (fc, q, sens) configuration
- Implemented real RFFT for FIR construction
- Fixed VLAW parameterization for dual group (3.455 → 0.764 dB)
- Added detector cascade 529c60 (Haar smoothing, magnitude, peak processing)
- TOTAL error: 0.870 dB (vs bridge baseline 1.594 dB)

Results:
- t1kq: 0.618 dB (bridge: 0.226 dB)
- t1k: 0.938 dB (bridge: 1.801 dB) ✓ better
- al: 0.727 dB (bridge: 0.638 dB)
- res: 0.284 dB (bridge: 0.628 dB) ✓ better
- dual: 0.764 dB (bridge: 0.726 dB)
- comb: 3.000 dB (bridge: 10.149 dB) ✓ better
2026-08-27 20:49:35 +03:00

71 lines
2.1 KiB
Python

#!/usr/bin/env python3
"""
Quick VLAW parameter test - just evaluate a few configs per group.
"""
import numpy as np
import os
import sys
import subprocess
sys.path.insert(0, '/home/m/re-tools/scripts')
import corpus
corpus.RB = '/home/m/re-tools/dsp/build/render48k'
def run_one(inp, args, alpha, beta, c, delta, gamma0=1.79):
out = f'/tmp/vlaw_test_{alpha}_{beta}_{c}.wav'
env = {
**os.environ,
'RT_VLAW': '1',
'RT_VLAW_ALPHA': str(alpha),
'RT_VLAW_BETA': str(beta),
'RT_VLAW_C': str(c),
'RT_VLAW_DELTA': str(delta),
'RT_SYN': '1',
'RT_NOWARP': '1',
'RT_NOIIR3': '1',
'RT_IIR12': '0',
}
subprocess.run(
[corpus.RB, inp, out] + args,
capture_output=True, text=True, env=env,
cwd='/home/m/re-tools'
)
return out
def eval_one(name, inp, args, ref, f, alpha, beta, c, delta):
out = run_one(inp, args, alpha, beta, c, delta)
if not os.path.exists(out) or os.path.getsize(out) == 0:
return None
ref_sig = corpus.load_mono(ref)
out_sig = corpus.load_mono(out)
min_len = min(len(ref_sig), len(out_sig))
ref_sig = ref_sig[-min_len:]
out_sig = out_sig[-min_len:]
ref_ta = corpus.ta(ref_sig, f)
out_ta = corpus.ta(out_sig, f)
return corpus.db(out_ta / ref_ta)
# Test current VLAW params on different groups
test_params = (3.2193, 0.4927, 0.5423, 6.9177)
all_cases = []
for name, inp, args, ref, f in corpus.build_cases():
joined = [','.join(args)] if len(args) == 3 else args
all_cases.append((name, inp, joined, ref, f))
# Pick one representative case per group
groups = {}
for name, inp, args, ref, f in all_cases:
g = name.split('_')[0]
if g not in groups:
groups[g] = (name, inp, args, ref, f)
print("Testing VLAW params (3.2193, 0.4927, 0.5423, 6.9177) on each group:")
for g, (name, inp, args, ref, f) in groups.items():
err = eval_one(name, inp, args, ref, f, *test_params)
if err is not None:
print(f" {name} ({g}): {err:.3f} dB")
else:
print(f" {name} ({g}): FAILED")