new automation state model, sort of working, but not really
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 27 Oct 2006 02:45:45 +0000 (02:45 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 27 Oct 2006 02:45:45 +0000 (02:45 +0000)
git-svn-id: svn://localhost/ardour2/trunk@1031 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/automation_event.cc
libs/ardour/io.cc
libs/ardour/panner.cc

index 50c429ca7009610db1632ba2bc81992344fa12b1..f94a1f7cc3658b68181d73df4384a5359a7078a8 100644 (file)
@@ -1141,70 +1141,40 @@ AutomationList::get_state ()
 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 ();
index 38259c97e8e0284ee0e4106d4813ea1ef739f8ef..6cc279a046ffa7d496aa022f26ce077674dcad11 100644 (file)
@@ -1589,7 +1589,8 @@ IO::set_state (const XMLNode& node)
                }
 
                if ((*iter)->name() == X_("Automation")) {
-                       set_automation_state (*(*iter));
+
+                       set_automation_state (*(*iter)->children().front());
                }
 
                if ((*iter)->name() == X_("gaincontrol")) {
@@ -1649,14 +1650,7 @@ IO::set_state (const XMLNode& node)
 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&
index 6d9faa92b712bd802386508143e63efe9d603e69..faf2e03e2f33bf730c891aadea047912cdeee68e 100644 (file)
@@ -511,7 +511,7 @@ EqualPowerStereoPanner::set_state (const XMLNode& node)
                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()));
                }
        }
        
@@ -1028,10 +1028,6 @@ Panner::state (bool full)
        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);