temporal: implement a faster method to lookup TempoPoint

There is no reason to build a TempoMetric if you only need the Tempo
This commit is contained in:
Paul Davis 2021-11-11 16:50:04 -07:00
parent 5105083394
commit 4f3bf37680
2 changed files with 54 additions and 4 deletions

View file

@ -2774,6 +2774,47 @@ TempoMap::previous_tempo (TempoPoint const & point) const
return 0;
}
TempoPoint const &
TempoMap::tempo_at (timepos_t const & pos) const
{
if (pos.is_beats()) {
return tempo_at (pos.beats());
}
return tempo_at (pos.superclocks());
}
TempoPoint const &
TempoMap::tempo_at (superclock_t sc) const
{
assert (!_tempos.empty());
Point::sclock_comparator cmp;
Tempos::const_iterator t = std::lower_bound (_tempos.begin(), _tempos.end(), sc, cmp);
assert (t != _tempos.end());
return *t;
}
TempoPoint const &
TempoMap::tempo_at (Beats const & b) const
{
assert (!_tempos.empty());
Point::beat_comparator cmp;
Tempos::const_iterator t = std::lower_bound (_tempos.begin(), _tempos.end(), b, cmp);
assert (t != _tempos.end());
return *t;
}
TempoPoint const &
TempoMap::tempo_at (BBT_Time const & bbt) const
{
assert (!_tempos.empty());
Point::bbt_comparator cmp;
Tempos::const_iterator t = std::lower_bound (_tempos.begin(), _tempos.end(), bbt, cmp);
assert (t != _tempos.end());
return *t;
}
TempoMetric
TempoMap::metric_at (timepos_t const & pos) const
{