Temporal: further improvements to a timepos_t::distance() method

This commit is contained in:
Paul Davis 2020-12-02 23:43:09 -07:00
parent 7b0d812e92
commit 5887ee524e

View File

@ -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);
}
/* */