From a0f00d7d227e1fe3cc935d6e7570e0f6a0ec2f18 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 15 Nov 2012 16:22:43 +0000 Subject: [PATCH] add a "guard" point after a write/touch automation insertion, preserving the shape of the later segment of the existing line git-svn-id: svn://localhost/ardour2/branches/3.0@13507 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/evoral/src/ControlList.cpp | 43 ++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/libs/evoral/src/ControlList.cpp b/libs/evoral/src/ControlList.cpp index 31811e2fc9..7db4e74650 100644 --- a/libs/evoral/src/ControlList.cpp +++ b/libs/evoral/src/ControlList.cpp @@ -493,6 +493,27 @@ ControlList::add (double when, double value) } ++most_recent_insert_iterator; } + + if (most_recent_insert_iterator != _events.end()) { + if ((*most_recent_insert_iterator)->when - when > 64) { + /* next control point is some + * distance from where our new + * point is going to go - add a + * new point to avoid changing + * the shape of the line too + * much. the insert iterator needs + * to point to the new control + * point so that our insert + * will happen correctly. + */ + most_recent_insert_iterator = _events.insert (most_recent_insert_iterator, + new ControlEvent (when+1, (*most_recent_insert_iterator)->value)); + DEBUG_TRACE (DEBUG::ControlList, string_compose ("@%1 added post-erase guard point @ %2 = %3\n", + this, when+1, + (*most_recent_insert_iterator)->value)); + } + } + } else { /* not in a write pass: figure out the iterator we should insert in front of */ @@ -599,7 +620,27 @@ ControlList::add (double when, double value) } } } - + + if (most_recent_insert_iterator != _events.end()) { + if ((*most_recent_insert_iterator)->when - when > 64) { + /* next control point is some + * distance from where our new + * point is going to go - add a + * new point to avoid changing + * the shape of the line too + * much. the insert iterator needs + * to point to the new control + * point so that our insert + * will happen correctly. + */ + most_recent_insert_iterator = _events.insert (most_recent_insert_iterator, + new ControlEvent (when+1, (*most_recent_insert_iterator)->value)); + DEBUG_TRACE (DEBUG::ControlList, string_compose ("@%1 added insert-post-erase guard point @ %2 = %3\n", + this, when+1, + (*most_recent_insert_iterator)->value)); + } + } + if (!done) { EventList::iterator x = _events.insert (most_recent_insert_iterator, new ControlEvent (when, value)); DEBUG_TRACE (DEBUG::ControlList, string_compose ("@%1 inserted new value before MRI, size now %2\n", this, _events.size()));