[PD-cvs] externals/grill/vst/src EditorMac.cpp,NONE,1.1 VstHost.cpp,1.14,1.15 VstHost.h,1.10,1.11 main.cpp,1.19,1.20 main.h,1.5,1.6

Thomas Grill xovo at users.sourceforge.net
Sun Nov 14 04:34:34 CET 2004


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

Modified Files:
	VstHost.cpp VstHost.h main.cpp main.h 
Added Files:
	EditorMac.cpp 
Log Message:
a bit of code for OS X
editor-less Mac version


--- NEW FILE: EditorMac.cpp ---
(This appears to be a binary file; contents omitted.)

Index: main.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/vst/src/main.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** main.cpp	11 Sep 2004 04:09:17 -0000	1.19
--- main.cpp	14 Nov 2004 03:34:31 -0000	1.20
***************
*** 14,24 ****
  
  #include <stdlib.h>
  #include <direct.h>
  #include <io.h>
! 
! #include <string>
  
  
! #define VST_VERSION "0.1.0pre16"
  
  
--- 14,27 ----
  
  #include <stdlib.h>
+ #include <string.h>
+ #include <string>
+ 
+ #if FLEXT_OS == FLEXT_OS_WIN
  #include <direct.h>
  #include <io.h>
! #endif
  
  
! #define VST_VERSION "0.1.0pre17"
  
  
***************
*** 265,269 ****
      FLEXT_ASSERT(plug);
  
! 	vstfun = plug->IsReplacing()?VSTPlugin::processReplacing:VSTPlugin::process;
      sigmatch = plug->GetNumInputs() == CntInSig() && plug->GetNumOutputs() == CntOutSig();
      InitPlugDSP();
--- 268,272 ----
      FLEXT_ASSERT(plug);
  
! 	vstfun = plug->IsReplacing()?&VSTPlugin::processReplacing:&VSTPlugin::process;
      sigmatch = plug->GetNumInputs() == CntInSig() && plug->GetNumOutputs() == CntOutSig();
      InitPlugDSP();
