Tweak/optimize VST callback:
authorRobin Gareus <robin@gareus.org>
Tue, 28 Feb 2017 19:08:03 +0000 (20:08 +0100)
committerRobin Gareus <robin@gareus.org>
Tue, 28 Feb 2017 19:20:18 +0000 (20:20 +0100)
The audioMasterAutomate callback from plugin to host does include
the parameter-value.

Previously there was a redundant call
Plugin::parameter_changed_externally() -> get_parameter
-> VSTPlugin::get_parameter()   back into the plugin to query the value.

calling back into the plugin from the callback, may explain
oddities and/or crashes with some VSTs.

libs/ardour/ardour/plugin.h
libs/ardour/ardour/vst_plugin.h
libs/ardour/vst_plugin.cc

index e4efb2a441011e158f974b566ced706f6d1d6d18..ce9c2f4268aba45b88251e0c1c63aa84043a0a77 100644 (file)
@@ -333,7 +333,7 @@ protected:
        /* 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);
+       virtual 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
index 00bf68021701191f845116eb432054256cb2749d..f96b35ff4b11f08584598234b9ce0442b1bf8702 100644 (file)
@@ -40,6 +40,7 @@ class PluginInsert;
 class LIBARDOUR_API VSTPlugin : public Plugin
 {
 public:
+       friend class Session;
        VSTPlugin (AudioEngine &, Session &, VSTHandle *);
        VSTPlugin (const VSTPlugin& other);
        virtual ~VSTPlugin ();
@@ -99,6 +100,7 @@ public:
 
 
 protected:
+       void parameter_changed_externally (uint32_t which, float val);
        void set_plugin (AEffect *);
        gchar* get_chunk (bool) const;
        int set_chunk (gchar const *, bool);
index 44972151f0c7c3c3e30f6663ce7b377b79b65918..1088e80c70366c307eb9392a2efff7e760b65896 100644 (file)
@@ -137,6 +137,14 @@ VSTPlugin::set_parameter (uint32_t which, float newval)
        }
 }
 
+void
+VSTPlugin::parameter_changed_externally (uint32_t which, float value )
+{
+       ParameterChangedExternally (which, value); /* EMIT SIGNAL */
+       Plugin::set_parameter (which, value);
+}
+
+
 uint32_t
 VSTPlugin::nth_parameter (uint32_t n, bool& ok) const
 {