1 /* This file is part of Evoral.
2 * Copyright (C) 2008 Dave Robillard <http://drobilla.net>
3 * Copyright (C) 2000-2008 Paul Davis
5 * Evoral is free software; you can redistribute it and/or modify it under the
6 * terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or (at your option) any later
10 * Evoral is distributed in the hope that it will be useful, but WITHOUT ANY
11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include <evoral/ControlList.hpp>
30 inline bool event_time_less_than (ControlEvent* a, ControlEvent* b)
32 return a->when < b->when;
36 ControlList::ControlList (const Parameter& id)
38 , _interpolation(Linear)
39 , _curve(new Curve(*this))
42 _changed_when_thawed = false;
45 _max_xval = 0; // means "no limit"
46 _rt_insertion_point = _events.end();
47 _lookup_cache.left = -1;
48 _lookup_cache.range.first = _events.end();
49 _search_cache.left = -1;
50 _search_cache.range.first = _events.end();
51 _sort_pending = false;
54 ControlList::ControlList (const ControlList& other)
55 : _parameter(other._parameter)
56 , _interpolation(Linear)
57 , _curve(new Curve(*this))
60 _changed_when_thawed = false;
61 _min_yval = other._min_yval;
62 _max_yval = other._max_yval;
63 _max_xval = other._max_xval;
64 _default_value = other._default_value;
65 _rt_insertion_point = _events.end();
66 _lookup_cache.range.first = _events.end();
67 _search_cache.range.first = _events.end();
68 _sort_pending = false;
70 for (const_iterator i = other._events.begin(); i != other._events.end(); ++i) {
71 _events.push_back (new ControlEvent (**i));
77 ControlList::ControlList (const ControlList& other, double start, double end)
78 : _parameter(other._parameter)
79 , _interpolation(Linear)
80 , _curve(new Curve(*this))
83 _changed_when_thawed = false;
84 _min_yval = other._min_yval;
85 _max_yval = other._max_yval;
86 _max_xval = other._max_xval;
87 _default_value = other._default_value;
88 _rt_insertion_point = _events.end();
89 _lookup_cache.range.first = _events.end();
90 _search_cache.range.first = _events.end();
91 _sort_pending = false;
93 /* now grab the relevant points, and shift them back if necessary */
95 boost::shared_ptr<ControlList> section = const_cast<ControlList*>(&other)->copy (start, end);
97 if (!section->empty()) {
98 for (iterator i = section->begin(); i != section->end(); ++i) {
99 _events.push_back (new ControlEvent ((*i)->when, (*i)->value));
106 ControlList::~ControlList()
108 for (EventList::iterator x = _events.begin(); x != _events.end(); ++x) {
114 boost::shared_ptr<ControlList>
115 ControlList::create(Parameter id)
117 return boost::shared_ptr<ControlList>(new ControlList(id));
122 ControlList::operator== (const ControlList& other)
124 return _events == other._events;
128 ControlList::operator= (const ControlList& other)
130 if (this != &other) {
134 for (const_iterator i = other._events.begin(); i != other._events.end(); ++i) {
135 _events.push_back (new ControlEvent (**i));
138 _min_yval = other._min_yval;
139 _max_yval = other._max_yval;
140 _max_xval = other._max_xval;
141 _default_value = other._default_value;
144 maybe_signal_changed ();
151 ControlList::maybe_signal_changed ()
156 _changed_when_thawed = true;
160 ControlList::clear ()
163 Glib::Mutex::Lock lm (_lock);
168 maybe_signal_changed ();
172 ControlList::x_scale (double factor)
174 Glib::Mutex::Lock lm (_lock);
179 ControlList::extend_to (double when)
181 Glib::Mutex::Lock lm (_lock);
182 if (_events.empty() || _events.back()->when == when) {
185 double factor = when / _events.back()->when;
190 void ControlList::_x_scale (double factor)
192 for (iterator i = _events.begin(); i != _events.end(); ++i) {
193 (*i)->when = floor ((*i)->when * factor);
200 ControlList::reposition_for_rt_add (double when)
202 _rt_insertion_point = _events.end();
206 ControlList::rt_add (double when, double value)
208 // cerr << "RT: alist @ " << this << " add " << value << " @ " << when << endl;
211 Glib::Mutex::Lock lm (_lock);
214 ControlEvent cp (when, 0.0);
217 if ((_rt_insertion_point != _events.end()) && ((*_rt_insertion_point)->when < when) ) {
219 /* we have a previous insertion point, so we should delete
220 everything between it and the position where we are going
221 to insert this point.
224 iterator after = _rt_insertion_point;
226 if (++after != _events.end()) {
227 iterator far = after;
229 while (far != _events.end()) {
230 if ((*far)->when > when) {
238 _rt_insertion_point = where;
240 if ((*where)->when == when) {
241 (*where)->value = value;
245 where = _events.erase (after, far);
254 iterator previous = _rt_insertion_point;
257 if (_rt_insertion_point != _events.begin() && (*_rt_insertion_point)->value == value && (*previous)->value == value) {
258 (*_rt_insertion_point)->when = when;
265 where = lower_bound (_events.begin(), _events.end(), &cp, time_comparator);
267 if (where != _events.end()) {
268 if ((*where)->when == when) {
269 (*where)->value = value;
276 _rt_insertion_point = _events.insert (where, new ControlEvent (when, value));
283 maybe_signal_changed ();
287 ControlList::fast_simple_add (double when, double value)
289 /* to be used only for loading pre-sorted data from saved state */
290 _events.insert (_events.end(), new ControlEvent (when, value));
291 assert(_events.back());
295 ControlList::add (double when, double value)
297 /* this is for graphical editing */
300 Glib::Mutex::Lock lm (_lock);
301 ControlEvent cp (when, 0.0f);
303 iterator insertion_point;
305 for (insertion_point = lower_bound (_events.begin(), _events.end(), &cp, time_comparator); insertion_point != _events.end(); ++insertion_point) {
307 /* only one point allowed per time point */
309 if ((*insertion_point)->when == when) {
310 (*insertion_point)->value = value;
315 if ((*insertion_point)->when >= when) {
322 _events.insert (insertion_point, new ControlEvent (when, value));
323 reposition_for_rt_add (0);
330 maybe_signal_changed ();
334 ControlList::erase (iterator i)
337 Glib::Mutex::Lock lm (_lock);
339 reposition_for_rt_add (0);
342 maybe_signal_changed ();
346 ControlList::erase (iterator start, iterator end)
349 Glib::Mutex::Lock lm (_lock);
350 _events.erase (start, end);
351 reposition_for_rt_add (0);
354 maybe_signal_changed ();
358 ControlList::reset_range (double start, double endt)
363 Glib::Mutex::Lock lm (_lock);
364 ControlEvent cp (start, 0.0f);
368 if ((s = lower_bound (_events.begin(), _events.end(), &cp, time_comparator)) != _events.end()) {
371 e = upper_bound (_events.begin(), _events.end(), &cp, time_comparator);
373 for (iterator i = s; i != e; ++i) {
374 (*i)->value = _default_value;
384 maybe_signal_changed ();
389 ControlList::erase_range (double start, double endt)
394 Glib::Mutex::Lock lm (_lock);
395 ControlEvent cp (start, 0.0f);
399 if ((s = lower_bound (_events.begin(), _events.end(), &cp, time_comparator)) != _events.end()) {
401 e = upper_bound (_events.begin(), _events.end(), &cp, time_comparator);
402 _events.erase (s, e);
403 reposition_for_rt_add (0);
411 maybe_signal_changed ();
416 ControlList::move_range (iterator start, iterator end, double xdelta, double ydelta)
418 /* note: we assume higher level logic is in place to avoid this
419 reordering the time-order of control events in the list. ie. all
420 points after end are later than (end)->when.
424 Glib::Mutex::Lock lm (_lock);
426 while (start != end) {
427 (*start)->when += xdelta;
428 (*start)->value += ydelta;
429 if (isnan ((*start)->value)) {
436 _events.sort (event_time_less_than);
438 _sort_pending = true;
444 maybe_signal_changed ();
448 ControlList::slide (iterator before, double distance)
451 Glib::Mutex::Lock lm (_lock);
453 if (before == _events.end()) {
457 while (before != _events.end()) {
458 (*before)->when += distance;
463 maybe_signal_changed ();
467 ControlList::modify (iterator iter, double when, double val)
469 /* note: we assume higher level logic is in place to avoid this
470 reordering the time-order of control events in the list. ie. all
471 points after *iter are later than when.
475 Glib::Mutex::Lock lm (_lock);
477 (*iter)->when = when;
478 (*iter)->value = val;
485 _events.sort (event_time_less_than);
487 _sort_pending = true;
493 maybe_signal_changed ();
496 std::pair<ControlList::iterator,ControlList::iterator>
497 ControlList::control_points_adjacent (double xval)
499 Glib::Mutex::Lock lm (_lock);
501 ControlEvent cp (xval, 0.0f);
502 std::pair<iterator,iterator> ret;
504 ret.first = _events.end();
505 ret.second = _events.end();
507 for (i = lower_bound (_events.begin(), _events.end(), &cp, time_comparator); i != _events.end(); ++i) {
509 if (ret.first == _events.end()) {
510 if ((*i)->when >= xval) {
511 if (i != _events.begin()) {
520 if ((*i)->when > xval) {
530 ControlList::set_max_xval (double x)
536 ControlList::freeze ()
551 Glib::Mutex::Lock lm (_lock);
554 _events.sort (event_time_less_than);
555 _sort_pending = false;
561 ControlList::mark_dirty () const
563 _lookup_cache.left = -1;
564 _search_cache.left = -1;
566 _curve->mark_dirty();
570 ControlList::truncate_end (double last_coordinate)
573 Glib::Mutex::Lock lm (_lock);
574 ControlEvent cp (last_coordinate, 0);
575 ControlList::reverse_iterator i;
578 if (_events.empty()) {
582 if (last_coordinate == _events.back()->when) {
586 if (last_coordinate > _events.back()->when) {
591 iterator foo = _events.begin();
594 if (foo == _events.end()) {
596 } else if (++foo == _events.end()) {
603 /* less than 2 points: add a new point */
604 _events.push_back (new ControlEvent (last_coordinate, _events.back()->value));
607 /* more than 2 points: check to see if the last 2 values
608 are equal. if so, just move the position of the
609 last point. otherwise, add a new point.
612 iterator penultimate = _events.end();
613 --penultimate; /* points at last point */
614 --penultimate; /* points at the penultimate point */
616 if (_events.back()->value == (*penultimate)->value) {
617 _events.back()->when = last_coordinate;
619 _events.push_back (new ControlEvent (last_coordinate, _events.back()->value));
627 last_val = unlocked_eval (last_coordinate);
628 last_val = max ((double) _min_yval, last_val);
629 last_val = min ((double) _max_yval, last_val);
631 i = _events.rbegin();
633 /* make i point to the last control point */
637 /* now go backwards, removing control points that are
638 beyond the new last coordinate.
641 uint32_t sz = _events.size();
643 while (i != _events.rend() && sz > 2) {
644 ControlList::reverse_iterator tmp;
649 if ((*i)->when < last_coordinate) {
653 _events.erase (i.base());
659 _events.back()->when = last_coordinate;
660 _events.back()->value = last_val;
663 reposition_for_rt_add (0);
667 maybe_signal_changed ();
671 ControlList::truncate_start (double overall_length)
674 Glib::Mutex::Lock lm (_lock);
676 double first_legal_value;
677 double first_legal_coordinate;
679 assert(!_events.empty());
681 if (overall_length == _events.back()->when) {
682 /* no change in overall length */
686 if (overall_length > _events.back()->when) {
688 /* growing at front: duplicate first point. shift all others */
690 double shift = overall_length - _events.back()->when;
693 for (np = 0, i = _events.begin(); i != _events.end(); ++i, ++np) {
699 /* less than 2 points: add a new point */
700 _events.push_front (new ControlEvent (0, _events.front()->value));
704 /* more than 2 points: check to see if the first 2 values
705 are equal. if so, just move the position of the
706 first point. otherwise, add a new point.
709 iterator second = _events.begin();
710 ++second; /* points at the second point */
712 if (_events.front()->value == (*second)->value) {
713 /* first segment is flat, just move start point back to zero */
714 _events.front()->when = 0;
716 /* leave non-flat segment in place, add a new leading point. */
717 _events.push_front (new ControlEvent (0, _events.front()->value));
723 /* shrinking at front */
725 first_legal_coordinate = _events.back()->when - overall_length;
726 first_legal_value = unlocked_eval (first_legal_coordinate);
727 first_legal_value = max (_min_yval, first_legal_value);
728 first_legal_value = min (_max_yval, first_legal_value);
730 /* remove all events earlier than the new "front" */
734 while (i != _events.end() && !_events.empty()) {
735 ControlList::iterator tmp;
740 if ((*i)->when > first_legal_coordinate) {
750 /* shift all remaining points left to keep their same
754 for (i = _events.begin(); i != _events.end(); ++i) {
755 (*i)->when -= first_legal_coordinate;
758 /* add a new point for the interpolated new value */
760 _events.push_front (new ControlEvent (0, first_legal_value));
763 reposition_for_rt_add (0);
768 maybe_signal_changed ();
772 ControlList::unlocked_eval (double x) const
774 pair<EventList::iterator,EventList::iterator> range;
780 npoints = _events.size();
784 return _default_value;
787 if (x >= _events.front()->when) {
788 return _events.front()->value;
790 // return _default_value;
791 return _events.front()->value;
795 if (x >= _events.back()->when) {
796 return _events.back()->value;
797 } else if (x == _events.front()->when) {
798 return _events.front()->value;
799 } else if (x < _events.front()->when) {
800 // return _default_value;
801 return _events.front()->value;
804 lpos = _events.front()->when;
805 lval = _events.front()->value;
806 upos = _events.back()->when;
807 uval = _events.back()->value;
809 if (_interpolation == Discrete)
812 /* linear interpolation betweeen the two points
815 fraction = (double) (x - lpos) / (double) (upos - lpos);
816 return lval + (fraction * (uval - lval));
820 if (x >= _events.back()->when) {
821 return _events.back()->value;
822 } else if (x == _events.front()->when) {
823 return _events.front()->value;
824 } else if (x < _events.front()->when) {
825 // return _default_value;
826 return _events.front()->value;
829 return multipoint_eval (x);
833 /*NOTREACHED*/ /* stupid gcc */
838 ControlList::multipoint_eval (double x) const
844 /* "Stepped" lookup (no interpolation) */
845 /* FIXME: no cache. significant? */
846 if (_interpolation == Discrete) {
847 const ControlEvent cp (x, 0);
848 EventList::const_iterator i = lower_bound (_events.begin(), _events.end(), &cp, time_comparator);
850 // shouldn't have made it to multipoint_eval
851 assert(i != _events.end());
853 if (i == _events.begin() || (*i)->when == x)
856 return (*(--i))->value;
859 /* Only do the range lookup if x is in a different range than last time
860 * this was called (or if the lookup cache has been marked "dirty" (left<0) */
861 if ((_lookup_cache.left < 0) ||
862 ((_lookup_cache.left > x) ||
863 (_lookup_cache.range.first == _events.end()) ||
864 ((*_lookup_cache.range.second)->when < x))) {
866 const ControlEvent cp (x, 0);
868 _lookup_cache.range = equal_range (_events.begin(), _events.end(), &cp, time_comparator);
871 pair<const_iterator,const_iterator> range = _lookup_cache.range;
873 if (range.first == range.second) {
875 /* x does not exist within the list as a control point */
877 _lookup_cache.left = x;
879 if (range.first != _events.begin()) {
881 lpos = (*range.first)->when;
882 lval = (*range.first)->value;
884 /* we're before the first point */
885 // return _default_value;
886 return _events.front()->value;
889 if (range.second == _events.end()) {
890 /* we're after the last point */
891 return _events.back()->value;
894 upos = (*range.second)->when;
895 uval = (*range.second)->value;
897 /* linear interpolation betweeen the two points
901 fraction = (double) (x - lpos) / (double) (upos - lpos);
902 return lval + (fraction * (uval - lval));
906 /* x is a control point in the data */
907 _lookup_cache.left = -1;
908 return (*range.first)->value;
912 ControlList::build_search_cache_if_necessary(double start, double end) const
914 /* Only do the range lookup if x is in a different range than last time
915 * this was called (or if the search cache has been marked "dirty" (left<0) */
916 if (!_events.empty() && ((_search_cache.left < 0) ||
917 ((_search_cache.left > start) ||
918 (_search_cache.right < end)))) {
920 const ControlEvent start_point (start, 0);
921 const ControlEvent end_point (end, 0);
923 //cerr << "REBUILD: (" << _search_cache.left << ".." << _search_cache.right << ") := ("
924 // << start << ".." << end << ")" << endl;
926 _search_cache.range.first = lower_bound (_events.begin(), _events.end(), &start_point, time_comparator);
927 _search_cache.range.second = upper_bound (_events.begin(), _events.end(), &end_point, time_comparator);
929 _search_cache.left = start;
930 _search_cache.right = end;
934 /** Get the earliest event between \a start and \a end, using the current interpolation style.
936 * If an event is found, \a x and \a y are set to its coordinates.
938 * \param inclusive Include events with timestamp exactly equal to \a start
939 * \return true if event is found (and \a x and \a y are valid).
942 ControlList::rt_safe_earliest_event(double start, double end, double& x, double& y, bool inclusive) const
944 // FIXME: It would be nice if this was unnecessary..
945 Glib::Mutex::Lock lm(_lock, Glib::TRY_LOCK);
950 return rt_safe_earliest_event_unlocked(start, end, x, y, inclusive);
954 /** Get the earliest event between \a start and \a end, using the current interpolation style.
956 * If an event is found, \a x and \a y are set to its coordinates.
958 * \param inclusive Include events with timestamp exactly equal to \a start
959 * \return true if event is found (and \a x and \a y are valid).
962 ControlList::rt_safe_earliest_event_unlocked(double start, double end, double& x, double& y, bool inclusive) const
964 if (_interpolation == Discrete)
965 return rt_safe_earliest_event_discrete_unlocked(start, end, x, y, inclusive);
967 return rt_safe_earliest_event_linear_unlocked(start, end, x, y, inclusive);
971 /** Get the earliest event between \a start and \a end (Discrete (lack of) interpolation)
973 * If an event is found, \a x and \a y are set to its coordinates.
975 * \param inclusive Include events with timestamp exactly equal to \a start
976 * \return true if event is found (and \a x and \a y are valid).
979 ControlList::rt_safe_earliest_event_discrete_unlocked (double start, double end, double& x, double& y, bool inclusive) const
981 build_search_cache_if_necessary(start, end);
983 const pair<const_iterator,const_iterator>& range = _search_cache.range;
985 if (range.first != _events.end()) {
986 const ControlEvent* const first = *range.first;
988 const bool past_start = (inclusive ? first->when >= start : first->when > start);
990 /* Earliest points is in range, return it */
991 if (past_start >= start && first->when < end) {
996 /* Move left of cache to this point
997 * (Optimize for immediate call this cycle within range) */
998 _search_cache.left = x;
999 ++_search_cache.range.first;
1009 /* No points in range */
1015 /** Get the earliest time the line crosses an integer (Linear interpolation).
1017 * If an event is found, \a x and \a y are set to its coordinates.
1019 * \param inclusive Include events with timestamp exactly equal to \a start
1020 * \return true if event is found (and \a x and \a y are valid).
1023 ControlList::rt_safe_earliest_event_linear_unlocked (double start, double end, double& x, double& y, bool inclusive) const
1025 //cerr << "earliest_event(" << start << ", " << end << ", " << x << ", " << y << ", " << inclusive << endl;
1027 if (_events.size() == 0)
1029 else if (_events.size() == 1)
1030 return rt_safe_earliest_event_discrete_unlocked(start, end, x, y, inclusive);
1032 // Hack to avoid infinitely repeating the same event
1033 build_search_cache_if_necessary(start, end);
1035 pair<const_iterator,const_iterator> range = _search_cache.range;
1037 if (range.first != _events.end()) {
1039 const ControlEvent* first = NULL;
1040 const ControlEvent* next = NULL;
1042 /* Step is after first */
1043 if (range.first == _events.begin() || (*range.first)->when == start) {
1044 first = *range.first;
1045 next = *(++range.first);
1046 ++_search_cache.range.first;
1048 /* Step is before first */
1050 const_iterator prev = range.first;
1053 next = *range.first;
1056 if (inclusive && first->when == start) {
1059 /* Move left of cache to this point
1060 * (Optimize for immediate call this cycle within range) */
1061 _search_cache.left = x;
1062 //++_search_cache.range.first;
1066 if (abs(first->value - next->value) <= 1) {
1067 if (next->when <= end && (!inclusive || next->when > start)) {
1070 /* Move left of cache to this point
1071 * (Optimize for immediate call this cycle within range) */
1072 _search_cache.left = x;
1073 //++_search_cache.range.first;
1080 const double slope = (next->value - first->value) / (double)(next->when - first->when);
1081 //cerr << "start y: " << start_y << endl;
1083 //y = first->value + (slope * fabs(start - first->when));
1086 if (first->value < next->value) // ramping up
1088 else // ramping down
1091 x = first->when + (y - first->value) / (double)slope;
1093 while ((inclusive && x < start) || (x <= start && y != next->value)) {
1095 if (first->value < next->value) // ramping up
1097 else // ramping down
1100 x = first->when + (y - first->value) / (double)slope;
1103 /*cerr << first->value << " @ " << first->when << " ... "
1104 << next->value << " @ " << next->when
1105 << " = " << y << " @ " << x << endl;*/
1107 assert( (y >= first->value && y <= next->value)
1108 || (y <= first->value && y >= next->value) );
1111 const bool past_start = (inclusive ? x >= start : x > start);
1112 if (past_start && x < end) {
1113 /* Move left of cache to this point
1114 * (Optimize for immediate call this cycle within range) */
1115 _search_cache.left = x;
1123 /* No points in the future, so no steps (towards them) in the future */
1129 boost::shared_ptr<ControlList>
1130 ControlList::cut (iterator start, iterator end)
1132 boost::shared_ptr<ControlList> nal = create (_parameter);
1135 Glib::Mutex::Lock lm (_lock);
1137 for (iterator x = start; x != end; ) {
1143 nal->_events.push_back (new ControlEvent (**x));
1146 reposition_for_rt_add (0);
1154 maybe_signal_changed ();
1159 boost::shared_ptr<ControlList>
1160 ControlList::cut_copy_clear (double start, double end, int op)
1162 boost::shared_ptr<ControlList> nal = create (_parameter);
1164 ControlEvent cp (start, 0.0);
1165 bool changed = false;
1168 Glib::Mutex::Lock lm (_lock);
1170 if ((s = lower_bound (_events.begin(), _events.end(), &cp, time_comparator)) == _events.end()) {
1175 e = upper_bound (_events.begin(), _events.end(), &cp, time_comparator);
1177 if (op != 2 && (*s)->when != start) {
1178 nal->_events.push_back (new ControlEvent (0, unlocked_eval (start)));
1181 for (iterator x = s; x != e; ) {
1189 /* adjust new points to be relative to start, which
1190 has been set to zero.
1194 nal->_events.push_back (new ControlEvent ((*x)->when - start, (*x)->value));
1204 if (op != 2 && nal->_events.back()->when != end - start) {
1205 nal->_events.push_back (new ControlEvent (end - start, unlocked_eval (end)));
1209 reposition_for_rt_add (0);
1215 maybe_signal_changed ();
1221 boost::shared_ptr<ControlList>
1222 ControlList::copy (iterator start, iterator end)
1224 boost::shared_ptr<ControlList> nal = create (_parameter);
1227 Glib::Mutex::Lock lm (_lock);
1229 for (iterator x = start; x != end; ) {
1235 nal->_events.push_back (new ControlEvent (**x));
1244 boost::shared_ptr<ControlList>
1245 ControlList::cut (double start, double end)
1247 return cut_copy_clear (start, end, 0);
1250 boost::shared_ptr<ControlList>
1251 ControlList::copy (double start, double end)
1253 return cut_copy_clear (start, end, 1);
1257 ControlList::clear (double start, double end)
1259 (void) cut_copy_clear (start, end, 2);
1263 ControlList::paste (ControlList& alist, double pos, float times)
1265 if (alist._events.empty()) {
1270 Glib::Mutex::Lock lm (_lock);
1274 ControlEvent cp (pos, 0.0);
1276 where = upper_bound (_events.begin(), _events.end(), &cp, time_comparator);
1278 for (iterator i = alist.begin();i != alist.end(); ++i) {
1279 _events.insert (where, new ControlEvent( (*i)->when+pos,( *i)->value));
1280 end = (*i)->when + pos;
1284 /* move all points after the insertion along the timeline by
1288 while (where != _events.end()) {
1290 if ((*where)->when <= end) {
1293 _events.erase(where);
1301 reposition_for_rt_add (0);
1305 maybe_signal_changed ();
1309 } // namespace Evoral