***************
*** 287,296 ****
  
      if(vstin) {
!         for(I i = 0; i < plug->GetNumInputs(); ++i) delete[] vstin[i];
          delete[] vstin; vstin = NULL;
          delete[] tmpin; tmpin = NULL;
      }
      if(vstout) {
!         for(I i = 0; i < plug->GetNumOutputs(); ++i) delete[] vstout[i];
          delete[] vstout; vstout = NULL;
          delete[] tmpout; tmpout = NULL;
--- 290,299 ----
  
      if(vstin) {
!         for(I i = 0; i < plug->GetNumInputs(); ++i) FreeAligned(vstin[i]);
          delete[] vstin; vstin = NULL;
          delete[] tmpin; tmpin = NULL;
      }
      if(vstout) {
!         for(I i = 0; i < plug->GetNumOutputs(); ++i) FreeAligned(vstout[i]);
          delete[] vstout; vstout = NULL;
          delete[] tmpout; tmpout = NULL;
***************
*** 307,321 ****
      vstin = new R *[inputs];
      tmpin = new R *[inputs];
!     for(i = 0; i < inputs; ++i) vstin[i] = new R[Blocksize()];
      
      vstout = new R *[outputs];
      tmpout = new R *[outputs];
!     for(i = 0; i < outputs; ++i) vstout[i] = new R[Blocksize()];
  }
  
  static std::string findFilePath(const std::string &path,const std::string &dllname)
  {
- 	_chdir( path.c_str() );
  #if FLEXT_OS == FLEXT_OS_WIN
      WIN32_FIND_DATA data;
      HANDLE fh = FindFirstFile(dllname.c_str(),&data);
--- 310,324 ----
      vstin = new R *[inputs];
      tmpin = new R *[inputs];
!     for(i = 0; i < inputs; ++i) vstin[i] = (R *)NewAligned(Blocksize()*sizeof(R));
      
      vstout = new R *[outputs];
      tmpout = new R *[outputs];
!     for(i = 0; i < outputs; ++i) vstout[i] = (R *)NewAligned(Blocksize()*sizeof(R));
  }
  
  static std::string findFilePath(const std::string &path,const std::string &dllname)
  {
  #if FLEXT_OS == FLEXT_OS_WIN
+ 	_chdir( path.c_str() );
      WIN32_FIND_DATA data;
      HANDLE fh = FindFirstFile(dllname.c_str(),&data);
***************
*** 359,363 ****
--- 362,368 ----
  		if(i > 0) plugname += ' ';
  		GetAString(argv[i],buf,sizeof buf);
+ #if FLEXT_OS == FLEXT_OS_WIN
          strlwr(buf);
+ #endif
  
  #if FLEXT_SYS == FLEXT_SYS_PD
***************
*** 448,452 ****
  
      if(!lf) { // failed - don't make any ins or outs
! 		post("%s - unable to load plugin '%s', load error %i",thisName(),plugname,loaderr);
  		ClearPlug();
  	}
--- 453,457 ----
  
      if(!lf) { // failed - don't make any ins or outs
! 		post("%s - unable to load plugin '%s', load error %i",thisName(),plugname.c_str(),loaderr);
  		ClearPlug();
  	}

Index: VstHost.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/vst/src/VstHost.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** VstHost.cpp	11 Sep 2004 04:09:17 -0000	1.14
--- VstHost.cpp	14 Nov 2004 03:34:31 -0000	1.15
***************
*** 29,32 ****
--- 29,70 ----
  }
   
+ static void FreeVST(void *handle)
+ {
+ #if FLEXT_OS == FLEXT_OS_WIN
+     FreeLibrary(h_dll); 
+ #elif FLEXT_OS == FLEXT_OS_MAC
+ #else
+ #error Platform not supported
+ #endif    
+ } 
+ 
+ #if FLEXT_OS == FLEXT_OS_MAC
+ OSStatus FSPathMakeFSSpec(
+   const UInt8 *path,
+   FSSpec *spec,
+   Boolean *isDirectory)  /* can be NULL */
+ {
+   OSStatus  result;
+   FSRef    ref;
+   
+   /* check parameters */
+   require_action(NULL != spec, BadParameter, result = paramErr);
+   
+   /* convert the POSIX path to an FSRef */
+   result = FSPathMakeRef(path, &ref, isDirectory);
+   require_noerr(result, FSPathMakeRef);
+   
+   /* and then convert the FSRef to an FSSpec */
+   result = FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, NULL, spec, NULL);
+   require_noerr(result, FSGetCatalogInfo);
+   
+ FSGetCatalogInfo:
+ FSPathMakeRef:
+ BadParameter:
+ 
+   return ( result );
+ }
+ #endif
+ 
  int VSTPlugin::Instance(const char *dllname)
  {
***************
*** 35,45 ****
  #endif
  
      h_dll = LoadLibrary(dllname);
  	if(!h_dll)
  		return VSTINSTANCE_ERR_NO_VALID_FILE;
  
! 	PVSTMAIN main = (PVSTMAIN)GetProcAddress(h_dll,"main");
! 	if(!main) {	
! 		FreeLibrary(h_dll);
  		_pEffect = NULL;
  		return VSTINSTANCE_ERR_NO_VST_PLUGIN;
--- 73,141 ----
  #endif
  
+     PVSTMAIN pluginmain;
+ #if FLEXT_OS == FLEXT_OS_WIN
      h_dll = LoadLibrary(dllname);
  	if(!h_dll)
  		return VSTINSTANCE_ERR_NO_VALID_FILE;
  
!     pluginmain = (PVSTMAIN)GetProcAddress(h_dll,"main");
!     void *audioMasterFPtr = Master;
!     
! #elif FLEXT_OS == FLEXT_OS_MAC
!     short   resFileID;
!     FSSpec  spec;
!     OSErr err;
! 
!     err = FSPathMakeFSSpec(dllname,&spec,NULL);
!     resFileID = FSpOpenResFile(&spec, fsRdPerm);
!     short cResCB = Count1Resources('aEff');
! 
!     for(int i = 0; i < cResCB; i++) {
!         Handle             codeH;
!         CFragConnectionID  connID;
!         Ptr                mainAddr;
!         Str255             errName;
!         Str255             fragName;
!         char               fragNameCStr[256];
!         short              resID;
!         OSType             resType;
! 
!         codeH = Get1IndResource('aEff', short(i+1));
!         if (!codeH) continue;
! 
!         GetResInfo(codeH, &resID, &resType, fragName);
!         DetachResource(codeH);
!         HLock(codeH);
! 
!         err = GetMemFragment(*codeH,
!                              GetHandleSize(codeH),
!                              fragName,
!                              kPrivateCFragCopy,
!                              &connID, (Ptr *) & mainAddr, errName);
! 
!         if (!err) {
!            #ifdef __CFM__
!            pluginmain = (PVSTMAIN)NewMachOFromCFM(mainAddr);
!            #else
!            pluginmain = (PVSTMAIN)mainAddr;
!            #endif
!         }
!     }
! 
!     CloseResFile(resFileID);
! 
!     void *audioMasterFPtr = 
! #ifdef __CFM__
!         NewCFMFromMachO(Master);
! #else
!         Master;
! #endif
! 
! #else
! #error Platform not supported
! #endif    
! 
! 	if(!pluginmain) {	
! 		FreeVST(h_dll);
  		_pEffect = NULL;
  		return VSTINSTANCE_ERR_NO_VST_PLUGIN;
***************
*** 47,57 ****
  
  	//This calls the "main" function and receives the pointer to the AEffect structure.
! 	_pEffect = main((audioMasterCallback)Master);
  	
  	if(!_pEffect || _pEffect->magic != kEffectMagic) {
  		post("VST plugin : Unable to create effect");
  
  	    _pEffect = NULL;
! 		FreeLibrary(h_dll); h_dll = NULL;
  	    return VSTINSTANCE_ERR_REJECTED;
      }
--- 143,162 ----
  
  	//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");
  
  	    _pEffect = NULL;
! 		FreeVST(h_dll); 
!         h_dll = NULL;
  	    return VSTINSTANCE_ERR_REJECTED;
      }
***************
*** 159,163 ****
          // holding the necessary data, so that both can operate independently
  
!         if(h_dll) { FreeLibrary(h_dll); h_dll = NULL; }
  
  #ifdef FLEXT_DEBUG
--- 264,271 ----
          // holding the necessary data, so that both can operate independently
  
!         if(h_dll) { 
!             FreeVST(h_dll); 
!             h_dll = NULL; 
!         }
  
  #ifdef FLEXT_DEBUG
***************
*** 426,430 ****
  long VSTPlugin::Master(AEffect *effect, long opcode, long index, long value, void *ptr, float opt)
  {
! #if 1
      audioMasterEnum op = (audioMasterEnum)opcode;
      audioMasterEnumx opx = (audioMasterEnumx)opcode;
--- 534,538 ----
  long VSTPlugin::Master(AEffect *effect, long opcode, long index, long value, void *ptr, float opt)
  {
! #if 0
      audioMasterEnum op = (audioMasterEnum)opcode;
      audioMasterEnumx opx = (audioMasterEnumx)opcode;

Index: VstHost.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/vst/src/VstHost.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** VstHost.h	11 Sep 2004 04:09:17 -0000	1.10
--- VstHost.h	14 Nov 2004 03:34:31 -0000	1.11
***************
*** 14,21 ****
--- 14,25 ----
  #include "AEffectx.h"
  #include "AEffEditor.hpp"
+ #include <string>
  
  #if FLEXT_OS == FLEXT_OS_WIN
  #include <windows.h>
  typedef HWND WHandle;
+ #elif FLEXT_OS == FLEXT_OS_MAC
+ #include <CoreServices/CoreServices.h>
+ typedef Handle WHandle;
  #else
  #error Platform not supported!
***************
*** 55,59 ****
      bool Is() const { return _pEffect != NULL; }
  
!     ULONG GetVersion() const { return _pEffect?_pEffect->version:0; }
  
      bool IsSynth() const { return HasFlags(effFlagsIsSynth); }
--- 59,63 ----
      bool Is() const { return _pEffect != NULL; }
  
!     long GetVersion() const { return _pEffect?_pEffect->version:0; }
  
      bool IsSynth() const { return HasFlags(effFlagsIsSynth); }
***************
*** 140,143 ****
--- 144,149 ----
  #if FLEXT_OS == FLEXT_OS_WIN
  	HMODULE h_dll;
+ #elif FLEXT_OS == FLEXT_OS_MAC
+ 	void *h_dll;
  #else
  #error

Index: main.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/vst/src/main.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** main.h	23 Jan 2004 04:20:41 -0000	1.5
--- main.h	14 Nov 2004 03:34:31 -0000	1.6
***************
*** 19,23 ****
  #endif
  
! #if FLEXT_OS == FLEXT_OS_WIN
  //
  #else
--- 19,23 ----
  #endif
  
! #if FLEXT_OS == FLEXT_OS_WIN || FLEXT_OS == FLEXT_OS_MAC
  //
  #else





More information about the Pd-cvs mailing list