step editing now accessed via a context menu on MIDI track rec-enable buttons. along...
[ardour.git] / libs / ardour / plugin_insert.cc
index 2ad4d4b350ffed899ee11409ec3b806fff103a3a..f50483beaf2e143f18424c439d5543f34766b67e 100644 (file)
@@ -62,35 +62,16 @@ using namespace PBD;
 const string PluginInsert::port_automation_node_name = "PortAutomation";
 
 PluginInsert::PluginInsert (Session& s, boost::shared_ptr<Plugin> plug)
-       : Processor (s, plug->name())
+       : Processor (s, (plug ? plug->name() : string ("toBeRenamed")))
        , _signal_analysis_collected_nframes(0)
        , _signal_analysis_collect_nframes_max(0)
 {
        /* the first is the master */
 
-       _plugins.push_back (plug);
-       set_automatable ();
+        if (plug) {
+                _plugins.push_back (plug);
+                set_automatable ();
 
-       {
-               Glib::Mutex::Lock em (_session.engine().process_lock());
-               IO::PortCountChanged (max(input_streams(), output_streams()));
-       }
-
-       ProcessorCreated (this); /* EMIT SIGNAL */
-}
-
-PluginInsert::PluginInsert (Session& s, const XMLNode& node)
-       : Processor (s, "unnamed plugin insert"),
-          _signal_analysis_collected_nframes(0),
-          _signal_analysis_collect_nframes_max(0)
-{
-       if (set_state (node, Stateful::loading_state_version)) {
-               throw failed_constructor();
-       }
-
-       _pending_active = _active;
-
-       {
                Glib::Mutex::Lock em (_session.engine().process_lock());
                IO::PortCountChanged (max(input_streams(), output_streams()));
        }
@@ -798,8 +779,11 @@ PluginInsert::set_state(const XMLNode& node, int version)
                set_automatable ();
        }
 
+       /* Handle the node list for this Processor (or Insert if an A2 session) */
        for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
+
                if ((*niter)->name() == plugin->state_node_name()) {
+
                        for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i) {
                                (*i)->set_state (**niter, version);
                        }
@@ -807,7 +791,10 @@ PluginInsert::set_state(const XMLNode& node, int version)
                }
        }
 
+        Processor::set_state (node, version);
+
        if (version < 3000) {
+
                for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
                        if ((*niter)->name() == "Redirect") {
                                /* XXX do we need to tackle placement? i think not (pd; oct 16 2009) */
@@ -815,15 +802,24 @@ PluginInsert::set_state(const XMLNode& node, int version)
                                break;
                        }
                }
+               
                set_parameter_state_2X (node, version);
+               
        } else {
-               Processor::set_state (node, version);
+
                set_parameter_state (node, version);
        }
 
        // The name of the PluginInsert comes from the plugin, nothing else
        _name = plugin->get_info()->name;
 
+        /* catch up on I/O */
+
+       {
+               Glib::Mutex::Lock em (_session.engine().process_lock());
+               IO::PortCountChanged (max(input_streams(), output_streams()));
+       }
+
        return 0;
 }
 
@@ -910,7 +906,7 @@ PluginInsert::set_parameter_state_2X (const XMLNode& node, int version)
                
                cnodes = (*niter)->children ("port");
                
-               for(iter = cnodes.begin(); iter != cnodes.end(); ++iter){
+               for (iter = cnodes.begin(); iter != cnodes.end(); ++iter){
                        
                        child = *iter;
                        
@@ -969,30 +965,7 @@ PluginInsert::signal_latency() const
 ARDOUR::PluginType
 PluginInsert::type ()
 {
-       boost::shared_ptr<LadspaPlugin> lp;
-#ifdef VST_SUPPORT
-       boost::shared_ptr<VSTPlugin> vp;
-#endif
-#ifdef HAVE_AUDIOUNITS
-       boost::shared_ptr<AUPlugin> ap;
-#endif
-
-       PluginPtr other = plugin ();
-
-       if ((lp = boost::dynamic_pointer_cast<LadspaPlugin> (other)) != 0) {
-               return ARDOUR::LADSPA;
-#ifdef VST_SUPPORT
-       } else if ((vp = boost::dynamic_pointer_cast<VSTPlugin> (other)) != 0) {
-               return ARDOUR::VST;
-#endif
-#ifdef HAVE_AUDIOUNITS
-       } else if ((ap = boost::dynamic_pointer_cast<AUPlugin> (other)) != 0) {
-               return ARDOUR::AudioUnit;
-#endif
-       } else {
-               /* NOT REACHED */
-               return (ARDOUR::PluginType) 0;
-       }
+       return plugin()->get_info()->type;
 }
 
 PluginInsert::PluginControl::PluginControl (PluginInsert* p, const Evoral::Parameter &param, boost::shared_ptr<AutomationList> list)