From 1ba2e28d6f44e001a6e10fc7546f8d65020eb5fb Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 17 Nov 2021 08:56:05 -0700 Subject: [PATCH] tempo map: fix grid generation with ramped tempos The old code used the instantaneous tempo at T0 to compute where the next quarter note would be. This is incorrect, since the tempo is changing (continuously, for now) during the time represented by that quarter note. Instead, we need to add a quarter note (or technically, whatever the tempo note type is) to get a new position in beats, then compute the superclock time at that location (which will use our equations for tempo, including the use of omega, the ramp factor). --- libs/temporal/tempo.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libs/temporal/tempo.cc b/libs/temporal/tempo.cc index 037dd8e335..a56a1fe52b 100644 --- a/libs/temporal/tempo.cc +++ b/libs/temporal/tempo.cc @@ -1947,11 +1947,10 @@ TempoMap::get_grid (TempoMapPoints& ret, superclock_t start, superclock_t end, u if (bar_mod == 0) { /* Advance by the meter note value size */ - - step = metric.superclocks_per_grid_at (start); - start += step; - bbt = metric.bbt_at (timepos_t::from_superclock (start)); - DEBUG_TRACE (DEBUG::Grid, string_compose ("step for note type was %1, now @ %2\n", step, start)); + beats += metric.tempo().note_type_as_beats (); + bbt = metric.bbt_at (beats); + start = metric.superclock_at (beats); + DEBUG_TRACE (DEBUG::Grid, string_compose ("step at %3 for note type was %1, now @ %2 beats = %4\n", step, start, bbt, beats)); } else {