diff --git a/libs/temporal/tempo.cc b/libs/temporal/tempo.cc index d7874beb7a..09a922f52b 100644 --- a/libs/temporal/tempo.cc +++ b/libs/temporal/tempo.cc @@ -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 () diff --git a/libs/temporal/temporal/tempo.h b/libs/temporal/temporal/tempo.h index 180c15da04..69d82c8c55 100644 --- a/libs/temporal/temporal/tempo.h +++ b/libs/temporal/temporal/tempo.h @@ -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 TempoPoint const & _tempo_at (TimeType when, Comparator cmp) const { assert (!_tempos.empty());