[PD-cvs] externals/grill/vst/src Editor.h,1.1,1.2 EditorWin.cpp,1.1,1.2 VstHost.cpp,1.6,1.7 VstHost.h,1.4,1.5 main.cpp,1.12,1.13

xovo at projects.sourceforge.net xovo at projects.sourceforge.net
Tue Jan 27 04:41:29 CET 2004


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

Modified Files:
	Editor.h EditorWin.cpp VstHost.cpp VstHost.h main.cpp 
Log Message:
 ""

Index: Editor.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/vst/src/Editor.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Editor.h	23 Jan 2004 04:20:14 -0000	1.1
--- Editor.h	27 Jan 2004 03:41:26 -0000	1.2
***************
*** 17,20 ****
--- 17,23 ----
  void StopEditor(VSTPlugin *p);
  void ShowEditor(VSTPlugin *p,bool show);
+ void MoveEditor(VSTPlugin *p,int x,int y);
+ void SizeEditor(VSTPlugin *p,int x,int y);
+ bool IsEditorShown(const VSTPlugin *p);
  
  #endif // __EDITOR_H

Index: EditorWin.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/vst/src/EditorWin.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** EditorWin.cpp	23 Jan 2004 04:20:36 -0000	1.1
--- EditorWin.cpp	27 Jan 2004 03:41:26 -0000	1.2
***************
*** 40,44 ****
          case WM_CREATE: 
              // Initialize the window. 
!             plug->SetEditWindow(hwnd);
              break; 
          case WM_CLOSE:
--- 40,44 ----
          case WM_CREATE: 
              // Initialize the window. 
!             plug->StartEditing(hwnd);
              break; 
          case WM_CLOSE:
***************
*** 55,65 ****
              plug->EditorIdle();		
              break; 
