int
AutomationList::set_state (const XMLNode& node)
{
- const XMLNodeList& elist = node.children();
- XMLNodeConstIterator i;
- XMLProperty* prop;
+ if (node.name() != X_("events")) {
+ warning << _("automation list: passed XML node not called \"events\" - ignored.") << endmsg;
+ return -1;
+ }
freeze ();
-
clear ();
-
- for (i = elist.begin(); i != elist.end(); ++i) {
-
- if ((*i)->name() == X_("events")) {
- /* new style */
-
- if (!node.content().empty()) {
-
- stringstream str (node.content());
-
- double x;
- double y;
- bool ok = true;
-
-
- while (str) {
- str >> x;
- if (!str) {
- ok = false;
- break;
- }
- str >> y;
- if (!str) {
- ok = false;
- break;
- }
- add (x, y);
- }
-
- if (!ok) {
- clear ();
- error << _("automation list: cannot load coordinates from XML, all points ignored") << endmsg;
- }
- }
-
- } else {
-
- /* old style */
-
- nframes_t x;
- double y;
-
- if ((prop = (*i)->property ("x")) == 0) {
- error << _("automation list: no x-coordinate stored for control point (point ignored)") << endmsg;
- continue;
+ if (!node.content().empty()) {
+
+ stringstream str (node.content());
+
+ double x;
+ double y;
+ bool ok = true;
+
+ while (str) {
+ str >> x;
+ if (!str) {
+ ok = false;
+ break;
}
- x = atoi (prop->value().c_str());
-
- if ((prop = (*i)->property ("y")) == 0) {
- error << _("automation list: no y-coordinate stored for control point (point ignored)") << endmsg;
- continue;
+ str >> y;
+ if (!str) {
+ ok = false;
+ break;
}
- y = atof (prop->value().c_str());
-
add (x, y);
}
+
+ if (!ok) {
+ clear ();
+ error << _("automation list: cannot load coordinates from XML, all points ignored") << endmsg;
+ }
}
thaw ();
}
if ((*iter)->name() == X_("Automation")) {
- set_automation_state (*(*iter));
+
+ set_automation_state (*(*iter)->children().front());
}
if ((*iter)->name() == X_("gaincontrol")) {
int
IO::set_automation_state (const XMLNode& node)
{
- /* IO has only one automation sub-node, and it should always be the
- first one (i.e. derived classes should always call
- IO::set_automation_state() if they need the IO's automation
- state. Note that Plugin + Insert Redirects do not need this, so they
- don't call it at all, though Sends do.
- */
-
- return _gain_automation_curve.set_state (*node.children().front());
+ return _gain_automation_curve.set_state (node);
}
XMLNode&
if ((*iter)->name() == X_("panner")) {
_control.set_state (**iter);
} else if ((*iter)->name() == X_("Automation")) {
- _automation.set_state (**iter);
+ _automation.set_state (*((*iter)->children().front()));
}
}
XMLNode* root = new XMLNode (X_("Panner"));
char buf[32];
- for (iterator p = begin(); p != end(); ++p) {
- root->add_child_nocopy ((*p)->state (full));
- }
-
root->add_property (X_("linked"), (_linked ? "yes" : "no"));
snprintf (buf, sizeof (buf), "%d", _link_direction);
root->add_property (X_("link_direction"), buf);