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.
This commit is contained in:
Paul Davis 2022-05-21 16:32:54 -06:00
parent 029ef88059
commit c4844b00e3

View File

@ -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<TempoPoint*> (&*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<MeterPoint*> (&*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<TempoPoint*> (&metric.tempo())->compute_omega_from_next_tempo (*tp);
need_initial_ramp_reset = false;
}
Points::iterator pp = p;
nxt_tempo = 0;
++pp;