From 5887ee524e64e639d48cdbb4df221d6f5f0ea8bb Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 2 Dec 2020 23:43:09 -0700 Subject: [PATCH] Temporal: further improvements to a timepos_t::distance() method --- libs/temporal/timeline.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libs/temporal/timeline.cc b/libs/temporal/timeline.cc index 841be465af..c791a8c894 100644 --- a/libs/temporal/timeline.cc +++ b/libs/temporal/timeline.cc @@ -542,10 +542,16 @@ timepos_t::expensive_distance (Temporal::Beats const & b) const timecnt_t timepos_t::expensive_distance (timepos_t const & other) const { + /* Called when other's time domain does not match our own, requiring us + to call either ::beats() or ::superclocks() on other to convert it to + our time domain. + */ if (is_beats()) { - return timecnt_t (other.beats() - beats(), *this); + /* we are known to use beat time: val() is ticks */ + return timecnt_t::from_ticks (other.ticks() - val(), *this); } - return timecnt_t::from_superclock (other.superclocks() - superclocks(), *this); + /* we known to be audio: val() is superclocks */ + return timecnt_t::from_superclock (other.superclocks() - val(), *this); } /* */