From 7804a524dc106ec1540fa5f02e26f84c71cbef9a Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 20 Oct 2015 10:10:35 -0400 Subject: Revert "rename ParameterChanged signal in Plugin to ParameterChangedExternally to reflect its intent, and clean up the result." This reverts commit 336b2eb9a4a8634bae84a15e952d20335aa28c12. --- libs/ardour/ardour/plugin.h | 22 ++------ libs/ardour/ardour/plugin_insert.h | 4 +- libs/ardour/plugin.cc | 12 ++--- libs/ardour/plugin_insert.cc | 105 ++++++++++++++++++------------------- libs/ardour/session_vst.cc | 2 +- libs/ardour/source.cc | 2 +- libs/ardour/vst_plugin.cc | 6 +++ 7 files changed, 69 insertions(+), 84 deletions(-) (limited to 'libs/ardour') diff --git a/libs/ardour/ardour/plugin.h b/libs/ardour/ardour/plugin.h index 7bef40ab88..2554a6816c 100644 --- a/libs/ardour/ardour/plugin.h +++ b/libs/ardour/ardour/plugin.h @@ -208,17 +208,10 @@ class LIBARDOUR_API Plugin : public PBD::StatefulDestructible, public Latent /** Emitted when a preset has been loaded */ PBD::Signal0 PresetLoaded; - /** Emitted when a parameter is altered in a way that may have - * changed the settings with respect to any loaded preset. - */ - PBD::Signal0 PresetDirty; - virtual bool has_editor () const = 0; - /** Emitted when a parameter is altered by something outside of our - * control, most typically a Plugin GUI/editor - */ - PBD::Signal2 ParameterChangedExternally; + /** Emitted when any parameter changes */ + PBD::Signal2 ParameterChanged; virtual bool configure_io (ChanCount /*in*/, ChanCount /*out*/) { return true; } @@ -279,18 +272,9 @@ class LIBARDOUR_API Plugin : public PBD::StatefulDestructible, public Latent protected: friend class PluginInsert; - friend class Session; - /* Called when a parameter of the plugin is changed outside of this - * host's control (typical via a plugin's own GUI/editor) - */ - void parameter_changed_externally (uint32_t which, float val); - - /* should be overridden by plugin API specific derived types to - * actually implement changing the parameter. The derived type should - * call this after the change is made. - */ virtual void set_parameter (uint32_t which, float val); + virtual void set_parameter_automated (uint32_t which, float val); /** Do the actual saving of the current plugin settings to a preset of the provided name. * Should return a URI on success, or an empty string on failure. diff --git a/libs/ardour/ardour/plugin_insert.h b/libs/ardour/ardour/plugin_insert.h index d4d9adb54d..8788778a3a 100644 --- a/libs/ardour/ardour/plugin_insert.h +++ b/libs/ardour/ardour/plugin_insert.h @@ -96,7 +96,6 @@ class LIBARDOUR_API PluginInsert : public Processor void set_value (double val); double get_value (void) const; - void catch_up_with_external_value (double val); XMLNode& get_state(); private: @@ -165,9 +164,10 @@ class LIBARDOUR_API PluginInsert : public Processor /* disallow copy construction */ PluginInsert (const PluginInsert&); - void parameter_changed_externally (uint32_t, float); + void parameter_changed (uint32_t, float); void set_parameter (Evoral::Parameter param, float val); + float get_parameter (Evoral::Parameter param); float default_parameter_value (const Evoral::Parameter& param); diff --git a/libs/ardour/plugin.cc b/libs/ardour/plugin.cc index d68502713c..f14c56798b 100644 --- a/libs/ardour/plugin.cc +++ b/libs/ardour/plugin.cc @@ -356,21 +356,19 @@ Plugin::clear_preset () PresetLoaded (); /* EMIT SIGNAL */ } +/** @param val `plugin' value */ void -Plugin::set_parameter (uint32_t /* which */, float /* value */) +Plugin::set_parameter (uint32_t which, float) { _parameter_changed_since_last_preset = true; _session.set_dirty (); - PresetDirty (); /* EMIT SIGNAL */ + ParameterChanged (which, get_parameter (which)); /* EMIT SIGNAL */ } void -Plugin::parameter_changed_externally (uint32_t which, float /* value */) +Plugin::set_parameter_automated (uint32_t which, float val) { - _parameter_changed_since_last_preset = true; - _session.set_dirty (); - ParameterChangedExternally (which, get_parameter (which)); /* EMIT SIGNAL */ - PresetDirty (); /* EMIT SIGNAL */ + Plugin::set_parameter (which, val); } int diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index ec6d86d71a..98ff9ab4f0 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -264,53 +264,26 @@ PluginInsert::create_automatable_parameters () } } } -/** Called when something outside of this host has modified a plugin - * parameter. Responsible for propagating the change to two places: - * - * 1) anything listening to the Control itself - * 2) any replicated plugins that make up this PluginInsert. - * - * The PluginInsert is connected to the ParameterChangedExternally signal for - * the first (primary) plugin, and here broadcasts that change to any others. - * - * XXX We should probably drop this whole replication idea (Paul, October 2015) - * since it isn't used by sensible plugin APIs (AU, LV2). - */ + void -PluginInsert::parameter_changed_externally (uint32_t which, float val) +PluginInsert::parameter_changed (uint32_t which, float val) { boost::shared_ptr ac = automation_control (Evoral::Parameter (PluginAutomation, 0, which)); - /* First propagation: alter the underlying value of the control, - * without telling the plugin(s) that own/use it to set it. - */ - - if (!ac) { - return; - } - - boost::shared_ptr pc = boost::dynamic_pointer_cast (ac); - - if (pc) { - pc->catch_up_with_external_value (val); - } - - /* Second propagation: tell all plugins except the first to - update the value of this parameter. For sane plugin APIs, - there are no other plugins, so this is a no-op in those - cases. - */ + if (ac) { + ac->set_value (val); - Plugins::iterator i = _plugins.begin(); + Plugins::iterator i = _plugins.begin(); - /* don't set the first plugin, just all the slaves */ + /* don't set the first plugin, just all the slaves */ - if (i != _plugins.end()) { - ++i; - for (; i != _plugins.end(); ++i) { - (*i)->set_parameter (which, val); - } - } + if (i != _plugins.end()) { + ++i; + for (; i != _plugins.end(); ++i) { + (*i)->set_parameter (which, val); + } + } + } } int @@ -533,6 +506,41 @@ PluginInsert::run (BufferSet& bufs, framepos_t start_frame, framepos_t /*end_fra } +void +PluginInsert::set_parameter (Evoral::Parameter param, float val) +{ + if (param.type() != PluginAutomation) { + return; + } + + /* the others will be set from the event triggered by this */ + + _plugins[0]->set_parameter (param.id(), val); + + boost::shared_ptr ac + = boost::dynamic_pointer_cast(control(param)); + + if (ac) { + ac->set_value(val); + } else { + warning << "set_parameter called for nonexistent parameter " + << EventTypeMap::instance().to_symbol(param) << endmsg; + } + + _session.set_dirty(); +} + +float +PluginInsert::get_parameter (Evoral::Parameter param) +{ + if (param.type() != PluginAutomation) { + return 0.0; + } else { + assert (!_plugins.empty ()); + return _plugins[0]->get_parameter (param.id()); + } +} + void PluginInsert::automation_run (BufferSet& bufs, framepos_t start, pframes_t nframes) { @@ -1309,12 +1317,6 @@ PluginInsert::PluginControl::set_value (double user_val) AutomationControl::set_value (user_val); } -void -PluginInsert::PluginControl::catch_up_with_external_value (double user_val) -{ - AutomationControl::set_value (user_val); -} - XMLNode& PluginInsert::PluginControl::get_state () { @@ -1331,13 +1333,8 @@ PluginInsert::PluginControl::get_state () double PluginInsert::PluginControl::get_value () const { - boost::shared_ptr plugin = _plugin->plugin (0); - - if (!plugin) { - return 0.0; - } - - return plugin->get_parameter (_list->parameter().id()); + /* FIXME: probably should be taking out some lock here.. */ + return _plugin->get_parameter (_list->parameter()); } PluginInsert::PluginPropertyControl::PluginPropertyControl (PluginInsert* p, @@ -1433,7 +1430,7 @@ PluginInsert::add_plugin (boost::shared_ptr plugin) /* first (and probably only) plugin instance - connect to relevant signals */ - plugin->ParameterChangedExternally.connect_same_thread (*this, boost::bind (&PluginInsert::parameter_changed_externally, this, _1, _2)); + plugin->ParameterChanged.connect_same_thread (*this, boost::bind (&PluginInsert::parameter_changed, this, _1, _2)); plugin->StartTouch.connect_same_thread (*this, boost::bind (&PluginInsert::start_touch, this, _1)); plugin->EndTouch.connect_same_thread (*this, boost::bind (&PluginInsert::end_touch, this, _1)); } diff --git a/libs/ardour/session_vst.cc b/libs/ardour/session_vst.cc index 009a4acc40..9bf2847331 100644 --- a/libs/ardour/session_vst.cc +++ b/libs/ardour/session_vst.cc @@ -86,7 +86,7 @@ intptr_t Session::vst_callback ( SHOW_CALLBACK ("audioMasterAutomate"); // index, value, returns 0 if (plug) { - plug->parameter_changed_externally (index, opt); + plug->set_parameter_automated (index, opt); } return 0; diff --git a/libs/ardour/source.cc b/libs/ardour/source.cc index aaa50ff297..29093035c2 100644 --- a/libs/ardour/source.cc +++ b/libs/ardour/source.cc @@ -178,7 +178,7 @@ Source::set_been_analysed (bool yn) yn = false; } } - if (yn != _analysed) { + if (yn != _analysed); { Glib::Threads::Mutex::Lock lm (_analysis_lock); _analysed = yn; } diff --git a/libs/ardour/vst_plugin.cc b/libs/ardour/vst_plugin.cc index 1614b1d8fe..08db7dec5e 100644 --- a/libs/ardour/vst_plugin.cc +++ b/libs/ardour/vst_plugin.cc @@ -117,6 +117,12 @@ VSTPlugin::set_parameter (uint32_t which, float newval) } } +void +VSTPlugin::set_parameter_automated (uint32_t which, float newval) +{ + Plugin::set_parameter_automated (which, newval); +} + uint32_t VSTPlugin::nth_parameter (uint32_t n, bool& ok) const { -- cgit v1.2.3