From 8de52a74bb1d028c5d69d1019de31a11941dc05f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 21 May 2022 17:28:38 -0600 Subject: [PATCH] temporal: better fix for tempo ramp setting during ::reset_starting_at() --- libs/temporal/tempo.cc | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/libs/temporal/tempo.cc b/libs/temporal/tempo.cc index 1c6556fbd1..b1666b73ac 100644 --- a/libs/temporal/tempo.cc +++ b/libs/temporal/tempo.cc @@ -1,4 +1,3 @@ - /* Copyright (C) 2017 Paul Davis @@ -1187,6 +1186,21 @@ TempoMap::reset_starting_at (superclock_t sc) } } + /* if the tempo point the defines our starting metric for position + * @param sc is ramped, recompute its omega value based on the beat + * time of the following tempo point. If we do not do this before we + * start, then ::superclock_at() for subsequent points will be + * incorrect. + */ + + if (need_initial_ramp_reset) { + const TempoPoint *nxt = next_tempo (metric.tempo()); + if (nxt) { + const_cast (&metric.tempo())->compute_omega_from_next_tempo (*nxt); + } + need_initial_ramp_reset = false; + } + /* Now iterate over remaining points and recompute their audio time * positions. */ @@ -1208,11 +1222,6 @@ TempoMap::reset_starting_at (superclock_t sc) if (tp) { - if (need_initial_ramp_reset) { - const_cast (&metric.tempo())->compute_omega_from_next_tempo (*tp); - need_initial_ramp_reset = false; - } - Points::iterator pp = p; nxt_tempo = 0; ++pp;