!         case WM_MOVE:
!             plug->setPos(LOWORD(lp),HIWORD(lp));
              break; 
  /*
!         case WM_PAINT: 
              // Paint the window's client area. 
              break;  
          case WM_SIZE: 
              // Set the size and position of the window. 
--- 55,73 ----
              plug->EditorIdle();		
              break; 
!         case WM_MOVE: {
!             WORD x = LOWORD(lp),y = HIWORD(lp);
!             plug->SetPos(reinterpret_cast<short &>(x),reinterpret_cast<short &>(y),false);
              break; 
+         }
  /*
!         case WM_PAINT: {
              // Paint the window's client area. 
+             RECT rect;
+             GetUpdateRect(hwnd,rect,FALSE);
+             plug->Paint(rect);
              break;  
+         }
+ */
+ /*
          case WM_SIZE: 
              // Set the size and position of the window. 
***************
*** 113,118 ****
  	    SetTimer(wnd,0,25,NULL);
  
! 	    RECT r = plug->GetEditorRect();
! 	    SetWindowPos(wnd,HWND_TOPMOST,plug->getX(),plug->getY(),(r.right - r.left) + 6 , r.bottom - r.top + 26 , SWP_SHOWWINDOW);
      //	ShowWindow( SW_SHOW );		
      //  BringWindowToTop(wnd);
--- 121,129 ----
  	    SetTimer(wnd,0,25,NULL);
  
! 	    ERect r;
!         plug->GetEditorRect(r);
! //	    SetWindowPos(wnd,HWND_TOP,plug->getX(),plug->getY(),(r.right - r.left) + 6 , r.bottom - r.top + 26 , SWP_SHOWWINDOW);
! 	    SetWindowPos(wnd,HWND_TOP,r.left,r.top,(r.right - r.left) + 6 , r.bottom - r.top + 26 , SWP_SHOWWINDOW);
! 
      //	ShowWindow( SW_SHOW );		
      //  BringWindowToTop(wnd);
***************
*** 178,180 ****
--- 189,207 ----
  }
  
+ void MoveEditor(VSTPlugin *p,int x,int y) 
+ {
+     // the client region must be taken into account
+ //    SetWindowPos(p->EditorHandle(),NULL,x,y,0,0,SWP_NOSIZE|SWP_NOZORDER);
+ }
+ 
+ void SizeEditor(VSTPlugin *p,int x,int y) 
+ {
+     SetWindowPos(p->EditorHandle(),NULL,0,0,x,y,SWP_NOMOVE|SWP_NOZORDER);
+ }
+ 
+ bool IsEditorShown(const VSTPlugin *p) 
+ {
+     return IsWindowVisible(p->EditorHandle()) != FALSE;
+ }
+ 
  #endif // FLEXT_OS_WIN

Index: VstHost.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/vst/src/VstHost.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** VstHost.cpp	23 Jan 2004 04:20:36 -0000	1.6
--- VstHost.cpp	27 Jan 2004 03:41:26 -0000	1.7
***************
*** 10,98 ****
  #include "Editor.h"
  #include "VstHost.h"
- #include "vst\aeffeditor.h"
  #include "vst\aeffectx.h"
  
  using namespace std;
  
! VstTimeInfo VSTPlugin::_timeInfo;
  
! float VSTPlugin::sample_rate = 44100;
  
  
- ////////////////////
- //
- /////////////////////
  VSTPlugin::VSTPlugin():
      posx(0),posy(0),
!     hwnd(NULL),
!     _editor(false)
! {
! 	queue_size=0;
! 	_sDllName = NULL;
! 	h_dll=NULL;
! 	instantiated=false;		// Constructin' with no instance
! 	overwrite = false;
! //    wantidle = false;
! //	 show_params = false;
! 	 _midichannel = 0;
! }
  
  VSTPlugin::~VSTPlugin()
  {
  	Free();				// Call free
- 	delete _sDllName;	// if _sDllName = NULL , the operation does nothing -> it's safe.
  }
   
! int VSTPlugin::Instance( const char *dllname)
  {
  	h_dll = LoadLibrary(dllname);
! 
! 	if(!h_dll) {
  		return VSTINSTANCE_ERR_NO_VALID_FILE;
- 	}
  
- //	post("Loaded library %s" , dllname);
  	PVSTMAIN main = (PVSTMAIN)GetProcAddress(h_dll,"main");
  	if(!main) {	
  		FreeLibrary(h_dll);
! 		_pEffect=NULL;
! 		instantiated=false;
  		return VSTINSTANCE_ERR_NO_VST_PLUGIN;
  	}
! 	//post("Found main function - about to call it");
  	//This calls the "main" function and receives the pointer to the AEffect structure.
! 	_pEffect = main((audioMasterCallback)&(this->Master));
! 	
! 	if(!_pEffect) {
! 		post("VST plugin : unable to create effect");
! 		FreeLibrary(h_dll);
! 		_pEffect=NULL;
! 		instantiated=false;
! 		return VSTINSTANCE_ERR_REJECTED;
! 	}
  	
! 	if(  _pEffect->magic!=kEffectMagic) {
! 		post("VST plugin : Instance query rejected by 0x%.8X\n",(int)_pEffect);
! 		FreeLibrary(h_dll);
! 		_pEffect=NULL;
! 		instantiated=false;
! 		return VSTINSTANCE_ERR_REJECTED;
! 	}
! 
! 	//post("VST plugin : Instanced at (Effect*): %.8X\n",(int)_pEffect);
  
  	//init plugin 
  	_pEffect->user = this;
! 	Dispatch( effOpen        ,  0, 0, NULL, 0.0f);
! 	Dispatch( effSetProgram  ,  0, 0, NULL, 0.0f);
! //	Dispatch( effMainsChanged,  0, 1, NULL, 0.0f);
! 
! 	//************************************set samplerate and stream size here
!     // we get it when we init our DSP
! 
! //	Dispatch( effSetSampleRate, 0, 0, NULL, (float)Global::pConfig->_pOutputDriver->_samplesPerSec);
! //	Dispatch( effSetBlockSize,  0, STREAM_SIZE, NULL, 0.0f);
  
- 	
  	if (!Dispatch( effGetProductString, 0, 0, &_sProductName, 0.0f)) {
  		string str1(dllname);
--- 10,62 ----
  #include "Editor.h"
  #include "VstHost.h"
  #include "vst\aeffectx.h"
  
  using namespace std;
  
! static VstTimeInfo _timeInfo;
  
! typedef AEffect *(*PVSTMAIN)(audioMasterCallback audioMaster);
  
  
  VSTPlugin::VSTPlugin():
+     h_dll(NULL),hwnd(NULL),_pEffect(NULL),
      posx(0),posy(0),
! 	_midichannel(0),queue_size(0)
! {}
  
  VSTPlugin::~VSTPlugin()
  {
  	Free();				// Call free
  }
   
! int VSTPlugin::Instance(const char *dllname)
  {
  	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;
  	}
! 
  	//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;
+     }
+ 	
  	//init plugin 
  	_pEffect->user = this;
!     FLEXT_ASSERT(Dispatch( effOpen ));
! //	Dispatch( effMainsChanged,  0, 1);
  
  	if (!Dispatch( effGetProductString, 0, 0, &_sProductName, 0.0f)) {
  		string str1(dllname);
***************
*** 106,146 ****
  	}
  	
! 	if (!_pEffect->dispatcher(_pEffect, effGetVendorString, 0, 0, &_sVendorName, 0.0f)) {
  		strcpy(_sVendorName, "Unknown vendor");
- 	}
- 
- 	_version = _pEffect->version;
- 	_isSynth = (_pEffect->flags & effFlagsIsSynth)?true:false;
- 	overwrite = (_pEffect->flags & effFlagsCanReplacing)?true:false;
- 	_editor = (_pEffect->flags & effFlagsHasEditor)?true:false;
  
! 	if ( _sDllName != NULL ) delete _sDllName;
! 	_sDllName = new char[strlen(dllname)+1];
! 	sprintf(_sDllName,dllname);
! 	
  	
- 	//keep plugin name
- 	instantiated=true;
- 
  	return VSTINSTANCE_NO_ERROR;
  }
  
- int VSTPlugin::getNumInputs( void )
- {
- 	return _pEffect->numInputs;
- }
- 
- int VSTPlugin::getNumOutputs( void )
- {
- 	return _pEffect->numOutputs;
- }
- 
  
  void VSTPlugin::Create(VSTPlugin *plug)
  {
! 	h_dll=plug->h_dll;
! 	_pEffect=plug->_pEffect;
! 	_pEffect->user=this;
! 	Dispatch( effMainsChanged,  0, 1, NULL, 0.0f);
  //	strcpy(_editName,plug->_editName); On current implementation, this replaces the right one. 
  	strcpy(_sProductName,plug->_sProductName);
--- 70,90 ----
  	}
  	
! 	if(!Dispatch( effGetVendorString, 0, 0, &_sVendorName, 0.0f))
  		strcpy(_sVendorName, "Unknown vendor");
  
! 	_sDllName = dllname;
  	
  	return VSTINSTANCE_NO_ERROR;
  }
  
  
+ /*
  void VSTPlugin::Create(VSTPlugin *plug)
  {
! 	h_dll = plug->h_dll;
! 	_pEffect = plug->_pEffect;
! 	_pEffect->user = this;
! 
! 	Dispatch( effMainsChanged,  0, 1);
  //	strcpy(_editName,plug->_editName); On current implementation, this replaces the right one. 
  	strcpy(_sProductName,plug->_sProductName);
***************
*** 158,195 ****
  	instantiated=true;
  }
  
  void VSTPlugin::Free() // Called also in destruction
  {
!     if(IsEdited()) StopEditor(this);
  
- 	if(instantiated) {
- 		instantiated=false;
- 		post("VST plugin : Free query 0x%.8X\n",(int)_pEffect);
- 		_pEffect->user = NULL;
- 		Dispatch( effMainsChanged, 0, 0, NULL, 0.0f);
- 		Dispatch( effClose,        0, 0, NULL, 0.0f);
  //		delete _pEffect; // <-  Should check for the necessity of this command.
! 		_pEffect=NULL;
! 		FreeLibrary(h_dll);
  	}
  }
  
! void VSTPlugin::Init( float samplerate , float blocksize )
  {
! 	sample_rate = samplerate;
! 	Dispatch(effOpen        ,  0, 0, NULL, 0.f);
! 	Dispatch(effMainsChanged,  0, 1, NULL, 0.f);
! 	Dispatch(effSetSampleRate, 0, 0, 0, (float) sample_rate );
! 	Dispatch(effSetBlockSize,  0, blocksize, NULL, 0.f );
  }
  
  
! bool VSTPlugin::DescribeValue(int p,char* psTxt)
  {
! 	int parameter = p;
! 	if(instantiated)
! 	{
! 		if(parameter<_pEffect->numParams)
! 		{
  //			char par_name[64];
  			char par_display[64];
--- 102,153 ----
  	instantiated=true;
  }
+ */
  
  void VSTPlugin::Free() // Called also in destruction
  {
! 	if(Is()) {
!         if(IsEdited()) StopEditor(this);
! 
!         // shut down plugin
! 		Dispatch(effMainsChanged, 0, 0);
! 		Dispatch(effClose);
  
  //		delete _pEffect; // <-  Should check for the necessity of this command.
! 		_pEffect = NULL;
!         if(h_dll) { FreeLibrary(h_dll); h_dll = NULL; }
  	}
  }
  
