use a note tracker to resolve notes cut off during render by the end of the region
[ardour.git] / libs / ardour / linux_vst_support.cc
index 065e8bd755b9e79674b7cc05d480642860c89eba..cace4bd1e2cce7a9e91a7898e4aa79c4b669f9a3 100644 (file)
@@ -1,21 +1,21 @@
 /*
-    Copyright (C) 2012 Paul Davis
-
-    This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
+ * Copyright (C) 2012-2016 Paul Davis <paul@linuxaudiosystems.com>
+ * Copyright (C) 2013-2017 Robin Gareus <robin@gareus.org>
+ *
* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
 
 #include <stdio.h>
 #include <stdarg.h>
@@ -219,12 +219,10 @@ vstfx_load (const char *path)
 
        /*Find the main entry point into the plugin*/
 
-       fhandle->main_entry = (main_entry_t) dlsym(fhandle->dll, "main");
+       fhandle->main_entry = (main_entry_t) dlsym(fhandle->dll, "VSTPluginMain");
 
        if (fhandle->main_entry == 0) {
-               if ((fhandle->main_entry = (main_entry_t) dlsym(fhandle->dll, "VSTPluginMain")) != 0) {
-                       PBD::warning << path << _(": is a VST >= 2.4 - this plugin may or may not function correctly with this version of Ardour.") << endmsg;
-               }
+               fhandle->main_entry = (main_entry_t) dlsym(fhandle->dll, "main");
        }
 
        if (fhandle->main_entry == 0)
@@ -299,7 +297,7 @@ vstfx_instantiate (VSTHandle* fhandle, audioMasterCallback amc, void* userptr)
        }
 
        vstfx->handle = fhandle;
-       vstfx->plugin->user = userptr;
+       vstfx->plugin->ptr1 = userptr;
 
        if (vstfx->plugin->magic != kEffectMagic)
        {
@@ -308,14 +306,16 @@ vstfx_instantiate (VSTHandle* fhandle, audioMasterCallback amc, void* userptr)
                return 0;
        }
 
-       vstfx->plugin->dispatcher (vstfx->plugin, effOpen, 0, 0, 0, 0);
-
-       /*May or May not need to 'switch the plugin on' here - unlikely
-       since FST doesn't and most plugins start up 'On' by default - I think this is the least of our worries*/
-
-       //vstfx->plugin->dispatcher (vstfx->plugin, effMainsChanged, 0, 1, 0, 0);
-
-       vstfx->vst_version = vstfx->plugin->dispatcher (vstfx->plugin, effGetVstVersion, 0, 0, 0, 0);
+       if (!userptr) {
+               /* scanning.. or w/o master-callback userptr == 0, open now.
+                *
+                * Session::vst_callback needs a pointer to the AEffect
+                *     ((VSTPlugin*)userptr)->_plugin = vstfx->plugin
+                * before calling effOpen, because effOpen may call back
+                */
+               vstfx->plugin->dispatcher (vstfx->plugin, effOpen, 0, 0, 0, 0);
+               vstfx->vst_version = vstfx->plugin->dispatcher (vstfx->plugin, effGetVstVersion, 0, 0, 0, 0);
+       }
 
        vstfx->handle->plugincnt++;
        vstfx->wantIdle = 0;