web: band-split dB-flux onset detector, synthetic drum bench

Replaces the log1p-compressed whole-spectrum flux with four-band flux in dB,
a two-frame max-filtered reference, a per-band median+8 MAD threshold with a
per-band minimum rise, and one refractory period. Level-independent.

tools/onset-bench.mjs synthesises kick/snare/hat patterns with known onset
times (3 patterns x 3 tempos x 3 levels x 3 beds = 81 signals), scores hit
rate, false positives and median timing at 30 fps and 512-sample hops.
tools/onset-legacy.mjs freezes the old detector for the before numbers.

Synthetic only. Nothing was listened to; no real music, no real GPU.
Corpus adjustments made after the first baseline run: coincident kick+snare
count as one onset; voices end in a 60 ms fade because truncation clicks read
as onsets in the near-silent gaps; hats raised relative to the snare tail.
Baseline was rerun after each change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Aqua 2026-11-06 12:34:14 +00:00
commit 908e8dcb3b
7 changed files with 346 additions and 49 deletions

View file

@ -14,7 +14,7 @@ export class Analysis {
constructor(sampleRate, binCount) {
this.sampleRate = sampleRate; this.binCount = binCount;
this.lin = new Float32Array(binCount);
this.onsets = new OnsetDetector({ maxBin: Math.min(binCount, Math.round(8000 / (sampleRate / 2 / binCount))) });
this.onsets = new OnsetDetector({ binHz: sampleRate / 2 / binCount });
this.keyEst = new KeyEstimator(sampleRate, binCount);
this.bands = new Float32Array(NB);
this.row = new Uint8Array(NB); // newest row, as texture bytes