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
a1d317be98
commit
5a647cd84a
@ -732,8 +732,8 @@ ControlList::editor_add_ordered (OrderedPoints const & points, bool with_guard)
|
||||
{
|
||||
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||
|
||||
Temporal::timepos_t earliest = points.front().when;
|
||||
Temporal::timepos_t latest = points.back().when;
|
||||
Temporal::timepos_t earliest = ensure_time_domain (points.front().when);
|
||||
Temporal::timepos_t latest = ensure_time_domain (points.back().when);
|
||||
|
||||
assert (earliest <= latest);
|
||||
|
||||
@ -742,20 +742,12 @@ ControlList::editor_add_ordered (OrderedPoints const & points, bool with_guard)
|
||||
(void) erase_range_internal (earliest, latest, _events);
|
||||
|
||||
if (with_guard) {
|
||||
ControlEvent cp (earliest, 0.0);
|
||||
double v = unlocked_eval (earliest);
|
||||
iterator s = lower_bound (_events.begin (), _events.end (), &cp, time_comparator);
|
||||
if (s != _events.end ()) {
|
||||
_events.insert (s, new ControlEvent (earliest, v));
|
||||
}
|
||||
unlocked_invalidate_insert_iterator ();
|
||||
add_guard_point (earliest, -GUARD_POINT_DELTA (*this));
|
||||
}
|
||||
if (with_guard && !distance.is_zero()) {
|
||||
ControlEvent cp (latest, 0.0);
|
||||
double v = unlocked_eval (latest);
|
||||
iterator s = lower_bound (_events.begin (), _events.end (), &cp, time_comparator);
|
||||
if (s != _events.end ()) {
|
||||
_events.insert (s, new ControlEvent (latest, v));
|
||||
}
|
||||
unlocked_invalidate_insert_iterator ();
|
||||
add_guard_point (latest, GUARD_POINT_DELTA (*this));
|
||||
}
|
||||
|
||||
/* Get the iterator where we should start insertion */
|
||||
|
Loading…
Reference in New Issue
Block a user