Fix guard point logic for editor_add_ordered API.
Previously the code was too simple and potentially added points out of order, leading to automation jumping back in time.
This commit is contained in:
parent
ac5e59e94d
commit
cfdba3e515
@ -732,8 +732,8 @@ ControlList::editor_add_ordered (OrderedPoints const & points, bool with_guard)
|
|||||||
{
|
{
|
||||||
Glib::Threads::RWLock::WriterLock lm (_lock);
|
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||||
|
|
||||||
Temporal::timepos_t earliest = points.front().when;
|
Temporal::timepos_t earliest = ensure_time_domain (points.front().when);
|
||||||
Temporal::timepos_t latest = points.back().when;
|
Temporal::timepos_t latest = ensure_time_domain (points.back().when);
|
||||||
|
|
||||||
assert (earliest <= latest);
|
assert (earliest <= latest);
|
||||||
|
|
||||||
@ -742,20 +742,12 @@ ControlList::editor_add_ordered (OrderedPoints const & points, bool with_guard)
|
|||||||
(void) erase_range_internal (earliest, latest, _events);
|
(void) erase_range_internal (earliest, latest, _events);
|
||||||
|
|
||||||
if (with_guard) {
|
if (with_guard) {
|
||||||
ControlEvent cp (earliest, 0.0);
|
unlocked_invalidate_insert_iterator ();
|
||||||
double v = unlocked_eval (earliest);
|
add_guard_point (earliest, -GUARD_POINT_DELTA (*this));
|
||||||
iterator s = lower_bound (_events.begin (), _events.end (), &cp, time_comparator);
|
|
||||||
if (s != _events.end ()) {
|
|
||||||
_events.insert (s, new ControlEvent (earliest, v));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (with_guard && !distance.is_zero()) {
|
if (with_guard && !distance.is_zero()) {
|
||||||
ControlEvent cp (latest, 0.0);
|
unlocked_invalidate_insert_iterator ();
|
||||||
double v = unlocked_eval (latest);
|
add_guard_point (latest, GUARD_POINT_DELTA (*this));
|
||||||
iterator s = lower_bound (_events.begin (), _events.end (), &cp, time_comparator);
|
|
||||||
if (s != _events.end ()) {
|
|
||||||
_events.insert (s, new ControlEvent (latest, v));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the iterator where we should start insertion */
|
/* Get the iterator where we should start insertion */
|
||||||
|
Loading…
Reference in New Issue
Block a user