From c4844b00e3ecfdda5284ebedbccb1d3bc266745e Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 21 May 2022 16:32:54 -0600 Subject: [PATCH] temporal: when calling TempoMap::reset_starting_at(), fix ramps Even if we start at time T, if the tempo point before T is ramped, we need to adjust it's omega value based on the beat time of the following tempo point. If we don't do this, then using that tempo to compute ::superclock_at() for subsequent points will be incorrect. Note: there may be an ordering issue here with Tempo/Meter points. We might need to pass over all tempo points first, then process meters etc. Something like that. --- libs/temporal/tempo.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libs/temporal/tempo.cc b/libs/temporal/tempo.cc index f336e060c7..6bc473ab01 100644 --- a/libs/temporal/tempo.cc +++ b/libs/temporal/tempo.cc @@ -1151,6 +1151,7 @@ TempoMap::reset_starting_at (superclock_t sc) MusicTimePoint* mtp; TempoMetric metric (_tempos.front(), _meters.front()); Points::iterator p; + bool need_initial_ramp_reset = false; DEBUG_TRACE (DEBUG::MapReset, string_compose ("we begin at %1 with metric %2\n", sc, metric)); @@ -1180,6 +1181,11 @@ TempoMap::reset_starting_at (superclock_t sc) DEBUG_TRACE (DEBUG::MapReset, "Bartime!\n"); } else if ((tp = dynamic_cast (&*p)) != 0) { metric = TempoMetric (*tp, metric.meter()); + if (tp->ramped()) { + need_initial_ramp_reset = true; + } else { + need_initial_ramp_reset = true; + } DEBUG_TRACE (DEBUG::MapReset, "Tempo!\n"); } else if ((mp = dynamic_cast (&*p)) != 0) { metric = TempoMetric (metric.tempo(), *mp); @@ -1208,6 +1214,11 @@ 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;