2 Copyright (C) 2002 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include <sigc++/bind.h>
27 #include <ardour/parameter.h>
28 #include <ardour/automation_event.h>
29 #include <ardour/curve.h>
30 #include <pbd/stacktrace.h>
35 using namespace ARDOUR;
39 sigc::signal<void,AutomationList *> AutomationList::AutomationListCreated;
41 static bool sort_events_by_time (ControlEvent* a, ControlEvent* b)
43 return a->when < b->when;
47 static void dumpit (const AutomationList& al, string prefix = "")
49 cerr << prefix << &al << endl;
50 for (AutomationList::const_iterator i = al.const_begin(); i != al.const_end(); ++i) {
51 cerr << prefix << '\t' << (*i)->when << ',' << (*i)->value << endl;
57 AutomationList::AutomationList (Parameter id, double min_val, double max_val, double default_val)
59 , _curve(new Curve(*this))
63 _changed_when_thawed = false;
69 _max_xval = 0; // means "no limit"
70 _default_value = default_val;
71 _rt_insertion_point = _events.end();
72 _lookup_cache.left = -1;
73 _lookup_cache.range.first = _events.end();
74 _search_cache.left = -1;
75 _search_cache.range.first = _events.end();
76 _sort_pending = false;
78 assert(_parameter.type() != NullAutomation);
79 AutomationListCreated(this);
82 AutomationList::AutomationList (const AutomationList& other)
83 : _parameter(other._parameter)
84 , _curve(new Curve(*this))
87 _changed_when_thawed = false;
88 _style = other._style;
89 _min_yval = other._min_yval;
90 _max_yval = other._max_yval;
91 _max_xval = other._max_xval;
92 _default_value = other._default_value;
93 _state = other._state;
94 _touching = other._touching;
95 _rt_insertion_point = _events.end();
96 _lookup_cache.range.first = _events.end();
97 _search_cache.range.first = _events.end();
98 _sort_pending = false;
100 for (const_iterator i = other._events.begin(); i != other._events.end(); ++i) {
101 _events.push_back (new ControlEvent (**i));
105 assert(_parameter.type() != NullAutomation);
106 AutomationListCreated(this);
109 AutomationList::AutomationList (const AutomationList& other, double start, double end)
110 : _parameter(other._parameter)
111 , _curve(new Curve(*this))
114 _changed_when_thawed = false;
115 _style = other._style;
116 _min_yval = other._min_yval;
117 _max_yval = other._max_yval;
118 _max_xval = other._max_xval;
119 _default_value = other._default_value;
120 _state = other._state;
121 _touching = other._touching;
122 _rt_insertion_point = _events.end();
123 _lookup_cache.range.first = _events.end();
124 _search_cache.range.first = _events.end();
125 _sort_pending = false;
127 /* now grab the relevant points, and shift them back if necessary */
129 AutomationList* section = const_cast<AutomationList*>(&other)->copy (start, end);
131 if (!section->empty()) {
132 for (iterator i = section->begin(); i != section->end(); ++i) {
133 _events.push_back (new ControlEvent ((*i)->when, (*i)->value));
141 assert(_parameter.type() != NullAutomation);
142 AutomationListCreated(this);
145 /** \a id is used for legacy sessions where the type is not present
146 * in or below the <AutomationList> node. It is used if \a id is non-null.
148 AutomationList::AutomationList (const XMLNode& node, Parameter id)
149 : _curve(new Curve(*this))
152 _changed_when_thawed = false;
156 _max_xval = 0; // means "no limit"
159 _rt_insertion_point = _events.end();
160 _lookup_cache.range.first = _events.end();
161 _search_cache.range.first = _events.end();
162 _sort_pending = false;
169 assert(_parameter.type() != NullAutomation);
170 AutomationListCreated(this);
173 AutomationList::~AutomationList()
177 for (EventList::iterator x = _events.begin(); x != _events.end(); ++x) {
183 AutomationList::operator== (const AutomationList& other)
185 return _events == other._events;
189 AutomationList::operator= (const AutomationList& other)
191 if (this != &other) {
195 for (const_iterator i = other._events.begin(); i != other._events.end(); ++i) {
196 _events.push_back (new ControlEvent (**i));
199 _min_yval = other._min_yval;
200 _max_yval = other._max_yval;
201 _max_xval = other._max_xval;
202 _default_value = other._default_value;
205 maybe_signal_changed ();
212 AutomationList::maybe_signal_changed ()
217 _changed_when_thawed = true;
224 AutomationList::set_automation_state (AutoState s)
228 automation_state_changed (); /* EMIT SIGNAL */
233 AutomationList::set_automation_style (AutoStyle s)
237 automation_style_changed (); /* EMIT SIGNAL */
242 AutomationList::start_touch ()
249 AutomationList::stop_touch ()
256 AutomationList::clear ()
259 Glib::Mutex::Lock lm (_lock);
264 maybe_signal_changed ();
268 AutomationList::x_scale (double factor)
270 Glib::Mutex::Lock lm (_lock);
275 AutomationList::extend_to (double when)
277 Glib::Mutex::Lock lm (_lock);
278 if (_events.empty() || _events.back()->when == when) {
281 double factor = when / _events.back()->when;
286 void AutomationList::_x_scale (double factor)
288 for (iterator i = _events.begin(); i != _events.end(); ++i) {
289 (*i)->when = floor ((*i)->when * factor);
296 AutomationList::reposition_for_rt_add (double when)
298 _rt_insertion_point = _events.end();
302 AutomationList::rt_add (double when, double value)
304 /* this is for automation recording */
306 if ((_state & Touch) && !_touching) {
310 // cerr << "RT: alist @ " << this << " add " << value << " @ " << when << endl;
313 Glib::Mutex::Lock lm (_lock);
317 ControlEvent cp (when, 0.0);
320 if ((_rt_insertion_point != _events.end()) && ((*_rt_insertion_point)->when < when) ) {
322 /* we have a previous insertion point, so we should delete
323 everything between it and the position where we are going
324 to insert this point.
327 iterator after = _rt_insertion_point;
329 if (++after != _events.end()) {
330 iterator far = after;
332 while (far != _events.end()) {
333 if ((*far)->when > when) {
341 _rt_insertion_point = where;
343 if ((*where)->when == when) {
344 (*where)->value = value;
348 where = _events.erase (after, far);
357 iterator previous = _rt_insertion_point;
360 if (_rt_insertion_point != _events.begin() && (*_rt_insertion_point)->value == value && (*previous)->value == value) {
361 (*_rt_insertion_point)->when = when;
368 where = lower_bound (_events.begin(), _events.end(), &cp, cmp);
370 if (where != _events.end()) {
371 if ((*where)->when == when) {
372 (*where)->value = value;
379 _rt_insertion_point = _events.insert (where, new ControlEvent (when, value));
386 maybe_signal_changed ();
390 AutomationList::fast_simple_add (double when, double value)
392 /* to be used only for loading pre-sorted data from saved state */
393 _events.insert (_events.end(), new ControlEvent (when, value));
397 AutomationList::add (double when, double value)
399 /* this is for graphical editing */
402 Glib::Mutex::Lock lm (_lock);
404 ControlEvent cp (when, 0.0f);
406 iterator insertion_point;
408 for (insertion_point = lower_bound (_events.begin(), _events.end(), &cp, cmp); insertion_point != _events.end(); ++insertion_point) {
410 /* only one point allowed per time point */
412 if ((*insertion_point)->when == when) {
413 (*insertion_point)->value = value;
418 if ((*insertion_point)->when >= when) {
425 _events.insert (insertion_point, new ControlEvent (when, value));
426 reposition_for_rt_add (0);
433 maybe_signal_changed ();
437 AutomationList::erase (iterator i)
440 Glib::Mutex::Lock lm (_lock);
442 reposition_for_rt_add (0);
445 maybe_signal_changed ();
449 AutomationList::erase (iterator start, iterator end)
452 Glib::Mutex::Lock lm (_lock);
453 _events.erase (start, end);
454 reposition_for_rt_add (0);
457 maybe_signal_changed ();
461 AutomationList::reset_range (double start, double endt)
466 Glib::Mutex::Lock lm (_lock);
468 ControlEvent cp (start, 0.0f);
472 if ((s = lower_bound (_events.begin(), _events.end(), &cp, cmp)) != _events.end()) {
475 e = upper_bound (_events.begin(), _events.end(), &cp, cmp);
477 for (iterator i = s; i != e; ++i) {
478 (*i)->value = _default_value;
488 maybe_signal_changed ();
493 AutomationList::erase_range (double start, double endt)
498 Glib::Mutex::Lock lm (_lock);
500 ControlEvent cp (start, 0.0f);
504 if ((s = lower_bound (_events.begin(), _events.end(), &cp, cmp)) != _events.end()) {
506 e = upper_bound (_events.begin(), _events.end(), &cp, cmp);
507 _events.erase (s, e);
508 reposition_for_rt_add (0);
516 maybe_signal_changed ();
521 AutomationList::move_range (iterator start, iterator end, double xdelta, double ydelta)
523 /* note: we assume higher level logic is in place to avoid this
524 reordering the time-order of control events in the list. ie. all
525 points after end are later than (end)->when.
529 Glib::Mutex::Lock lm (_lock);
531 while (start != end) {
532 (*start)->when += xdelta;
533 (*start)->value += ydelta;
534 if (isnan ((*start)->value)) {
541 _events.sort (sort_events_by_time);
543 _sort_pending = true;
549 maybe_signal_changed ();
553 AutomationList::slide (iterator before, double distance)
556 Glib::Mutex::Lock lm (_lock);
558 if (before == _events.end()) {
562 while (before != _events.end()) {
563 (*before)->when += distance;
568 maybe_signal_changed ();
572 AutomationList::modify (iterator iter, double when, double val)
574 /* note: we assume higher level logic is in place to avoid this
575 reordering the time-order of control events in the list. ie. all
576 points after *iter are later than when.
580 Glib::Mutex::Lock lm (_lock);
582 (*iter)->when = when;
583 (*iter)->value = val;
590 _events.sort (sort_events_by_time);
592 _sort_pending = true;
598 maybe_signal_changed ();
601 std::pair<AutomationList::iterator,AutomationList::iterator>
602 AutomationList::control_points_adjacent (double xval)
604 Glib::Mutex::Lock lm (_lock);
607 ControlEvent cp (xval, 0.0f);
608 std::pair<iterator,iterator> ret;
610 ret.first = _events.end();
611 ret.second = _events.end();
613 for (i = lower_bound (_events.begin(), _events.end(), &cp, cmp); i != _events.end(); ++i) {
615 if (ret.first == _events.end()) {
616 if ((*i)->when >= xval) {
617 if (i != _events.begin()) {
626 if ((*i)->when > xval) {
636 AutomationList::freeze ()
642 AutomationList::thaw ()
645 PBD::stacktrace (cerr);
646 fatal << string_compose (_("programming error: %1"), X_("AutomationList::thaw() called while not frozen")) << endmsg;
655 Glib::Mutex::Lock lm (_lock);
658 _events.sort (sort_events_by_time);
659 _sort_pending = false;
663 if (_changed_when_thawed) {
664 StateChanged(); /* EMIT SIGNAL */
669 AutomationList::set_max_xval (double x)
675 AutomationList::mark_dirty ()
677 _lookup_cache.left = -1;
678 _search_cache.left = -1;
679 Dirty (); /* EMIT SIGNAL */
683 AutomationList::truncate_end (double last_coordinate)
686 Glib::Mutex::Lock lm (_lock);
687 ControlEvent cp (last_coordinate, 0);
688 list<ControlEvent*>::reverse_iterator i;
691 if (_events.empty()) {
695 if (last_coordinate == _events.back()->when) {
699 if (last_coordinate > _events.back()->when) {
704 iterator foo = _events.begin();
707 if (foo == _events.end()) {
709 } else if (++foo == _events.end()) {
716 /* less than 2 points: add a new point */
717 _events.push_back (new ControlEvent (last_coordinate, _events.back()->value));
720 /* more than 2 points: check to see if the last 2 values
721 are equal. if so, just move the position of the
722 last point. otherwise, add a new point.
725 iterator penultimate = _events.end();
726 --penultimate; /* points at last point */
727 --penultimate; /* points at the penultimate point */
729 if (_events.back()->value == (*penultimate)->value) {
730 _events.back()->when = last_coordinate;
732 _events.push_back (new ControlEvent (last_coordinate, _events.back()->value));
740 last_val = unlocked_eval (last_coordinate);
741 last_val = max ((double) _min_yval, last_val);
742 last_val = min ((double) _max_yval, last_val);
744 i = _events.rbegin();
746 /* make i point to the last control point */
750 /* now go backwards, removing control points that are
751 beyond the new last coordinate.
754 uint32_t sz = _events.size();
756 while (i != _events.rend() && sz > 2) {
757 list<ControlEvent*>::reverse_iterator tmp;
762 if ((*i)->when < last_coordinate) {
766 _events.erase (i.base());
772 _events.back()->when = last_coordinate;
773 _events.back()->value = last_val;
776 reposition_for_rt_add (0);
780 maybe_signal_changed ();
784 AutomationList::truncate_start (double overall_length)
787 Glib::Mutex::Lock lm (_lock);
789 double first_legal_value;
790 double first_legal_coordinate;
792 if (_events.empty()) {
793 fatal << _("programming error:")
794 << "AutomationList::truncate_start() called on an empty list"
800 if (overall_length == _events.back()->when) {
801 /* no change in overall length */
805 if (overall_length > _events.back()->when) {
807 /* growing at front: duplicate first point. shift all others */
809 double shift = overall_length - _events.back()->when;
812 for (np = 0, i = _events.begin(); i != _events.end(); ++i, ++np) {
818 /* less than 2 points: add a new point */
819 _events.push_front (new ControlEvent (0, _events.front()->value));
823 /* more than 2 points: check to see if the first 2 values
824 are equal. if so, just move the position of the
825 first point. otherwise, add a new point.
828 iterator second = _events.begin();
829 ++second; /* points at the second point */
831 if (_events.front()->value == (*second)->value) {
832 /* first segment is flat, just move start point back to zero */
833 _events.front()->when = 0;
835 /* leave non-flat segment in place, add a new leading point. */
836 _events.push_front (new ControlEvent (0, _events.front()->value));
842 /* shrinking at front */
844 first_legal_coordinate = _events.back()->when - overall_length;
845 first_legal_value = unlocked_eval (first_legal_coordinate);
846 first_legal_value = max (_min_yval, first_legal_value);
847 first_legal_value = min (_max_yval, first_legal_value);
849 /* remove all events earlier than the new "front" */
853 while (i != _events.end() && !_events.empty()) {
854 list<ControlEvent*>::iterator tmp;
859 if ((*i)->when > first_legal_coordinate) {
869 /* shift all remaining points left to keep their same
873 for (i = _events.begin(); i != _events.end(); ++i) {
874 (*i)->when -= first_legal_coordinate;
877 /* add a new point for the interpolated new value */
879 _events.push_front (new ControlEvent (0, first_legal_value));
882 reposition_for_rt_add (0);
887 maybe_signal_changed ();
891 AutomationList::unlocked_eval (double x) const
893 pair<EventList::iterator,EventList::iterator> range;
899 npoints = _events.size();
903 return _default_value;
906 if (x >= _events.front()->when) {
907 return _events.front()->value;
909 // return _default_value;
910 return _events.front()->value;
914 if (x >= _events.back()->when) {
915 return _events.back()->value;
916 } else if (x == _events.front()->when) {
917 return _events.front()->value;
918 } else if (x < _events.front()->when) {
919 // return _default_value;
920 return _events.front()->value;
923 lpos = _events.front()->when;
924 lval = _events.front()->value;
925 upos = _events.back()->when;
926 uval = _events.back()->value;
928 /* linear interpolation betweeen the two points
931 fraction = (double) (x - lpos) / (double) (upos - lpos);
932 return lval + (fraction * (uval - lval));
936 if (x >= _events.back()->when) {
937 return _events.back()->value;
938 } else if (x == _events.front()->when) {
939 return _events.front()->value;
940 } else if (x < _events.front()->when) {
941 // return _default_value;
942 return _events.front()->value;
945 return multipoint_eval (x);
951 AutomationList::multipoint_eval (double x) const
957 /* Only do the range lookup if x is in a different range than last time
958 * this was called (or if the lookup cache has been marked "dirty" (left<0) */
959 if ((_lookup_cache.left < 0) ||
960 ((_lookup_cache.left > x) ||
961 (_lookup_cache.range.first == _events.end()) ||
962 ((*_lookup_cache.range.second)->when < x))) {
964 const ControlEvent cp (x, 0);
967 _lookup_cache.range = equal_range (_events.begin(), _events.end(), &cp, cmp);
970 pair<const_iterator,const_iterator> range = _lookup_cache.range;
972 if (range.first == range.second) {
974 /* x does not exist within the list as a control point */
976 _lookup_cache.left = x;
978 if (range.first != _events.begin()) {
980 lpos = (*range.first)->when;
981 lval = (*range.first)->value;
983 /* we're before the first point */
984 // return _default_value;
985 return _events.front()->value;
988 if (range.second == _events.end()) {
989 /* we're after the last point */
990 return _events.back()->value;
993 upos = (*range.second)->when;
994 uval = (*range.second)->value;
996 /* linear interpolation betweeen the two points
1000 fraction = (double) (x - lpos) / (double) (upos - lpos);
1001 return lval + (fraction * (uval - lval));
1005 /* x is a control point in the data */
1006 _lookup_cache.left = -1;
1007 return (*range.first)->value;
1010 /** Get the earliest event between \a start and \a end.
1012 * If an event is found, \a x and \a y are set to its coordinates.
1013 * \return true if event is found (and \a x and \a y are valid).
1016 AutomationList::rt_safe_earliest_event (double start, double end, double& x, double& y) const
1018 // FIXME: It would be nice if this was unnecessary..
1019 Glib::Mutex::Lock lm(_lock, Glib::TRY_LOCK);
1024 /* Only do the range lookup if x is in a different range than last time
1025 * this was called (or if the search cache has been marked "dirty" (left<0) */
1026 if ((_search_cache.left < 0) ||
1027 ((_search_cache.left > start) ||
1028 (_search_cache.right < end))) {
1030 const ControlEvent start_point (start, 0);
1031 const ControlEvent end_point (end, 0);
1034 //cerr << "REBUILD: (" << _search_cache.left << ".." << _search_cache.right << ") -> ("
1035 // << start << ".." << end << ")" << endl;
1037 _search_cache.range.first = lower_bound (_events.begin(), _events.end(), &start_point, cmp);
1038 _search_cache.range.second = upper_bound (_events.begin(), _events.end(), &end_point, cmp);
1040 _search_cache.left = start;
1041 _search_cache.right = end;
1044 pair<const_iterator,const_iterator> range = _search_cache.range;
1046 if (range.first != _events.end()) {
1047 const ControlEvent* const first = *range.first;
1049 /* Earliest points is in range, return it */
1050 if (first->when >= start && first->when < end) {
1055 /* Move left of cache to this point
1056 * (Optimize for immediate call this cycle within range) */
1057 _search_cache.left = x;
1058 ++_search_cache.range.first;
1069 /* No points in range */
1076 AutomationList::cut (iterator start, iterator end)
1078 AutomationList* nal = new AutomationList (_parameter, _min_yval, _max_yval, _default_value);
1081 Glib::Mutex::Lock lm (_lock);
1083 for (iterator x = start; x != end; ) {
1089 nal->_events.push_back (new ControlEvent (**x));
1092 reposition_for_rt_add (0);
1100 maybe_signal_changed ();
1106 AutomationList::cut_copy_clear (double start, double end, int op)
1108 AutomationList* nal = new AutomationList (_parameter, _min_yval, _max_yval, _default_value);
1110 ControlEvent cp (start, 0.0);
1112 bool changed = false;
1115 Glib::Mutex::Lock lm (_lock);
1117 if ((s = lower_bound (_events.begin(), _events.end(), &cp, cmp)) == _events.end()) {
1122 e = upper_bound (_events.begin(), _events.end(), &cp, cmp);
1124 if (op != 2 && (*s)->when != start) {
1125 nal->_events.push_back (new ControlEvent (0, unlocked_eval (start)));
1128 for (iterator x = s; x != e; ) {
1136 /* adjust new points to be relative to start, which
1137 has been set to zero.
1141 nal->_events.push_back (new ControlEvent ((*x)->when - start, (*x)->value));
1151 if (op != 2 && nal->_events.back()->when != end - start) {
1152 nal->_events.push_back (new ControlEvent (end - start, unlocked_eval (end)));
1156 reposition_for_rt_add (0);
1162 maybe_signal_changed ();
1169 AutomationList::copy (iterator start, iterator end)
1171 AutomationList* nal = new AutomationList (_parameter, _min_yval, _max_yval, _default_value);
1174 Glib::Mutex::Lock lm (_lock);
1176 for (iterator x = start; x != end; ) {
1182 nal->_events.push_back (new ControlEvent (**x));
1192 AutomationList::cut (double start, double end)
1194 return cut_copy_clear (start, end, 0);
1198 AutomationList::copy (double start, double end)
1200 return cut_copy_clear (start, end, 1);
1204 AutomationList::clear (double start, double end)
1206 (void) cut_copy_clear (start, end, 2);
1210 AutomationList::paste (AutomationList& alist, double pos, float times)
1212 if (alist._events.empty()) {
1217 Glib::Mutex::Lock lm (_lock);
1221 ControlEvent cp (pos, 0.0);
1224 where = upper_bound (_events.begin(), _events.end(), &cp, cmp);
1226 for (iterator i = alist.begin();i != alist.end(); ++i) {
1227 _events.insert (where, new ControlEvent( (*i)->when+pos,( *i)->value));
1228 end = (*i)->when + pos;
1232 /* move all points after the insertion along the timeline by
1236 while (where != _events.end()) {
1238 if ((*where)->when <= end) {
1241 _events.erase(where);
1249 reposition_for_rt_add (0);
1253 maybe_signal_changed ();
1258 AutomationList::get_state ()
1260 return state (true);
1264 AutomationList::state (bool full)
1266 XMLNode* root = new XMLNode (X_("AutomationList"));
1268 LocaleGuard lg (X_("POSIX"));
1270 root->add_property ("automation-id", _parameter.to_string());
1272 root->add_property ("id", _id.to_s());
1274 snprintf (buf, sizeof (buf), "%.12g", _default_value);
1275 root->add_property ("default", buf);
1276 snprintf (buf, sizeof (buf), "%.12g", _min_yval);
1277 root->add_property ("min_yval", buf);
1278 snprintf (buf, sizeof (buf), "%.12g", _max_yval);
1279 root->add_property ("max_yval", buf);
1280 snprintf (buf, sizeof (buf), "%.12g", _max_xval);
1281 root->add_property ("max_xval", buf);
1284 root->add_property ("state", auto_state_to_string (_state));
1286 /* never save anything but Off for automation state to a template */
1287 root->add_property ("state", auto_state_to_string (Off));
1290 root->add_property ("style", auto_style_to_string (_style));
1292 if (!_events.empty()) {
1293 root->add_child_nocopy (serialize_events());
1300 AutomationList::serialize_events ()
1302 XMLNode* node = new XMLNode (X_("events"));
1305 for (iterator xx = _events.begin(); xx != _events.end(); ++xx) {
1306 str << (double) (*xx)->when;
1308 str <<(double) (*xx)->value;
1312 /* XML is a bit wierd */
1314 XMLNode* content_node = new XMLNode (X_("foo")); /* it gets renamed by libxml when we set content */
1315 content_node->set_content (str.str());
1317 node->add_child_nocopy (*content_node);
1323 AutomationList::deserialize_events (const XMLNode& node)
1325 if (node.children().empty()) {
1329 XMLNode* content_node = node.children().front();
1331 if (content_node->content().empty()) {
1338 stringstream str (content_node->content());
1354 fast_simple_add (x, y);
1359 error << _("automation list: cannot load coordinates from XML, all points ignored") << endmsg;
1362 reposition_for_rt_add (0);
1363 maybe_signal_changed ();
1372 AutomationList::set_state (const XMLNode& node)
1374 XMLNodeList nlist = node.children();
1376 XMLNodeIterator niter;
1377 const XMLProperty* prop;
1379 if (node.name() == X_("events")) {
1380 /* partial state setting*/
1381 return deserialize_events (node);
1384 if (node.name() == X_("Envelope") || node.name() == X_("FadeOut") || node.name() == X_("FadeIn")) {
1386 if ((nsos = node.child (X_("AutomationList")))) {
1387 /* new school in old school clothing */
1388 return set_state (*nsos);
1393 const XMLNodeList& elist = node.children();
1394 XMLNodeConstIterator i;
1402 for (i = elist.begin(); i != elist.end(); ++i) {
1404 if ((prop = (*i)->property ("x")) == 0) {
1405 error << _("automation list: no x-coordinate stored for control point (point ignored)") << endmsg;
1408 x = atoi (prop->value().c_str());
1410 if ((prop = (*i)->property ("y")) == 0) {
1411 error << _("automation list: no y-coordinate stored for control point (point ignored)") << endmsg;
1414 y = atof (prop->value().c_str());
1416 fast_simple_add (x, y);
1424 if (node.name() != X_("AutomationList") ) {
1425 error << string_compose (_("AutomationList: passed XML node called %1, not \"AutomationList\" - ignored"), node.name()) << endmsg;
1429 if ((prop = node.property ("id")) != 0) {
1430 _id = prop->value ();
1431 /* update session AL list */
1432 AutomationListCreated(this);
1435 if ((prop = node.property (X_("automation-id"))) != 0){
1436 _parameter = Parameter(prop->value());
1438 warning << "Legacy session: automation list has no automation-id property.";
1441 if ((prop = node.property (X_("default"))) != 0){
1442 _default_value = atof (prop->value().c_str());
1444 _default_value = 0.0;
1447 if ((prop = node.property (X_("style"))) != 0) {
1448 _style = string_to_auto_style (prop->value());
1453 if ((prop = node.property (X_("state"))) != 0) {
1454 _state = string_to_auto_state (prop->value());
1459 if ((prop = node.property (X_("min_yval"))) != 0) {
1460 _min_yval = atof (prop->value ().c_str());
1462 _min_yval = FLT_MIN;
1465 if ((prop = node.property (X_("max_yval"))) != 0) {
1466 _max_yval = atof (prop->value ().c_str());
1468 _max_yval = FLT_MAX;
1471 if ((prop = node.property (X_("max_xval"))) != 0) {
1472 _max_xval = atof (prop->value ().c_str());
1474 _max_xval = 0; // means "no limit ;
1477 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
1478 if ((*niter)->name() == X_("events")) {
1479 deserialize_events (*(*niter));