mark BBT_Offset (double) constructor explicit to avoid implicit conversion in timeline expressions.
Also clean up the mess this had caused.
This commit is contained in:
parent
b01b6929fb
commit
def35cf043
@ -255,7 +255,7 @@ SMFSource::read_unlocked (const Lock& lock,
|
||||
_smf_last_read_end = start + duration;
|
||||
return timecnt_t();
|
||||
}
|
||||
time += ev_delta_t; // accumulate delta time
|
||||
time += timepos_t::from_ticks (ev_delta_t); // accumulate delta time
|
||||
}
|
||||
} else {
|
||||
DEBUG_TRACE (DEBUG::MidiSourceIO, string_compose ("SMF read_unlocked: set time to %1\n", _smf_last_read_time));
|
||||
@ -272,7 +272,7 @@ SMFSource::read_unlocked (const Lock& lock,
|
||||
break;
|
||||
}
|
||||
|
||||
time += ev_delta_t; // accumulate delta time
|
||||
time += timepos_t::from_ticks (ev_delta_t); // accumulate delta time
|
||||
_smf_last_read_time = time;
|
||||
|
||||
if (ret == 0) { // meta-event (skipped, just accumulate time)
|
||||
|
@ -2053,10 +2053,10 @@ ControlList::move_ranges (const list< RangeMove> & movements)
|
||||
|
||||
switch (_time_domain) {
|
||||
case AudioTime:
|
||||
ev->when += dx.samples();
|
||||
ev->when += dx;
|
||||
break;
|
||||
case BeatTime:
|
||||
ev->when += dx.beats().to_ticks();
|
||||
ev->when += dx;
|
||||
break;
|
||||
default:
|
||||
/*NOTREACHED*/
|
||||
|
@ -146,7 +146,7 @@ struct LIBTEMPORAL_API BBT_Offset
|
||||
BBT_Offset () : bars (0), beats (0), ticks (0) {}
|
||||
BBT_Offset (int32_t ba, uint32_t be, uint32_t t) : bars (ba), beats (be), ticks (t) {}
|
||||
BBT_Offset (BBT_Time const & bbt) : bars (bbt.bars), beats (bbt.beats), ticks (bbt.ticks) {}
|
||||
BBT_Offset (double beats);
|
||||
explicit BBT_Offset (double beats);
|
||||
|
||||
/* unlike BBT_Time, we can define +,-,* and / operators for BBT_Offset
|
||||
* because there is no requirement that the result is "well-formed" or
|
||||
|
@ -362,6 +362,7 @@ std::operator<< (std::ostream & o, timecnt_t const & tc)
|
||||
timepos_t::timepos_t (timecnt_t const & t)
|
||||
{
|
||||
if (t.distance() < 0) {
|
||||
std::cerr << "timecnt_t has negative distance distance " << " val " << t.distance().val() << " flagged " << t.distance().flagged() << std::endl;
|
||||
throw std::domain_error("negative value for timepos_t constructor");
|
||||
}
|
||||
|
||||
@ -577,48 +578,34 @@ timepos_t::earlier (Temporal::BBT_Offset const & offset) const
|
||||
}
|
||||
|
||||
|
||||
timepos_t &
|
||||
timepos_t::shift_earlier (Temporal::BBT_Offset const & offset)
|
||||
{
|
||||
TempoMap::SharedPtr tm (TempoMap::use());
|
||||
|
||||
if (is_superclock()) {
|
||||
v = build (false, (tm->superclock_at (tm->bbt_walk (tm->bbt_at (superclocks()), -offset))));
|
||||
} else {
|
||||
v = build (true, tm->bbtwalk_to_quarters (beats(), -offset).to_ticks());
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
timepos_t
|
||||
timepos_t::earlier (timepos_t const & other) const
|
||||
{
|
||||
if (other.is_superclock()) {
|
||||
return earlier (other.superclocks());
|
||||
if (is_superclock()) {
|
||||
return timepos_t::from_superclock (val() - other.superclocks());
|
||||
}
|
||||
|
||||
return earlier (other.beats());
|
||||
return timepos_t::from_ticks (val() - other.ticks());
|
||||
}
|
||||
|
||||
timepos_t
|
||||
timepos_t::earlier (timecnt_t const & distance) const
|
||||
{
|
||||
if (distance.time_domain() == AudioTime) {
|
||||
return earlier (distance.superclocks());
|
||||
if (is_superclock()) {
|
||||
return timepos_t::from_superclock (val() - distance.superclocks());
|
||||
}
|
||||
return earlier (distance.beats());
|
||||
|
||||
return timepos_t::from_ticks (val() - distance.ticks());
|
||||
}
|
||||
|
||||
bool
|
||||
timepos_t::expensive_lt (timepos_t const & other) const
|
||||
{
|
||||
if (time_domain() == AudioTime) {
|
||||
return superclocks() < other.superclocks();
|
||||
return val() < other.superclocks();
|
||||
}
|
||||
|
||||
return beats() < other.beats ();
|
||||
return ticks() < other.ticks ();
|
||||
}
|
||||
|
||||
bool
|
||||
@ -656,21 +643,25 @@ timepos_t::expensive_gte (timepos_t const & other) const
|
||||
timepos_t &
|
||||
timepos_t::shift_earlier (timepos_t const & d)
|
||||
{
|
||||
if (d.time_domain() == AudioTime) {
|
||||
return shift_earlier (d.superclocks());
|
||||
if (is_superclock()) {
|
||||
v = build (false, val() - d.superclocks());
|
||||
} else {
|
||||
v = build (true, val() - d.ticks());
|
||||
}
|
||||
|
||||
return shift_earlier (d.beats());
|
||||
return *this;
|
||||
}
|
||||
|
||||
timepos_t &
|
||||
timepos_t::shift_earlier (timecnt_t const & d)
|
||||
{
|
||||
if (d.time_domain() == AudioTime) {
|
||||
return shift_earlier (d.superclocks());
|
||||
if (is_superclock()) {
|
||||
v = build (false, val() - d.superclocks());
|
||||
} else {
|
||||
v = build (true, val() - d.ticks());
|
||||
}
|
||||
|
||||
return shift_earlier (d.beats());
|
||||
return *this;
|
||||
}
|
||||
|
||||
timepos_t &
|
||||
@ -690,6 +681,20 @@ timepos_t::shift_earlier (Temporal::Beats const & b)
|
||||
return *this;
|
||||
}
|
||||
|
||||
timepos_t &
|
||||
timepos_t::shift_earlier (Temporal::BBT_Offset const & offset)
|
||||
{
|
||||
TempoMap::SharedPtr tm (TempoMap::use());
|
||||
|
||||
if (is_superclock()) {
|
||||
v = build (false, (tm->superclock_at (tm->bbt_walk (tm->bbt_at (superclocks()), -offset))));
|
||||
} else {
|
||||
v = build (true, tm->bbtwalk_to_quarters (beats(), -offset).to_ticks());
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/* */
|
||||
|
||||
timepos_t &
|
||||
|
Loading…
Reference in New Issue
Block a user