diff options
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/vst_plugin.h | 3 | ||||
-rw-r--r-- | libs/ardour/plugin_insert.cc | 15 | ||||
-rw-r--r-- | libs/ardour/vst_plugin.cc | 45 |
3 files changed, 63 insertions, 0 deletions
diff --git a/libs/ardour/ardour/vst_plugin.h b/libs/ardour/ardour/vst_plugin.h index f96b35ff4b..50cfc5e21a 100644 --- a/libs/ardour/ardour/vst_plugin.h +++ b/libs/ardour/ardour/vst_plugin.h @@ -68,6 +68,8 @@ public: bool parameter_is_input (uint32_t) const { return true; } bool parameter_is_output (uint32_t) const { return false; } + uint32_t designated_bypass_port (); + int connect_and_run (BufferSet&, framepos_t start, framepos_t end, double speed, ChanMapping in, ChanMapping out, @@ -125,6 +127,7 @@ protected: framepos_t _transport_frame; float _transport_speed; mutable std::map <uint32_t, float> _parameter_defaults; + bool _eff_bypassed; }; } diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index c82257a4f4..8e3e138201 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -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)) { diff --git a/libs/ardour/vst_plugin.cc b/libs/ardour/vst_plugin.cc index 1088e80c70..8541e8eaf7 100644 --- a/libs/ardour/vst_plugin.cc +++ b/libs/ardour/vst_plugin.cc @@ -49,6 +49,7 @@ VSTPlugin::VSTPlugin (AudioEngine& engine, Session& session, VSTHandle* handle) , _num (0) , _transport_frame (0) , _transport_speed (0.f) + , _eff_bypassed (false) { memset (&_timeInfo, 0, sizeof(_timeInfo)); } @@ -64,6 +65,7 @@ VSTPlugin::VSTPlugin (const VSTPlugin& other) , _transport_frame (0) , _transport_speed (0.f) , _parameter_defaults (other._parameter_defaults) + , _eff_bypassed (other._eff_bypassed) { memset (&_timeInfo, 0, sizeof(_timeInfo)); } @@ -85,6 +87,27 @@ VSTPlugin::set_plugin (AEffect* e) _plugin->dispatcher (_plugin, effSetBlockSize, 0, _session.get_block_size(), NULL, 0.0f); } + +uint32_t +VSTPlugin::designated_bypass_port () +{ + if (_plugin->dispatcher (_plugin, effCanDo, 0, 0, const_cast<char*> ("bypass"), 0.0f) != 0) { + /* check if plugin actually supports it, + * e.g. u-he Presswerk CanDo "bypass" but calling effSetBypass is a NO-OP. + * (presumably the plugin-author thinks hard-bypassing is a bad idea, + * particularly since the plugin itself provides a bypass-port) + */ + intptr_t value = 0; // not bypassed + if (0 != _plugin->dispatcher (_plugin, 44 /*effSetBypass*/, 0, value, NULL, 0)) { + cerr << "Emulate VST Bypass Port for " << name() << endl; // XXX DEBUG + return UINT32_MAX - 1; // emulate a port + } else { + cerr << "Do *not* Emulate VST Bypass Port for " << name() << endl; // XXX DEBUG + } + } + return UINT32_MAX; +} + void VSTPlugin::deactivate () { @@ -115,12 +138,29 @@ VSTPlugin::default_value (uint32_t which) float VSTPlugin::get_parameter (uint32_t which) const { + if (which == UINT32_MAX - 1) { + // ardour uses enable-semantics: 1: enabled, 0: bypassed + return _eff_bypassed ? 0.f : 1.f; + } return _plugin->getParameter (_plugin, which); } void VSTPlugin::set_parameter (uint32_t which, float newval) { + if (which == UINT32_MAX - 1) { + // ardour uses enable-semantics: 1: enabled, 0: bypassed + intptr_t value = (newval <= 0.f) ? 1 : 0; + cerr << "effSetBypass " << value << endl; // XXX DEBUG + int rv = _plugin->dispatcher (_plugin, 44 /*effSetBypass*/, 0, value, NULL, 0); + if (0 != rv) { + _eff_bypassed = (value == 1); + } else { + cerr << "effSetBypass failed rv=" << rv << endl; // XXX DEBUG + } + return; + } + float oldval = get_parameter (which); if (PBD::floateq (oldval, newval, 1)) { @@ -548,6 +588,11 @@ string VSTPlugin::describe_parameter (Evoral::Parameter param) { char name[64]; + if (param.id() == UINT32_MAX - 1) { + strcpy (name, _("Plugin Enable")); + return name; + } + memset (name, 0, sizeof (name)); /* some VST plugins expect this buffer to be zero-filled */ |