aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/vst
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2004-01-27 03:41:26 +0000
committerThomas Grill <xovo@users.sourceforge.net>2004-01-27 03:41:26 +0000
commit851555a3e26e6e37908696f45223896dc86e6d1c (patch)
treefe4630694fd85409d8c3d0a064341b91c2e13adf /externals/grill/vst
parentc58e9c41c48256950c2d6469a14686a3bd5036bf (diff)
""
svn path=/trunk/; revision=1296
Diffstat (limited to 'externals/grill/vst')
-rw-r--r--externals/grill/vst/pd/vst~.pd84
-rw-r--r--externals/grill/vst/src/Editor.h3
-rw-r--r--externals/grill/vst/src/EditorWin.cpp39
-rw-r--r--externals/grill/vst/src/VstHost.cpp507
-rw-r--r--externals/grill/vst/src/VstHost.h184
-rw-r--r--externals/grill/vst/src/main.cpp87
6 files changed, 417 insertions, 487 deletions
diff --git a/externals/grill/vst/pd/vst~.pd b/externals/grill/vst/pd/vst~.pd
index 73ae8ae5..752a16fd 100644
--- a/externals/grill/vst/pd/vst~.pd
+++ b/externals/grill/vst/pd/vst~.pd
@@ -1,19 +1,19 @@
-#N canvas 105 26 856 641 12;
+#N canvas 123 23 866 651 12;
#X obj 26 190 dac~;
#X obj 26 94 noise~;
#X obj 444 172 hsl 128 15 0 1 0 0 empty empty empty -2 -6 0 8 -225271
-1 -1 0 1;
#X msg 441 189 param 2 \$1;
#X obj 133 191 print A;
-#X obj 27 451 tgl 15 0 empty empty empty 0 -6 0 8 -225271 -1 -1 0 1
+#X obj 27 451 tgl 15 0 empty empty empty 0 -6 0 8 -225271 -1 -1 1 1
;
#X msg 26 473 vis \$1;
-#X obj 27 367 tgl 15 0 empty empty empty 0 -6 0 8 -225271 -1 -1 0 1
+#X obj 27 367 tgl 15 0 empty empty empty 0 -6 0 8 -225271 -1 -1 1 1
;
#X msg 26 389 edit \$1;
#X msg 94 389 getedit;
#X msg 89 473 getvis;
-#N canvas 367 122 546 453 info 0;
+#N canvas 367 122 548 455 info 0;
#X msg 94 130 getversion;
#X msg 94 75 getname;
#X msg 95 153 getvendor;
@@ -75,21 +75,21 @@
#X text 134 53 http://www.parasitaere-kapazitaeten.net;
#X text 140 169 attribute outlet;
#X text 143 140 inlets outlets [plugname];
-#N canvas 367 122 480 335 win 0;
+#N canvas 367 122 488 343 win 0;
#X obj 14 187 s \$0-vst;
-#X msg 94 84 getx;
-#X text 186 84 get window coordinates;
-#X msg 139 84 gety;
+#X msg 94 89 getx;
+#X text 186 89 get window coordinates;
+#X msg 139 89 gety;
#X msg 93 141 gettitle;
#X text 273 139 get/set window title;
#X msg 175 141 title hugo;
-#X obj 94 34 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -6 0 10
+#X obj 94 39 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -6 0 10
-225271 -1 -1 0 256;
-#X msg 95 54 x \$1;
-#X obj 164 34 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
+#X msg 95 59 x \$1;
+#X obj 164 39 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
10 -225271 -1 -1 0 256;
-#X msg 165 52 y \$1;
-#X text 229 44 set window coordinates;
+#X msg 165 57 y \$1;
+#X text 229 49 set window coordinates;
#X msg 90 218 getstyle;
#X text 278 218 get/set window style;
#X obj 173 193 vradio 15 1 0 3 empty empty empty 0 -6 0 8 -225271 -1
@@ -98,7 +98,7 @@
#X msg 198 218 style \$1;
#X msg 168 281 mode 101;
#X text 253 279 get/set window sys menu;
-#X text 5 2 NOT IMPLEMENTED;
+#X text 10 7 NOT IMPLEMENTED;
#X connect 1 0 0 0;
#X connect 3 0 0 0;
#X connect 4 0 0 0;
@@ -129,37 +129,43 @@
#X obj 27 240 bng 25 250 50 0 empty empty empty 0 -6 0 8 -225271 -1
-1;
#X obj 27 271 openpanel;
-#N canvas 0 0 460 310 midi 0;
-#X obj 20 249 s \$0-vst;
-#X msg 32 66 note 10 100;
-#X msg 61 118 ctlchg 3 123;
-#X msg 87 170 pbend 1000;
-#X text 128 65 note on;
-#X msg 49 90 note 10 0;
-#X text 225 89 note off;
-#X text 171 117 control change;
-#X text 179 168 pitch bend;
-#X text 157 144 program change;
-#X msg 75 145 progchg 2;
-#X msg 135 90 noteoff 10;
-#X msg 101 195 atouch 70;
-#X text 180 194 after touch;
+#N canvas 0 0 462 312 midi 0;
+#X obj 20 279 s \$0-vst;
+#X msg 20 29 note 10 100;
+#X msg 156 105 ctlchg 3 123;
+#X text 116 28 note on;
+#X msg 36 59 note 10 0;
+#X text 212 58 note off;
+#X text 266 104 control change;
+#X text 230 191 pitch bend;
+#X text 237 132 program change;
+#X msg 155 133 progchg 2;
+#X msg 122 59 noteoff 10;
+#X text 233 240 after touch;
+#X obj 156 171 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
+10 -262144 -1 -1 0 256;
+#X obj 156 222 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
+10 -262144 -1 -1 0 256;
+#X msg 155 191 pbend \$1;
+#X msg 154 241 atouch \$1;
#X connect 1 0 0 0;
#X connect 2 0 0 0;
-#X connect 3 0 0 0;
-#X connect 5 0 0 0;
+#X connect 4 0 0 0;
+#X connect 9 0 0 0;
#X connect 10 0 0 0;
-#X connect 11 0 0 0;
-#X connect 12 0 0 0;
+#X connect 12 0 14 0;
+#X connect 13 0 15 0;
+#X connect 14 0 0 0;
+#X connect 15 0 0 0;
#X restore 25 581 pd midi;
#X text 93 582 midi messages for vst synths;
#X msg 414 442 getprogcats;
#X text 509 439 get number of program categories;
#X text 134 33 based on the work of Jarno Seppanen and Mark Williamson
;
-#X obj 26 140 vst~ 1 2;
#X text 133 14 VST plugins for PD \, (C)2003-04 Thomas Grill;
-#X connect 1 0 55 0;
+#X obj 26 140 vst~ 1 2;
+#X connect 1 0 56 0;
#X connect 2 0 3 0;
#X connect 3 0 17 0;
#X connect 5 0 6 0;
@@ -168,7 +174,7 @@
#X connect 8 0 13 0;
#X connect 9 0 13 0;
#X connect 10 0 14 0;
-#X connect 12 0 55 0;
+#X connect 12 0 56 0;
#X connect 19 0 18 0;
#X connect 20 0 18 0;
#X connect 21 0 17 0;
@@ -184,6 +190,6 @@
#X connect 48 0 49 0;
#X connect 49 0 47 0;
#X connect 52 0 18 0;
-#X connect 55 0 0 0;
-#X connect 55 1 0 1;
-#X connect 55 2 4 0;
+#X connect 56 0 0 0;
+#X connect 56 1 0 1;
+#X connect 56 2 4 0;
diff --git a/externals/grill/vst/src/Editor.h b/externals/grill/vst/src/Editor.h
index b77d8916..e3f9a3d6 100644
--- a/externals/grill/vst/src/Editor.h
+++ b/externals/grill/vst/src/Editor.h
@@ -16,5 +16,8 @@ void SetupEditor();
void StartEditor(VSTPlugin *p);
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
diff --git a/externals/grill/vst/src/EditorWin.cpp b/externals/grill/vst/src/EditorWin.cpp
index c41f02e3..5418ba80 100644
--- a/externals/grill/vst/src/EditorWin.cpp
+++ b/externals/grill/vst/src/EditorWin.cpp
@@ -39,7 +39,7 @@ static LRESULT CALLBACK wndproc(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp)
// case WM_NCREATE: res = TRUE; break;
case WM_CREATE:
// Initialize the window.
- plug->SetEditWindow(hwnd);
+ plug->StartEditing(hwnd);
break;
case WM_CLOSE:
plug->StopEditing();
@@ -54,13 +54,21 @@ static LRESULT CALLBACK wndproc(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp)
case WM_ENTERIDLE:
plug->EditorIdle();
break;
- case WM_MOVE:
- plug->setPos(LOWORD(lp),HIWORD(lp));
+ 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:
+ 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.
break;
@@ -112,8 +120,11 @@ static void threadfun(flext::thr_params *p)
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);
+ 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);
// SetFocus();
@@ -177,4 +188,20 @@ void ShowEditor(VSTPlugin *p,bool show)
ShowWindow(p->EditorHandle(),show);
}
+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
diff --git a/externals/grill/vst/src/VstHost.cpp b/externals/grill/vst/src/VstHost.cpp
index 830da33c..75cd3d35 100644
--- a/externals/grill/vst/src/VstHost.cpp
+++ b/externals/grill/vst/src/VstHost.cpp
@@ -9,91 +9,55 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include "Editor.h"
#include "VstHost.h"
-#include "vst\aeffeditor.h"
#include "vst\aeffectx.h"
using namespace std;
-VstTimeInfo VSTPlugin::_timeInfo;
+static VstTimeInfo _timeInfo;
-float VSTPlugin::sample_rate = 44100;
+typedef AEffect *(*PVSTMAIN)(audioMasterCallback audioMaster);
-////////////////////
-//
-/////////////////////
VSTPlugin::VSTPlugin():
+ h_dll(NULL),hwnd(NULL),_pEffect(NULL),
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;
-}
+ _midichannel(0),queue_size(0)
+{}
VSTPlugin::~VSTPlugin()
{
Free(); // Call free
- delete _sDllName; // if _sDllName = NULL , the operation does nothing -> it's safe.
}
-int VSTPlugin::Instance( const char *dllname)
+int VSTPlugin::Instance(const char *dllname)
{
h_dll = LoadLibrary(dllname);
-
- if(!h_dll) {
+ 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;
+ _pEffect = NULL;
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));
+ _pEffect = main((audioMasterCallback)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);
+ 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;
- Dispatch( effOpen , 0, 0, NULL, 0.0f);
- Dispatch( effSetProgram , 0, 0, NULL, 0.0f);
-// Dispatch( effMainsChanged, 0, 1, NULL, 0.0f);
+ FLEXT_ASSERT(Dispatch( effOpen ));
+// Dispatch( effMainsChanged, 0, 1);
- //************************************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);
string str2 = str1.substr(str1.rfind('\\')+1);
@@ -105,43 +69,23 @@ int VSTPlugin::Instance( const char *dllname)
strcpy(_sProductName,str1.c_str());
}
- if (!_pEffect->dispatcher(_pEffect, effGetVendorString, 0, 0, &_sVendorName, 0.0f)) {
+ if(!Dispatch( 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);
-
+ _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);
+ 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);
strcpy(_sVendorName,plug->_sVendorName);
@@ -157,96 +101,117 @@ void VSTPlugin::Create(VSTPlugin *plug)
// doesn't unload the Dll.
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);
+ 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;
- FreeLibrary(h_dll);
+ _pEffect = NULL;
+ if(h_dll) { FreeLibrary(h_dll); h_dll = NULL; }
}
}
-void VSTPlugin::Init( float samplerate , float blocksize )
+void VSTPlugin::DspInit(float samplerate,int 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 );
+// 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::DescribeValue(int p,char* psTxt)
+bool VSTPlugin::SetParamFloat(int parameter,float value)
{
- int parameter = p;
- if(instantiated)
- {
- if(parameter<_pEffect->numParams)
- {
+ 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];
char par_label[64];
// Dispatch(effGetParamName,parameter,0,par_name,0.0f);
- Dispatch(effGetParamDisplay,parameter,0,par_display,0.0f);
- Dispatch(effGetParamLabel,parameter,0,par_label,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(psTxt,"%s%s",par_display,par_label);
- return true;
- }
- else sprintf(psTxt,"NumParams Exeeded");
- }
- else sprintf(psTxt,"Not loaded");
-
- return false;
+ sprintf(parval,"%s%s",par_display,par_label);
+ }
+ else
+ strcpy(parval,"Index out of range");
+ }
+ else
+ strcpy(parval,"Plugin not loaded");
}
-bool VSTPlugin::SetParameter(int parameter, float value)
+float VSTPlugin::GetParamValue(int numparam) const
{
- if(instantiated)
- {
- if (( parameter >= 0 ) && (parameter<=_pEffect->numParams))
- {
- _pEffect->setParameter(_pEffect,parameter,value);
- return true;
- }
- }
+ if(Is() && numparam < GetNumParams())
+ return _pEffect->getParameter(_pEffect, numparam);
+ else
+ return -1.0;
+}
- return false;
+void VSTPlugin::Edit(bool open)
+{
+ if(Is()) {
+ if(open) {
+ if(HasEditor() && !IsEdited())
+ StartEditor(this);
+ }
+ else if(IsEdited())
+ StopEditor(this);
+ }
}
-bool VSTPlugin::SetParameter(int parameter, int value)
+void VSTPlugin::StartEditing(WHandle h)
{
- return SetParameter(parameter,value/65535.0f);
+ FLEXT_ASSERT(h != NULL);
+ Dispatch(effEditOpen,0,0,hwnd = h);
}
-int VSTPlugin::GetCurrentProgram()
-{
- if(instantiated)
- return Dispatch(effGetProgram,0,0,NULL,0.0f);
- else
- return 0;
+void VSTPlugin::StopEditing()
+{
+ Dispatch(effEditClose);
+ hwnd = NULL;
}
-void VSTPlugin::SetCurrentProgram(int prg)
-{
- if(instantiated)
- Dispatch(effSetProgram,0,prg,NULL,0.0f);
+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 (instantiated)
- {
- VstMidiEvent* pevent=&midievent[queue_size];
+ if(Is()) {
+ VstMidiEvent* pevent = &midievent[queue_size];
pevent->type = kVstMidiType;
pevent->byteSize = 24;
@@ -273,18 +238,74 @@ bool VSTPlugin::AddMIDI(unsigned char data0,unsigned char data1,unsigned char da
void VSTPlugin::SendMidi()
{
- if(/*instantiated &&*/ queue_size>0)
- {
+ 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];
+ for(int q = 0; q < queue_size; q++)
+ events.events[q] = (VstEvent*)&midievent[q];
Dispatch(effProcessEvents, 0, 0, &events, 0.0f);
- queue_size=0;
+ 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 )
{
@@ -297,16 +318,31 @@ void VSTPlugin::process( float **inputs, float **outputs, long sampleframes )
_pEffect->process( _pEffect , inputs , outputs , sampleframes );
}
+#if 1
// 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");
+ 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;
}
-#endif
+}
+
+#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
if(opcode != audioMasterGetTime)
@@ -331,17 +367,11 @@ long VSTPlugin::Master(AEffect *effect, long opcode, long index, long value, voi
return 0; // call application idle routine (this will call effEditIdle for all open editors too)
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;
+ if(value == 0)
+ return index < 2?0:1; //input
+ else
+ return index < 2?0:1; //output
+
/*
case audioMasterWantMidi:
return 0;
@@ -352,7 +382,7 @@ long VSTPlugin::Master(AEffect *effect, long opcode, long index, long value, voi
case audioMasterGetTime:
memset(&_timeInfo, 0, sizeof(_timeInfo));
_timeInfo.samplePos = 0;
- _timeInfo.sampleRate = sample_rate;
+ _timeInfo.sampleRate = th?th->sample_rate:0;
return (long)&_timeInfo;
@@ -364,7 +394,7 @@ long VSTPlugin::Master(AEffect *effect, long opcode, long index, long value, voi
return 1;
case audioMasterGetSampleRate:
- return sample_rate;
+ return th?(long)th->sample_rate:0;
case audioMasterGetVendorString: // Just fooling version string
strcpy((char*)ptr,"Steinberg");
@@ -374,37 +404,32 @@ long VSTPlugin::Master(AEffect *effect, long opcode, long index, long value, voi
return 5000; // HOST version 5000
case audioMasterGetProductString: // Just fooling product string
- strcpy((char*)ptr,"Cubase 5.0");
+ strcpy((char *)ptr,"Cubase 5.0");
return 0;
case audioMasterVendorSpecific:
- {
- return 0;
- }
-
+ return 0;
case audioMasterGetLanguage:
return kVstLangEnglish;
case audioMasterUpdateDisplay:
-#ifdef FLEXT_DEBUG
- post("audioMasterUpdateDisplay");
-#endif
+ FLEXT_LOG("audioMasterUpdateDisplay");
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;
+ 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",
// "receiveVstTimeInfo",
// "reportConnectionChanges",
// "acceptIOChanges",
- if (!strcmp((char*)ptr,"sizeWindow")) return 1;
- if (!strcmp((char*)ptr,"supplyIdle")) return 1;
+// else if (!strcmp((char*)ptr,"sizeWindow")) return 1;
+ else if (!strcmp((char*)ptr,"supplyIdle")) return 1;
return -1;
case audioMasterSetTime: FLEXT_LOG("VST master dispatcher: Set Time");break;
@@ -433,137 +458,13 @@ long VSTPlugin::Master(AEffect *effect, long opcode, long index, long value, voi
case audioMasterGetDirectory: FLEXT_LOG("VST master dispatcher: GetDirectory");break;
// case audioMasterUpdateDisplay: post("VST master dispatcher: audioMasterUpdateDisplay");break;
- default: post("VST master dispatcher: undefed: %d , %d",opcode , effKeysRequired ) ;break;
+#ifdef FLEXT_DEBUG
+ default:
+ post("VST master dispatcher: undefed: %d , %d",opcode , effKeysRequired );
+#endif
}
return 0;
}
-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;
-}
+#endif
diff --git a/externals/grill/vst/src/VstHost.h b/externals/grill/vst/src/VstHost.h
index b6246e7d..6b856956 100644
--- a/externals/grill/vst/src/VstHost.h
+++ b/externals/grill/vst/src/VstHost.h
@@ -7,18 +7,21 @@ For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
*/
-#ifndef _VSTPLUGIN_HOST
-#define _VSTPLUGIN_HOST
+#ifndef __VSTHOST_H
+#define __VSTHOST_H
-#include "Vst\AEffectx.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
@@ -35,138 +38,127 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#define MIDI_AFTERTOUCH 208
#define MIDI_PITCHBEND 224
-typedef AEffect* (*PVSTMAIN)(audioMasterCallback audioMaster);
-typedef HWND (*POPWIN)(void);
-typedef HWND (*GETWIN)(void);
class VSTPlugin:
public flext
{
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();
+ int Instance(const char *dllname);
+// void Create(VSTPlugin *plug);
void Free();
- int Instance( const char *dllname);
- void Create(VSTPlugin *plug);
- void Init( float samplerate , float blocksize );
+ void DspInit(float samplerate,int 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");
+ bool Is() const { return _pEffect != NULL; }
- }
- 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;
- }
+ ULONG GetVersion() const { return _pEffect?_pEffect->version: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 IsSynth() const { return HasFlags(effFlagsIsSynth); }
+ bool IsReplacing() const { return HasFlags(effFlagsCanReplacing); }
+ bool HasEditor() const { return HasFlags(effFlagsHasEditor); }
- bool AddMIDI(unsigned char data0,unsigned char data1=0,unsigned char data2=0);
- void SendMidi();
+ 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; }
- void processReplacing( float **inputs, float **outputs, long sampleframes );
- void process( float **inputs, float **outputs, long sampleframes );
+ 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;
- AEffect *_pEffect;
- long Dispatch(long opCode, long index, long value, void *ptr, float opt)
- {
- return _pEffect->dispatcher(_pEffect, opCode, index, value, ptr, opt);
- }
+ 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;
- static long Master(AEffect *effect, long opcode, long index, long value, void *ptr, float opt);
+
+ 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 );
- 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; }
+ 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;
- HMODULE h_winddll;
- HWND hwnd;
+#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];
- char *_sDllName; // Contains dll name
- ULONG _version;
- bool _isSynth,_editor;
+ std::string _sDllName; // Contains dll name
- float * inputs[MAX_INOUTS];
- float * outputs[MAX_INOUTS];
- float junk[256];
+/*
+ float *inputs[MAX_INOUTS];
+ float *outputs[MAX_INOUTS];
+*/
- static VstTimeInfo _timeInfo;
+// static VstTimeInfo _timeInfo;
VstMidiEvent midievent[MAX_EVENTS];
VstEvents events;
int queue_size;
- bool overwrite;
-private:
+// float sample_rate;
+
+ void SendMidi();
+ char _midichannel;
+
int posx,posy;
- bool show_params;
- static float sample_rate;
};
-#endif // _VSTPLUGIN_HOST
+#endif
diff --git a/externals/grill/vst/src/main.cpp b/externals/grill/vst/src/main.cpp
index a3566897..76de5c27 100644
--- a/externals/grill/vst/src/main.cpp
+++ b/externals/grill/vst/src/main.cpp
@@ -20,7 +20,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
using namespace std;
-#define VST_VERSION "0.1.0pre8"
+#define VST_VERSION "0.1.0pre10"
class vst:
@@ -40,20 +40,22 @@ protected:
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()); }
- 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 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->NumPrograms():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():""); }
V mg_plugvendor(const S *&s) const { s = MakeSymbol(plug?plug->GetVendorName():""); }
@@ -104,8 +106,7 @@ private:
FLEXT_CALLVAR_B(mg_edit,ms_edit)
FLEXT_CALLGET_B(mg_editor)
- FLEXT_CALLSET_B(ms_vis)
- FLEXT_ATTRGET_B(visible)
+ FLEXT_CALLVAR_B(mg_vis,ms_vis)
// FLEXT_CALLBACK_2(m_control,t_symptr,int)
FLEXT_CALLBACK_I(m_pitchbend)
@@ -151,7 +152,7 @@ V vst::Setup(t_classid c)
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);
- FLEXT_CADDATTR_VAR(c,"vis",visible,ms_vis);
+ FLEXT_CADDATTR_VAR(c,"vis",mg_vis,ms_vis);
FLEXT_CADDMETHOD_(c,0,"print",m_print);
FLEXT_CADDMETHOD_II(c,0,"note",m_note);
@@ -170,10 +171,10 @@ V vst::Setup(t_classid c)
FLEXT_CADDMETHOD_I(c,0,"getptext",m_ptext);
FLEXT_CADDATTR_VAR1(c,"echo",echoparam);
- FLEXT_CADDATTR_VAR(c,"x",mg_winx,ms_winx);
+ 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,"ins",mg_chnsin);
FLEXT_CADDATTR_GET(c,"outs",mg_chnsout);
FLEXT_CADDATTR_GET(c,"params",mg_params);
FLEXT_CADDATTR_GET(c,"programs",mg_programs);
@@ -224,8 +225,8 @@ V vst::InitPlug()
{
FLEXT_ASSERT(plug);
- vstfun = plug->replace()?VSTPlugin::processReplacing:VSTPlugin::process;
- sigmatch = plug->getNumInputs() == CntInSig() && plug->getNumOutputs() == CntOutSig();
+ vstfun = plug->IsReplacing()?VSTPlugin::processReplacing:VSTPlugin::process;
+ sigmatch = plug->GetNumInputs() == CntInSig() && plug->GetNumOutputs() == CntOutSig();
InitBuf();
}
@@ -235,12 +236,12 @@ V vst::ClearBuf()
if(!plug) return;
if(vstin) {
- for(I i = 0; i < plug->getNumInputs(); ++i) delete[] vstin[i];
+ 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];
+ for(I i = 0; i < plug->GetNumOutputs(); ++i) delete[] vstout[i];
delete[] vstout; vstout = NULL;
delete[] tmpout; tmpout = NULL;
}
@@ -249,16 +250,17 @@ V vst::ClearBuf()
V vst::InitBuf()
{
FLEXT_ASSERT(!vstin && !tmpin && !vstout && !tmpout);
+ const int inputs = plug->GetNumInputs(),outputs = plug->GetNumOutputs();
I i;
- vstin = new R *[plug->getNumInputs()];
- tmpin = new R *[plug->getNumInputs()];
- for(i = 0; i < plug->getNumInputs(); ++i) vstin[i] = new R[Blocksize()];
+ vstin = new R *[inputs];
+ tmpin = new R *[inputs];
+ for(i = 0; i < inputs; ++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()];
+ vstout = new R *[outputs];
+ tmpout = new R *[outputs];
+ for(i = 0; i < outputs; ++i) vstout[i] = new R[Blocksize()];
}
static string findFilePath(const string &path,const string &dllname)
@@ -397,7 +399,7 @@ BL vst::ms_plug(I argc,const A *argv)
V vst::m_dsp(I n,t_signalvec const *,t_signalvec const *)
{
if(plug) {
- plug->Init(Samplerate(),(F)Blocksize());
+ plug->DspInit(Samplerate(),Blocksize());
FLEXT_ASSERT(vstfun);
if(blsz != Blocksize()) {
@@ -411,12 +413,14 @@ V vst::m_dsp(I n,t_signalvec const *,t_signalvec const *)
V vst::m_signal(I n,R *const *insigs,R *const *outsigs)
{
if(plug) {
+ const int inputs = plug->GetNumInputs(),outputs = plug->GetNumOutputs();
+
if(sigmatch)
(plug->*vstfun)(const_cast<R **>(insigs),const_cast<R **>(outsigs),n);
else {
R **inv,**outv;
- if(plug->getNumInputs() <= CntInSig())
+ if(inputs <= CntInSig())
inv = const_cast<R **>(insigs);
else { // more plug inputs than inlets
I i;
@@ -424,18 +428,18 @@ V vst::m_signal(I n,R *const *insigs,R *const *outsigs)
// set dangling inputs to zero
// according to mode... (e.g. set zero)
- for(; i < plug->getNumInputs(); ++i) ZeroSamples(tmpin[i] = vstin[i],n);
+ for(; i < inputs; ++i) ZeroSamples(tmpin[i] = vstin[i],n);
inv = tmpin;
}
- const BL more = plug->getNumOutputs() <= CntOutSig();
+ const BL more = outputs <= CntOutSig();
if(more) // more outlets than plug outputs
outv = const_cast<R **>(outsigs);
else {
I i;
for(i = 0; i < CntOutSig(); ++i) tmpout[i] = outsigs[i];
- for(; i < plug->getNumOutputs(); ++i) tmpout[i] = vstout[i];
+ for(; i < outputs; ++i) tmpout[i] = vstout[i];
outv = tmpout;
}
@@ -557,19 +561,15 @@ V vst::m_print(I ac,const A *av)
if ( header ) {
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",
+ post("parameters %d\naudio: %d in(s)/%d out(s) \nLoaded from library \"%s\".\n",
plug->GetNumParams(),
CntInSig(),
CntOutSig(),
plug->GetDllName());
post("Flags");
- if ( plug->_pEffect->flags & effFlagsHasEditor ) {
- post("Has editor");
- }
- if ( plug->_pEffect->flags & effFlagsCanReplacing ) {
- post("Can do replacing");
- }
+ if ( plug->HasEditor() ) post("Has editor");
+ if ( plug->IsReplacing() ) post("Can do replacing");
}
if ( parameters ) {
@@ -609,7 +609,8 @@ V vst::display_parameter(I param,BL showparams)
if(*name) {
if (showparams) {
- plug->DescribeValue( j , display );
+// plug->DescribeValue( j , display );
+ plug->GetParamValue(j,display);
val = plug->GetParamValue( j );
post ("parameter[#%d], \"%s\" value=%f (%s) ", j, name, val,display);
}
@@ -630,7 +631,7 @@ V vst::ms_param(I pnum,F val)
// if(xval <= 1.0f) // What's that????
if(true)
{
- plug->SetParameter( pnum, val );
+ plug->SetParamFloat( pnum, val );
if(echoparam) display_parameter(pnum , true );
}
else
@@ -669,7 +670,7 @@ V vst::m_ptext(I pnum)
C display[164]; /* the Steinberg(tm) way... */
memset(display,0,sizeof(display));
- plug->DescribeValue(pnum,display);
+ plug->GetParamValue(pnum,display);
A at[2];
SetInt(at[0],pnum);