13
0

temporal: add TempoMap::{next,previous_}meter()

This commit is contained in:
Paul Davis 2023-05-03 21:53:36 -06:00
parent 49e1f7f79d
commit faac648502
2 changed files with 30 additions and 0 deletions

View File

@ -3119,6 +3119,33 @@ TempoMap::previous_tempo (TempoPoint const & point) const
return &(*i);
}
MeterPoint const *
TempoMap::next_meter (MeterPoint const & t) const
{
Meters::const_iterator i = _meters.iterator_to (t);
++i;
if (i != _meters.end()) {
return &(*i);
}
return 0;
}
MeterPoint const *
TempoMap::previous_meter (MeterPoint const & point) const
{
Meters::const_iterator i = _meters.iterator_to (point);
if (i == _meters.begin()) {
return 0;
}
--i;
return &(*i);
}
double
TempoMap::quarters_per_minute_at (timepos_t const & pos) const
{

View File

@ -796,6 +796,9 @@ class /*LIBTEMPORAL_API*/ TempoMap : public PBD::StatefulDestructible
LIBTEMPORAL_API TempoPoint const* previous_tempo (TempoPoint const &) const;
LIBTEMPORAL_API TempoPoint const* next_tempo (TempoPoint const &) const;
LIBTEMPORAL_API MeterPoint const* previous_meter (MeterPoint const &) const;
LIBTEMPORAL_API MeterPoint const* next_meter (MeterPoint const &) const;
LIBTEMPORAL_API bool tempo_exists_before (TempoPoint const & t) const { return (bool) previous_tempo (t); }
LIBTEMPORAL_API bool tempo_exists_after (TempoPoint const & t) const { return (bool) next_tempo (t); }