summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-07-05 21:26:45 +0200
committerRobin Gareus <robin@gareus.org>2016-07-05 23:30:21 +0200
commite845b9f9357c4ff471c02b1f63a61275bb4a7d28 (patch)
tree845b8928ae70f7983883ce3438e58dbda853c8ac
parent860ffed6d17c6eaa3d947b905c1c1118fb147924 (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
-rw-r--r--libs/ardour/ardour/plugin.h2
-rw-r--r--libs/ardour/ardour/plugin_insert.h8
-rw-r--r--libs/ardour/ardour/processor.h7
-rw-r--r--libs/ardour/plugin_insert.cc67
4 files changed, 83 insertions, 1 deletions
diff --git a/libs/ardour/ardour/plugin.h b/libs/ardour/ardour/plugin.h
index 935b75faea..dcb6577e7a 100644
--- a/libs/ardour/ardour/plugin.h
+++ b/libs/ardour/ardour/plugin.h
@@ -113,6 +113,8 @@ class LIBARDOUR_API Plugin : public PBD::StatefulDestructible, public Latent
virtual bool parameter_is_input(uint32_t) const = 0;
virtual bool parameter_is_output(uint32_t) const = 0;
+ virtual uint32_t designated_bypass_port () { return UINT32_MAX; }
+
struct LIBARDOUR_API IOPortDescription {
public:
IOPortDescription (const std::string& n)
diff --git a/libs/ardour/ardour/plugin_insert.h b/libs/ardour/ardour/plugin_insert.h
index 9f1d56b811..6f7b10cd46 100644
--- a/libs/ardour/ardour/plugin_insert.h
+++ b/libs/ardour/ardour/plugin_insert.h
@@ -68,6 +68,10 @@ class LIBARDOUR_API PluginInsert : public Processor
void deactivate ();
void flush ();
+ void enable (bool yn);
+ bool enabled () const;
+ bool bypassable () const;
+
bool reset_parameters_to_default ();
bool can_reset_all_parameters ();
@@ -355,6 +359,9 @@ class LIBARDOUR_API PluginInsert : public Processor
void set_parameter_state_2X (const XMLNode& node, int version);
void set_control_ids (const XMLNode&, int version);
+ void enable_changed ();
+ void bypassable_changed ();
+
boost::shared_ptr<Plugin> plugin_factory (boost::shared_ptr<Plugin>);
void add_plugin (boost::shared_ptr<Plugin>);
@@ -363,6 +370,7 @@ class LIBARDOUR_API PluginInsert : public Processor
void latency_changed (framecnt_t, framecnt_t);
bool _latency_changed;
+ uint32_t _bypass_port;
};
} // namespace ARDOUR
diff --git a/libs/ardour/ardour/processor.h b/libs/ardour/ardour/processor.h
index c86827c13b..1a4863ff2d 100644
--- a/libs/ardour/ardour/processor.h
+++ b/libs/ardour/ardour/processor.h
@@ -59,7 +59,9 @@ class LIBARDOUR_API Processor : public SessionObject, public Automatable, public
virtual bool display_to_user() const { return _display_to_user; }
virtual void set_display_to_user (bool);
- bool active () const { return _pending_active; }
+ bool active () const { return _pending_active; } ///< ardour hard bypass
+ virtual bool enabled () const { return _pending_active; } ///< processor enabled/bypass
+ virtual bool bypassable () const { return true; } ///< enable is not automated or locked
virtual bool does_routing() const { return false; }
@@ -81,6 +83,8 @@ class LIBARDOUR_API Processor : public SessionObject, public Automatable, public
virtual void deactivate () { _pending_active = false; ActiveChanged(); }
virtual void flush() {}
+ virtual void enable (bool yn) { if (yn) { activate (); } else { deactivate (); } }
+
virtual bool configure_io (ChanCount in, ChanCount out);
/* Derived classes should override these, or processor appears as an in-place pass-through */
@@ -111,6 +115,7 @@ class LIBARDOUR_API Processor : public SessionObject, public Automatable, public
virtual void set_pre_fader (bool);
PBD::Signal0<void> ActiveChanged;
+ PBD::Signal0<void> BypassableChanged;
PBD::Signal2<void,ChanCount,ChanCount> ConfigurationChanged;
void set_ui (void*);
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);
}