[PD-cvs] externals/grill/vst/src main.cpp,1.20,1.21 main.h,1.6,1.7 vsthost.cpp,1.2,1.3 vsthost.h,1.2,1.3

Thomas Grill xovo at users.sourceforge.net
Thu Mar 10 06:01:33 CET 2005


Update of /cvsroot/pure-data/externals/grill/vst/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3653/src

Modified Files:
	main.cpp main.h vsthost.cpp vsthost.h 
Log Message:
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)


Index: vsthost.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/vst/src/vsthost.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** vsthost.h	20 Dec 2004 05:11:56 -0000	1.2
--- vsthost.h	10 Mar 2005 05:01:30 -0000	1.3
***************
*** 54,59 ****
  	~VSTPlugin();
  
! 	int Instance(const char *dllname);
! //	void Create(VSTPlugin *plug);
  	void Free();
  	void DspInit(float samplerate,int blocksize);
--- 54,58 ----
  	~VSTPlugin();
  
! 	int Instance(const char *dllname,const char *subplug = NULL);
  	void Free();
  	void DspInit(float samplerate,int blocksize);
***************
*** 167,175 ****
      int paramnamecnt;
      NameMap paramnames;
! 
! /*
! 	float *inputs[MAX_INOUTS];
! 	float *outputs[MAX_INOUTS];
! */
  
  //	static VstTimeInfo _timeInfo;
--- 166,170 ----
      int paramnamecnt;
      NameMap paramnames;
!  
  
  //	static VstTimeInfo _timeInfo;
***************
*** 178,183 ****
  	int	queue_size;
  
- //    float sample_rate;
- 
  	void SendMidi();
  	char _midichannel;
--- 173,176 ----

Index: vsthost.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/vst/src/vsthost.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** vsthost.cpp	20 Dec 2004 05:11:55 -0000	1.2
--- vsthost.cpp	10 Mar 2005 05:01:30 -0000	1.3
***************
*** 17,20 ****
--- 17,21 ----
  
  
+ 
  VSTPlugin::VSTPlugin():
      h_dll(NULL),hwnd(NULL),_pEffect(NULL),
***************
*** 67,71 ****
  #endif
  
! int VSTPlugin::Instance(const char *dllname)
  {
  #ifdef FLEXT_DEBUG
--- 68,74 ----
  #endif
  
! static long uniqueid = 0;
! 
! int VSTPlugin::Instance(const char *dllname,const char *subname)
  {
  #ifdef FLEXT_DEBUG
***************
*** 142,156 ****
  	}
  
  	//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");
--- 145,153 ----
  	}
  
+ 
+     uniqueid = 0;
+ 
  	//This calls the "main" function and receives the pointer to the AEffect structure.
  	_pEffect = pluginmain((audioMasterCallback)audioMasterFPtr);
  	if(!_pEffect || _pEffect->magic != kEffectMagic) {
  		post("VST plugin : Unable to create effect");
***************
*** 162,165 ****
--- 159,195 ----
      }
  	
