Fix some warnings.
[ardour.git] / libs / evoral / src / ControlList.cpp
index 880198dc53ad3eb18a8a7d3c3cdacd81bb5a05af..e90b28c1479fa0598942e490c77284cf17b42151 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of Evoral.
- * Copyright (C) 2008 Dave Robillard <http://drobilla.net>
+ * Copyright (C) 2008 David Robillard <http://drobilla.net>
  * Copyright (C) 2000-2008 Paul Davis
  *
  * Evoral is free software; you can redistribute it and/or modify it under the
@@ -33,6 +33,21 @@ inline bool event_time_less_than (ControlEvent* a, ControlEvent* b)
        return a->when < b->when;
 }
 
+/* this has no units but corresponds to the area of a rectangle
+   computed between three points in the list. If the area is
+   large, it indicates significant non-linearity between the
+   points. 
+
+   during automation recording we thin the recorded points
+   using this value. if a point is sufficiently co-linear 
+   with its neighbours (as defined by the area of the rectangle
+   formed by three of them), we will not include it in the
+   ControlList. a smaller value will exclude less points,
+   a larger value will exclude more points, so it effectively
+   measures the amount of thinning to be done.
+*/
+
+double ControlList::_thinning_factor = 20.0; 
 
 ControlList::ControlList (const Parameter& id)
        : _parameter(id)
@@ -43,9 +58,7 @@ ControlList::ControlList (const Parameter& id)
        _changed_when_thawed = false;
        _min_yval = id.min();
        _max_yval = id.max();
-       _max_xval = 0; // means "no limit"
        _default_value = 0;
-       _rt_insertion_point = _events.end();
        _lookup_cache.left = -1;
        _lookup_cache.range.first = _events.end();
        _search_cache.left = -1;
@@ -62,9 +75,7 @@ ControlList::ControlList (const ControlList& other)
        _changed_when_thawed = false;
        _min_yval = other._min_yval;
        _max_yval = other._max_yval;
-       _max_xval = other._max_xval;
        _default_value = other._default_value;
-       _rt_insertion_point = _events.end();
        _lookup_cache.range.first = _events.end();
        _search_cache.first = _events.end();
        _sort_pending = false;
@@ -85,9 +96,7 @@ ControlList::ControlList (const ControlList& other, double start, double end)
        _changed_when_thawed = false;
        _min_yval = other._min_yval;
        _max_yval = other._max_yval;
-       _max_xval = other._max_xval;
        _default_value = other._default_value;
-       _rt_insertion_point = _events.end();
        _lookup_cache.range.first = _events.end();
        _search_cache.first = _events.end();
        _sort_pending = false;
@@ -111,6 +120,13 @@ ControlList::~ControlList()
                delete (*x);
        }
 
+       for (list<NascentInfo*>::iterator n = nascent.begin(); n != nascent.end(); ++n) {
+               for (EventList::iterator x = (*n)->events.begin(); x != (*n)->events.end(); ++x) {
+                       delete *x;
+               }
+               delete (*n);
+       }
+
        delete _curve;
 }
 
@@ -139,7 +155,6 @@ ControlList::operator= (const ControlList& other)
 
                _min_yval = other._min_yval;
                _max_yval = other._max_yval;
-               _max_xval = other._max_xval;
                _default_value = other._default_value;
 
                mark_dirty ();
@@ -203,100 +218,245 @@ ControlList::extend_to (double when)
        return true;
 }
 
-void ControlList::_x_scale (double factor)
+void
+ControlList::_x_scale (double factor)
 {
        for (iterator i = _events.begin(); i != _events.end(); ++i) {
-               (*i)->when = floor ((*i)->when * factor);
+               (*i)->when *= factor;
        }
 
        mark_dirty ();
 }
 
 void
-ControlList::reposition_for_rt_add (double /*when*/)
+ControlList::write_pass_finished (double when)
 {
-       _rt_insertion_point = _events.end();
+       merge_nascent (when);
 }
 
+
+struct ControlEventTimeComparator {
+       bool operator() (ControlEvent* a, ControlEvent* b) {
+               return a->when < b->when;
+       }
+};
+
 void
