Skip to main content

Module downbeat

Module downbeat 

Source
Expand description

Downbeat estimation: which beat is beat 1 (ADR-0050 Layer 2).

No preset can build an 8-bar arc or land a drop without knowing where the bar starts. Estimating that on real music has genuine failure modes — syncopation, half-time feel, non-4/4 — and a wrong downbeat is worse than none: a preset accenting beat 1 on beat 3 reads as broken in a way a plain counter never does. So the aggressive capability is kept and its failure mode is made the conservative one.

The method: accumulate a bass-weighted accent per detected beat, fold that history over the four candidate beat-1 alignments of a 4/4 hypothesis, and take the strongest. What the four alignments are alignments of changed in Plan 0095: the fold buckets by the grid’s tempo-driven beat count, not by beat_index, which counts transients at 1.35x-2.10x per musical beat and so gave the fold a unit that was not a beat and a “bar” that was not a bar (ADR-0109). Confidence is how much of the accent variation the alignment explains, corrected for the share noise alone would explain, so a pattern with no accent structure scores near zero rather than picking a winner by coincidence. Below a threshold the estimator does not publish, and switching alignment mid-stream is hysteretic so the bar line cannot hop beat to beat.

The gate chooses an alignment, nothing else. Locked and unlocked output come from one formula, differing only in whether the alignment is the estimate or 0 — so the fallback is counters derived from whatever beat count it was handed, by construction rather than by a parallel code path that could drift. That is what makes “worst case, it behaves exactly like the counters” a structural claim.

4/4 is assumed and documented. Pure and allocation-free after construction: state is fixed arrays and the only clock is the beat stream (NFR section 6).

Structs§

BarClock
Bar-position output for one hop.
DownbeatTerms
A read-only decomposition of what the estimator currently believes (Plan 0068’s instrument).
DownbeatTracker
Folds per-beat accents over the four 4/4 alignments and publishes a bar position when the winner is convincing enough.

Constants§

BEATS_PER_BAR
Beats per bar. 4/4 is assumed (ADR-0050); a different meter falls back to the counters rather than mis-accenting.