Templateify MidiBuffer iterators (avoid code duplication since they're about to get...
[ardour.git] / libs / ardour / processor.cc
index 76c780f2dbba9efffb7fe2f47772dccbe47c509d..a528a4587cc7a4e1d3d97ef297bb5cfdbca22a7d 100644 (file)
@@ -59,7 +59,8 @@ sigc::signal<void,Processor*> Processor::ProcessorCreated;
 const string Processor::state_node_name = "Processor";
 
 Processor::Processor(Session& session, const string& name, Placement p)
-       : Automatable(session, name)
+       : SessionObject(session, name)
+       , AutomatableControls(session)
        , _active(false)
        , _next_ab_is_active(false)
        , _configured(false)
@@ -104,13 +105,6 @@ Processor::set_placement (Placement p)
        }
 }
 
-void
-Processor::set_active (bool yn)
-{
-       _active = yn; 
-       ActiveChanged (); 
-}
-
 XMLNode&
 Processor::get_state (void)
 {
@@ -157,7 +151,7 @@ Processor::state (bool full_state)
 
                XMLNode& automation = Automatable::get_automation_state(); 
                
-               for (set<ParamID>::iterator x = _visible_controls.begin(); x != _visible_controls.end(); ++x) {
+               for (set<Evoral::Parameter>::iterator x = _visible_controls.begin(); x != _visible_controls.end(); ++x) {
                        if (x != _visible_controls.begin()) {
                                sstr << ' ';
                        }
@@ -176,6 +170,8 @@ int
 Processor::set_state (const XMLNode& node)
 {
        const XMLProperty *prop;
+       const XMLProperty *legacy_active = 0;
+       const XMLProperty *legacy_placement = 0;
 
        // may not exist for legacy sessions
        if ((prop = node.property ("name")) != 0) {
@@ -195,7 +191,7 @@ Processor::set_state (const XMLNode& node)
                        if ((prop = (*niter)->property ("path")) != 0) {
                                old_set_automation_state (*(*niter));
                        } else {
-                               set_automation_state (*(*niter), ParamID(PluginAutomation));
+                               set_automation_state (*(*niter), Evoral::Parameter(PluginAutomation));
                        }
 
                        if ((prop = (*niter)->property ("visible")) != 0) {
@@ -211,28 +207,45 @@ Processor::set_state (const XMLNode& node)
                                                break;
                                        }
                                        // FIXME: other automation types?
-                                       mark_automation_visible (ParamID(PluginAutomation, what), true);
+                                       mark_automation_visible (Evoral::Parameter(PluginAutomation, 0, what), true);
                                }
                        }
 
                } else if ((*niter)->name() == "extra") {
                        _extra_xml = new XMLNode (*(*niter));
+               } else if ((*niter)->name() == "Redirect") {
+                       if ( !(legacy_active = (*niter)->property("active"))) {
+                               error << string_compose(_("No %1 property flag in element %2"), "active", (*niter)->name()) << endl;
+                       }
+                       if ( !(legacy_placement = (*niter)->property("placement"))) {
+                               error << string_compose(_("No %1 property flag in element %2"), "placement", (*niter)->name()) << endl;
+                       }
                }
        }
 
        if ((prop = node.property ("active")) == 0) {
-               error << _("XML node describing a processor is missing the `active' field") << endmsg;
-               return -1;
+               warning << _("XML node describing a processor is missing the `active' field, trying legacy active flag from child node") << endmsg;
+               if (legacy_active) {
+                       prop = legacy_active;
+               } else {
+                       error << _("No child node with active property") << endmsg;
+                       return -1;
+               }
        }
 
        if (_active != (prop->value() == "yes")) {
                _active = !_active;
                ActiveChanged (); /* EMIT_SIGNAL */
-       }
-       
+       }       
+
        if ((prop = node.property ("placement")) == 0) {
-               error << _("XML node describing a processor is missing the `placement' field") << endmsg;
-               return -1;
+               warning << _("XML node describing a processor is missing the `placement' field, trying legacy placement flag from child node") << endmsg;
+               if (legacy_placement) {
+                       prop = legacy_placement; 
+               } else {
+                       error << _("No child node with placement property") << endmsg;
+                       return -1;
+               }
        }
 
        /* hack to handle older sessions before we only used EnumWriter */
@@ -253,3 +266,16 @@ Processor::set_state (const XMLNode& node)
        return 0;
 }
 
+bool
+Processor::configure_io (ChanCount in, ChanCount out)
+{
+       /* this class assumes static output stream count.
+          Derived classes must override, and must set "out"
+          to reflect "in" before calling this.
+       */
+
+       _configured_input = in; 
+       _configured = true;
+
+       return true;
+}