From ca9f41c4b2cf7bd978e1e28bd99f2eb35cc0d818 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 9 Jan 2025 22:29:54 -0700 Subject: [PATCH] temporal: tempo changes must be on meter-provided grid, not quarter notes --- libs/temporal/tempo.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libs/temporal/tempo.cc b/libs/temporal/tempo.cc index f2099ec66f..f2443b4b91 100644 --- a/libs/temporal/tempo.cc +++ b/libs/temporal/tempo.cc @@ -1353,11 +1353,12 @@ TempoMap::set_tempo (Tempo const & t, timepos_t const & time) /* tempo changes are required to be on-beat */ - Beats on_beat = time.beats().round_to_beat(); + TempoMetric metric (metric_at (time.beats(), false)); + Beats on_beat = time.beats().round_to_multiple (Beats::ticks (metric.meter().ticks_per_grid())); superclock_t sc; BBT_Time bbt; - TempoMetric metric (metric_at (on_beat, false)); + metric = metric_at (on_beat, false); bbt = metric.bbt_at (on_beat); sc = metric.superclock_at (on_beat); @@ -1375,7 +1376,7 @@ TempoMap::set_tempo (Tempo const & t, timepos_t const & time) /* tempo changes must be on beat */ - beats = tm.quarters_at_superclock (sc).round_to_beat (); + beats = tm.quarters_at_superclock (sc).round_to_multiple (Beats::ticks (tm.meter().ticks_per_grid())); bbt = tm.bbt_at (beats); /* recompute superclock position of rounded beat */