summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/ardour/ardour/vst_plugin.h1
-rw-r--r--libs/ardour/linux_vst_support.cc29
-rwxr-xr-xlibs/ardour/lxvst_plugin.cc4
3 files changed, 22 insertions, 12 deletions
diff --git a/libs/ardour/ardour/vst_plugin.h b/libs/ardour/ardour/vst_plugin.h
index 7ca973cbb7..d9cfd87bad 100644
--- a/libs/ardour/ardour/vst_plugin.h
+++ b/libs/ardour/ardour/vst_plugin.h
@@ -73,6 +73,7 @@ public:
AEffect * plugin () const { return _plugin; }
VSTState * state () const { return _state; }
+ void set_state (VSTState* s) { _state = s; }
int set_state (XMLNode const &, int);
diff --git a/libs/ardour/linux_vst_support.cc b/libs/ardour/linux_vst_support.cc
index 99251f08e4..9106d69009 100644
--- a/libs/ardour/linux_vst_support.cc
+++ b/libs/ardour/linux_vst_support.cc
@@ -34,6 +34,8 @@
#include <glibmm/fileutils.h>
#include "ardour/linux_vst_support.h"
+#include "ardour/vst_plugin.h"
+
#include "pbd/basename.h"
#include "pbd/error.h"
@@ -293,36 +295,43 @@ vstfx_unload (VSTHandle* fhandle)
return 0;
}
-/*This instantiates a plugin*/
+/**
+ Instantiates a VST plugin and also set _state of its plugin argument
+ */
-VSTState *
-vstfx_instantiate (VSTHandle* fhandle, audioMasterCallback amc, void* userptr)
+VSTState*
+vstfx_instantiate (VSTHandle* fhandle, audioMasterCallback amc, void *ptr)
{
VSTState* vstfx = vstfx_new ();
+ ARDOUR::VSTPlugin* plugin = reinterpret_cast<ARDOUR::VSTPlugin*> (ptr);
- if(fhandle == 0)
- {
+ if (fhandle == 0) {
vstfx_error( "** ERROR ** VSTFX : The handle was 0\n" );
return 0;
}
- if ((vstfx->plugin = fhandle->main_entry (amc)) == 0)
- {
+ if ((vstfx->plugin = fhandle->main_entry (amc)) == 0) {
vstfx_error ("** ERROR ** VSTFX : %s could not be instantiated :(\n", fhandle->name);
free (vstfx);
return 0;
}
vstfx->handle = fhandle;
- vstfx->plugin->user = userptr;
+ vstfx->plugin->user = plugin;
- if (vstfx->plugin->magic != kEffectMagic)
- {
+ if (vstfx->plugin->magic != kEffectMagic) {
vstfx_error ("** ERROR ** VSTFX : %s is not a VST plugin\n", fhandle->name);
free (vstfx);
return 0;
}
+
+ /* need to set this here because some plugins make audioMaster
+ * callbacks from within effOpen, and _state must be set for
+ * that to work.
+ */
+ plugin->set_state (vstfx);
+
vstfx->plugin->dispatcher (vstfx->plugin, effOpen, 0, 0, 0, 0);
/*May or May not need to 'switch the plugin on' here - unlikely
diff --git a/libs/ardour/lxvst_plugin.cc b/libs/ardour/lxvst_plugin.cc
index 6e30e0c443..80e6b9c286 100755
--- a/libs/ardour/lxvst_plugin.cc
+++ b/libs/ardour/lxvst_plugin.cc
@@ -32,7 +32,7 @@ LXVSTPlugin::LXVSTPlugin (AudioEngine& e, Session& session, VSTHandle* h)
{
/* Instantiate the plugin and return a VSTState* */
- if ((_state = vstfx_instantiate (_handle, Session::vst_callback, this)) == 0) {
+ if (vstfx_instantiate (_handle, Session::vst_callback, this) == 0) {
throw failed_constructor();
}
@@ -44,7 +44,7 @@ LXVSTPlugin::LXVSTPlugin (const LXVSTPlugin &other)
{
_handle = other._handle;
- if ((_state = vstfx_instantiate (_handle, Session::vst_callback, this)) == 0) {
+ if (vstfx_instantiate (_handle, Session::vst_callback, this) == 0) {
throw failed_constructor();
}
_plugin = _state->plugin;