! void VSTPlugin::DspInit(float samplerate,int blocksize)
  {
! //	sample_rate = samplerate;
! 
!     Dispatch(effMainsChanged,  0, 1);
! 	Dispatch(effSetSampleRate, 0, 0,NULL,samplerate);
! 	Dispatch(effSetBlockSize,  0, blocksize);
  }
  
+ void VSTPlugin::GetParamName(int numparam,char *name) const
+ {
+ 	if(numparam < GetNumParams()) 
+         Dispatch(effGetParamName,numparam,0,name,0.0f);
+ 	else 
+         strcpy(name,"Index out of Range");
+ }
  
! bool VSTPlugin::SetParamFloat(int parameter,float value)
  {
! 	if(Is() && parameter >= 0 && parameter < GetNumParams()) {
! 		_pEffect->setParameter(_pEffect,parameter,value);
! 		return true;
! 	}
!     else
! 	    return false;
! }
! 
! void VSTPlugin::GetParamValue(int numparam,char *parval) const
! {
!     if(Is()) {
!         if(numparam < GetNumParams()) {
  //			char par_name[64];
  			char par_display[64];
***************
*** 197,251 ****
  
  //			Dispatch(effGetParamName,parameter,0,par_name,0.0f);
! 			Dispatch(effGetParamDisplay,parameter,0,par_display,0.0f);
! 			Dispatch(effGetParamLabel,parameter,0,par_label,0.0f);
  //			sprintf(psTxt,"%s:%s%s",par_name,par_display,par_label);
! 			sprintf(psTxt,"%s%s",par_display,par_label);
! 			return true;
! 		}
! 		else	sprintf(psTxt,"NumParams Exeeded");
! 	}
! 	else		sprintf(psTxt,"Not loaded");
! 
! 	return false;
  }
  
! bool VSTPlugin::SetParameter(int parameter, float value)
  {
! 	if(instantiated)
! 	{
! 		if (( parameter >= 0 ) && (parameter<=_pEffect->numParams))
! 		{
! 			_pEffect->setParameter(_pEffect,parameter,value);
! 			return true;
! 		}
! 	}
  
! 	return false;
  }
  
! bool VSTPlugin::SetParameter(int parameter, int value)
  {
! 	return SetParameter(parameter,value/65535.0f);
  }
  
! int VSTPlugin::GetCurrentProgram()
! {
! 	if(instantiated)
! 		return Dispatch(effGetProgram,0,0,NULL,0.0f);
! 	else
! 		return 0;
  }
  
! void VSTPlugin::SetCurrentProgram(int prg)
! {
! 	if(instantiated)
! 		Dispatch(effSetProgram,0,prg,NULL,0.0f);
  }
  
  bool VSTPlugin::AddMIDI(unsigned char data0,unsigned char data1,unsigned char data2)
  {
! 	if (instantiated)
! 	{
! 		VstMidiEvent* pevent=&midievent[queue_size];
  
  		pevent->type = kVstMidiType;
--- 155,216 ----
  
  //			Dispatch(effGetParamName,parameter,0,par_name,0.0f);
! 			Dispatch(effGetParamDisplay,numparam,0,par_display,0.0f);
! 			Dispatch(effGetParamLabel,numparam,0,par_label,0.0f);
  //			sprintf(psTxt,"%s:%s%s",par_name,par_display,par_label);
! 			sprintf(parval,"%s%s",par_display,par_label);
!         }
! 	    else 
!             strcpy(parval,"Index out of range");
!     }
! 	else		
!         strcpy(parval,"Plugin not loaded");
  }
  
! float VSTPlugin::GetParamValue(int numparam) const
  {
! 	if(Is() && numparam < GetNumParams()) 
!         return _pEffect->getParameter(_pEffect, numparam);
! 	else 
!         return -1.0;
! }
  
! void VSTPlugin::Edit(bool open)
! {	
! 	if(Is()) { 	
!         if(open) {
! 		    if(HasEditor() && !IsEdited())
!                 StartEditor(this);
!         }
!         else if(IsEdited())
!             StopEditor(this);
! 	}
  }
  
! void VSTPlugin::StartEditing(WHandle h)
  {
!     FLEXT_ASSERT(h != NULL);
! 	Dispatch(effEditOpen,0,0,hwnd = h);
  }
  
! void VSTPlugin::StopEditing() 
! { 
! 	Dispatch(effEditClose);					
!     hwnd = NULL; 
  }
  
