From 3a174ff91449fa198a7c1d399e02c787c68ebc58 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Sun, 15 May 2022 10:37:20 -0500 Subject: [PATCH] add support for 'positive' guard points in ControlList --- libs/evoral/ControlList.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/libs/evoral/ControlList.cc b/libs/evoral/ControlList.cc index 4ba4f25c47..85371785a6 100644 --- a/libs/evoral/ControlList.cc +++ b/libs/evoral/ControlList.cc @@ -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,