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/build/nmake-win-msvc.inc | 2 +- externals/grill/vst/pd/help-vst~.pd | 64 ++++++++++++++----------- externals/grill/vst/readme.txt | 2 + externals/grill/vst/src/main.cpp | 51 ++++++++++++++++++-- externals/grill/vst/src/main.h | 2 +- externals/grill/vst/src/vsthost.cpp | 70 +++++++++++++++++++++------- externals/grill/vst/src/vsthost.h | 11 +---- externals/grill/vst/vst.vcproj | 32 +++++++------ 8 files changed, 160 insertions(+), 74 deletions(-) diff --git a/externals/grill/vst/build/nmake-win-msvc.inc b/externals/grill/vst/build/nmake-win-msvc.inc index c51834ed..7503c914 100644 --- a/externals/grill/vst/build/nmake-win-msvc.inc +++ b/externals/grill/vst/build/nmake-win-msvc.inc @@ -1,2 +1,2 @@ INCPATH=/I$(VSTSDKPATH)\source\common -LIBS=user32.lib +LIBS=user32.lib ole32.lib diff --git a/externals/grill/vst/pd/help-vst~.pd b/externals/grill/vst/pd/help-vst~.pd index 01e7db6b..dcf48343 100644 --- a/externals/grill/vst/pd/help-vst~.pd +++ b/externals/grill/vst/pd/help-vst~.pd @@ -1,15 +1,15 @@ -#N canvas 146 124 817 543 12; +#N canvas 146 124 833 559 12; #X obj 26 190 dac~; #X obj 26 94 noise~; #X obj 140 192 print A; -#X obj 230 433 tgl 15 0 empty empty empty 0 -6 0 8 -225271 -1 -1 0 +#X obj 443 431 tgl 15 0 empty empty empty 0 -6 0 8 -225271 -1 -1 1 1; -#X msg 229 455 vis \$1; -#X obj 25 430 tgl 15 0 empty empty empty 0 -6 0 8 -225271 -1 -1 0 1 -; -#X msg 24 452 edit \$1; -#X msg 92 452 getedit; -#X msg 292 455 getvis; +#X msg 442 453 vis \$1; +#X obj 231 430 tgl 15 0 empty empty empty 0 -6 0 8 -225271 -1 -1 1 +1; +#X msg 230 452 edit \$1; +#X msg 298 452 getedit; +#X msg 505 453 getvis; #N canvas 367 122 558 434 info 0; #X msg 94 130 getversion; #X msg 94 75 getname; @@ -52,10 +52,10 @@ #X connect 23 0 7 0; #X restore 445 110 pd info; #X obj 96 96 r \$0-vst; -#X obj 23 479 s \$0-vst; -#X obj 228 481 s \$0-vst; -#X text 50 429 display edit window; -#X text 253 431 make edit window (in)visible; +#X obj 229 479 s \$0-vst; +#X obj 441 479 s \$0-vst; +#X text 256 429 display edit window; +#X text 466 429 make edit window (in)visible; #X msg 105 295 getplug; #X obj 26 323 s \$0-vst; #X text 65 249 set/get plugin; @@ -142,10 +142,8 @@ #X restore 445 208 pd midi; #X text 134 33 based on the work of Jarno Seppanen and Mark Williamson ; -#X text 133 14 VST plugins for PD \, (C)2003-04 Thomas Grill; -#X obj 26 140 vst~ 1 2 @pnames 100; -#X obj 666 433 loadbang; -#X msg 666 460 \; pd dsp 1; +#X obj 723 444 loadbang; +#X msg 723 471 \; pd dsp 1; #X obj 230 324 tgl 15 0 empty empty empty 0 -6 0 8 -225271 -1 -1 0 1; #X obj 228 373 s \$0-vst; @@ -228,25 +226,35 @@ #X text 513 209 midi messages for VST synths; #X text 448 314 Attention: this vst~ version will crash when a plugin is unloaded with the editor window open!; -#X connect 1 0 30 0; +#X text 133 14 VST plugins for PD \, (C)2003-05 Thomas Grill; +#X msg 27 429 subplug AudioTrack; +#X obj 27 479 s \$0-vst; +#X msg 39 452 getsubplug; +#X obj 26 140 vst~ 2 2 @pnames 100; +#X text 27 387 subplugin name for plugin shells; +#X text 229 501 you can also alt-click on the vst~ object; +#X connect 1 0 52 0; +#X connect 1 0 52 1; #X connect 3 0 4 0; #X connect 4 0 12 0; #X connect 5 0 6 0; #X connect 6 0 11 0; #X connect 7 0 11 0; #X connect 8 0 12 0; -#X connect 10 0 30 0; +#X connect 10 0 52 0; #X connect 15 0 16 0; #X connect 24 0 16 0; #X connect 25 0 26 0; #X connect 26 0 24 0; -#X connect 30 0 0 0; -#X connect 30 1 0 1; -#X connect 30 2 2 0; -#X connect 31 0 32 0; -#X connect 33 0 35 0; -#X connect 35 0 34 0; -#X connect 36 0 34 0; -#X connect 38 0 41 0; -#X connect 41 0 39 0; -#X connect 42 0 39 0; +#X connect 29 0 30 0; +#X connect 31 0 33 0; +#X connect 33 0 32 0; +#X connect 34 0 32 0; +#X connect 36 0 39 0; +#X connect 39 0 37 0; +#X connect 40 0 37 0; +#X connect 49 0 50 0; +#X connect 51 0 50 0; +#X connect 52 0 0 0; +#X connect 52 1 0 1; +#X connect 52 2 2 0; diff --git a/externals/grill/vst/readme.txt b/externals/grill/vst/readme.txt index 48a9676e..5c52e97f 100644 --- a/externals/grill/vst/readme.txt +++ b/externals/grill/vst/readme.txt @@ -53,6 +53,8 @@ Version history: - pre12: added "bypass" and "mute" attributes - pre13: with flext 0.4.7 no more interruptions on window close - pre14: allow window titles with spaces and update it on window startup +- pre18: open plug interface on Alt-Click +- pre18: experimental plug shell support 0.0.0: - version of mark@junklight.com 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 #include +#include #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 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; diff --git a/externals/grill/vst/vst.vcproj b/externals/grill/vst/vst.vcproj index 574d1f9b..4541b83d 100644 --- a/externals/grill/vst/vst.vcproj +++ b/externals/grill/vst/vst.vcproj @@ -24,7 +24,7 @@ InlineFunctionExpansion="2" FavorSizeOrSpeed="1" OmitFramePointers="TRUE" - AdditionalIncludeDirectories=""c:\data\prog\pd\pd-cvs\src";..\flext\source;c:\data\prog\audio\vstsdk2.3\source\common" + AdditionalIncludeDirectories="c:\programme\audio\pd\src;..\flext\source;c:\data\prog\audio\vstsdk2.3\source\common" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;WINVER=0x0501;_USRDLL;FLEXT_SYS=2;FLEXT_THREADS" StringPooling="TRUE" RuntimeLibrary="0" @@ -41,7 +41,7 @@ OutputFile="./pd-msvc/vst~.dll" LinkIncremental="1" SuppressStartupBanner="TRUE" - AdditionalLibraryDirectories=""c:\data\prog\pd\pd-cvs\bin"" + AdditionalLibraryDirectories="c:\programme\audio\pd\bin" ProgramDatabaseFile=".\pd-msvc/r/vst~.pdb" OptimizeReferences="2" ImportLibrary=".\pd-msvc/r/vst~.lib" @@ -86,8 +86,8 @@ + RelativePath="..\..\prog\audio\vstsdk2.3\source\common\AEffect.h"> + + + RelativePath="..\..\prog\audio\vstsdk2.3\source\common\AudioEffect.hpp"> + RelativePath="..\..\prog\audio\vstsdk2.3\source\common\audioeffectx.h"> + RelativePath="..\..\prog\audio\vstsdk2.3\source\common\vstcontrols.h"> + RelativePath="..\..\prog\audio\vstsdk2.3\source\common\vstgui.h"> + RelativePath="..\..\prog\audio\vstsdk2.3\source\common\vstplugscarbon.h"> + RelativePath="..\..\prog\audio\vstsdk2.3\source\common\vstplugsmac.h"> + RelativePath="..\..\prog\audio\vstsdk2.3\source\common\vstplugsmacho.h"> + +