! void VSTPlugin::Visible(bool vis)
! {	
! 	if(Is() && IsEdited()) ShowEditor(this,vis);
! }
! 
! bool VSTPlugin::IsVisible() const
! {	
! 	return Is() && IsEdited() && IsEditorShown(this);
  }
  
  bool VSTPlugin::AddMIDI(unsigned char data0,unsigned char data1,unsigned char data2)
  {
! 	if(Is()) {
! 		VstMidiEvent* pevent = &midievent[queue_size];
  
  		pevent->type = kVstMidiType;
***************
*** 274,289 ****
  void VSTPlugin::SendMidi()
  {
! 	if(/*instantiated &&*/ queue_size>0)
! 	{
  		// Prepare MIDI events and free queue dispatching all events
  		events.numEvents = queue_size;
  		events.reserved  = 0;
! 		for(int q=0;q<queue_size;q++) events.events[q] = (VstEvent*)&midievent[q];
  		
  		Dispatch(effProcessEvents, 0, 0, &events, 0.0f);
! 		queue_size=0;
  	}
  }
  
  
  void VSTPlugin::processReplacing( float **inputs, float **outputs, long sampleframes )
--- 239,310 ----
  void VSTPlugin::SendMidi()
  {
! 	if(Is() && queue_size > 0) {
  		// Prepare MIDI events and free queue dispatching all events
  		events.numEvents = queue_size;
  		events.reserved  = 0;
! 		for(int q = 0; q < queue_size; q++) 
!             events.events[q] = (VstEvent*)&midievent[q];
  		
  		Dispatch(effProcessEvents, 0, 0, &events, 0.0f);
! 		queue_size = 0;
  	}
  }
  
+ static int range(int value,int mn = 0,int mx = 127) 
+ {
+     return value < mn?mn:(value > mx?mx:value);
+ }
+ 
+ bool VSTPlugin::AddNoteOn( unsigned char note,unsigned char speed,unsigned char midichannel)
+ {
+     return AddMIDI((char)MIDI_NOTEON | midichannel,note,speed);
+ }
+ 
+ bool VSTPlugin::AddNoteOff( unsigned char note,unsigned char midichannel)
+ {
+     return AddMIDI((char)MIDI_NOTEOFF | midichannel,note,0);
+ }
+ 
+ void VSTPlugin::AddAftertouch(int value)
+ {
+  	AddMIDI( (char)MIDI_NOTEOFF | _midichannel , range(value) );
+ }
+ 
+ void VSTPlugin::AddPitchBend(int value)
+ {
+ 	AddMIDI( MIDI_PITCHBEND + (_midichannel & 0xf) , ((value>>7) & 127), (value & 127));
+ }
+ 
+ void VSTPlugin::AddProgramChange(int value)
+ {
+     AddMIDI( MIDI_PROGRAMCHANGE + (_midichannel & 0xf), range(value), 0);
+ }
+ 
+ void VSTPlugin::AddControlChange(int control, int value)
+ {
+     AddMIDI( MIDI_CONTROLCHANGE + (_midichannel & 0xf), range(control), range(value));
+ }
+ 
+ 
+ bool VSTPlugin::GetProgramName( int cat , int p, char *buf) const
+ {
+ 	int parameter = p;
+ 	if(parameter < GetNumPrograms()) {
+ 		Dispatch(effGetProgramNameIndexed,parameter,cat,buf,0.0f);
+ 		return true;
+ 	}
+ 	else
+         return false;
+ }
+ 
+ void VSTPlugin::SetPos(int x,int y,bool upd) 
+ {
+     if(Is()) {
+         posx = x; posy = y; 
+         if(upd && IsEdited()) MoveEditor(this,posx,posy);
+     }
+ }
+ 
+ 
  
  void VSTPlugin::processReplacing( float **inputs, float **outputs, long sampleframes )
***************
*** 298,311 ****
  }
  
  
  // Host callback dispatcher
  long VSTPlugin::Master(AEffect *effect, long opcode, long index, long value, void *ptr, float opt)
  {
! #if 0
!     if(!effect) {
!         FLEXT_LOG("effect = NULL");
          return 0;
      }
! #endif
  
  #ifdef FLEXT_DEBUG
--- 319,347 ----
  }
  
+ #if 1
  
  // Host callback dispatcher
  long VSTPlugin::Master(AEffect *effect, long opcode, long index, long value, void *ptr, float opt)
  {
!     switch (opcode) {
!     case audioMasterVersion:
!         return 2;
!     case audioMasterCurrentId:
!         return 'AASH';
!     default:
! #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
          return 0;
      }
! }
! 
! #else
! 
! // Host callback dispatcher
! long VSTPlugin::Master(AEffect *effect, long opcode, long index, long value, void *ptr, float opt)
! {
!     VSTPlugin *th = effect?(VSTPlugin *)effect->user:NULL;
!     if(!th) FLEXT_LOG("No this");
  
  #ifdef FLEXT_DEBUG
***************
*** 332,346 ****
  		
  	case audioMasterPinConnected:	
! 		if (value == 0) //input
! 		{
! 			if ( index < 2) return 0;
! 			else return 1;
! 		}
! 		else //output
! 		{
! 			if ( index < 2) return 0;
! 			else return 1;
! 		}
! 		return 0;	// inquire if an input or output is beeing connected;
  /*
  	case audioMasterWantMidi:			
--- 368,376 ----
  		
  	case audioMasterPinConnected:	
! 		if(value == 0)
!             return index < 2?0:1; //input
! 		else 
!             return index < 2?0:1; //output
! 
  /*
  	case audioMasterWantMidi:			
***************
*** 353,357 ****
  		memset(&_timeInfo, 0, sizeof(_timeInfo));
  		_timeInfo.samplePos = 0;
! 		_timeInfo.sampleRate = sample_rate;
  		return (long)&_timeInfo;
  		
--- 383,387 ----
  		memset(&_timeInfo, 0, sizeof(_timeInfo));
  		_timeInfo.samplePos = 0;
!         _timeInfo.sampleRate = th?th->sample_rate:0;
  		return (long)&_timeInfo;
  		
***************
*** 365,369 ****
  
  	case audioMasterGetSampleRate:		
! 		return sample_rate;	
  
  	case audioMasterGetVendorString:	// Just fooling version string
--- 395,399 ----
  
  	case audioMasterGetSampleRate:		
!         return th?(long)th->sample_rate:0;	
  
  	case audioMasterGetVendorString:	// Just fooling version string
***************
*** 375,386 ****
  
  	case audioMasterGetProductString:	// Just fooling product string
! 		strcpy((char*)ptr,"Cubase 5.0");
  		return 0;
  
  	case audioMasterVendorSpecific:		
! 		{
! 			return 0;
! 		}
! 		
  
  	case audioMasterGetLanguage:		
--- 405,413 ----
  
  	case audioMasterGetProductString:	// Just fooling product string
! 		strcpy((char *)ptr,"Cubase 5.0");
  		return 0;
  
  	case audioMasterVendorSpecific:		
! 		return 0;
  
  	case audioMasterGetLanguage:		
***************
*** 388,401 ****
  	
  	case audioMasterUpdateDisplay:
! #ifdef FLEXT_DEBUG
! 		post("audioMasterUpdateDisplay");
! #endif
  		effect->dispatcher(effect, effEditIdle, 0, 0, NULL, 0.0f);
  		return 0;
  
  	case 	audioMasterCanDo:
! 		if (!strcmp((char*)ptr,"sendVstEvents")) return 1;
! 		if (!strcmp((char*)ptr,"sendVstMidiEvent")) return 1;
! 		if (!strcmp((char*)ptr,"sendVstTimeInfo")) return 1;
  //			"receiveVstEvents",
  //			"receiveVstMidiEvent",
--- 415,426 ----
  	
  	case audioMasterUpdateDisplay:
! 		FLEXT_LOG("audioMasterUpdateDisplay");
  		effect->dispatcher(effect, effEditIdle, 0, 0, NULL, 0.0f);
  		return 0;
  
  	case 	audioMasterCanDo:
! 		if (!strcmp((char *)ptr,"sendVstEvents")) return 1;
! 		else if (!strcmp((char *)ptr,"sendVstMidiEvent")) return 1;
! 		else if (!strcmp((char *)ptr,"sendVstTimeInfo")) return 1;
  //			"receiveVstEvents",
  //			"receiveVstMidiEvent",
***************
*** 404,409 ****
  //			"reportConnectionChanges",
  //			"acceptIOChanges",
! 		if (!strcmp((char*)ptr,"sizeWindow")) return 1;
! 		if (!strcmp((char*)ptr,"supplyIdle")) return 1;
  		return -1;
  		
--- 429,434 ----
  //			"reportConnectionChanges",
  //			"acceptIOChanges",
! //		else if (!strcmp((char*)ptr,"sizeWindow")) return 1;
! 		else if (!strcmp((char*)ptr,"supplyIdle")) return 1;
  		return -1;
  		
***************
*** 434,438 ****
  //	case		audioMasterUpdateDisplay:				post("VST master dispatcher: audioMasterUpdateDisplay");break;
  
! 	default: post("VST master dispatcher: undefed: %d , %d",opcode , effKeysRequired )	;break;
  	}	
  	
--- 459,466 ----
  //	case		audioMasterUpdateDisplay:				post("VST master dispatcher: audioMasterUpdateDisplay");break;
  
! #ifdef FLEXT_DEBUG
! 	default: 
!         post("VST master dispatcher: undefed: %d , %d",opcode , effKeysRequired );
! #endif
  	}	
  	
***************
*** 440,569 ****
  }
  
! bool VSTPlugin::AddNoteOn( unsigned char note,unsigned char speed,unsigned char midichannel)
! {
!     return AddMIDI((char)MIDI_NOTEON | midichannel,note,speed);
! }
! 
! bool VSTPlugin::AddNoteOff( unsigned char note,unsigned char midichannel)
! {
!     return AddMIDI((char)MIDI_NOTEOFF | midichannel,note,0);
! }
! 
! 
! bool VSTPlugin::replace()
! {
! 	return overwrite;
! }
! 
! 
! void VSTPlugin::edit(bool open)
! {	
! 	if(instantiated) { 	
!         if(open) {
! 		    if(HasEditor() && !IsEdited())
!                 StartEditor(this);
!         }
!         else if(IsEdited())
!             StopEditor(this);
! 	}
! }
! 
! void VSTPlugin::visible(bool vis)
! {	
! 	if(instantiated && IsEdited()) ShowEditor(this,vis);
! }
! 
! void VSTPlugin::EditorIdle()
! {
!     FLEXT_ASSERT(hwnd != NULL);
! 	Dispatch(effEditIdle,0,0, hwnd,0.0f);			
! }
! 
! RECT VSTPlugin::GetEditorRect()
! {
! 	RECT ret;
! 	ERect *r;
! 	Dispatch(effEditGetRect,0,0, &r,0.0f);				
! 	ret.top = r->top;
! 	ret.bottom = r->bottom;
! 	ret.left = r->left;
! 	ret.right = r->right;
! 	return ret;
! }
! 
! void VSTPlugin::SetEditWindow(HWND h)
! {
! 	hwnd = h;	
!     FLEXT_ASSERT(hwnd != NULL);
! 	Dispatch(effEditOpen,0,0, hwnd,0.0f);							
! }
! 
! void VSTPlugin::OnEditorClose()
! {
!     FLEXT_ASSERT(hwnd != NULL);
! 	Dispatch(effEditClose,0,0, hwnd,0.0f);					
! }
! 
! void VSTPlugin::StopEditing()
! {
!     hwnd = NULL;
! }
! 
! /*
! void VSTPlugin::SetShowParameters(bool s)
! {
! 	show_params = s;
! }
! 
! bool VSTPlugin::ShowParams()
! {
! 	return show_params;
! }
! */
! 
! void VSTPlugin::AddAftertouch(int value)
! {
! 	if (value < 0) value = 0; else if (value > 127) value = 127;
!  	AddMIDI( (char)MIDI_NOTEOFF | _midichannel , value );
! }
! 
! void VSTPlugin::AddPitchBend(int value)
! {
! 		AddMIDI( MIDI_PITCHBEND + (_midichannel & 0xf) , ((value>>7) & 127), (value & 127));
! }
! 
! void VSTPlugin::AddProgramChange(int value)
! {
!  if (value < 0) value = 0; else if (value > 127) value = 127;
!     AddMIDI( MIDI_PROGRAMCHANGE + (_midichannel & 0xf), value, 0);
! }
! 
! void VSTPlugin::AddControlChange(int control, int value)
! {
!   if (control < 0) control = 0;  else if (control > 127) control = 127;
!     if (value < 0) value = 0;  else if (value > 127) value = 127;
!     AddMIDI( MIDI_CONTROLCHANGE + (_midichannel & 0xf), control, value);
! }
! 
! 
! bool VSTPlugin::GetProgramName( int cat , int p, char *buf)
! {
! 	int parameter = p;
! 	if(instantiated)
! 	{
! 		if(parameter<NumPrograms())
! 		{
! 			Dispatch(effGetProgramNameIndexed,parameter,cat,buf,0.0f);
! 			return true;
! 		}
! 	}
! 	return false;
! }
! 
! int VSTPlugin::GetNumCategories()
! {
! 	if(instantiated)
! 		return Dispatch(effGetNumProgramCategories,0,0,NULL,0.0f);
! 	else
! 		return 0;
! }
--- 468,470 ----
  }
  
! #endif 

Index: VstHost.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/vst/src/VstHost.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** VstHost.h	23 Jan 2004 04:20:38 -0000	1.4
--- VstHost.h	27 Jan 2004 03:41:26 -0000	1.5
***************
*** 8,23 ****
  */
  
! #ifndef _VSTPLUGIN_HOST
! #define _VSTPLUGIN_HOST
  
- #include "Vst\AEffectx.h"
  #include <flext.h>
  
  #if FLEXT_OS == FLEXT_OS_WIN
  #include <windows.h>
  #else
  #error Platform not supported!
  #endif
  
  #define MAX_EVENTS		64
  #define MAX_INOUTS		8
--- 8,26 ----
  */
  
! #ifndef __VSTHOST_H
! #define __VSTHOST_H
  
  #include <flext.h>
+ #include "Vst\AEffectx.h"
+ #include "vst\aeffeditor.h"
  
  #if FLEXT_OS == FLEXT_OS_WIN
  #include <windows.h>
+ typedef HWND WHandle;
  #else
  #error Platform not supported!
  #endif
  
+ 
  #define MAX_EVENTS		64
  #define MAX_INOUTS		8
***************
*** 36,42 ****
  #define MIDI_PITCHBEND 224
  
- typedef AEffect* (*PVSTMAIN)(audioMasterCallback audioMaster);
- typedef HWND (*POPWIN)(void);
- typedef HWND (*GETWIN)(void);
  
  class VSTPlugin:
--- 39,42 ----
***************
*** 44,172 ****
  {
  public:
- 	int GetNumCategories();
- 	bool GetProgramName( int cat, int p , char* buf);
- 	void AddControlChange( int control , int value );
- 	void AddProgramChange( int value );
- 	void AddPitchBend( int value );
- 	void AddAftertouch( int value );
- 	bool ShowParams();
- 	void SetShowParameters( bool s);
- 
- 	void SetEditWindow( HWND h );
- 	void StopEditing();
- 	void OnEditorClose();
-     HWND EditorHandle() { return hwnd; }
- 
- 	RECT GetEditorRect();
- 	void EditorIdle();
- 
- 	void edit(bool open);
-     void visible(bool vis);
- 	bool replace(  );
  
  	VSTPlugin();
  	~VSTPlugin();
  
  	void Free();
! 	int Instance( const char *dllname);
! 	void Create(VSTPlugin *plug);
! 	void Init( float samplerate , float blocksize );
  
! 	virtual int GetNumParams(void) { return _pEffect->numParams; }
! 	virtual void GetParamName(int numparam,char* name)
! 	{
! 		if ( numparam < _pEffect->numParams ) Dispatch(effGetParamName,numparam,0,name,0.0f);
! 		else strcpy(name,"Out of Range");
  
! 	}
! 	virtual void GetParamValue(int numparam,char* parval)
! 	{
! 		if ( numparam < _pEffect->numParams ) DescribeValue(numparam,parval);
! 		else strcpy(parval,"Out of Range");
! 	}
! 	virtual float GetParamValue(int numparam)
! 	{
! 		if ( numparam < _pEffect->numParams ) return (_pEffect->getParameter(_pEffect, numparam));
! 		else return -1.0;
! 	}
  
! 	int getNumInputs( void );
! 	int getNumOutputs( void );
  
! 	virtual char* GetName(void) { return _sProductName; }
! 	unsigned long  GetVersion() { return _version; }
! 	char* GetVendorName(void) { return _sVendorName; }
! 	char* GetDllName(void) { return _sDllName; }
  
! 	long NumParameters(void) { return _pEffect->numParams; }
! 	float GetParameter(long parameter) { return _pEffect->getParameter(_pEffect, parameter); }
! 	bool DescribeValue(int parameter,char* psTxt);
! 	bool SetParameter(int parameter, float value);
! 	bool SetParameter(int parameter, int value);
! 	void SetCurrentProgram(int prg);
! 	int GetCurrentProgram();
! 	int NumPrograms() { return _pEffect->numPrograms; }
! 	bool IsSynth() { return _isSynth; }
! 	bool HasEditor() const { return _editor; }
  
! 	bool AddMIDI(unsigned char data0,unsigned char data1=0,unsigned char data2=0);
! 	void SendMidi();
  
  
! 	void processReplacing( float **inputs, float **outputs, long sampleframes );
! 	void process( float **inputs, float **outputs, long sampleframes );
  
! 	AEffect *_pEffect;
! 	long Dispatch(long opCode, long index, long value, void *ptr, float opt)
! 	{
! 		return _pEffect->dispatcher(_pEffect, opCode, index, value, ptr, opt);
! 	}
  
! 	static long Master(AEffect *effect, long opcode, long index, long value, void *ptr, float opt);
  
  	bool AddNoteOn( unsigned char note,unsigned char speed,unsigned char midichannel=0);
  	bool AddNoteOff( unsigned char note,unsigned char midichannel=0);
  	
  
! 	char _midichannel;
! 	bool instantiated;
! 	int _instance;		// Remove when Changing the FileFormat.
! 
!     void setPos(int x,int y) { posx = x; posy = y; }
!     void setX(int x) { posx = x; }
!     void setY(int y) { posy = y; }
!     int getX() const { return posx; }
!     int getY() const { return posy; }
  
      bool IsEdited() const { return hwnd != NULL; }
  
  protected:
  
  	HMODULE h_dll;
! 	HMODULE h_winddll;
! 	HWND hwnd;
  
  
  	char _sProductName[64];
  	char _sVendorName[64];
! 	char *_sDllName;	// Contains dll name
! 	ULONG _version;
! 	bool _isSynth,_editor;
  
! 	float * inputs[MAX_INOUTS];
! 	float * outputs[MAX_INOUTS];
! 	float junk[256];
  
! 	static VstTimeInfo _timeInfo;
  	VstMidiEvent midievent[MAX_EVENTS];
  	VstEvents events;
  	int	queue_size;
- 	bool overwrite;
  
! private:
      int posx,posy;
- 	bool show_params;
- 	static float sample_rate;
  };
  
! #endif // _VSTPLUGIN_HOST
--- 44,164 ----
  {
  public:
  
  	VSTPlugin();
  	~VSTPlugin();
  
+ 	int Instance(const char *dllname);
+ //	void Create(VSTPlugin *plug);
  	void Free();
! 	void DspInit(float samplerate,int blocksize);
  
!     bool Is() const { return _pEffect != NULL; }
  
!     ULONG GetVersion() const { return _pEffect?_pEffect->version:0; }
  
!     bool IsSynth() const { return HasFlags(effFlagsIsSynth); }
!     bool IsReplacing() const { return HasFlags(effFlagsCanReplacing); }
!     bool HasEditor() const { return HasFlags(effFlagsHasEditor); }
  
! 	const char *GetName() const { return _sProductName; }
! 	const char *GetVendorName() const { return _sVendorName; }
! 	const char *GetDllName() const { return _sDllName.c_str(); }
  
!     int GetNumInputs() const { return _pEffect?_pEffect->numInputs:0; }
!     int GetNumOutputs() const { return _pEffect?_pEffect->numOutputs:0; }
  
!     int GetNumParams() const { return _pEffect?_pEffect->numParams:0; }
! 	void GetParamName(int numparam,char *name) const;
! 	void GetParamValue(int numparam,char *parval) const;
! 	float GetParamValue(int numparam) const;
  
+     bool SetParamFloat(int parameter, float value);
+     bool SetParamInt(int parameter, int value) { return SetParamFloat(parameter,value/65535.0f); }
  
!     void SetCurrentProgram(int prg) { Dispatch(effSetProgram,0,prg); }
!     int GetCurrentProgram() const { return Dispatch(effGetProgram); }
! 	int GetNumPrograms() const { return _pEffect->numPrograms; }
  
!     int GetNumCategories() const { return Dispatch(effGetNumProgramCategories); }
! 	bool GetProgramName( int cat, int p , char* buf) const;
  
! 
! 	bool AddMIDI(unsigned char data0,unsigned char data1=0,unsigned char data2=0);
  
  	bool AddNoteOn( unsigned char note,unsigned char speed,unsigned char midichannel=0);
  	bool AddNoteOff( unsigned char note,unsigned char midichannel=0);
  	
+ 	void AddControlChange( int control , int value );
+ 	void AddProgramChange( int value );
+ 	void AddPitchBend( int value );
+ 	void AddAftertouch( int value );
  
! 	void Edit(bool open);
  
+ 	void StartEditing(WHandle h );
+     void StopEditing();
      bool IsEdited() const { return hwnd != NULL; }
+     WHandle EditorHandle() const { return hwnd; }
+ 
+     void GetEditorRect(ERect &er) const { ERect *r; Dispatch(effEditGetRect,0,0,&r); er = *r; }
+     void EditorIdle() { Dispatch(effEditIdle); }
+ 
+     void Visible(bool vis);
+     bool IsVisible() const;
+ 
+ //    void Paint(ERect &r) const { Dispatch(effEditDraw,0,0,&r); }
+ 
+ 	void processReplacing( float **inputs, float **outputs, long sampleframes );
+ 	void process( float **inputs, float **outputs, long sampleframes );
+ 
+ 	long Dispatch(long opCode, long index = 0, long value = 0, void *ptr = NULL, float opt = 0) const
+ 	{
+         return Is()?_pEffect->dispatcher(_pEffect, opCode, index, value, ptr, opt):0;
+ 	}
+ 
+ 	static long Master(AEffect *effect, long opcode, long index, long value, void *ptr, float opt);
+ 
+     void SetPos(int x,int y,bool upd = true);
+     void SetX(int x,bool upd = true) { SetPos(x,posy,upd); }
+     void SetY(int y,bool upd = true) { SetPos(posx,y,upd); }
+     int GetX() const { return posx; }
+     int GetY() const { return posy; }
  
  protected:
  
+ #if FLEXT_OS == FLEXT_OS_WIN
  	HMODULE h_dll;
! #else
! #error
! #endif
  
+     WHandle hwnd;
+ 
+ 	AEffect *_pEffect;
+ 
+     inline long GetFlags() const { return _pEffect?_pEffect->flags:0; } 
+     inline bool HasFlags(long msk) const { return _pEffect && (_pEffect->flags&msk); } 
  
  	char _sProductName[64];
  	char _sVendorName[64];
!     std::string _sDllName;	// Contains dll name
  
! /*
! 	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;
! 
      int posx,posy;
  };
  
! #endif

Index: main.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/vst/src/main.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** main.cpp	23 Jan 2004 04:20:40 -0000	1.12
--- main.cpp	27 Jan 2004 03:41:26 -0000	1.13
***************
*** 21,25 ****
  
  
! #define VST_VERSION "0.1.0pre8"
  
  
--- 21,25 ----
  
  
! #define VST_VERSION "0.1.0pre10"
  
  
***************
*** 41,58 ****
      V mg_plug(AtomList &sym) const { sym(1); SetString(sym[0],plugname.c_str()); }
  
-     V ms_edit(BL on) { if(plug) plug->edit(on); }
-     V mg_edit(BL &ed) { ed = plug && plug->IsEdited(); }
      V mg_editor(BL &ed) { ed = plug && plug->HasEditor(); }
-     V ms_vis(BL vis) { if(plug) plug->visible(vis); }
  
!     V mg_winx(I &x) const { x = plug?plug->getX():0; }
!     V mg_winy(I &y) const { y = plug?plug->getY():0; }
!     V ms_winx(I x) { if(plug) plug->setX(x); }
!     V ms_winy(I y) { if(plug) plug->setY(y); }
!  
!     V mg_chnsin(I &c) const { c = plug?plug->getNumInputs():0; }
!     V mg_chnsout(I &c) const { c = plug?plug->getNumOutputs():0; }
      V mg_params(I &p) const { p = plug?plug->GetNumParams():0; }
!     V mg_programs(I &p) const { p = plug?plug->NumPrograms():0; }
      V mg_progcats(I &p) const { p = plug?plug->GetNumCategories():0; }
      V mg_plugname(const S *&s) const { s = MakeSymbol(plug?plug->GetName():""); }
--- 41,60 ----
      V mg_plug(AtomList &sym) const { sym(1); SetString(sym[0],plugname.c_str()); }
  
      V mg_editor(BL &ed) { ed = plug && plug->HasEditor(); }
  
!     V ms_edit(BL on) { if(plug) plug->Edit(on); }
!     V mg_edit(BL &ed) { ed = plug && plug->IsEdited(); }
!     V ms_vis(BL vis) { if(plug) plug->Visible(vis); }
!     V mg_vis(BL &vis) { vis = plug && plug->IsVisible(); }
! 
!     V mg_winx(I &x) const { x = plug?plug->GetX():0; }
!     V mg_winy(I &y) const { y = plug?plug->GetY():0; }
!     V ms_winx(I x) { if(plug) plug->SetX(x); }
!     V ms_winy(I y) { if(plug) plug->SetY(y); }
! 
!     V mg_chnsin(I &c) const { c = plug?plug->GetNumInputs():0; }
!     V mg_chnsout(I &c) const { c = plug?plug->GetNumOutputs():0; }
      V mg_params(I &p) const { p = plug?plug->GetNumParams():0; }
!     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():""); }
***************
*** 105,110 ****
      FLEXT_CALLVAR_B(mg_edit,ms_edit)
      FLEXT_CALLGET_B(mg_editor)
!     FLEXT_CALLSET_B(ms_vis)
!     FLEXT_ATTRGET_B(visible)
  
  //    FLEXT_CALLBACK_2(m_control,t_symptr,int)
--- 107,111 ----
      FLEXT_CALLVAR_B(mg_edit,ms_edit)
      FLEXT_CALLGET_B(mg_editor)
!     FLEXT_CALLVAR_B(mg_vis,ms_vis)
  
  //    FLEXT_CALLBACK_2(m_control,t_symptr,int)
***************
*** 152,156 ****
  	FLEXT_CADDATTR_VAR(c,"edit",mg_edit,ms_edit);
  	FLEXT_CADDATTR_GET(c,"editor",mg_editor);
! 	FLEXT_CADDATTR_VAR(c,"vis",visible,ms_vis);
  	FLEXT_CADDMETHOD_(c,0,"print",m_print);
  
--- 153,157 ----
  	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);
  	FLEXT_CADDMETHOD_(c,0,"print",m_print);
  
***************
*** 171,178 ****
  
  	FLEXT_CADDATTR_VAR1(c,"echo",echoparam);
! 	FLEXT_CADDATTR_VAR(c,"x",mg_winx,ms_winx);
  	FLEXT_CADDATTR_VAR(c,"y",mg_winy,ms_winy);
  
! 	FLEXT_CADDATTR_GET(c,"ins",mg_chnsin);
  	FLEXT_CADDATTR_GET(c,"outs",mg_chnsout);
  	FLEXT_CADDATTR_GET(c,"params",mg_params);
--- 172,179 ----
  
  	FLEXT_CADDATTR_VAR1(c,"echo",echoparam);
!     FLEXT_CADDATTR_VAR(c,"x",mg_winx,ms_winx);
  	FLEXT_CADDATTR_VAR(c,"y",mg_winy,ms_winy);
  
!     FLEXT_CADDATTR_GET(c,"ins",mg_chnsin);
  	FLEXT_CADDATTR_GET(c,"outs",mg_chnsout);
  	FLEXT_CADDATTR_GET(c,"params",mg_params);
***************
*** 225,230 ****
      FLEXT_ASSERT(plug);
  
! 	vstfun = plug->replace()?VSTPlugin::processReplacing:VSTPlugin::process;
!     sigmatch = plug->getNumInputs() == CntInSig() && plug->getNumOutputs() == CntOutSig();
  
      InitBuf();
--- 226,231 ----
      FLEXT_ASSERT(plug);
  
! 	vstfun = plug->IsReplacing()?VSTPlugin::processReplacing:VSTPlugin::process;
!     sigmatch = plug->GetNumInputs() == CntInSig() && plug->GetNumOutputs() == CntOutSig();
  
      InitBuf();
***************
*** 236,245 ****
  
      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;
--- 237,246 ----
  
      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;
***************
*** 250,263 ****
  {
      FLEXT_ASSERT(!vstin && !tmpin && !vstout && !tmpout);
  
      I i;
  
!     vstin = new R *[plug->getNumInputs()];
!     tmpin = new R *[plug->getNumInputs()];
!     for(i = 0; i < plug->getNumInputs(); ++i) vstin[i] = new R[Blocksize()];
      
!     vstout = new R *[plug->getNumOutputs()];
!     tmpout = new R *[plug->getNumOutputs()];
!     for(i = 0; i < plug->getNumOutputs(); ++i) vstout[i] = new R[Blocksize()];
  }
  
--- 251,265 ----
  {
      FLEXT_ASSERT(!vstin && !tmpin && !vstout && !tmpout);
+     const int inputs = plug->GetNumInputs(),outputs = plug->GetNumOutputs();
  
      I i;
  
!     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()];
  }
  
***************
*** 398,402 ****
  {
      if(plug) {
!         plug->Init(Samplerate(),(F)Blocksize());
          FLEXT_ASSERT(vstfun);
  
--- 400,404 ----
  {
      if(plug) {
!         plug->DspInit(Samplerate(),Blocksize());
          FLEXT_ASSERT(vstfun);
  
***************
*** 412,415 ****
--- 414,419 ----
  {
      if(plug) {
+         const int inputs = plug->GetNumInputs(),outputs = plug->GetNumOutputs();
+ 
          if(sigmatch)
              (plug->*vstfun)(const_cast<R **>(insigs),const_cast<R **>(outsigs),n);
***************
*** 417,421 ****
              R **inv,**outv;
  
!             if(plug->getNumInputs() <= CntInSig()) 
                  inv = const_cast<R **>(insigs);
              else { // more plug inputs than inlets
--- 421,425 ----
              R **inv,**outv;
  
!             if(inputs <= CntInSig()) 
                  inv = const_cast<R **>(insigs);
              else { // more plug inputs than inlets
***************
*** 425,434 ****
                  // set dangling inputs to zero
                  // according to mode... (e.g. set zero)
!                 for(; i < plug->getNumInputs(); ++i) ZeroSamples(tmpin[i] = vstin[i],n);
  
                  inv = tmpin;
              }
  
!             const BL more = plug->getNumOutputs() <= CntOutSig();
              if(more) // more outlets than plug outputs 
                  outv = const_cast<R **>(outsigs);
--- 429,438 ----
                  // set dangling inputs to zero
                  // according to mode... (e.g. set zero)
!                 for(; i < inputs; ++i) ZeroSamples(tmpin[i] = vstin[i],n);
  
                  inv = tmpin;
              }
  
!             const BL more = outputs <= CntOutSig();
              if(more) // more outlets than plug outputs 
                  outv = const_cast<R **>(outsigs);
***************
*** 436,440 ****
                  I i;
                  for(i = 0; i < CntOutSig(); ++i) tmpout[i] = outsigs[i];
!                 for(; i < plug->getNumOutputs(); ++i) tmpout[i] = vstout[i];
  
                  outv = tmpout;
--- 440,444 ----
                  I i;
                  for(i = 0; i < CntOutSig(); ++i) tmpout[i] = outsigs[i];
!                 for(; i < outputs; ++i) tmpout[i] = vstout[i];
  
                  outv = tmpout;
***************
*** 558,562 ****
  		post("VST~ plugin: %s " , plug->GetName() );
  		post("made by: %s " , plug->GetVendorName() );
! 		post("parameterss %d\naudio: %d in(s)/%d out(s) \nLoaded from library \"%s\".\n",
  			plug->GetNumParams(),
  			CntInSig(),
--- 562,566 ----
  		post("VST~ plugin: %s " , plug->GetName() );
  		post("made by: %s " , plug->GetVendorName() );
! 		post("parameters %d\naudio: %d in(s)/%d out(s) \nLoaded from library \"%s\".\n",
  			plug->GetNumParams(),
  			CntInSig(),
***************
*** 565,574 ****
  
  		post("Flags");
! 		if ( plug->_pEffect->flags & effFlagsHasEditor ) {
! 			post("Has editor");
! 		}
! 		if ( plug->_pEffect->flags & effFlagsCanReplacing ) {
! 			post("Can do replacing");
! 		}
  	 }
  
--- 569,574 ----
  
  		post("Flags");
! 		if ( plug->HasEditor() ) post("Has editor");
! 		if ( plug->IsReplacing() ) post("Can do replacing");
  	 }
  
***************
*** 610,614 ****
  	if(*name) {
  		if (showparams) {
! 			plug->DescribeValue( j , display );		
  			val = plug->GetParamValue( j );
  			post ("parameter[#%d], \"%s\" value=%f (%s) ", j, name,  val,display);			
--- 610,615 ----
  	if(*name) {
  		if (showparams) {
! //			plug->DescribeValue( j , display );		
!             plug->GetParamValue(j,display);
  			val = plug->GetParamValue( j );
  			post ("parameter[#%d], \"%s\" value=%f (%s) ", j, name,  val,display);			
***************
*** 631,635 ****
      if(true)
      { 
! 		plug->SetParameter( pnum, val );
  		if(echoparam) display_parameter(pnum , true );
  	}	
--- 632,636 ----
      if(true)
      { 
! 		plug->SetParamFloat( pnum, val );
  		if(echoparam) display_parameter(pnum , true );
  	}	
***************
*** 670,674 ****
  
  	memset(display,0,sizeof(display));
! 	plug->DescribeValue(pnum,display);
  
      A at[2];
--- 671,675 ----
  
  	memset(display,0,sizeof(display));
! 	plug->GetParamValue(pnum,display);
  
      A at[2];





More information about the Pd-cvs mailing list