-ControlList::rt_add (double when, double value)
+ControlList::merge_nascent (double when)
 {
-       //cerr << "RT: alist " << this << " add " << value << " @ " << when << endl;
-
        {
                Glib::Mutex::Lock lm (_lock);
 
-               iterator where;
-               ControlEvent cp (when, 0.0);
-               bool done = false;
+               if (nascent.empty()) {
+                       return;
+               }
 
-               if ((_rt_insertion_point != _events.end()) && ((*_rt_insertion_point)->when < when) ) {
+               for (list<NascentInfo*>::iterator n = nascent.begin(); n != nascent.end(); ++n) {
 
-                       /* we have a previous insertion point, so we should delete
-                          everything between it and the position where we are going
-                          to insert this point.
-                       */
+                       NascentInfo* ninfo = *n;
+                       EventList& nascent_events (ninfo->events);
+                       bool need_adjacent_start_clamp;
+                       bool need_adjacent_end_clamp;
+
+                       if (nascent_events.empty()) {
+                               delete ninfo;
+                               continue;
+                       }
+
+                       nascent_events.sort (ControlEventTimeComparator ());
+
+                       if (ninfo->start_time < 0.0) {
+                               ninfo->start_time = nascent_events.front()->when;
+                       }
+
+                       if (ninfo->end_time < 0.0) {
+                               ninfo->end_time = when;
+                       }
+
+                       bool preexisting = !_events.empty();
+
+                       if (!preexisting) {
+
+                               _events = nascent_events;
 
-                       iterator after = _rt_insertion_point;
+                       } else if (ninfo->end_time < _events.front()->when) {
 
-                       if (++after != _events.end()) {
-                               iterator far = after;
+                               /* all points in nascent are before the first existing point */
 
-                               while (far != _events.end()) {
-                                       if ((*far)->when > when) {
-                                               break;
+                               _events.insert (_events.begin(), nascent_events.begin(), nascent_events.end());
+
+                       } else if (ninfo->start_time > _events.back()->when) {
+
+                               /* all points in nascent are after the last existing point */
+
+                               _events.insert (_events.end(), nascent_events.begin(), nascent_events.end());
+
+                       } else {
+
+                               /* find the range that overlaps with nascent events,
+                                  and insert the contents of nascent events.
+                               */
+
+                               iterator i;
+                               iterator range_begin = _events.end();
+                               iterator range_end = _events.end();
+                               double end_value = unlocked_eval (ninfo->end_time);
+                               double start_value = unlocked_eval (ninfo->start_time - 1);
+
+                               need_adjacent_end_clamp = true;
+                               need_adjacent_start_clamp = true;
+
+                               for (i = _events.begin(); i != _events.end(); ++i) {
+
+                                       if ((*i)->when == ninfo->start_time) {
+                                               /* existing point at same time, remove it
+                                                  and the consider the next point instead.
+                                               */
+                                               i = _events.erase (i);
+
+                                               if (i == _events.end()) {
+                                                       break;
+                                               }
+
+                                               if (range_begin == _events.end()) {
+                                                       range_begin = i;
+                                                       need_adjacent_start_clamp = false;
+                                               } else {
+                                                       need_adjacent_end_clamp = false;
+                                               }
+
+                                               if ((*i)->when > ninfo->end_time) {
+                                                       range_end = i;
+                                                       break;
+                                               }
+
+                                       } else if ((*i)->when > ninfo->start_time) {
+
+                                               if (range_begin == _events.end()) {
+                                                       range_begin = i;
+                                               }
+
+                                               if ((*i)->when > ninfo->end_time) {
+                                                       range_end = i;
+                                                       break;
+                                               }
                                        }
-                                       ++far;
                                }
 
-                               if (_new_value) {
-                                       where = far;
-                                       _rt_insertion_point = where;
+                               /* Now:
+                                  range_begin is the first event on our list after the first nascent event
+                                  range_end   is the first event on our list after the last  nascent event
+
+                                  range_begin may be equal to _events.end() iff the last event on our list
+                                  was at the same time as the first nascent event.
+                               */
 
-                                       if ((*where)->when == when) {
-                                               (*where)->value = value;
-                                               done = true;
+                               if (range_begin != _events.begin()) {
+                                       /* clamp point before */
+                                       if (need_adjacent_start_clamp) {
+                                               _events.insert (range_begin, new ControlEvent (ninfo->start_time, start_value));
                                        }
-                               } else {
-                                       where = _events.erase (after, far);
                                }
 
-                       } else {
+                               _events.insert (range_begin, nascent_events.begin(), nascent_events.end());
 
-                               where = after;
+                               if (range_end != _events.end()) {
+                                       /* clamp point after */
+                                       if (need_adjacent_end_clamp) {
+                                               _events.insert (range_begin, new ControlEvent (ninfo->end_time, end_value));
+                                       }
+                               }
 
+                               _events.erase (range_begin, range_end);
                        }
 
-                       iterator previous = _rt_insertion_point;
-                       --previous;
+                       delete ninfo;
+               }
 
-                       if (_rt_insertion_point != _events.begin() && (*_rt_insertion_point)->value == value && (*previous)->value == value) {
-                               (*_rt_insertion_point)->when = when;
-                               done = true;
+               nascent.clear ();
 
-                       }
+               if (writing()) {
+                       nascent.push_back (new NascentInfo ());
+               }
+       }
 
-               } else {
+       maybe_signal_changed ();
+}
 
-                       where = lower_bound (_events.begin(), _events.end(), &cp, time_comparator);
+void
+ControlList::rt_add (double when, double value)
+{
+       // this is for automation recording
 
-                       if (where != _events.end()) {
-                               if ((*where)->when == when) {
-                                       (*where)->value = value;
-                                       done = true;
-                               }
-                       }
+       if (touch_enabled() && !touching()) {
+               return;
+       }
+
+       //cerr << "RT: alist " << this << " add " << value << " @ " << when << endl;
+
+       Glib::Mutex::Lock lm (_lock, Glib::TRY_LOCK);
+
+       if (lm.locked()) {
+               assert (!nascent.empty());
+               /* we don't worry about adding events out of time order as we will
+                  sort them in merge_nascent.
+               */
+
+               EventList& el (nascent.back()->events);
+
+               if (el.size() > 1 && (when >= el.back()->when) && (value == el.back()->value)) {
+                       /* same value, later timestamp, effective slope is
+                        * zero, so just move the last point in nascent to our
+                        * new time position. this avoids storing an unlimited
+                        * number of points to represent a flat line.
+                        */
+                       el.back()->when = when;
+               } else {
+                       nascent.back()->events.push_back (new ControlEvent (when, value));
                }
+       }
+}
 
-               if (!done) {
-                       _rt_insertion_point = _events.insert (where, new ControlEvent (when, value));
+void
+ControlList::thin ()
+{
+       Glib::Mutex::Lock lm (_lock);
+
+       ControlEvent* prevprev = 0;
+       ControlEvent* cur = 0;
+       ControlEvent* prev = 0;
+       iterator pprev;
+       int counter = 0;
+
+       for (iterator i = _events.begin(); i != _events.end(); ++i) {
+
+               cur = *i;
+               counter++;
+
+               if (counter > 2) {
+                       
+                       double area = fabs ((prevprev->when * (prev->value - cur->value)) + 
+                                           (prev->when * (cur->value - prevprev->value)) + 
+                                           (cur->when * (prevprev->value - prev->value)));
+                       
+                       if (area < _thinning_factor) {
+                               iterator tmp = pprev;
+
+                               /* pprev will change to current
+                                  i is incremented to the next event
+                               */
+
+                               pprev = i;
+                               _events.erase (tmp);
+
+                               continue;
+                       }
                }
 
-               _new_value = false;
-               mark_dirty ();
+               prevprev = prev;
+               prev = cur;
+               pprev = i;
        }
-
-       maybe_signal_changed ();
 }
 
 void
@@ -305,12 +465,20 @@ ControlList::fast_simple_add (double when, double value)
        /* to be used only for loading pre-sorted data from saved state */
        _events.insert (_events.end(), new ControlEvent (when, value));
        assert(_events.back());
+
+       mark_dirty ();
 }
 
 void
 ControlList::add (double when, double value)
 {
-       /* this is for graphical editing */
+       /* this is for making changes from some kind of user interface or
+          control surface (GUI, MIDI, OSC etc)
+       */
+
+       if (!clamp_value (when, value)) {
+               return;
+       }
 
        {
                Glib::Mutex::Lock lm (_lock);
@@ -336,7 +504,6 @@ ControlList::add (double when, double value)
                if (insert) {
 
                        _events.insert (insertion_point, new ControlEvent (when, value));
-                       reposition_for_rt_add (0);
 
                }
 
@@ -352,7 +519,6 @@ ControlList::erase (iterator i)
        {
                Glib::Mutex::Lock lm (_lock);
                _events.erase (i);
-               reposition_for_rt_add (0);
                mark_dirty ();
        }
        maybe_signal_changed ();
@@ -364,12 +530,33 @@ ControlList::erase (iterator start, iterator end)
        {
                Glib::Mutex::Lock lm (_lock);
                _events.erase (start, end);
-               reposition_for_rt_add (0);
                mark_dirty ();
        }
        maybe_signal_changed ();
 }
 
+/** Erase the first event which matches the given time and value */
+void
+ControlList::erase (double when, double value)
+{
+       {
+               Glib::Mutex::Lock lm (_lock);
+
+               iterator i = begin ();
+               while (i != end() && ((*i)->when != when || (*i)->value != value)) {
+                       ++i;
+               }
+
+               if (i != end ()) {
+                       _events.erase (i);
+               }
+
+               mark_dirty ();
+       }
+
+       maybe_signal_changed ();
+}
+
 void
 ControlList::reset_range (double start, double endt)
 {
@@ -411,7 +598,6 @@ ControlList::erase_range (double start, double endt)
                erased = erase_range_internal (start, endt, _events);
 
                if (erased) {
-                       reposition_for_rt_add (0);
                        mark_dirty ();
                }
 
@@ -434,7 +620,9 @@ ControlList::erase_range_internal (double start, double endt, EventList & events
                cp.when = endt;
                e = upper_bound (events.begin(), events.end(), &cp, time_comparator);
                events.erase (s, e);
-               erased = true;
+               if (s != e) {
+                       erased = true;
+               }
        }
 
        return erased;
@@ -454,6 +642,26 @@ ControlList::slide (iterator before, double distance)
                        (*before)->when += distance;
                        ++before;
                }
+
+               mark_dirty ();
+       }
+
+       maybe_signal_changed ();
+}
+
+void
+ControlList::shift (double pos, double frames)
+{
+       {
+               Glib::Mutex::Lock lm (_lock);
+
+               for (iterator i = _events.begin(); i != _events.end(); ++i) {
+                       if ((*i)->when >= pos) {
+                               (*i)->when += frames;
+                       }
+               }
+
+               mark_dirty ();
        }
 
        maybe_signal_changed ();
@@ -473,7 +681,7 @@ ControlList::modify (iterator iter, double when, double val)
                (*iter)->when = when;
                (*iter)->value = val;
 
-               if (isnan (val)) {
+               if (std::isnan (val)) {
                        abort ();
                }
 
@@ -522,12 +730,6 @@ ControlList::control_points_adjacent (double xval)
        return ret;
 }
 
-void
-ControlList::set_max_xval (double x)
-{
-       _max_xval = x;
-}
-
 void
 ControlList::freeze ()
 {
@@ -586,7 +788,7 @@ ControlList::truncate_end (double last_coordinate)
                if (last_coordinate > _events.back()->when) {
 
                        /* extending end:
-                       */
+                        */
 
                        iterator foo = _events.begin();
                        bool lessthantwo;
@@ -662,7 +864,6 @@ ControlList::truncate_end (double last_coordinate)
                        _events.back()->value = last_val;
                }
 
-               reposition_for_rt_add (0);
                mark_dirty();
        }
 
@@ -762,8 +963,6 @@ ControlList::truncate_start (double overall_length)
                        _events.push_front (new ControlEvent (0, first_legal_value));
                }
 
-               reposition_for_rt_add (0);
-
                mark_dirty();
        }
 
@@ -991,7 +1190,7 @@ ControlList::rt_safe_earliest_event_discrete_unlocked (double start, double& x,
                        return false;
                }
 
-       /* No points in range */
+               /* No points in range */
        } else {
                return false;
        }
@@ -1012,9 +1211,9 @@ ControlList::rt_safe_earliest_event_linear_unlocked (double start, double& x, do
        const_iterator length_check_iter = _events.begin();
        if (_events.empty()) { // 0 events
                return false;
-        } else if (_events.end() == ++length_check_iter) { // 1 event
+       } else if (_events.end() == ++length_check_iter) { // 1 event
                return rt_safe_earliest_event_discrete_unlocked (start, x, y, inclusive);
-        }
+       }
 
        // Hack to avoid infinitely repeating the same event
        build_search_cache_if_necessary (start);
@@ -1033,7 +1232,7 @@ ControlList::rt_safe_earliest_event_linear_unlocked (double start, double& x, do
                        }
                        next = *_search_cache.first;
 
-               /* Step is before first */
+                       /* Step is before first */
                } else {
                        const_iterator prev = _search_cache.first;
                        --prev;
@@ -1091,11 +1290,11 @@ ControlList::rt_safe_earliest_event_linear_unlocked (double start, double& x, do
                }
 
                /*cerr << first->value << " @ " << first->when << " ... "
-                               << next->value << " @ " << next->when
-                               << " = " << y << " @ " << x << endl;*/
+                 << next->value << " @ " << next->when
+                 << " = " << y << " @ " << x << endl;*/
 
                assert(    (y >= first->value && y <= next->value)
-                               || (y <= first->value && y >= next->value) );
+                          || (y <= first->value && y >= next->value) );
 
 
                const bool past_start = (inclusive ? x >= start : x > start);
@@ -1109,73 +1308,72 @@ ControlList::rt_safe_earliest_event_linear_unlocked (double start, double& x, do
                        return false;
                }
 
-       /* No points in the future, so no steps (towards them) in the future */
+               /* No points in the future, so no steps (towards them) in the future */
        } else {
                return false;
        }
 }
 
