Refactor notification system to use HTTP POST for buzz events, updating configuration and documentation accordingly.

This commit is contained in:
2026-10-19 15:28:48 -05:00
parent 63d9995f59
commit 753a62beca
10 changed files with 183 additions and 149 deletions
+20 -15
View File
@@ -8,7 +8,7 @@ Usage:
[--background bg1.wav bg2.wav ...] recordings WITHOUT the buzzer
[--out main/template.h] (main/test_vector.h is written next to it)
[--gate-mult 4.0] auto-detect gate: noise floor * this
[--min-rms 200] [--window-n 15] [--window-m 10] [--cooldown 20]
[--min-rms 200] [--window-n 15] [--window-m 10] [--cooldown 0.5]
[--threshold T] override threshold used in the false-trigger estimate
What it does:
@@ -218,21 +218,24 @@ def bar_chart(tpl, P, edges):
print(" %2d %6.0f Hz %+.3f %s|%s" % (b, fc, v, left, right))
def simulate_triggers(match, nframes_cooldown, N, M):
"""Same N-of-M + cooldown logic as detector.c, on a boolean match array."""
hist, state, cd, trig = 0, "IDLE", 0, 0
def simulate_triggers(match, nframes_quiet_tail, N, M):
"""Simulate N-of-M detection and group matches inside the quiet tail."""
hist, state, quiet_left, trig = 0, "IDLE", 0, 0
mask = (1 << N) - 1
for m in match:
if state != "IDLE":
if quiet_left <= 1:
state, hist = "IDLE", 0
else:
quiet_left = nframes_quiet_tail if m else quiet_left - 1
continue
if state == "IDLE":
hist = ((hist << 1) | int(m)) & 0xFFFFFFFF
if bin(hist & mask).count("1") >= M:
trig += 1; state = "TRIGGERED"
elif state == "TRIGGERED":
state, cd, hist = "COOLDOWN", nframes_cooldown, 0
else:
cd -= 1
if cd <= 0:
state, hist = "IDLE", 0
trig += 1
state = "GROUPING"
quiet_left = nframes_quiet_tail
hist = 0
return trig
@@ -289,7 +292,8 @@ def main():
ap.add_argument("--min-rms", type=float, default=200.0, help="firmware loudness gate (default Kconfig 200)")
ap.add_argument("--window-n", type=int, default=15)
ap.add_argument("--window-m", type=int, default=10)
ap.add_argument("--cooldown", type=float, default=20.0)
ap.add_argument("--cooldown", type=float, default=0.5,
help="quiet tail for grouping buzz frames, in seconds (default 0.5)")
ap.add_argument("--threshold", type=float, help="threshold for the false-trigger estimate")
a = ap.parse_args()
@@ -364,9 +368,10 @@ def main():
secs += dur
print("Frames passing the loudness gate (RMS>=%.0f): %.1f%%" % (
a.min_rms, 100.0 * np.mean(np.concatenate([f[2] for f in per_file]) >= a.min_rms)))
print("False-trigger estimate at threshold %.3f with %d-of-%d window, %.0f s cooldown: "
"%d trigger(s) in %.1f min = %.2f per hour" % (
thr_use, a.window_m, a.window_n, a.cooldown, trig, secs / 60.0, trig / (secs / 3600.0)))
print("False-trigger estimate at threshold %.3f with %d-of-%d window, %.0f ms quiet tail: "
"%d buzz event(s) in %.1f min = %.2f per hour" % (
thr_use, a.window_m, a.window_n, a.cooldown * 1000.0,
trig, secs / 60.0, trig / (secs / 3600.0)))
out_dir = os.path.dirname(os.path.abspath(a.out)) or "."
os.makedirs(out_dir, exist_ok=True)