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) {
113 boost::shared_ptr<ControlList>
114 ControlList::create(Parameter id)
116 return boost::shared_ptr<ControlList>(new ControlList(id));
120 ControlList::operator== (const ControlList& other)
122 return _events == other._events;
126 ControlList::operator= (const ControlList& other)
128 if (this != &other) {
132 for (const_iterator i = other._events.begin(); i != other._events.end(); ++i) {
133 _events.push_back (new ControlEvent (**i));
136 _min_yval = other._min_yval;
137 _max_yval = other._max_yval;
138 _max_xval = other._max_xval;
139 _default_value = other._default_value;
142 maybe_signal_changed ();
149 ControlList::maybe_signal_changed ()
154 _changed_when_thawed = true;
158 ControlList::clear ()
161 Glib::Mutex::Lock lm (_lock);
166 maybe_signal_changed ();
170 ControlList::x_scale (double factor)
172 Glib::Mutex::Lock lm (_lock);
177 ControlList::extend_to (double when)
179 Glib::Mutex::Lock lm (_lock);
180 if (_events.empty() || _events.back()->when == when) {
183 double factor = when / _events.back()->when;
188 void ControlList::_x_scale (double factor)
190 for (iterator i = _events.begin(); i != _events.end(); ++i) {
191 (*i)->when = floor ((*i)->when * factor);
198 ControlList::reposition_for_rt_add (double when)
200 _rt_insertion_point = _events.end();
204 ControlList::rt_add (double when, double value)
206 //cerr << "RT: alist " << this << " add " << value << " @ " << when << endl;
209 Glib::Mutex::Lock lm (_lock);
212 ControlEvent cp (when, 0.0);
215 if ((_rt_insertion_point != _events.end()) && ((*_rt_insertion_point)->when < when) ) {
217 /* we have a previous insertion point, so we should delete
218 everything between it and the position where we are going
219 to insert this point.
222 iterator after = _rt_insertion_point;
224 if (++after != _events.end()) {
225 iterator far = after;
227 while (far != _events.end()) {
228 if ((*far)->when > when) {
236 _rt_insertion_point = where;
238 if ((*where)->when == when) {
239 (*where)->value = value;
243 where = _events.erase (after, far);
252 iterator previous = _rt_insertion_point;
255 if (_rt_insertion_point != _events.begin() && (*_rt_insertion_point)->value == value && (*previous)->value == value) {
256 (*_rt_insertion_point)->when = when;
263 where = lower_bound (_events.begin(), _events.end(), &cp, time_comparator);
265 if (where != _events.end()) {
266 if ((*where)->when == when) {
267 (*where)->value = value;
274 _rt_insertion_point = _events.insert (where, new ControlEvent (when, value));
281 maybe_signal_changed ();
285 ControlList::fast_simple_add (double when, double value)
287 /* to be used only for loading pre-sorted data from saved state */
288 _events.insert (_events.end(), new ControlEvent (when, value));
289 assert(_events.back());
293 ControlList::add (double when, double value)
295 /* this is for graphical editing */
298 Glib::Mutex::Lock lm (_lock);
299 ControlEvent cp (when, 0.0f);
301 iterator insertion_point;
303 for (insertion_point = lower_bound (_events.begin(), _events.end(), &cp, time_comparator); insertion_point != _events.end(); ++insertion_point) {
305 /* only one point allowed per time point */
307 if ((*insertion_point)->when == when) {
308 (*insertion_point)->value = value;
313 if ((*insertion_point)->when >= when) {
320 _events.insert (insertion_point, new ControlEvent (when, value));
321 reposition_for_rt_add (0);
328 maybe_signal_changed ();
332 ControlList::erase (iterator i)
335 Glib::Mutex::Lock lm (_lock);
337 reposition_for_rt_add (0);
340 maybe_signal_changed ();
344 ControlList::erase (iterator start, iterator end)
347 Glib::Mutex::Lock lm (_lock);
348 _events.erase (start, end);
349 reposition_for_rt_add (0);
352 maybe_signal_changed ();
356 ControlList::reset_range (double start, double endt)
361 Glib::Mutex::Lock lm (_lock);
362 ControlEvent cp (start, 0.0f);
366 if ((s = lower_bound (_events.begin(), _events.end(), &cp, time_comparator)) != _events.end()) {
369 e = upper_bound (_events.begin(), _events.end(), &cp, time_comparator);
371 for (iterator i = s; i != e; ++i) {
372 (*i)->value = _default_value;
382 maybe_signal_changed ();
387 ControlList::erase_range (double start, double endt)
392 Glib::Mutex::Lock lm (_lock);
393 ControlEvent cp (start, 0.0f);
397 if ((s = lower_bound (_events.begin(), _events.end(), &cp, time_comparator)) != _events.end()) {
399 e = upper_bound (_events.begin(), _events.end(), &cp, time_comparator);
400 _events.erase (s, e);
401 reposition_for_rt_add (0);
409 maybe_signal_changed ();
414 ControlList::move_range (iterator start, iterator end, double xdelta, double ydelta)
416 /* note: we assume higher level logic is in place to avoid this
417 reordering the time-order of control events in the list. ie. all
418 points after end are later than (end)->when.
422 Glib::Mutex::Lock lm (_lock);
424 while (start != end) {
425 (*start)->when += xdelta;
426 (*start)->value += ydelta;
427 if (isnan ((*start)->value)) {
434 _events.sort (event_time_less_than);
436 _sort_pending = true;
442 maybe_signal_changed ();
446 ControlList::slide (iterator before, double distance)
449 Glib::Mutex::Lock lm (_lock);
451 if (before == _events.end()) {
455 while (before != _events.end()) {
456 (*before)->when += distance;
461 maybe_signal_changed ();
465 ControlList::modify (iterator iter, double when, double val)
467 /* note: we assume higher level logic is in place to avoid this
468 reordering the time-order of control events in the list. ie. all
469 points after *iter are later than when.
473 Glib::Mutex::Lock lm (_lock);
475 (*iter)->when = when;
476 (*iter)->value = val;
483 _events.sort (event_time_less_than);
485 _sort_pending = true;
491 maybe_signal_changed ();
494 std::pair<ControlList::iterator,ControlList::iterator>
495 ControlList::control_points_adjacent (double xval)
497 Glib::Mutex::Lock lm (_lock);
499 ControlEvent cp (xval, 0.0f);
500 std::pair<iterator,iterator> ret;
502 ret.first = _events.end();
503 ret.second = _events.end();
505 for (i = lower_bound (_events.begin(), _events.end(), &cp, time_comparator); i != _events.end(); ++i) {
507 if (ret.first == _events.end()) {
508 if ((*i)->when >= xval) {
509 if (i != _events.begin()) {
518 if ((*i)->when > xval) {
528 ControlList::set_max_xval (double x)
534 ControlList::freeze ()
549 Glib::Mutex::Lock lm (_lock);
552 _events.sort (event_time_less_than);
553 _sort_pending = false;
559 ControlList::mark_dirty () const
561 _lookup_cache.left = -1;
562 _search_cache.left = -1;
564 _curve->mark_dirty();
568 ControlList::truncate_end (double last_coordinate)
571 Glib::Mutex::Lock lm (_lock);
572 ControlEvent cp (last_coordinate, 0);
573 ControlList::reverse_iterator i;
576 if (_events.empty()) {
580 if (last_coordinate == _events.back()->when) {
584 if (last_coordinate > _events.back()->when) {
589 iterator foo = _events.begin();
592 if (foo == _events.end()) {
594 } else if (++foo == _events.end()) {
601 /* less than 2 points: add a new point */
602 _events.push_back (new ControlEvent (last_coordinate, _events.back()->value));
605 /* more than 2 points: check to see if the last 2 values
606 are equal. if so, just move the position of the
607 last point. otherwise, add a new point.
610 iterator penultimate = _events.end();
611 --penultimate; /* points at last point */
612 --penultimate; /* points at the penultimate point */
614 if (_events.back()->value == (*penultimate)->value) {
615 _events.back()->when = last_coordinate;
617 _events.push_back (new ControlEvent (last_coordinate, _events.back()->value));
625 last_val = unlocked_eval (last_coordinate);
626 last_val = max ((double) _min_yval, last_val);
627 last_val = min ((double) _max_yval, last_val);
629 i = _events.rbegin();
631 /* make i point to the last control point */
635 /* now go backwards, removing control points that are
636 beyond the new last coordinate.
639 // FIXME: SLOW! (size() == O(n))
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 const_iterator length_check_iter = _events.begin();
781 for (npoints = 0; npoints < 4; ++npoints, ++length_check_iter)
782 if (length_check_iter == _events.end())
787 return _default_value;
790 if (x >= _events.front()->when) {
791 return _events.front()->value;
793 // return _default_value;
794 return _events.front()->value;
798 if (x >= _events.back()->when) {
799 return _events.back()->value;
800 } else if (x == _events.front()->when) {
801 return _events.front()->value;
802 } else if (x < _events.front()->when) {
803 // return _default_value;
804 return _events.front()->value;
807 lpos = _events.front()->when;
808 lval = _events.front()->value;
809 upos = _events.back()->when;
810 uval = _events.back()->value;
812 if (_interpolation == Discrete)
815 /* linear interpolation betweeen the two points
818 fraction = (double) (x - lpos) / (double) (upos - lpos);
819 return lval + (fraction * (uval - lval));
823 if (x >= _events.back()->when) {
824 return _events.back()->value;
825 } else if (x == _events.front()->when) {
826 return _events.front()->value;
827 } else if (x < _events.front()->when) {
828 // return _default_value;
829 return _events.front()->value;
832 return multipoint_eval (x);
836 /*NOTREACHED*/ /* stupid gcc */
841 ControlList::multipoint_eval (double x) const
847 /* "Stepped" lookup (no interpolation) */
848 /* FIXME: no cache. significant? */
849 if (_interpolation == Discrete) {
850 const ControlEvent cp (x, 0);
851 EventList::const_iterator i = lower_bound (_events.begin(), _events.end(), &cp, time_comparator);
853 // shouldn't have made it to multipoint_eval
854 assert(i != _events.end());
856 if (i == _events.begin() || (*i)->when == x)
859 return (*(--i))->value;
862 /* Only do the range lookup if x is in a different range than last time
863 * this was called (or if the lookup cache has been marked "dirty" (left<0) */
864 if ((_lookup_cache.left < 0) ||
865 ((_lookup_cache.left > x) ||
866 (_lookup_cache.range.first == _events.end()) ||
867 ((*_lookup_cache.range.second)->when < x))) {
869 const ControlEvent cp (x, 0);
871 _lookup_cache.range = equal_range (_events.begin(), _events.end(), &cp, time_comparator);
874 pair<const_iterator,const_iterator> range = _lookup_cache.range;
876 if (range.first == range.second) {
878 /* x does not exist within the list as a control point */
880 _lookup_cache.left = x;
882 if (range.first != _events.begin()) {
884 lpos = (*range.first)->when;
885 lval = (*range.first)->value;
887 /* we're before the first point */
888 // return _default_value;
889 return _events.front()->value;
892 if (range.second == _events.end()) {
893 /* we're after the last point */
894 return _events.back()->value;
897 upos = (*range.second)->when;
898 uval = (*range.second)->value;
900 /* linear interpolation betweeen the two points
904 fraction = (double) (x - lpos) / (double) (upos - lpos);
905 return lval + (fraction * (uval - lval));
909 /* x is a control point in the data */
910 _lookup_cache.left = -1;
911 return (*range.first)->value;
915 ControlList::build_search_cache_if_necessary(double start, double end) const
917 /* Only do the range lookup if x is in a different range than last time
918 * this was called (or if the search cache has been marked "dirty" (left<0) */
919 if (!_events.empty() && ((_search_cache.left < 0) ||
920 ((_search_cache.left > start) ||
921 (_search_cache.right < end)))) {
923 const ControlEvent start_point (start, 0);
924 const ControlEvent end_point (end, 0);
926 //cerr << "REBUILD: (" << _search_cache.left << ".." << _search_cache.right << ") := ("
927 // << start << ".." << end << ")" << endl;
929 _search_cache.range.first = lower_bound (_events.begin(), _events.end(), &start_point, time_comparator);
930 _search_cache.range.second = upper_bound (_events.begin(), _events.end(), &end_point, time_comparator);
932 _search_cache.left = start;
933 _search_cache.right = end;
937 /** Get the earliest event between \a start and \a end, using the current interpolation style.
939 * If an event is found, \a x and \a y are set to its coordinates.
941 * \param inclusive Include events with timestamp exactly equal to \a start
942 * \return true if event is found (and \a x and \a y are valid).
945 ControlList::rt_safe_earliest_event(double start, double end, double& x, double& y, bool inclusive) const
947 // FIXME: It would be nice if this was unnecessary..
948 Glib::Mutex::Lock lm(_lock, Glib::TRY_LOCK);
953 return rt_safe_earliest_event_unlocked(start, end, x, y, inclusive);
957 /** Get the earliest event between \a start and \a end, using the current interpolation style.
959 * If an event is found, \a x and \a y are set to its coordinates.
961 * \param inclusive Include events with timestamp exactly equal to \a start
962 * \return true if event is found (and \a x and \a y are valid).
965 ControlList::rt_safe_earliest_event_unlocked(double start, double end, double& x, double& y, bool inclusive) const
967 if (_interpolation == Discrete)
968 return rt_safe_earliest_event_discrete_unlocked(start, end, x, y, inclusive);
970 return rt_safe_earliest_event_linear_unlocked(start, end, x, y, inclusive);
974 /** Get the earliest event between \a start and \a end (Discrete (lack of) interpolation)
976 * If an event is found, \a x and \a y are set to its coordinates.
978 * \param inclusive Include events with timestamp exactly equal to \a start
979 * \return true if event is found (and \a x and \a y are valid).
982 ControlList::rt_safe_earliest_event_discrete_unlocked (double start, double end, double& x, double& y, bool inclusive) const
984 build_search_cache_if_necessary(start, end);
986 const pair<const_iterator,const_iterator>& range = _search_cache.range;
988 if (range.first != _events.end()) {
989 const ControlEvent* const first = *range.first;
991 const bool past_start = (inclusive ? first->when >= start : first->when > start);
993 /* Earliest points is in range, return it */
994 if (past_start >= start && first->when < end) {
999 /* Move left of cache to this point
1000 * (Optimize for immediate call this cycle within range) */
1001 _search_cache.left = x;
1002 ++_search_cache.range.first;
1012 /* No points in range */
1018 /** Get the earliest time the line crosses an integer (Linear interpolation).
1020 * If an event is found, \a x and \a y are set to its coordinates.
1022 * \param inclusive Include events with timestamp exactly equal to \a start
1023 * \return true if event is found (and \a x and \a y are valid).
1026 ControlList::rt_safe_earliest_event_linear_unlocked (double start, double end, double& x, double& y, bool inclusive) const
1028 //cerr << "earliest_event(" << start << ", " << end << ", " << x << ", " << y << ", " << inclusive << endl;
1030 const_iterator length_check_iter = _events.begin();
1031 if (_events.empty()) // 0 events
1033 else if (_events.end() == ++length_check_iter) // 1 event
1034 return rt_safe_earliest_event_discrete_unlocked(start, end, x, y, inclusive);
1036 // Hack to avoid infinitely repeating the same event
1037 build_search_cache_if_necessary(start, end);
1039 pair<const_iterator,const_iterator> range = _search_cache.range;
1041 if (range.first != _events.end()) {
1043 const ControlEvent* first = NULL;
1044 const ControlEvent* next = NULL;
1046 /* Step is after first */
1047 if (range.first == _events.begin() || (*range.first)->when == start) {
1048 first = *range.first;
1049 next = *(++range.first);
1050 ++_search_cache.range.first;
1052 /* Step is before first */
1054 const_iterator prev = range.first;
1057 next = *range.first;
1060 if (inclusive && first->when == start) {
1063 /* Move left of cache to this point
1064 * (Optimize for immediate call this cycle within range) */
1065 _search_cache.left = x;
1066 //++_search_cache.range.first;
1067 assert(inclusive ? x >= start : x > start);
1071 if (abs(first->value - next->value) <= 1) {
1072 if (next->when <= end && (!inclusive || next->when > start)) {
1075 /* Move left of cache to this point
1076 * (Optimize for immediate call this cycle within range) */
1077 _search_cache.left = x;
1078 //++_search_cache.range.first;
1079 assert(inclusive ? x >= start : x > start);
1086 const double slope = (next->value - first->value) / (double)(next->when - first->when);
1087 //cerr << "start y: " << start_y << endl;
1089 //y = first->value + (slope * fabs(start - first->when));
1092 if (first->value < next->value) // ramping up
1094 else // ramping down
1097 x = first->when + (y - first->value) / (double)slope;
1099 while ((inclusive && x < start) || (x <= start && y != next->value)) {
1101 if (first->value < next->value) // ramping up
1103 else // ramping down
1106 x = first->when + (y - first->value) / (double)slope;
1109 /*cerr << first->value << " @ " << first->when << " ... "
1110 << next->value << " @ " << next->when
1111 << " = " << y << " @ " << x << endl;*/
1113 assert( (y >= first->value && y <= next->value)
1114 || (y <= first->value && y >= next->value) );
1117 const bool past_start = (inclusive ? x >= start : x > start);
1118 if (past_start && x < end) {
1119 /* Move left of cache to this point
1120 * (Optimize for immediate call this cycle within range) */
1121 _search_cache.left = x;
1122 assert(inclusive ? x >= start : x > start);
1128 /* No points in the future, so no steps (towards them) in the future */
1134 boost::shared_ptr<ControlList>
1135 ControlList::cut (iterator start, iterator end)
1137 boost::shared_ptr<ControlList> nal = create (_parameter);
1140 Glib::Mutex::Lock lm (_lock);
1142 for (iterator x = start; x != end; ) {
1148 nal->_events.push_back (new ControlEvent (**x));
1151 reposition_for_rt_add (0);
1159 maybe_signal_changed ();
1164 boost::shared_ptr<ControlList>
1165 ControlList::cut_copy_clear (double start, double end, int op)
1167 boost::shared_ptr<ControlList> nal = create (_parameter);
1169 ControlEvent cp (start, 0.0);
1170 bool changed = false;
1173 Glib::Mutex::Lock lm (_lock);
1175 if ((s = lower_bound (_events.begin(), _events.end(), &cp, time_comparator)) == _events.end()) {
1180 e = upper_bound (_events.begin(), _events.end(), &cp, time_comparator);
1182 if (op != 2 && (*s)->when != start) {
1183 nal->_events.push_back (new ControlEvent (0, unlocked_eval (start)));
1186 for (iterator x = s; x != e; ) {
1194 /* adjust new points to be relative to start, which
1195 has been set to zero.
1199 nal->_events.push_back (new ControlEvent ((*x)->when - start, (*x)->value));
1209 if (op != 2 && nal->_events.back()->when != end - start) {
1210 nal->_events.push_back (new ControlEvent (end - start, unlocked_eval (end)));
1214 reposition_for_rt_add (0);
1220 maybe_signal_changed ();
1226 boost::shared_ptr<ControlList>
1227 ControlList::copy (iterator start, iterator end)
1229 boost::shared_ptr<ControlList> nal = create (_parameter);
1232 Glib::Mutex::Lock lm (_lock);
1234 for (iterator x = start; x != end; ) {
1240 nal->_events.push_back (new ControlEvent (**x));
1249 boost::shared_ptr<ControlList>
1250 ControlList::cut (double start, double end)
1252 return cut_copy_clear (start, end, 0);
1255 boost::shared_ptr<ControlList>
1256 ControlList::copy (double start, double end)
1258 return cut_copy_clear (start, end, 1);
1262 ControlList::clear (double start, double end)
1264 (void) cut_copy_clear (start, end, 2);
1268 ControlList::paste (ControlList& alist, double pos, float times)
1270 if (alist._events.empty()) {
1275 Glib::Mutex::Lock lm (_lock);
1279 ControlEvent cp (pos, 0.0);
1281 where = upper_bound (_events.begin(), _events.end(), &cp, time_comparator);
1283 for (iterator i = alist.begin();i != alist.end(); ++i) {
1284 _events.insert (where, new ControlEvent( (*i)->when+pos,( *i)->value));
1285 end = (*i)->when + pos;
1289 /* move all points after the insertion along the timeline by
1293 while (where != _events.end()) {
1295 if ((*where)->when <= end) {
1298 _events.erase(where);
1306 reposition_for_rt_add (0);
1310 maybe_signal_changed ();
1314 } // namespace Evoral