Allow PluginControl to modulate plugin parameters

The concept here is

 PluginControl [not-yet-a SlavableAutomationControl] is-a AutomationControl

The AutomationControl base-class sets the baseline parameter-value.
This is also the value used for generic-control-UIs and Automation-Lane.
The PluginControl can modify this value when setting the actual
plugin control-parameter.

The Ardour-UI is not aware of the modulation and will have to explicitly
ask for the modulated value.
To custom plugin-UIs it will look as if the value is being automated.

The modulation value is to be set before running the plugin-instance
in connect_and_run().
This commit is contained in:
Robin Gareus 2017-02-21 22:14:56 +01:00
parent 02cf331403
commit 6ec5730276
2 changed files with 51 additions and 13 deletions

View file

@ -194,12 +194,18 @@ class LIBARDOUR_API PluginInsert : public Processor
boost::shared_ptr<AutomationList> list=boost::shared_ptr<AutomationList>());
double get_value (void) const;
double modulation_delta (void) const { return _modulation_delta; }
double modulated_value (void) const { return get_value () + _modulation_delta; }
void catch_up_with_external_value (double val);
void modulate_to (double val);
void modulate_by (double val);
XMLNode& get_state();
private:
PluginInsert* _plugin;
void actually_set_value (double val, PBD::Controllable::GroupControlDisposition group_override);
void set_plugin_parameters (double val);
double _modulation_delta; // ac_value + _modulation_delta = plugin_parameter
};
/** A control that manipulates a plugin property (message). */

View file

@ -522,6 +522,7 @@ PluginInsert::parameter_changed_externally (uint32_t which, float val)
if (pc) {
pc->catch_up_with_external_value (val);
//val += pc->modulation_delta ();
}
/* Second propagation: tell all plugins except the first to
@ -2793,6 +2794,7 @@ PluginInsert::PluginControl::PluginControl (PluginInsert* p,
boost::shared_ptr<AutomationList> list)
: AutomationControl (p->session(), param, desc, list, p->describe_parameter(param))
, _plugin (p)
, _modulation_delta (0)
{
if (alist()) {
alist()->reset_default (desc.normal);
@ -2807,24 +2809,54 @@ PluginInsert::PluginControl::PluginControl (PluginInsert* p,
void
PluginInsert::PluginControl::actually_set_value (double user_val, PBD::Controllable::GroupControlDisposition group_override)
{
/* FIXME: probably should be taking out some lock here.. */
for (Plugins::iterator i = _plugin->_plugins.begin(); i != _plugin->_plugins.end(); ++i) {
(*i)->set_parameter (_list->parameter().id(), user_val);
}
boost::shared_ptr<Plugin> iasp = _plugin->_impulseAnalysisPlugin.lock();
if (iasp) {
iasp->set_parameter (_list->parameter().id(), user_val);
}
set_plugin_parameters (user_val);
AutomationControl::actually_set_value (user_val, group_override);
}
void
PluginInsert::PluginControl::set_plugin_parameters (double user_val)
{
/* FIXME: probably should be taking out some lock here.. */
double val = user_val + _modulation_delta;
//val = std::min (upper(), std::max (lower(), val));
for (Plugins::iterator i = _plugin->_plugins.begin(); i != _plugin->_plugins.end(); ++i) {
(*i)->set_parameter (_list->parameter().id(), val);
}
boost::shared_ptr<Plugin> iasp = _plugin->_impulseAnalysisPlugin.lock();
if (iasp) {
iasp->set_parameter (_list->parameter().id(), val);
}
}
void
PluginInsert::PluginControl::catch_up_with_external_value (double user_val)
{
AutomationControl::actually_set_value (user_val, Controllable::NoGroup);
AutomationControl::actually_set_value (user_val - _modulation_delta, Controllable::NoGroup);
}
void
PluginInsert::PluginControl::modulate_by (double delta)
{
const double current = AutomationControl::get_value ();
// limit _modulation_delta so that sum does not exceed range
_modulation_delta = std::min (upper(), std::max (lower(), delta + current)) - current;
set_plugin_parameters (AutomationControl::get_value ());
// XXX calling plugin->set_parameter() implies Plugin::set_paramter() which
// markes the session and current preset as dirty..
}
void
PluginInsert::PluginControl::modulate_to (double val)
{
const double current = AutomationControl::get_value ();
val = std::min (upper(), std::max (lower(), val));
_modulation_delta = val - current;
set_plugin_parameters (current);
// XXX see above session+preset are marked as dirty
}
XMLNode&
@ -2855,7 +2887,7 @@ PluginInsert::PluginControl::get_value () const
return 0.0;
}
return plugin->get_parameter (_list->parameter().id());
return plugin->get_parameter (_list->parameter().id()) - _modulation_delta;
}
PluginInsert::PluginPropertyControl::PluginPropertyControl (PluginInsert* p,