13
0

libtemporal: fix logic for ::get_tempo_and_meter() if starting point is the timeline start

This commit is contained in:
Paul Davis 2021-03-27 09:11:10 -06:00
parent 5f3ad2cde9
commit bccdc95f32
2 changed files with 16 additions and 5 deletions

View File

@ -1642,7 +1642,7 @@ TempoMap::dump (std::ostream& ostr) const
ostr << "------------\n\n\n";
}
template<typename T> TempoMap::Points::const_iterator
template<typename T, typename T1> TempoMap::Points::const_iterator
TempoMap::_get_tempo_and_meter (TempoPoint const *& tp, MeterPoint const *& mp, T (Point::*method)() const, T arg, bool can_match) const
{
Points::const_iterator p;
@ -1656,6 +1656,17 @@ TempoMap::_get_tempo_and_meter (TempoPoint const *& tp, MeterPoint const *& mp,
tp = 0;
mp = 0;
/* if the starting position is the beginning of the timeline (indicated
* by the default constructor value for T1, then we are always allowed
* to use the tempo & meter at that position. Without this, it would be
* necessary to special case "can_match" in the caller if the start is
* "zero". Instead we do that here, since common cases
* (e.g. ::get_grid()) will use can_match = false, but may pass in a
* zero start point.
*/
can_match = (can_match || arg == T1());
for (tp = &_tempos.front(), mp = &_meters.front(), p = _points.begin(); p != _points.end(); ++p) {
TempoPoint const * tpp;

View File

@ -854,11 +854,11 @@ class LIBTEMPORAL_API TempoMap : public PBD::StatefulDestructible
BBT_Time bbt_at (Beats const &) const;
BBT_Time bbt_at (superclock_t sc) const;
template<typename T> Points::const_iterator _get_tempo_and_meter (TempoPoint const *& tp, MeterPoint const *& mp, T (Point::*method)() const, T arg, bool can_match) const;
template<typename T, typename T1> Points::const_iterator _get_tempo_and_meter (TempoPoint const *& tp, MeterPoint const *& mp, T (Point::*method)() const, T arg, bool can_match) const;
Points::const_iterator get_tempo_and_meter (TempoPoint const *& t, MeterPoint const *& m, BBT_Time const & bbt, bool can_match = true) const { return _get_tempo_and_meter<BBT_Time const &> (t, m, &Point::bbt, bbt, can_match); }
Points::const_iterator get_tempo_and_meter (TempoPoint const *& t, MeterPoint const *& m, superclock_t sc, bool can_match = true) const { return _get_tempo_and_meter<superclock_t> (t, m, &Point::sclock, sc, can_match); }
Points::const_iterator get_tempo_and_meter (TempoPoint const *& t, MeterPoint const *& m, Beats const & b, bool can_match = true) const { return _get_tempo_and_meter<Beats const &> (t, m, &Point::beats, b, can_match); }
Points::const_iterator get_tempo_and_meter (TempoPoint const *& t, MeterPoint const *& m, BBT_Time const & bbt, bool can_match = true) const { return _get_tempo_and_meter<BBT_Time const &, BBT_Time> (t, m, &Point::bbt, bbt, can_match); }
Points::const_iterator get_tempo_and_meter (TempoPoint const *& t, MeterPoint const *& m, superclock_t sc, bool can_match = true) const { return _get_tempo_and_meter<superclock_t,superclock_t> (t, m, &Point::sclock, sc, can_match); }
Points::const_iterator get_tempo_and_meter (TempoPoint const *& t, MeterPoint const *& m, Beats const & b, bool can_match = true) const { return _get_tempo_and_meter<Beats const &, Beats> (t, m, &Point::beats, b, can_match); }
/* parsing legacy tempo maps */