+     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;
***************
*** 540,546 ****
  
  #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);
  #endif
  
  	switch (opcode) {
      case audioMasterAutomate: // 0
--- 570,578 ----
  
  #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);
  #endif
  
+ //    VSTPlugin *th = effect?(VSTPlugin *)effect->user:NULL;
+ 
  	switch (opcode) {
      case audioMasterAutomate: // 0
***************
*** 553,560 ****
      case audioMasterVersion: // 1
          // support VST 2.3
! //        return 2300;
!         return 2;
!     case audioMasterCurrentId: // 2
!         return 0;
  	case audioMasterIdle: // 3
  		effect->dispatcher(effect, effEditIdle, 0, 0, NULL, 0.0f);
--- 585,594 ----
      case audioMasterVersion: // 1
          // support VST 2.3
!         return 2300;
! //        return 2;
!     case audioMasterCurrentId: { // 2
!         return uniqueid;
!     }
! 
  	case audioMasterIdle: // 3
  		effect->dispatcher(effect, effEditIdle, 0, 0, NULL, 0.0f);
***************
*** 645,653 ****
              return 1;
          else if(!strcmp((char *)ptr,"supportShell"))
!             return 0; // NOT YET!
          else if(!strcmp((char *)ptr,"offline"))
              return 0; // not supported
          else if(!strcmp((char *)ptr,"asyncProcessing"))
              return 0; // not supported
  
  		return 0; // not supported
--- 679,689 ----
              return 1;
          else if(!strcmp((char *)ptr,"supportShell"))
!             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
***************
*** 694,698 ****
  		
  	case audioMasterCurrentId:			
! 		return 'AASH';	// returns the unique id of a plug that's currently loading
  
  	case audioMasterIdle:
--- 730,734 ----
  		
  	case audioMasterCurrentId:			
! 		return subplugid;
  
  	case audioMasterIdle:

Index: main.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/vst/src/main.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** main.cpp	14 Nov 2004 03:34:31 -0000	1.20
--- main.cpp	10 Mar 2005 05:01:29 -0000	1.21
***************
*** 3,11 ****
  based on the work of Jarno Seppänen and Mark Williamson
  
! Copyright (c)2003-2004 Thomas Grill (xovo at gmx.net)
  For information on usage and redistribution, and for a DISCLAIMER OF ALL
  WARRANTIES, see the file, "license.txt," in this distribution.  
  */
  
  #include "main.h"
  
--- 3,14 ----
  based on the work of Jarno Seppänen and Mark Williamson
  
! Copyright (c)2003-2005 Thomas Grill (gr at 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"
  
***************
*** 20,27 ****
  #include <direct.h>
  #include <io.h>
  #endif
  
  
! #define VST_VERSION "0.1.0pre17"
  
  
--- 23,31 ----
  #include <direct.h>
  #include <io.h>
+ #include <objbase.h>
  #endif
  
  
! #define VST_VERSION "0.1.0pre18"
  
  
***************
*** 39,46 ****
--- 43,56 ----
      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(); }
  
***************
*** 98,102 ****
  
      VSTPlugin *plug;
!     std::string plugname;
      bool echoparam,visible,bypass,mute;
      int paramnames;
--- 108,112 ----
  
      VSTPlugin *plug;
!     std::string plugname,subplug;
      bool echoparam,visible,bypass,mute;
      int paramnames;
***************
*** 119,122 ****
--- 129,133 ----
  
      FLEXT_CALLVAR_V(mg_plug,ms_plug)
+     FLEXT_CALLVAR_V(mg_subplug,ms_subplug)
  
      FLEXT_CALLVAR_B(mg_edit,ms_edit)
***************
*** 176,184 ****
  {
      post("");
! 	post("vst~ %s - VST plugin object, (C)2003-04 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,"edit",mg_edit,ms_edit);
  	FLEXT_CADDATTR_GET(c,"editor",mg_editor);
--- 187,196 ----
  {
      post("");
! 	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);
***************
*** 248,251 ****
--- 260,268 ----
      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
  }
  
***************
*** 253,256 ****
--- 270,276 ----
  {
      ClearPlug();
+ #if FLEXT_OS == FLEXT_OS_WIN
+     CoUninitialize();
+ #endif
  }
  
***************
*** 391,395 ****
  
  	// try loading the dll from the raw filename 
! 	if ((loaderr = plug->Instance(plugname.c_str())) == VSTINSTANCE_NO_ERROR) {
  		FLEXT_LOG("raw filename loaded fine");
  		lf = true;
--- 411,415 ----
  
  	// try loading the dll from the raw filename 
! 	if ((loaderr = plug->Instance(plugname.c_str(),subplug.c_str())) == VSTINSTANCE_NO_ERROR) {
  		FLEXT_LOG("raw filename loaded fine");
  		lf = true;
***************
*** 463,466 ****
--- 483,507 ----
  }
  
+ 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 *)
  {

Index: main.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/vst/src/main.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** main.h	14 Nov 2004 03:34:31 -0000	1.6
--- main.h	10 Mar 2005 05:01:30 -0000	1.7
***************
*** 3,7 ****
  based on the work of Jarno Seppänen and Mark Williamson
  
! Copyright (c)2003-2004 Thomas Grill (xovo at gmx.net)
  For information on usage and redistribution, and for a DISCLAIMER OF ALL
  WARRANTIES, see the file, "license.txt," in this distribution.  
--- 3,7 ----
  based on the work of Jarno Seppänen and Mark Williamson
  
! Copyright (c)2003-2005 Thomas Grill (gr at grrrr.org)
  For information on usage and redistribution, and for a DISCLAIMER OF ALL
  WARRANTIES, see the file, "license.txt," in this distribution.  





More information about the Pd-cvs mailing list