From f033b5717d87f6599b89bd9132e3307ee83b4314 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 10 Feb 2023 23:10:59 -0700 Subject: [PATCH] tempo map: fix lookup of tempo/meter for a BBT time Find the first point/tempo/meter after the reference time of the BBT argument --- libs/temporal/temporal/tempo.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libs/temporal/temporal/tempo.h b/libs/temporal/temporal/tempo.h index 05394f79d2..9f4a8525a2 100644 --- a/libs/temporal/temporal/tempo.h +++ b/libs/temporal/temporal/tempo.h @@ -1035,7 +1035,20 @@ class /*LIBTEMPORAL_API*/ TempoMap : public PBD::StatefulDestructible will all be the const versions of these methods. */ - return _get_tempo_and_meter > (t, m, &Point::bbt, bbt, _points.begin(), _points.end(), &_tempos.front(), &_meters.front(), can_match, ret_iterator_after_not_at); + + /* Use the reference time of the BBT_Argument to determine + * where to start iterating. + */ + + Points::const_iterator pi = _points.begin(); + Tempos::const_iterator ti = _tempos.begin(); + Meters::const_iterator mi = _meters.begin(); + + while (pi != _points.end() && pi->sclock() < bbt.reference().superclocks()) ++pi; + while (ti != _tempos.end() && ti->sclock() < bbt.reference().superclocks()) ++ti; + while (mi != _meters.end() && mi->sclock() < bbt.reference().superclocks()) ++mi; + + return _get_tempo_and_meter > (t, m, &Point::bbt, bbt, pi, _points.end(), &*ti, &*mi, can_match, ret_iterator_after_not_at); } Points::const_iterator get_tempo_and_meter (TempoPoint const *& t, MeterPoint const *& m, superclock_t sc, bool can_match, bool ret_iterator_after_not_at) const { return _get_tempo_and_meter > (t, m, &Point::sclock, sc, _points.begin(), _points.end(), &_tempos.front(), &_meters.front(), can_match, ret_iterator_after_not_at);