13
0

add timepos_t::set_time_domain() to potentially change time domains

This commit is contained in:
Paul Davis 2021-01-15 14:51:58 -07:00
parent 6f861c63b5
commit 25375ee6f4
2 changed files with 15 additions and 0 deletions

View File

@ -74,6 +74,7 @@ class LIBTEMPORAL_API timepos_t : public int62_t {
bool zero () const { return val() == 0; }
Temporal::TimeDomain time_domain () const { if (flagged()) return Temporal::BeatTime; return Temporal::AudioTime; }
void set_time_domain (Temporal::TimeDomain);
superclock_t superclocks() const { if (is_superclock()) return val(); return _superclocks (); }
int64_t samples() const { return superclock_to_samples (superclocks(), TEMPORAL_SAMPLE_RATE); }

View File

@ -375,6 +375,20 @@ timepos_t::timepos_t (timecnt_t const & t)
v = build (t.distance().flagged(), t.distance ().val());
}
void
timepos_t::set_time_domain (TimeDomain td)
{
if (td == time_domain()) {
return;
}
if (td == AudioTime) {
v = build (false, superclock_to_samples (_superclocks(), TEMPORAL_SAMPLE_RATE));
} else {
v = build (true, _beats().to_ticks());
}
}
// timepos_t timepos_t::_max_timepos (Temporal::AudioTime);
timepos_t &