temporal: add TempoMap::duration() method

This commit is contained in:
Paul Davis 2025-08-05 11:27:50 -06:00
parent cc3d867ac4
commit ba00dc0920
2 changed files with 16 additions and 0 deletions

View file

@ -4768,6 +4768,20 @@ TempoMap::min_notes_per_minute() const
return npm;
}
timepos_t
TempoMap::duration(TimeDomain td) const
{
if (_points.empty()) {
return timepos_t::zero (td);
}
if (td == BeatTime) {
return timepos_t (_points.back().beats() + Beats (1, 0));
}
return timepos_t::from_superclock (_points.back().sclock() + 1);
}
#if 0
void
TempoMap::fix_legacy_session ()

View file

@ -872,6 +872,8 @@ class /*LIBTEMPORAL_API*/ TempoMap : public PBD::StatefulDestructible
LIBTEMPORAL_API void shift (timepos_t const & at, BBT_Offset const & by);
LIBTEMPORAL_API void shift (timepos_t const & at, timecnt_t const & by);
LIBTEMPORAL_API timepos_t duration (TimeDomain) const;
private:
template<typename TimeType, typename Comparator> TempoPoint const & _tempo_at (TimeType when, Comparator cmp) const {
assert (!_tempos.empty());