[PD-cvs] externals/grill/vst/src VstHost.cpp,1.10,1.11 main.cpp,1.14,1.15

Thomas Grill xovo at users.sourceforge.net
Sun Aug 22 04:47:22 CEST 2004


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

Modified Files:
	VstHost.cpp main.cpp 
Log Message:
 ""

Index: main.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/vst/src/main.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** main.cpp	24 Feb 2004 03:37:12 -0000	1.14
--- main.cpp	22 Aug 2004 02:47:19 -0000	1.15
***************
*** 21,25 ****
  
  
! #define VST_VERSION "0.1.0pre11"
  
  
--- 21,25 ----
  
  
! #define VST_VERSION "0.1.0pre12"
  
  
***************
*** 58,64 ****
      V mg_programs(I &p) const { p = plug?plug->GetNumPrograms():0; }
      V mg_progcats(I &p) const { p = plug?plug->GetNumCategories():0; }
!     V mg_plugname(const S *&s) const { s = MakeSymbol(plug?plug->GetName():""); }
!     V mg_plugvendor(const S *&s) const { s = MakeSymbol(plug?plug->GetVendorName():""); }
!     V mg_plugdll(const S *&s) const { s = MakeSymbol(plug?plug->GetDllName():""); }
      V mg_plugversion(I &v) const { v = plug?plug->GetVersion():0; }
      V mg_issynth(BL &s) const { s = plug && plug->IsSynth(); }
--- 58,64 ----
      V mg_programs(I &p) const { p = plug?plug->GetNumPrograms():0; }
      V mg_progcats(I &p) const { p = plug?plug->GetNumCategories():0; }
!     V mg_plugname(const S *&s) const { s = plug?MakeSymbol(plug->GetName()):sym__; }
!     V mg_plugvendor(const S *&s) const { s = plug?MakeSymbol(plug->GetVendorName()):sym__; }
!     V mg_plugdll(const S *&s) const { s = plug?MakeSymbol(plug->GetDllName()):sym__; }
      V mg_plugversion(I &v) const { v = plug?plug->GetVersion():0; }
      V mg_issynth(BL &s) const { s = plug && plug->IsSynth(); }
***************
*** 87,91 ****
      VSTPlugin *plug;
      string plugname;
!     BL echoparam,visible;
  
      I blsz;
--- 87,91 ----
      VSTPlugin *plug;
      string plugname;
!     BL echoparam,visible,bypass,mute;
  
      I blsz;
***************
*** 96,102 ****
      V InitPlug();
      V ClearPlug();
      V InitBuf();
      V ClearBuf();
! 	static V Setup(t_classid);
  	
  
--- 96,104 ----
      V InitPlug();
      V ClearPlug();
+     V InitPlugDSP();
      V InitBuf();
      V ClearBuf();
! 
!     static V Setup(t_classid);
  	
  
***************
*** 108,111 ****
--- 110,115 ----
      FLEXT_CALLGET_B(mg_editor)
      FLEXT_CALLVAR_B(mg_vis,ms_vis)
+     FLEXT_ATTRVAR_B(bypass)
+     FLEXT_ATTRVAR_B(mute)
  
  //    FLEXT_CALLBACK_2(m_control,t_symptr,int)
***************
*** 154,157 ****
--- 158,163 ----
  	FLEXT_CADDATTR_GET(c,"editor",mg_editor);
  	FLEXT_CADDATTR_VAR(c,"vis",mg_vis,ms_vis);
+ 	FLEXT_CADDATTR_VAR1(c,"bypass",bypass);
+ 	FLEXT_CADDATTR_VAR1(c,"mute",mute);
  	FLEXT_CADDMETHOD_(c,0,"print",m_print);
  
***************
*** 194,198 ****
      blsz(0),
      vstfun(NULL),vstin(NULL),vstout(NULL),tmpin(NULL),tmpout(NULL),
