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
This commit is contained in:
parent
860ffed6d1
commit
e845b9f935
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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*);
|
||||
|
@ -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:
|
||||
@ -559,6 +571,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
|
||||
{
|
||||
@ -2832,6 +2898,7 @@ PluginInsert::add_plugin (boost::shared_ptr<Plugin> plugin)
|
||||
vst->set_insert (this, _plugins.size ());
|
||||
}
|
||||
#endif
|
||||
|
||||
_plugins.push_back (plugin);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user