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);