+
+/** @param start Start position in model coordinates.
+ *  @param end End position in model coordinates.
+ *  @param op 0 = cut, 1 = copy, 2 = clear.
+ */
 boost::shared_ptr<ControlList>
-ControlList::cut (iterator start, iterator end)
+ControlList::cut_copy_clear (double start, double end, int op)
 {
        boost::shared_ptr<ControlList> nal = create (_parameter);
+       iterator s, e;
+       ControlEvent cp (start, 0.0);
 
        {
                Glib::Mutex::Lock lm (_lock);
 
-               for (iterator x = start; x != end; ) {
-                       iterator tmp;
+               /* first, determine s & e, two iterators that define the range of points
+                  affected by this operation
+               */
 
-                       tmp = x;
-                       ++tmp;
+               if ((s = lower_bound (_events.begin(), _events.end(), &cp, time_comparator)) == _events.end()) {
+                       return nal;
+               }
 
-                       nal->_events.push_back (new ControlEvent (**x));
-                       _events.erase (x);
+               /* and the last that is at or after `end' */
+               cp.when = end;
+               e = upper_bound (_events.begin(), _events.end(), &cp, time_comparator);
 
-                       reposition_for_rt_add (0);
 
-                       x = tmp;
-               }
+               /* if "start" isn't the location of an existing point,
+                  evaluate the curve to get a value for the start. Add a point to
+                  both the existing event list, and if its not a "clear" operation,
+                  to the copy ("nal") as well.
 
-               mark_dirty ();
-       }
+                  Note that the time positions of the points in each list are different
+                  because we want the copy ("nal") to have a zero time reference.
+               */
 
-       maybe_signal_changed ();
 
-       return nal;
-}
+               /* before we begin any cut/clear operations, get the value of the curve
+                  at "end".
+               */
 
-/** @param op 0 = cut, 1 = copy, 2 = clear */
-boost::shared_ptr<ControlList>
-ControlList::cut_copy_clear (double start, double end, int op)
-{
-       boost::shared_ptr<ControlList> nal = create (_parameter);
-       
-       iterator s, e;
-       bool changed = false;
+               double end_value = unlocked_eval (end);
 
-       {
-               Glib::Mutex::Lock lm (_lock);
+               if ((*s)->when != start) {
 
-               /* find the first event in our list that is at or before `start' in time */
-               ControlEvent cp (start, 0.0);
-               if ((s = lower_bound (_events.begin(), _events.end(), &cp, time_comparator)) == _events.end()) {
-                       return nal;
-               }
+                       double val = unlocked_eval (start);
 
-               /* and the last that is at or after `end' */
-               cp.when = end;
-               e = upper_bound (_events.begin(), _events.end(), &cp, time_comparator);
+                       if (op == 0) { // cut
+                               if (start > _events.front()->when) {
+                                       _events.insert (s, (new ControlEvent (start, val)));
+                               }
+                       }
 
-               if (op != 2 && (*s)->when != start) {
-                       nal->_events.push_back (new ControlEvent (0, unlocked_eval (start)));
+                       if (op != 2) { // ! clear
+                               nal->_events.push_back (new ControlEvent (0, val));
+                       }
                }
 
                for (iterator x = s; x != e; ) {
-                       iterator tmp = x;
-                       ++tmp;
-
-                       changed = true;
 
                        /* adjust new points to be relative to start, which
                           has been set to zero.
@@ -1186,52 +1384,37 @@ ControlList::cut_copy_clear (double start, double end, int op)
                        }
 
                        if (op != 1) {
-                               _events.erase (x);
+                               x = _events.erase (x);
+                       } else {
+                               ++x;
                        }
-
-                       x = tmp;
                }
 
-               if (op != 2 && nal->_events.back()->when != end - start) {
-                       nal->_events.push_back (new ControlEvent (end - start, unlocked_eval (end)));
-               }
+               if (e == _events.end() || (*e)->when != end) {
 
-               if (changed) {
-                       reposition_for_rt_add (0);
+                       /* only add a boundary point if there is a point after "end"
+                        */
+
+                       if (op == 0 && (e != _events.end() && end < (*e)->when)) { // cut
+                               _events.insert (e, new ControlEvent (end, end_value));
+                       }
+
+                       if (op != 2 && (e != _events.end() && end < (*e)->when)) { // cut/copy
+                               nal->_events.push_back (new ControlEvent (end - start, end_value));
+                       }
                }
 
                mark_dirty ();
        }
 
-       maybe_signal_changed ();
-
-       return nal;
-
-}
-
-boost::shared_ptr<ControlList>
-ControlList::copy (iterator start, iterator end)
-{
-       boost::shared_ptr<ControlList> nal = create (_parameter);
-
-       {
-               Glib::Mutex::Lock lm (_lock);
-
-               for (iterator x = start; x != end; ) {
-                       iterator tmp;
-
-                       tmp = x;
-                       ++tmp;
-
-                       nal->_events.push_back (new ControlEvent (**x));
-
-                       x = tmp;
-               }
+       if (op != 1) {
+               maybe_signal_changed ();
        }
 
        return nal;
 }
 
+
 boost::shared_ptr<ControlList>
 ControlList::cut (double start, double end)
 {
@@ -1247,9 +1430,10 @@ ControlList::copy (double start, double end)
 void
 ControlList::clear (double start, double end)
 {
-       (void) cut_copy_clear (start, end, 2);
+       cut_copy_clear (start, end, 2);
 }
 
+/** @param pos Position in model coordinates */
 bool
 ControlList::paste (ControlList& alist, double pos, float /*times*/)
 {
@@ -1289,7 +1473,6 @@ ControlList::paste (ControlList& alist, double pos, float /*times*/)
                        }
                }
 
-               reposition_for_rt_add (0);
                mark_dirty ();
        }
 
@@ -1297,8 +1480,10 @@ ControlList::paste (ControlList& alist, double pos, float /*times*/)
        return true;
 }
 
-/** Move automation around according to a list of region movements */
-void
+/** Move automation around according to a list of region movements.
+ *  @param return true if anything was changed, otherwise false (ie nothing needed changing)
+ */
+bool
 ControlList::move_ranges (const list< RangeMove<double> >& movements)
 {
        typedef list< RangeMove<double> > RangeMoveList;
@@ -1310,11 +1495,21 @@ ControlList::move_ranges (const list< RangeMove<double> >& movements)
                EventList old_events = _events;
 
                /* clear the source and destination ranges in the new list */
+               bool things_erased = false;
                for (RangeMoveList::const_iterator i = movements.begin (); i != movements.end (); ++i) {
 
-                       erase_range_internal (i->from, i->from + i->length, _events);
-                       erase_range_internal (i->to, i->to + i->length, _events);
+                       if (erase_range_internal (i->from, i->from + i->length, _events)) {
+                               things_erased = true;
+                       }
+
+                       if (erase_range_internal (i->to, i->to + i->length, _events)) {
+                               things_erased = true;
+                       }
+               }
 
+               /* if nothing was erased, there is nothing to do */
+               if (!things_erased) {
+                       return false;
                }
 
                /* copy the events into the new list */
@@ -1338,11 +1533,11 @@ ControlList::move_ranges (const list< RangeMove<double> >& movements)
                        _sort_pending = true;
                }
 
-               reposition_for_rt_add (0);
                mark_dirty ();
        }
 
        maybe_signal_changed ();
+       return true;
 }
 
 void
@@ -1356,5 +1551,11 @@ ControlList::set_interpolation (InterpolationStyle s)
        InterpolationChanged (s); /* EMIT SIGNAL */
 }
 
+void
+ControlList::set_thinning_factor (double v)
+{
+       _thinning_factor = v;
+}
+
 } // namespace Evoral