diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2009-03-27 19:32:59 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2009-03-27 19:32:59 +0000 |
commit | 24bb797853b884fbcdc0f51e420258a49236f49c (patch) | |
tree | ff87af16a0ac5ba6c15c2340141a3e7acd45aacc | |
parent | 75119176e300f559e1a080b5127b85dff4947d36 (diff) |
save+restore VST preset program number; don't call begin/endSetProgram for VST 1.0 plugins
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@4917 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | libs/ardour/vst_plugin.cc | 35 | ||||
-rw-r--r-- | libs/fst/fst.h | 1 | ||||
-rw-r--r-- | libs/fst/vstwin.c | 18 |
3 files changed, 33 insertions, 21 deletions
diff --git a/libs/ardour/vst_plugin.cc b/libs/ardour/vst_plugin.cc index eb067d6c5a..2bcc354bfa 100644 --- a/libs/ardour/vst_plugin.cc +++ b/libs/ardour/vst_plugin.cc @@ -151,6 +151,12 @@ VSTPlugin::get_state() XMLNode *root = new XMLNode (state_node_name()); LocaleGuard lg (X_("POSIX")); + if (_fst->current_program != -1) { + char buf[32]; + snprintf (buf, sizeof (buf), "%d", _fst->current_program); + root->add_property ("current-program", buf); + } + if (_plugin->flags & 32 /* effFlagsProgramChunks */) { /* fetch the current chunk */ @@ -194,39 +200,36 @@ int VSTPlugin::set_state(const XMLNode& node) { LocaleGuard lg (X_("POSIX")); - + const XMLProperty* prop; + if (node.name() != state_node_name()) { error << _("Bad node sent to VSTPlugin::set_state") << endmsg; return 0; } + if ((prop = node.property ("current-program")) != 0) { + _fst->current_program = atoi (prop->value()); + } + XMLNode* child; + int ret = -1; if ((child = find_named_node (node, X_("chunk"))) != 0) { XMLPropertyList::const_iterator i; - XMLNodeList::const_iterator n; + int ret = -1; + for (n = child->children ().begin (); n != child->children ().end (); ++n) { if ((*n)->is_content ()) { gsize chunk_size = 0; guchar * data = g_base64_decode ((*n)->content ().c_str (), &chunk_size); //cerr << "Dispatch setChunk for " << name() << endl; - if (_plugin->dispatcher (_plugin, 24 /* effSetChunk */, 0, chunk_size, data, 0) == 0) { - g_free (data); - return 0; - } else { - g_free (data); - return -1; - } + ret = _plugin->dispatcher (_plugin, 24 /* effSetChunk */, 0, chunk_size, data, 0); + g_free (data); } } - _fst->current_program = _plugin->dispatcher (_plugin, 3, /* effGetProgram */, 0, NULL, NULL, 0); - cerr << name() << ": current program is " << _fst->current_program << endl; - - return 0; - } else if ((child = find_named_node (node, X_("parameters"))) != 0) { XMLPropertyList::const_iterator i; @@ -246,12 +249,12 @@ VSTPlugin::set_state(const XMLNode& node) _fst->current_program = -1; - return 0; + ret = 0; } - return -1; + return ret; } int diff --git a/libs/fst/fst.h b/libs/fst/fst.h index 1cecc71d52..6ef5acf794 100644 --- a/libs/fst/fst.h +++ b/libs/fst/fst.h @@ -80,6 +80,7 @@ struct _FST int height; int wantIdle; int destroy; + int vst_version; int want_program; int current_program; diff --git a/libs/fst/vstwin.c b/libs/fst/vstwin.c index 82c4d81d68..09ca8f18d3 100644 --- a/libs/fst/vstwin.c +++ b/libs/fst/vstwin.c @@ -166,11 +166,17 @@ again: } if (fst->want_program != -1 ) { - fst->plugin->dispatcher (fst->plugin, 67 /* effBeginSetProgram */, 0, 0, NULL, 0); - fst->plugin->dispatcher (fst->plugin, effSetProgram, 0, fst->want_program, NULL, 0)) - fst->plugin->dispatcher (fst->plugin, 68 /* effEndSetProgram */, 0, 0, NULL, 0); - /* assume it worked */ - fst->current_program = fst->want_program; + if (fst->vst_version >= 2) { + fst->plugin->dispatcher (fst->plugin, 67 /* effBeginSetProgram */, 0, 0, NULL, 0); + } + + fst->plugin->dispatcher (fst->plugin, effSetProgram, 0, fst->want_program, NULL, 0); + + if (fst->vst_version >= 2) { + fst->plugin->dispatcher (fst->plugin, 68 /* effEndSetProgram */, 0, 0, NULL, 0); + } + /* did it work? */ + fst->current_program = fst->plugin->dispatcher (fst->plugin, 3, /* effGetProgram */ 0, 0, NULL, 0); fst->want_program = -1; } @@ -569,6 +575,8 @@ fst_instantiate (FSTHandle* fhandle, audioMasterCallback amc, void* userptr) fst->plugin->dispatcher (fst->plugin, effOpen, 0, 0, 0, 0); //fst->plugin->dispatcher (fst->plugin, effMainsChanged, 0, 0, NULL, 0); + fst->vst_version = fst->plugin->dispatcher (fst->plugin, effGetVstVersion, 0, 0, 0, 0); + fst->handle->plugincnt++; fst->wantIdle = 0; |