Commit 81aecc96 by PLN (Algolia)

fix(gig-log): the DJ filter has TWO halves — the report was reading only one

BootTidal.hs:376-377 applies BOTH:

    gDJF ch = (# lpf (range 180 20000 (fmap (\v -> 1 - 2 * max 0 (0.5 - v)) ...)))
            . (# hpf (range 20   8000  (fmap (\v -> 2 * max 0 (v - 0.5))     ...)))

Yesterday's `left at` column transcribed only the `# lpf` line, so it called
gF3-parked-at-80 "open" when it is really a ~2 kHz HIGH-PASS — which guts a bass
or a voice, and which is exactly the helper PLN had commented off two different
d5 orbits to get the sound back. The report was confidently wrong about the whole
upper half of the knob, in the direction of reassurance.

Now models both bands and grades on the pair:
    0   lpf   180  hpf   20    NEAR-SILENT
    64  lpf 20000  hpf   83   open
    80  lpf 20000  hpf 2094    thin — low end cut
    127 lpf 20000  hpf 8000    NO BODY LEFT
Hard right is not "open". It never was.

Two of the existing tests encoded the old blind spot — they used cc 49 = 100 as
the "safe" control value, which is hpf 4607 Hz. The code was right and the tests
were wrong, so the tests moved to the centre.

And the new test caught something small and real: "centre = true bypass" is an
APPROXIMATION, not an identity. 0..127 is an ODD range, so 0.5 falls between cc 63
and cc 64 and no cc value hits bypass exactly — 63 gives a ~19.7 kHz lowpass, 64
an 83 Hz highpass. Both inaudible, so the knob is fine in practice, but the test
now asserts the truth rather than the comment in BootTidal.hs.

453 tests green across tools/.
parent a4dc37ba
......@@ -680,20 +680,41 @@ CONTROL_ROLE = {
def djf_lpf(value: int) -> float:
"""Hz that gDJF applies for a raw CC value. See the note above."""
"""LPF hz that gDJF applies for a raw CC value. See the note above."""
v = max(0, min(127, int(value))) / 127.0
x = 1.0 - 2.0 * max(0.0, 0.5 - v)
return 180.0 + (20000.0 - 180.0) * x
def djf_verdict(hz: float) -> str:
def djf_hpf(value: int) -> float:
"""HPF hz — the half the first version of this report FORGOT.
gDJF is two-sided (BootTidal.hs:376-377); reading only the `# lpf` line made
the report call gF3-at-80 "open" when it is really a ~2 kHz high-pass, which
guts a bass or a voice. Both halves, or the verdict is a lie on one side.
"""
v = max(0, min(127, int(value))) / 127.0
return 20.0 + (8000.0 - 20.0) * (2.0 * max(0.0, v - 0.5))
def djf_bands(value: int) -> tuple[float, float]:
return djf_lpf(value), djf_hpf(value)
def djf_verdict(lpf: float, hpf: float) -> str:
"""How a parked DJ filter will SOUND. Thresholds are by ear, not by maths."""
if hz < 400:
if lpf < 400:
return "⚠⚠ NEAR-SILENT"
if hz < 1500:
if hpf > 3000:
return "⚠⚠ NO BODY LEFT"
if lpf < 1500:
return "⚠ dark"
if hz < 6000:
if hpf > 700:
return "⚠ thin — low end cut"
if lpf < 6000:
return "filtered"
if hpf > 120:
return "slight hp"
return "open"
......@@ -979,8 +1000,9 @@ def cmd_report(path: Path, since: str | None = None,
for cc, a in sorted(agg.items(), key=lambda kv: -kv[1]["n"]):
flag = " ⚠ARDOUR-OWNED" if cc in ARDOUR_CC else ""
if cc in DJF_CC and a["v"] is not None:
hz = djf_lpf(a["v"])
flag = f" lpf {round(hz):>5} Hz {djf_verdict(hz)}"
lo, hi = djf_bands(a["v"])
flag = (f" lpf {round(lo):>5} hpf {round(hi):>4} Hz "
f"{djf_verdict(lo, hi)}")
v = "?" if a["v"] is None else str(a["v"])
p(f" {cc:>4} {a['n']:>6} {a['lo']:>4}-{a['hi']:<4} {v:>7} "
f"{hms(a['first']-t0):>7} {hms(a['last']-t0):>7} {a['s']:>5}s{flag}")
......@@ -1087,9 +1109,9 @@ def cmd_controls(path: Path, since: str | None = None,
role = CONTROL_ROLE.get(cc, "")
means = ""
if cc in DJF_CC and v is not None:
hz = djf_lpf(v)
verdict = djf_verdict(hz)
means = f"lpf {round(hz)} Hz — {verdict}"
lo, hi = djf_bands(v)
verdict = djf_verdict(lo, hi)
means = f"lpf {round(lo)} / hpf {round(hi)} Hz — {verdict}"
if "⚠" in verdict:
risky.append((cc, v, means))
elif cc in MUTE_CC and v is not None:
......
......@@ -589,9 +589,9 @@ def test_djf_lpf_is_linear_in_hz_which_is_the_footgun():
def test_djf_verdict_flags_only_the_genuinely_inaudible():
assert "NEAR-SILENT" in gl.djf_verdict(gl.djf_lpf(0))
assert gl.djf_verdict(gl.djf_lpf(127)) == "open"
assert gl.djf_verdict(gl.djf_lpf(64)) == "open"
assert "NEAR-SILENT" in gl.djf_verdict(*gl.djf_bands(0))
assert "NO BODY" in gl.djf_verdict(*gl.djf_bands(127))
assert gl.djf_verdict(*gl.djf_bands(64)) == "open"
def test_surface_state_keeps_the_last_value_not_the_last_seen_record():
......@@ -655,7 +655,9 @@ def test_controls_report_names_the_dangerous_parking(tmp_path, capsys):
r._write({"t": t, "k": "cc", "p": "24:0", "ch": 0, "cc": 74,
"n": 2, "v0": 0, "v1": 127, "lo": 0, "hi": 127}) # mute held on
r._write({"t": t, "k": "cc", "p": "24:0", "ch": 0, "cc": 49,
"n": 2, "v0": 0, "v1": 100, "lo": 0, "hi": 100}) # safe
"n": 2, "v0": 0, "v1": 64, "lo": 0, "hi": 100}) # safe = CENTRE
# NB 100 is NOT safe: gDJF's upper half is a high-pass, and 100 is
# hpf 4607 Hz. Only the centre is true bypass on both sides.
r.f.close()
assert gl.cmd_controls(r.path) == 0
out = capsys.readouterr().out
......@@ -670,7 +672,7 @@ def test_controls_report_is_quiet_when_the_surface_is_safe(tmp_path, capsys):
r = gl.Recorder(out_dir=tmp_path, hz=50.0, xruns=False, midi=False)
r._write(r.header())
r._write({"t": time.time(), "k": "cc", "p": "24:0", "ch": 0, "cc": 49,
"n": 1, "v0": 100, "v1": 100, "lo": 100, "hi": 100})
"n": 1, "v0": 64, "v1": 64, "lo": 64, "hi": 64})
r.f.close()
assert gl.cmd_controls(r.path) == 0
assert "No control is parked in a known-dangerous zone" in capsys.readouterr().out
......@@ -737,3 +739,25 @@ def test_is_live_uses_data_recency_not_a_process_match():
assert gl.is_live([{"t": time.time()}], hdr) is True
assert gl.is_live([{"t": time.time() - 600}], hdr) is False
assert gl.is_live([], hdr) is False
def test_djf_models_BOTH_halves_not_just_the_lowpass():
# BootTidal.hs:376-377 applies lpf AND hpf. Reading only the lpf line made
# the report call gF3-parked-at-80 "open" when it is a ~2 kHz high-pass.
lo, hi = gl.djf_bands(80)
assert round(lo) == 20000, "upper half leaves the lowpass open"
assert 1900 < hi < 2200, hi
assert "open" not in gl.djf_verdict(lo, hi)
# "Centre = true bypass" is an APPROXIMATION, not an identity: 0..127 is an
# odd range, so 0.5 falls BETWEEN cc 63 and cc 64 and no cc value hits bypass
# exactly. cc 63 -> a ~19.7 kHz lowpass, cc 64 -> an 83 Hz highpass. Both are
# inaudible, so the knob is fine in practice — but assert the truth, not the
# comment in BootTidal.hs.
lo63, hi63 = gl.djf_bands(63)
lo64, hi64 = gl.djf_bands(64)
assert hi63 == 20 and lo63 > 19000 and lo63 < 20000
assert lo64 == 20000 and 20 < hi64 < 120
assert gl.djf_verdict(lo63, hi63) == "open"
assert gl.djf_verdict(lo64, hi64) == "open"
# hard right is a brutal high-pass, not "open"
assert gl.djf_hpf(127) > 7900
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment