DJ Brake: use the offset measured on a real DSP 204

Measured: limiter threshold minus output meter is about 26 dB when the limiter
starts (25.1 to 27.7, one DSP 204, one output, one piece of music), and the meter
is after the output gain. So the distance is right before the first hit.
The limiter flag also stayed on after raising a threshold, which would have
taught a false value: only limiters starting by themselves teach now.
The measuring tool no longer draws conclusions the data doesn't carry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
GivouandClaude Opus 5.5 committed 2026-11-02 21:54:29 +01:00
1 parent 4cd771eb5c
commit 63b3c17fb7
5 files changed
+106 -24

No files matched your search

+26 -12
View File
@@ -7,7 +7,7 @@ Play steady music into the DSP, close every other control software and run:
It only ever lowers one output's gain (by 6 dB) and limiter threshold, never raises anything above where it was, stores
nothing in a preset slot and puts both back at the end, also on Ctrl+C. A preset export is written first as a backup.
Takes about three minutes. The result goes to dsp-measure-<time>.json.
Takes about two minutes. The result goes to dsp-measure-<time>.json.
"""
import argparse
@@ -40,8 +40,8 @@ class Run:
self.polls: list[dict] = []
self.o = 0
self.ins: list[int] = []
self.gain = 0
self.thr = 0
self.gain = None # known once the output is chosen
self.thr = None
def on_event(self, ev: dict):
if ev["type"] == "meters" and self.dev.state:
@@ -94,9 +94,21 @@ class Run:
break
raw -= 2
await self.set(thr=self.start_thr, gain=self.start_gain)
await asyncio.sleep(3.0) # let the limiter release
result["flag_after_raise_s"] = await self.flag_clear()
return result
async def flag_clear(self) -> float:
"""The flag was seen staying on for 4 s after raising the threshold: the next round must not take that for a hit."""
start = time.monotonic()
await asyncio.sleep(3.0)
while time.monotonic() - start < 15:
recent = self.window(time.monotonic() - 0.8)
if recent and not any(p["limit"][self.o] for p in recent):
break
await asyncio.sleep(0.2)
on = [p["t"] for p in self.window(start) if p["limit"][self.o]]
return round(on[-1] - start, 2) if on else 0.0
def conclude(res: dict) -> list[str]:
lines = []
@@ -115,15 +127,16 @@ def conclude(res: dict) -> list[str]:
f"(rounds: {plain}, spread {max(plain) - min(plain):.1f} dB).")
low = [r for r in hits if r["gain_db"] != res["start"]["gain_db"]]
if plain and low:
base = statistics.fmean(r["threshold_db"] for r in hits if r["gain_db"] == res["start"]["gain_db"])
moved = statistics.fmean(r["threshold_db"] for r in low) - base
lines.append(f"With -6 dB gain the limiter started {moved:+.1f} dB in threshold: "
+ ("it works AFTER the gain." if abs(moved + 6) < 2 else "it works BEFORE the gain." if abs(moved) < 2 else "unclear."))
# the threshold alone moves with the music between rounds, threshold minus meter doesn't
a = statistics.fmean(r["offset_max_db"] for r in hits if r["gain_db"] == res["start"]["gain_db"])
b = statistics.fmean(r["offset_max_db"] for r in low)
lines.append(f"Threshold minus loudest meter reading: {a:+.1f} dB, with -6 dB gain {b:+.1f} dB. "
+ ("About the same, so meter and limiter seem to see the same level." if abs(a - b) < 2 else "They differ: compare with another run before concluding anything."))
c = res.get("limiting")
if c:
drop = c["limiting"]["mean_db"] - c["free"]["mean_db"]
lines.append(f"Holding the threshold 6 dB below the start of limiting changed the meter by {drop:+.1f} dB: "
+ ("the meter shows the level AFTER the limiter." if drop < -1.5 else "the meter shows the level BEFORE the limiter."))
drop = (c["limiting"]["mean_db"] - c["limiting"]["in_db"]) - (c["free"]["mean_db"] - c["free"]["in_db"])
lines.append(f"Holding the threshold 6 dB below the start of limiting changed the meter by {drop:+.1f} dB against the input: "
+ ("the meter shows the level AFTER the limiter." if drop < -3 else "too little to say whether the meter is before or after the limiter."))
lines.append(f"While limiting, threshold minus meter: p95 {c['threshold_db'] - c['limiting']['p95_db']:+.1f} dB, "
f"mean {c['threshold_db'] - c['limiting']['mean_db']:+.1f} dB.")
return lines
@@ -237,7 +250,8 @@ async def main(args):
res["error"] = error
res["polls"] = [[round(p["t"] - run.polls[0]["t"], 2), round(db(p["out"][run.o] ** 2), 1), round(db(sum(p["in"][i] ** 2 for i in run.ins)), 1),
int(p["limit"][run.o]), P.gain_to_db(p["gain"]), P.threshold_to_db(p["thr"])] for p in run.polls] if run.ins else []
int(p["limit"][run.o]), None if p["gain"] is None else P.gain_to_db(p["gain"]),
None if p["thr"] is None else P.threshold_to_db(p["thr"])] for p in run.polls] if run.ins else []
out = outdir / f"dsp-measure-{stamp}.json"
out.write_text(json.dumps(res), encoding="utf-8")
print("\nResult:", out)