libtemporal: rename TempoMap::full_duration_at() to ::convert_duration() and reorder parameters

This commit is contained in:
Paul Davis 2021-02-26 13:02:45 -07:00
parent 7773fc5b64
commit daad7b74ae
4 changed files with 16 additions and 16 deletions

View File

@ -1193,13 +1193,13 @@ RegionView::snap_region_time_to_region_time (timepos_t const & x, bool ensure_sn
timecnt_t
RegionView::region_relative_distance (timecnt_t const & duration, Temporal::TimeDomain domain)
{
return Temporal::TempoMap::use()->full_duration_at (_region->position(), duration, domain);
return Temporal::TempoMap::use()->convert_duration (duration, _region->position(), domain);
}
timecnt_t
RegionView::source_relative_distance (timecnt_t const & duration, Temporal::TimeDomain domain)
{
return Temporal::TempoMap::use()->full_duration_at (_region->source_position(), duration, domain);
return Temporal::TempoMap::use()->convert_duration (duration, _region->source_position(), domain);
}
void

View File

@ -2385,7 +2385,7 @@ TempoMap::bbt_duration_at (timepos_t const & pos, BBT_Offset const & dur) const
*/
timecnt_t
TempoMap::full_duration_at (timepos_t const & pos, timecnt_t const & duration, TimeDomain return_domain) const
TempoMap::convert_duration (timecnt_t const & duration, timepos_t const & new_position, TimeDomain return_domain) const
{
timepos_t p (return_domain);
Beats b;
@ -2393,7 +2393,7 @@ TempoMap::full_duration_at (timepos_t const & pos, timecnt_t const & duration, T
if (return_domain == duration.time_domain()) {
/* new timecnt_t: same distance, but new position */
return timecnt_t (duration.distance(), pos);
return timecnt_t (duration.distance(), new_position);
}
switch (return_domain) {
@ -2404,14 +2404,14 @@ TempoMap::full_duration_at (timepos_t const & pos, timecnt_t const & duration, T
break;
case BeatTime:
/* duration is in beats but we're asked to return superclocks */
switch (pos.time_domain()) {
switch (new_position.time_domain()) {
case BeatTime:
/* pos is already in beats */
p = pos;
/* new_position is already in beats */
p = new_position;
break;
case AudioTime:
/* Determine beats at sc pos, so that we can add beats */
p = timepos_t (metric_at (pos).quarters_at_superclock (pos.superclocks()));
p = timepos_t (metric_at (new_position).quarters_at_superclock (new_position.superclocks()));
break;
}
/* add beats */
@ -2419,7 +2419,7 @@ TempoMap::full_duration_at (timepos_t const & pos, timecnt_t const & duration, T
/* determine superclocks */
s = metric_at (p).superclock_at (p.beats());
/* return duration in sc */
return timecnt_t::from_superclock (s - pos.superclocks(), pos);
return timecnt_t::from_superclock (s - new_position.superclocks(), new_position);
break;
}
break;
@ -2428,14 +2428,14 @@ TempoMap::full_duration_at (timepos_t const & pos, timecnt_t const & duration, T
switch (duration.time_domain()) {
case AudioTime:
/* duration is in superclocks but we're asked to return beats */
switch (pos.time_domain ()) {
switch (new_position.time_domain ()) {
case AudioTime:
/* pos is already in superclocks */
p = pos;
p = new_position;
break;
case BeatTime:
/* determined sc at beat position so we can add superclocks */
p = timepos_t (metric_at (pos).sample_at (pos.beats()));
p = timepos_t (metric_at (new_position).sample_at (new_position.beats()));
break;
}
/* add superclocks */
@ -2443,7 +2443,7 @@ TempoMap::full_duration_at (timepos_t const & pos, timecnt_t const & duration, T
/* determine beats */
b = metric_at (p).quarters_at_superclock (p.superclocks());
/* return duration in beats */
return timecnt_t (b - pos.beats(), pos);
return timecnt_t (b - new_position.beats(), new_position);
break;
case BeatTime:
/*NOTREACHED*/

View File

@ -782,7 +782,7 @@ class LIBTEMPORAL_API TempoMap : public PBD::StatefulDestructible
timecnt_t bbt_duration_at (timepos_t const & pos, BBT_Offset const & bbt) const;
Beats bbtwalk_to_quarters (Beats const & start, BBT_Offset const & distance) const;
Temporal::timecnt_t full_duration_at (Temporal::timepos_t const &, Temporal::timecnt_t const & duration, Temporal::TimeDomain domain) const;
Temporal::timecnt_t convert_duration (Temporal::timecnt_t const & duration, Temporal::timepos_t const &, Temporal::TimeDomain domain) const;
BBT_Time bbt_walk (BBT_Time const &, BBT_Offset const &) const;

View File

@ -169,14 +169,14 @@ timecnt_t::compute_superclocks() const
{
assert (_distance.flagged());
TempoMap::SharedPtr tm (TempoMap::use());
return tm->full_duration_at (_position, *this, AudioTime).superclocks();
return tm->convert_duration (*this, _position, AudioTime).superclocks();
}
Beats
timecnt_t::compute_beats() const
{
assert (!_distance.flagged());
return TempoMap::use()->full_duration_at (_position, *this, BeatTime).beats();
return TempoMap::use()->convert_duration (*this, _position, BeatTime).beats();
}
timecnt_t