13
0

temporal: change return type of TempoMap::next_tempo()

It is more useful to get the actual TempoPoint than just the Tempo
that we discover.

Aside: it would be awesome to understand how to use boost::intrusive to get the
next tempo point directly from the tempo hook.
This commit is contained in:
Paul Davis 2022-05-02 11:40:23 -06:00
parent 2b8b9a3a2f
commit 00b9e3f86a
2 changed files with 26 additions and 25 deletions

View File

@ -2636,28 +2636,6 @@ TempoMap::convert_duration (timecnt_t const & duration, timepos_t const & new_po
}
Tempo const *
TempoMap::next_tempo (Tempo const & t) const
{
Tempos::const_iterator p = _tempos.begin();
while (p != _tempos.end()) {
if (&t == &*p) {
break;
}
++p;
}
if (p != _tempos.end()) {
++p;
if (p != _tempos.end()) {
return &*p;;
}
}
return 0;
}
uint32_t
TempoMap::n_meters () const
@ -2870,6 +2848,29 @@ TempoMap::remove_time (timepos_t const & pos, timecnt_t const & duration)
return moved;
}
TempoPoint const *
TempoMap::next_tempo (TempoPoint const & t) const
{
Tempos::const_iterator p = _tempos.begin();
while (p != _tempos.end()) {
if (&t == &*p) {
break;
}
++p;
}
if (p != _tempos.end()) {
++p;
if (p != _tempos.end()) {
return &*p;;
}
}
return 0;
}
TempoPoint const *
TempoMap::previous_tempo (TempoPoint const & point) const
{

View File

@ -756,7 +756,9 @@ class /*LIBTEMPORAL_API*/ TempoMap : public PBD::StatefulDestructible
LIBTEMPORAL_API uint32_t n_meters() const;
LIBTEMPORAL_API uint32_t n_tempos() const;
LIBTEMPORAL_API Tempo const* next_tempo (Tempo const &) const;
LIBTEMPORAL_API TempoPoint const* previous_tempo (TempoPoint const &) const;
LIBTEMPORAL_API TempoPoint const* next_tempo (TempoPoint const &) const;
LIBTEMPORAL_API Meter const* next_meter (Meter const &) const;
LIBTEMPORAL_API TempoMetric metric_at (timepos_t const &) const;
@ -816,8 +818,6 @@ class /*LIBTEMPORAL_API*/ TempoMap : public PBD::StatefulDestructible
LIBTEMPORAL_API TempoPoint const& tempo_at (Beats const & b) const { return _tempo_at (b, Point::beat_comparator()); }
LIBTEMPORAL_API TempoPoint const& tempo_at (BBT_Time const & bbt) const { return _tempo_at (bbt, Point::bbt_comparator()); }
LIBTEMPORAL_API TempoPoint const* previous_tempo (TempoPoint const &) const;
/* convenience function that hides some complexities behind fetching
* the bpm at position
*/