Fix setting Plugin-Owner (route) for analysis plugins
[ardour.git] / libs / ardour / plugin_insert.cc
index b4152d81e19a54d7e9a43fac464e0619cd640712..7196a6d8445df0063e1a69dc3258e7b9a0a27d79 100644 (file)
@@ -490,6 +490,21 @@ PluginInsert::create_automatable_parameters ()
 
        _bypass_port = plugin->designated_bypass_port ();
 
+       /* special case VST effSetBypass */
+       if (_bypass_port == UINT32_MAX -1) {
+               // emulate VST Bypass
+               Evoral::Parameter param (PluginAutomation, 0, _bypass_port);
+               ParameterDescriptor desc;
+               desc.label = _("Plugin Enable");
+               desc.toggled  = true;
+               desc.normal = 1;
+               desc.lower  = 0;
+               desc.upper  = 1;
+               boost::shared_ptr<AutomationList> list(new AutomationList(param, desc));
+               boost::shared_ptr<AutomationControl> c (new PluginControl(this, param, desc, list));
+               add_control (c);
+       }
+
        if (_bypass_port != UINT32_MAX) {
                boost::shared_ptr<AutomationControl> ac = automation_control (Evoral::Parameter (PluginAutomation, 0, _bypass_port));
                if (0 == (ac->flags () & Controllable::NotAutomatable)) {
@@ -618,7 +633,27 @@ PluginInsert::enable (bool yn)
                        activate ();
                }
                boost::shared_ptr<AutomationControl> ac = automation_control (Evoral::Parameter (PluginAutomation, 0, _bypass_port));
-               ac->set_value (yn ? 1.0 : 0.0, Controllable::NoGroup);
+               const double val = yn ? 1.0 : 0.0;
+               ac->set_value (val, Controllable::NoGroup);
+
+#ifdef ALLOW_VST_BYPASS_TO_FAIL // yet unused, see also vst_plugin.cc
+               /* special case VST.. bypass may fail */
+               if (_bypass_port == UINT32_MAX - 1) {
+                       /* check if bypass worked */
+                       if (ac->get_value () != val) {
+                               warning << _("PluginInsert: VST Bypass failed, falling back to host bypass.") << endmsg;
+                               // set plugin to enabled (not-byassed)
+                               ac->set_value (1.0, Controllable::NoGroup);
+                               // ..and use host-provided hard-bypass
+                               if (yn) {
+                                       activate ();
+                               } else {
+                                       deactivate ();
+                               }
+                               return;
+                       }
+               }
+#endif
                ActiveChanged ();
        }
 }
@@ -2565,6 +2600,14 @@ PluginInsert::set_state(const XMLNode& node, int version)
                                }
                        }
 
+                       /* when copying plugin state, notify UI */
+                       for (Controls::const_iterator li = controls().begin(); li != controls().end(); ++li) {
+                               boost::shared_ptr<PBD::Controllable> c = boost::dynamic_pointer_cast<PBD::Controllable> (li->second);
+                               if (c) {
+                                       c->Changed (false, Controllable::NoGroup); /* EMIT SIGNAL */
+                               }
+                       }
+
                        break;
                }
        }
@@ -2935,6 +2978,7 @@ PluginInsert::get_impulse_analysis_plugin()
                        assert (out == internal_output_streams ());
                }
                ret->configure_io (internal_input_streams (), out);
+               ret->set_owner (_owner);
                _impulseAnalysisPlugin = ret;
        } else {
                ret = _impulseAnalysisPlugin.lock();