continuity

Continuity metrics: how much of a track is tracked at the right metrical level, versus at any self-consistent one.

musicality.metrics.f_measure.beat_f_measure() scores each beat independently against a 70 ms window, so it cannot separate “the model is mistiming beats” from “the model is confidently tracking half-time”. Those have different fixes, and the gap between cmlt and amlt is what tells them apart: amlt forgives a whole-track octave or offbeat shift, cmlt does not.

Measured on merge_v4 over 60 merge-val tracks: cmlt 0.665 against amlt 0.839, so roughly 17 points of that checkpoint’s beat error is metrical-level ambiguity rather than timing failure. See plans/06_metric_calibration_and_eval_consolidation.md section 1.4.

Functions

beat_continuity(ref_times, est_times[, trim])

Continuity-based beat scores — thin wrapper around mir_eval.beat.continuity.

beat_continuity(ref_times, est_times, trim=True)[source]

Continuity-based beat scores — thin wrapper around mir_eval.beat.continuity.

mir_eval counts a beat as correct when both its own error and the preceding inter-beat interval fall within a relative tolerance (0.175) of the reference, so phase and local period have to agree — unlike beat_f_measure(), which judges each beat in isolation.

See the paper “Evaluation Methods for Musical Audio Beat Tracking Algorithms, Davies et al., 2009”

Parameters:
  • ref_times (ndarray) – Reference beat times, in seconds.

  • est_times (ndarray) – Estimated beat times, in seconds.

  • trim (bool) – If True, drop events before 5s from both sets first — mir_eval’s standard warm-up convention (see beat_f_measure()).

Returns:

None if either sequence has fewer than 2 beats left, since mir_eval cannot derive a period from one beat and returns zeros rather than raising — which would average in as if it were a real score. Otherwise a dict with:

  • cmlc — longest continuously correct stretch, as a fraction of the track, at the correct metrical level.

  • cmlt — total correct fraction at the correct metrical level, continuity not required.

  • amlc / amlt — the same two, but also accepting double-time, half-time and offbeat interpretations of the reference.

amlt - cmlt is the share of the track tracked consistently but at the wrong metrical level; amlt is always >= cmlt.

Return type:

dict | None