diff options
author | Robin Gareus <robin@gareus.org> | 2016-07-05 21:26:45 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-07-05 23:30:21 +0200 |
commit | e845b9f9357c4ff471c02b1f63a61275bb4a7d28 (patch) | |
tree | 845b8928ae70f7983883ce3438e58dbda853c8ac /libs/ardour/plugin_insert.cc | |
parent | 860ffed6d17c6eaa3d947b905c1c1118fb147924 (diff) |
add API to use a plugin provided bypass control port
* new separate API: en/disable
* old API remains in place for hard bypass
* PluginInsert::enable() falls back to activate/deativate if a plugin
does not provided designated bypass control port
Diffstat (limited to 'libs/ardour/plugin_insert.cc')
-rw-r--r-- | libs/ardour/plugin_insert.cc | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index 0de2d7fe5a..a8757fc97e 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -76,6 +76,7 @@ PluginInsert::PluginInsert (Session& s, boost::shared_ptr<Plugin> plug) , _strict_io (false) , _custom_cfg (false) , _maps_from_state (false) + , _bypass_port (UINT32_MAX) { /* the first is the master */ @@ -457,6 +458,7 @@ PluginInsert::create_automatable_parameters () plugin->set_automation_control (i, c); } + const Plugin::PropertyDescriptors& pdl (plugin->get_supported_properties ()); for (Plugin::PropertyDescriptors::const_iterator p = pdl.begin(); p != pdl.end(); ++p) { Evoral::Parameter param (PluginPropertyAutomation, 0, p->first); @@ -469,6 +471,16 @@ PluginInsert::create_automatable_parameters () add_control (boost::shared_ptr<AutomationControl> (new PluginPropertyControl(this, param, desc, list))); } } + + _bypass_port = plugin->designated_bypass_port (); + + if (_bypass_port != UINT32_MAX) { + boost::shared_ptr<AutomationControl> ac = automation_control (Evoral::Parameter (PluginAutomation, 0, _bypass_port)); + if (0 == (ac->flags () & Controllable::NotAutomatable)) { + ac->alist()->automation_state_changed.connect_same_thread (*this, boost::bind (&PluginInsert::bypassable_changed, this)); + ac->Changed.connect_same_thread (*this, boost::bind (&PluginInsert::enable_changed, this)); + } + } } /** Called when something outside of this host has modified a plugin * parameter. Responsible for propagating the change to two places: @@ -560,6 +572,60 @@ PluginInsert::flush () } void +PluginInsert::enable (bool yn) +{ + if (_bypass_port == UINT32_MAX) { + if (yn) { + activate (); + } else { + deactivate (); + } + } else { + if (!_pending_active) { + activate (); + } + boost::shared_ptr<AutomationControl> ac = automation_control (Evoral::Parameter (PluginAutomation, 0, _bypass_port)); + ac->set_value (yn ? 1.0 : 0.0, Controllable::NoGroup); + ActiveChanged (); + } +} + +bool +PluginInsert::enabled () const +{ + if (_bypass_port == UINT32_MAX) { + return Processor::enabled (); + } else { + boost::shared_ptr<const AutomationControl> ac = boost::const_pointer_cast<AutomationControl> (automation_control (Evoral::Parameter (PluginAutomation, 0, _bypass_port))); + return (ac->get_value () > 0 && _pending_active); + } +} + +bool +PluginInsert::bypassable () const +{ + if (_bypass_port == UINT32_MAX) { + return true; + } else { + boost::shared_ptr<const AutomationControl> ac = boost::const_pointer_cast<AutomationControl> (automation_control (Evoral::Parameter (PluginAutomation, 0, _bypass_port))); + + return !ac->automation_playback (); + } +} + +void +PluginInsert::enable_changed () +{ + ActiveChanged (); +} + +void +PluginInsert::bypassable_changed () +{ + BypassableChanged (); +} + +void PluginInsert::inplace_silence_unconnected (BufferSet& bufs, const PinMappings& out_map, framecnt_t nframes, framecnt_t offset) const { // TODO optimize: store "unconnected" in a fixed set. @@ -2832,6 +2898,7 @@ PluginInsert::add_plugin (boost::shared_ptr<Plugin> plugin) vst->set_insert (this, _plugins.size ()); } #endif + _plugins.push_back (plugin); } |