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
This commit is contained in:
Paul Davis 2023-02-10 23:10:59 -07:00
parent 43c8fae709
commit f033b5717d
1 changed files with 14 additions and 1 deletions

View File

@ -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<const_traits<BBT_Time const &, BBT_Time> > (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<const_traits<BBT_Time const &, BBT_Time> > (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<const_traits<superclock_t, superclock_t> > (t, m, &Point::sclock, sc, _points.begin(), _points.end(), &_tempos.front(), &_meters.front(), can_match, ret_iterator_after_not_at);