aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/vst/src
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2005-03-10 05:01:30 +0000
committerThomas Grill <xovo@users.sourceforge.net>2005-03-10 05:01:30 +0000
commit467591c8ba03dbd60ceada93482460de3b888838 (patch)
tree32862dcb5dd7675a76323da1747a4cca68087294 /externals/grill/vst/src
parentec67ac9af1c9a02130347c4ed6f32fa03f55eba2 (diff)
alt-click for plug editor
cleanups updated build system fix for build system update for flext build system added support for plug shells (like Waveshell) svn path=/trunk/; revision=2616
Diffstat (limited to 'externals/grill/vst/src')
-rw-r--r--externals/grill/vst/src/main.cpp51
-rw-r--r--externals/grill/vst/src/main.h2
-rw-r--r--externals/grill/vst/src/vsthost.cpp70
-rw-r--r--externals/grill/vst/src/vsthost.h11
4 files changed, 102 insertions, 32 deletions
diff --git a/externals/grill/vst/src/main.cpp b/externals/grill/vst/src/main.cpp
index 0291ba13..75b5feda 100644
--- a/externals/grill/vst/src/main.cpp
+++ b/externals/grill/vst/src/main.cpp
@@ -2,11 +2,14 @@
vst~ - VST plugin object for PD
based on the work of Jarno Seppänen and Mark Williamson
-Copyright (c)2003-2004 Thomas Grill (xovo@gmx.net)
+Copyright (c)2003-2005 Thomas Grill (gr@grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
*/
+// needed for CoInitializeEx
+#define _WIN32_DCOM
+
#include "main.h"
#include "Editor.h"
@@ -19,10 +22,11 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#if FLEXT_OS == FLEXT_OS_WIN
#include <direct.h>
#include <io.h>
+#include <objbase.h>
#endif
-#define VST_VERSION "0.1.0pre17"
+#define VST_VERSION "0.1.0pre18"
class vst:
@@ -38,10 +42,16 @@ protected:
virtual V m_dsp(I n,t_signalvec const *insigs,t_signalvec const *outsigs);
virtual V m_signal(I n,R *const *insigs,R *const *outsigs);
+ virtual void m_click() { ms_edit(true); }
+
BL ms_plug(I argc,const A *argv);
BL ms_plug(const AtomList &args) { return ms_plug(args.Count(),args.Atoms()); }
V mg_plug(AtomList &sym) const { sym(1); SetString(sym[0],plugname.c_str()); }
+ void ms_subplug(I argc,const A *argv);
+ void ms_subplug(const AtomList &args) { ms_subplug(args.Count(),args.Atoms()); }
+ void mg_subplug(AtomList &sym) const { sym(1); SetString(sym[0],subplug.c_str()); }
+
V mg_editor(BL &ed) { ed = plug && plug->HasEditor(); }
V ms_edit(BL on) { if(plug) plug->Edit(on); }
@@ -97,7 +107,7 @@ private:
V display_parameter(I param,BL showparams);
VSTPlugin *plug;
- std::string plugname;
+ std::string plugname,subplug;
bool echoparam,visible,bypass,mute;
int paramnames;
@@ -118,6 +128,7 @@ private:
FLEXT_CALLBACK_V(m_print)
FLEXT_CALLVAR_V(mg_plug,ms_plug)
+ FLEXT_CALLVAR_V(mg_subplug,ms_subplug)
FLEXT_CALLVAR_B(mg_edit,ms_edit)
FLEXT_CALLGET_B(mg_editor)
@@ -175,11 +186,12 @@ const t_symbol *vst::sym_progname,*vst::sym_pname,*vst::sym_param,*vst::sym_ptex
V vst::Setup(t_classid c)
{
post("");
- post("vst~ %s - VST plugin object, (C)2003-04 Thomas Grill",VST_VERSION);
+ post("vst~ %s - VST plugin object, (C)2003-05 Thomas Grill",VST_VERSION);
post("based on the work of Jarno Seppänen and Mark Williamson");
post("");
FLEXT_CADDATTR_VAR(c,"plug",mg_plug,ms_plug);
+ FLEXT_CADDATTR_VAR(c,"subplug",mg_subplug,ms_subplug);
FLEXT_CADDATTR_VAR(c,"edit",mg_edit,ms_edit);
FLEXT_CADDATTR_GET(c,"editor",mg_editor);
FLEXT_CADDATTR_VAR(c,"vis",mg_vis,ms_vis);
@@ -247,11 +259,19 @@ vst::vst(I argc,const A *argv):
}
else
throw "syntax: vst~ inputs outputs [plug]";
+
+#if FLEXT_OS == FLEXT_OS_WIN
+ // this is necessary for Waveshell
+ CoInitializeEx(NULL,COINIT_MULTITHREADED+COINIT_SPEED_OVER_MEMORY);
+#endif
}
vst::~vst()
{
ClearPlug();
+#if FLEXT_OS == FLEXT_OS_WIN
+ CoUninitialize();
+#endif
}
V vst::ClearPlug()
@@ -390,7 +410,7 @@ BL vst::ms_plug(I argc,const A *argv)
int loaderr = VSTINSTANCE_NO_ERROR;
// try loading the dll from the raw filename
- if ((loaderr = plug->Instance(plugname.c_str())) == VSTINSTANCE_NO_ERROR) {
+ if ((loaderr = plug->Instance(plugname.c_str(),subplug.c_str())) == VSTINSTANCE_NO_ERROR) {
FLEXT_LOG("raw filename loaded fine");
lf = true;
}
@@ -462,6 +482,27 @@ BL vst::ms_plug(I argc,const A *argv)
return lf;
}
+void vst::ms_subplug(I argc,const A *argv)
+{
+ subplug.clear();
+ C buf[255];
+ for(I i = 0; i < argc; i++) {
+ if(i > 0) subplug += ' ';
+ GetAString(argv[i],buf,sizeof buf);
+
+#if FLEXT_SYS == FLEXT_SYS_PD
+ // strip char escapes (only in newer/devel PD version)
+ char *cs = buf,*cd = cs;
+ while(*cs) {
+ if(*cs != '\\') *(cd++) = *cs;
+ ++cs;
+ }
+ *cd = 0;
+#endif
+ subplug += buf;
+ }
+}
+
V vst::m_dsp(I n,t_signalvec const *,t_signalvec const *)
{
if(plug) {
diff --git a/externals/grill/vst/src/main.h b/externals/grill/vst/src/main.h
index 65b03f3c..fab6b622 100644
--- a/externals/grill/vst/src/main.h
+++ b/externals/grill/vst/src/main.h
@@ -2,7 +2,7 @@
vst~ - VST plugin object for PD
based on the work of Jarno Seppänen and Mark Williamson
-Copyright (c)2003-2004 Thomas Grill (xovo@gmx.net)
+Copyright (c)2003-2005 Thomas Grill (gr@grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
*/
diff --git a/externals/grill/vst/src/vsthost.cpp b/externals/grill/vst/src/vsthost.cpp
index ffb58dee..0d883cd9 100644
--- a/externals/grill/vst/src/vsthost.cpp
+++ b/externals/grill/vst/src/vsthost.cpp
@@ -16,6 +16,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
typedef AEffect *(VSTCALLBACK *PVSTMAIN)(audioMasterCallback audioMaster);
+
VSTPlugin::VSTPlugin():
h_dll(NULL),hwnd(NULL),_pEffect(NULL),
posx(0),posy(0),caption(true),
@@ -66,7 +67,9 @@ BadParameter:
}
#endif
-int VSTPlugin::Instance(const char *dllname)
+static long uniqueid = 0;
+
+int VSTPlugin::Instance(const char *dllname,const char *subname)
{
#ifdef FLEXT_DEBUG
flext::post("New Plugin 1 - %x",this);
@@ -141,17 +144,11 @@ int VSTPlugin::Instance(const char *dllname)
return VSTINSTANCE_ERR_NO_VST_PLUGIN;
}
+
+ uniqueid = 0;
+
//This calls the "main" function and receives the pointer to the AEffect structure.
_pEffect = pluginmain((audioMasterCallback)audioMasterFPtr);
-
-#ifdef __MACOSX__
-#ifdef __CFM__
- DisposeCFMFromMachO(audioMasterFPtr);
- DisposeMachOFromCFM(pluginmain);
-#endif
-#endif
-
-
if(!_pEffect || _pEffect->magic != kEffectMagic) {
post("VST plugin : Unable to create effect");
@@ -161,6 +158,39 @@ int VSTPlugin::Instance(const char *dllname)
return VSTINSTANCE_ERR_REJECTED;
}
+ if(subname && *subname && Dispatch(effGetPlugCategory) == kPlugCategShell) {
+ // scan shell for subplugins
+ char tempName[64];
+ char idname[5]; idname[4] = 0;
+ while((uniqueid = Dispatch(effShellGetNextPlugin,0,0,tempName))) {
+ // subplug needs a name
+ *(long *)idname = uniqueid;
+ post("plug %s - %s",idname,tempName);
+ if(!strcmp(subname,tempName) || !strcmp(subname,idname)) break;
+ }
+ }
+
+ if(uniqueid) {
+ // re-init with uniqueID set
+ _pEffect = pluginmain((audioMasterCallback)audioMasterFPtr);
+ if(!_pEffect || _pEffect->magic != kEffectMagic) {
+ post("VST plugin : Unable to create effect");
+
+ _pEffect = NULL;
+ FreeVST(h_dll);
+ h_dll = NULL;
+ return VSTINSTANCE_ERR_REJECTED;
+ }
+ }
+
+#ifdef __MACOSX__
+#ifdef __CFM__
+ DisposeCFMFromMachO(audioMasterFPtr);
+ DisposeMachOFromCFM(pluginmain);
+#endif
+#endif
+
+
//init plugin
_pEffect->user = this;
@@ -539,9 +569,11 @@ long VSTPlugin::Master(AEffect *effect, long opcode, long index, long value, voi
#endif
#ifdef FLEXT_DEBUG
-// post("VST -> host: Eff = 0x%.8X, Opcode = %d, Index = %d, Value = %d, PTR = %.8X, OPT = %.3f\n",(int)effect, opcode,index,value,(int)ptr,opt);
+ post("VST -> host: Eff = 0x%.8X, Opcode = %d, Index = %d, Value = %d, PTR = %.8X, OPT = %.3f\n",(int)effect, opcode,index,value,(int)ptr,opt);
#endif
+// VSTPlugin *th = effect?(VSTPlugin *)effect->user:NULL;
+
switch (opcode) {
case audioMasterAutomate: // 0
#ifdef FLEXT_DEBUG
@@ -552,10 +584,12 @@ long VSTPlugin::Master(AEffect *effect, long opcode, long index, long value, voi
return 0;
case audioMasterVersion: // 1
// support VST 2.3
-// return 2300;
- return 2;
- case audioMasterCurrentId: // 2
- return 0;
+ return 2300;
+// return 2;
+ case audioMasterCurrentId: { // 2
+ return uniqueid;
+ }
+
case audioMasterIdle: // 3
effect->dispatcher(effect, effEditIdle, 0, 0, NULL, 0.0f);
return 0;
@@ -644,11 +678,13 @@ long VSTPlugin::Master(AEffect *effect, long opcode, long index, long value, voi
else if(!strcmp((char *)ptr,"sizeWindow"))
return 1;
else if(!strcmp((char *)ptr,"supportShell"))
- return 0; // NOT YET!
+ return 0; // deprecated - new one is shellCategory
else if(!strcmp((char *)ptr,"offline"))
return 0; // not supported
else if(!strcmp((char *)ptr,"asyncProcessing"))
return 0; // not supported
+ else if(!strcmp((char *)ptr,"shellCategory"))
+ return 1; // supported!
return 0; // not supported
case audioMasterGetLanguage: // 38
@@ -693,7 +729,7 @@ long VSTPlugin::Master(AEffect *effect, long opcode, long index, long value, voi
return 2; // vst version, currently 7 (0 for older)
case audioMasterCurrentId:
- return 'AASH'; // returns the unique id of a plug that's currently loading
+ return subplugid;
case audioMasterIdle:
effect->dispatcher(effect, effEditIdle, 0, 0, NULL, 0.0f);
diff --git a/externals/grill/vst/src/vsthost.h b/externals/grill/vst/src/vsthost.h
index 036f2806..185a7113 100644
--- a/externals/grill/vst/src/vsthost.h
+++ b/externals/grill/vst/src/vsthost.h
@@ -53,8 +53,7 @@ public:
VSTPlugin();
~VSTPlugin();
- int Instance(const char *dllname);
-// void Create(VSTPlugin *plug);
+ int Instance(const char *dllname,const char *subplug = NULL);
void Free();
void DspInit(float samplerate,int blocksize);
@@ -166,19 +165,13 @@ protected:
typedef std::map<std::string,int,NameCmp> NameMap;
int paramnamecnt;
NameMap paramnames;
-
-/*
- float *inputs[MAX_INOUTS];
- float *outputs[MAX_INOUTS];
-*/
+
// static VstTimeInfo _timeInfo;
VstMidiEvent midievent[MAX_EVENTS];
VstEvents events;
int queue_size;
-// float sample_rate;
-
void SendMidi();
char _midichannel;