add support for 'positive' guard points in ControlList

This commit is contained in:
Ben Loftis 2022-05-15 10:37:20 -05:00
parent c98561e95c
commit 3a174ff914
1 changed files with 14 additions and 3 deletions

View File

@ -562,9 +562,7 @@ ControlList::add_guard_point (timepos_t const & time, timecnt_t const & offset)
return;
}
assert (offset <= timecnt_t());
if (!offset.is_zero()) {
if (offset.is_negative()) {
/* check if there are points between when + offset .. when */
ControlEvent cp (when + offset, 0.0);
iterator s;
@ -577,6 +575,19 @@ ControlList::add_guard_point (timepos_t const & time, timecnt_t const & offset)
return;
}
}
} else {
/* check if there are points between when + offset .. when */
ControlEvent cp (when + offset, 0.0);
iterator s;
iterator e;
if ((s = upper_bound (_events.begin(), _events.end(), &cp, time_comparator)) != _events.end()) {
cp.when = when;
e = upper_bound (_events.begin(), _events.end(), &cp, time_comparator);
if (s != e) {
DEBUG_TRACE (DEBUG::ControlList, string_compose ("@%1 add_guard_point, none added, found event between %2 and %3\n", this, when.earlier (offset), when));
return;
}
}
}
/* don't do this again till the next write pass,