!     echoparam(false)
  {
      if(argc >= 2 && CanbeInt(argv[0]) && CanbeInt(argv[1])) {
--- 200,204 ----
      blsz(0),
      vstfun(NULL),vstin(NULL),vstout(NULL),tmpin(NULL),tmpout(NULL),
!     echoparam(false),bypass(false),mute(false)
  {
      if(argc >= 2 && CanbeInt(argv[0]) && CanbeInt(argv[1])) {
***************
*** 202,209 ****
          if(argc >= 3 && !ms_plug(argc-2,argv+2)) InitProblem();
      }
!     else {
!         post("%s - syntax: vst~ inputs outputs [plug]",thisName());
!         InitProblem();
!     }
  }
  
--- 208,213 ----
          if(argc >= 3 && !ms_plug(argc-2,argv+2)) InitProblem();
      }
!     else
!         throw "syntax: vst~ inputs outputs [plug]";
  }
  
***************
*** 228,235 ****
--- 232,248 ----
  	vstfun = plug->IsReplacing()?VSTPlugin::processReplacing:VSTPlugin::process;
      sigmatch = plug->GetNumInputs() == CntInSig() && plug->GetNumOutputs() == CntOutSig();
+     InitPlugDSP();
  
      InitBuf();
  }
  
+ V vst::InitPlugDSP()
+ {
+     FLEXT_ASSERT(plug);
+     // this might be invalid if DSP is switched off, 
+     // but the plug will get updated settings with m_dsp later
+     plug->DspInit(Samplerate(),Blocksize());
+ }
+ 
  V vst::ClearBuf()
  {
***************
*** 400,406 ****
  {
      if(plug) {
-         plug->DspInit(Samplerate(),Blocksize());
          FLEXT_ASSERT(vstfun);
  
          if(blsz != Blocksize()) {
              blsz = Blocksize();
--- 413,420 ----
  {
      if(plug) {
          FLEXT_ASSERT(vstfun);
  
+         InitPlugDSP();
+ 
          if(blsz != Blocksize()) {
              blsz = Blocksize();
***************
*** 413,417 ****
  V vst::m_signal(I n,R *const *insigs,R *const *outsigs)
  {
!     if(plug) {
          const int inputs = plug->GetNumInputs(),outputs = plug->GetNumOutputs();
  
--- 427,443 ----
  V vst::m_signal(I n,R *const *insigs,R *const *outsigs)
  {
!     if(mute)
!         flext_dsp::m_signal(n,insigs,outsigs);
!     else if(bypass) {
!         // copy as many channels as possible and zero dangling ones
! 
!         int i,mx = CntInSig();
!         if(mx > CntOutSig()) mx = CntOutSig();
!         for(i = 0; i < mx; ++i)
!             CopySamples(outsigs[i],insigs[i],n);
!         for(; i < CntOutSig(); ++i)
!             ZeroSamples(outsigs[i],n);
!     }
!     else if(plug) {
          const int inputs = plug->GetNumInputs(),outputs = plug->GetNumOutputs();
  
***************
*** 449,452 ****
--- 475,482 ----
              if(more) {
                  // according to mode set dangling output vectors
+ 
+                 // currently simply clear them....
+                 for(int i = outputs; i < CntOutSig(); ++i)
+                     ZeroSamples(outsigs[i],n);
              }
          }

Index: VstHost.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/vst/src/VstHost.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** VstHost.cpp	21 Jun 2004 14:07:23 -0000	1.10
--- VstHost.cpp	22 Aug 2004 02:47:19 -0000	1.11
***************
*** 134,138 ****
  		Dispatch(effClose);
  
- //		delete _pEffect; // <-  Should check for the necessity of this command.
  		_pEffect = NULL;
          if(h_dll) { FreeLibrary(h_dll); h_dll = NULL; }
--- 134,137 ----
***************
*** 345,359 ****
  long VSTPlugin::Master(AEffect *effect, long opcode, long index, long value, void *ptr, float opt)
  {
! #if 1 //def 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
  		// index, value given
  		//! \todo set effect parameter
          return 0;
      case audioMasterVersion: // 1
!         return 2;
      case audioMasterCurrentId: // 2
          return 0;
--- 344,367 ----
  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;
! #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);
  #endif
  
  	switch (opcode) {
      case audioMasterAutomate: // 0
+ #ifdef FLEXT_DEBUG
+         post("Automate index=%li value=%li",index,value);
+ #endif
  		// index, value given
  		//! \todo set effect parameter
          return 0;
      case audioMasterVersion: // 1
!         // support VST 2.3
!         return 2300;
      case audioMasterCurrentId: // 2
          return 0;
***************
*** 364,373 ****
--- 372,442 ----
  		//! \todo set connection state correctly (if possible..)
  		// index=pin, value=0..input, else..output
+ #ifdef FLEXT_DEBUG
+         post("Pin connected pin=%li conn=%li",index,value);
+ #endif
  		return 0; // 0 means connected
+ 	case audioMasterWantMidi: // 6
+ #ifdef FLEXT_DEBUG
+         post("Want MIDI = %li",value);
+ #endif
+ 		return 0; // VST header says: "currently ignored"
  	case audioMasterGetTime: // 7
  		return 0; // not supported
+     case audioMasterProcessEvents: { // 8
+         // VST event data from plugin
+         VstEvent *ev = static_cast<VstEvent *>(ptr);
+         if(ev->type == kVstMidiType) {
+             VstMidiEvent *mev = static_cast<VstMidiEvent *>(ptr);
+ #ifdef FLEXT_DEBUG
+             if(mev->byteSize == 24)
+                 post("MIDI event delta=%li len=%li offs=%li detune=%i offvel=%i",mev->deltaFrames,mev->noteLength,mev->noteOffset,(int)mev->detune,(int)mev->noteOffVelocity);
+             else
+                 // has incorrect size
+                 post("MIDI event");
+ #endif
+         }
+         else {
+ #ifdef FLEXT_DEBUG
+             post("VST event type=%li",ev->type);
+ #endif
+         }
+ 		return 1;
+     }
+     case audioMasterSetTime: { // 9
+         VstTimeInfo *tminfo = static_cast<VstTimeInfo *>(ptr);
+ #ifdef FLEXT_DEBUG
+         post("TimeInfo pos=%lf rate=%lf filter=%li",tminfo->samplePos,tminfo->sampleRate,value);
+ #endif
+         return 0; // not supported
+     }
+ 	case audioMasterTempoAt: // 10
+ 		return 0; // not supported
  	case audioMasterGetNumAutomatableParameters: // 11
  		return 0; // not supported
+     case audioMasterGetCurrentProcessLevel: // 23
+         // return thread state
+         return flext::GetThreadId() == flext::GetSysThreadId()?2:1;
+ 	case audioMasterGetVendorString: // 32
+ 		strcpy((char*)ptr,"grrrr.org");
+         return 0;
+ 	case audioMasterGetProductString: // 33
+ 		strcpy((char *)ptr,"vst~ host external");
+ 		return 0;
+ 	case audioMasterGetVendorVersion: // 34
+ 		return 100;
+ 	case audioMasterCanDo: // 37
+ #ifdef FLEXT_DEBUG
+     	post("\taudioMasterCanDo PTR = %s",ptr);
+ #endif
+ 		return 0; // not supported
+ 	case audioMasterGetLanguage: // 38
+ 		return kVstLangEnglish;
+ 	case audioMasterGetDirectory: // 41
+         // return full path of plugin
+ 		return 0; // not supported
      default:
+ #ifdef FLEXT_DEBUG
+         post("Unknown opcode %li",opcode);
+ #endif
          return 0;
      }





More information about the Pd-cvs mailing list