From 467591c8ba03dbd60ceada93482460de3b888838 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Thu, 10 Mar 2005 05:01:30 +0000 Subject: 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 --- externals/grill/vst/src/vsthost.cpp | 70 ++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 17 deletions(-) (limited to 'externals/grill/vst/src/vsthost.cpp') 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); -- cgit v1.2.1