DJ Brake: learn the limiter from its onset, for the whole DSP

Replaying real tracks through a limiter model showed the level during limiting
teaches little. One hit now counts for all outputs of a DSP.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
GivouandClaude Opus 5.5 committed 2026-11-02 21:24:32 +01:00
1 parent bbe8a73775
commit 6d467d4f2d
2 files changed
+32 -8

No files matched your search

+10 -6
View File
@@ -331,7 +331,7 @@ class App:
self.dj_rooms: dict = {} # device id -> dB left to the nearest watched limiter, False = nothing watched
self.dj_avgs: dict = {} # the same for the average level
self.dj_env: dict = {} # "device:output" -> peak and average of the level
self.dj_cal: dict = {} # "device:output" -> dB the limiter sits below its threshold on the meter, learned from hits
self.dj_cal: dict = {} # device id -> dB the limiters sit below their threshold on the meter, learned from hits
self.dj_cal_saved = 0.0
self.dj_streams = 0
self.logo = ""
@@ -385,8 +385,8 @@ class App:
self.djbrake = bool(cfg.get("djbrake"))
self.dj_ignore = clean_dj_ignore(cfg.get("dj_ignore"))
self.dj_margin = clean_dj_margin(cfg.get("dj_margin"))
self.dj_cal = {str(k)[:80]: float(v) for k, v in (cfg.get("dj_cal") if isinstance(cfg.get("dj_cal"), dict) else {}).items()
if type(v) in (int, float)}
self.dj_cal = {str(k)[:64]: float(v) for k, v in (cfg.get("dj_cal") if isinstance(cfg.get("dj_cal"), dict) else {}).items()
if type(v) in (int, float) and ":" not in str(k)}
self.dj_hint = bool(cfg.get("dj_hint", True))
self.dj_hint_en = bool(cfg.get("dj_hint_en", True))
if "logo" in cfg:
@@ -970,10 +970,14 @@ class App:
e["peak"] = max(db, e["peak"] - DJ_PEAK_FALL * dt)
e["pow"] += (level * level - e["pow"]) * (1 - math.exp(-dt / DJ_AVG_TAU))
thr = P.threshold_to_db(threshold)
if limit and e["peak"] > -70: # the limiter acts: this is where it really sits on the meter
# the moment a limiter starts is where it really sits on the meter. Later the level is what the limiter
# left of it. One DSP has one meter, so this counts for all its outputs
dev_id = key.rsplit(":", 1)[0]
if limit and not e.get("acting") and e["peak"] > -70:
seen = max(-6.0, min(30.0, thr - e["peak"]))
self.dj_cal[key] = seen if key not in self.dj_cal else self.dj_cal[key] + (seen - self.dj_cal[key]) * (1 - math.exp(-dt))
top = thr - self.dj_cal.get(key, 0.0) - self.dj_margin
self.dj_cal[dev_id] = (self.dj_cal[dev_id] + seen) / 2 if dev_id in self.dj_cal else seen
e["acting"] = limit
top = thr - self.dj_cal.get(dev_id, 0.0) - self.dj_margin
left = 0.0 if limit else max(0.0, top - e["peak"]) if e["peak"] > -70 else None
mean = max(0.0, top - 10 * math.log10(e["pow"])) if e["pow"] > 1e-7 else None
return left, mean, limit or bool(self.dj_margin and db >= top)