diff options
author | Thomas Grill <xovo@users.sourceforge.net> | 2004-08-23 02:42:16 +0000 |
---|---|---|
committer | Thomas Grill <xovo@users.sourceforge.net> | 2004-08-23 02:42:16 +0000 |
commit | c0a14908d98dad33c2732b084cc2580d78c5d98b (patch) | |
tree | fad2ce0a0c029c22d0cfc46f025eac3c6c198cb6 /externals/grill | |
parent | c4679700d4a75a1f8274880e075d6441f6f0b287 (diff) |
""
svn path=/trunk/; revision=1970
Diffstat (limited to 'externals/grill')
-rw-r--r-- | externals/grill/vst/pd/help-vst~.pd | 216 | ||||
-rw-r--r-- | externals/grill/vst/readme.txt | 12 | ||||
-rw-r--r-- | externals/grill/vst/src/VstHost.cpp | 92 | ||||
-rw-r--r-- | externals/grill/vst/src/VstHost.h | 17 | ||||
-rw-r--r-- | externals/grill/vst/src/main.cpp | 204 |
5 files changed, 359 insertions, 182 deletions
diff --git a/externals/grill/vst/pd/help-vst~.pd b/externals/grill/vst/pd/help-vst~.pd index 8aaeb983..f27c9e54 100644 --- a/externals/grill/vst/pd/help-vst~.pd +++ b/externals/grill/vst/pd/help-vst~.pd @@ -1,10 +1,10 @@ -#N canvas 118 11 818 647 12;
+#N canvas 180 14 842 665 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
+#X obj 473 178 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 msg 470 195 param 2 \$1;
+#X obj 140 192 print A;
#X obj 27 451 tgl 15 0 empty empty empty 0 -6 0 8 -225271 -1 -1 0 1
;
#X msg 26 473 vis \$1;
@@ -13,7 +13,7 @@ #X msg 26 389 edit \$1;
#X msg 94 389 getedit;
#X msg 89 473 getvis;
-#N canvas 367 122 548 455 info 0;
+#N canvas 367 122 550 426 info 0;
#X msg 94 130 getversion;
#X msg 94 75 getname;
#X msg 95 153 getvendor;
@@ -38,6 +38,7 @@ #X text 213 38 get all attributes;
#X msg 268 189 geteditor;
#X text 348 189 has editor?;
+#X msg 22 41 help;
#X connect 0 0 7 0;
#X connect 1 0 7 0;
#X connect 2 0 7 0;
@@ -51,85 +52,61 @@ #X connect 11 0 7 0;
#X connect 19 0 7 0;
#X connect 21 0 7 0;
-#X restore 414 561 pd info;
+#X connect 23 0 7 0;
+#X restore 26 616 pd info;
#X obj 96 96 r \$0-vst;
#X obj 25 416 s \$0-vst;
#X obj 25 499 s \$0-vst;
#X text 52 366 display edit window;
#X text 50 449 make edit window (in)visible;
-#X obj 413 353 s \$0-vst;
-#X obj 414 517 s \$0-vst;
-#X msg 443 471 program 2;
-#X msg 529 470 getprogram;
-#X msg 413 109 getparams;
-#X text 498 108 get number of parameters;
-#X text 509 414 get number of programs;
-#X msg 414 417 getprograms;
-#X msg 543 190 getparam 2;
+#X obj 432 360 s \$0-vst;
+#X obj 409 617 s \$0-vst;
+#X msg 532 478 getprogram;
+#X msg 433 96 getparams;
+#X text 511 96 get number of parameters;
+#X text 504 406 get number of programs;
+#X msg 409 409 getprograms;
+#X msg 572 196 getparam 2;
#X msg 105 295 getplug;
#X obj 26 323 s \$0-vst;
#X text 65 249 set/get plugin;
-#X text 480 561 further information;
-#X obj 23 15 cnv 15 700 58 empty empty vst~ 10 32 0 24 -260818 -1 0
+#X text 92 616 further information;
+#X obj 23 15 cnv 15 750 58 empty empty vst~ 10 32 0 24 -260818 -1 0
;
#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 488 343 win 0;
-#X obj 14 187 s \$0-vst;
-#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 39 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -6 0 10
+#X text 137 173 attribute outlet;
+#X text 103 137 inlets outlets [plugname];
+#N canvas 367 122 465 214 win 0;
+#X obj 34 160 s \$0-vst;
+#X msg 26 109 getx;
+#X text 155 110 get window coordinates;
+#X msg 71 109 gety;
+#X obj 23 51 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -6 0 10
-225271 -1 -1 0 256;
-#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 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
--1 0;
-#X msg 90 281 getmode;
-#X msg 198 218 style \$1;
-#X msg 168 281 mode 101;
-#X text 253 279 get/set window sys menu;
+#X msg 24 69 x \$1;
+#X obj 93 51 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -6 0 10
+-225271 -1 -1 0 256;
+#X msg 94 67 y \$1;
+#X text 154 61 set window coordinates;
#X text 10 7 NOT IMPLEMENTED;
#X connect 1 0 0 0;
#X connect 3 0 0 0;
-#X connect 4 0 0 0;
-#X connect 6 0 0 0;
-#X connect 7 0 8 0;
-#X connect 8 0 0 0;
-#X connect 9 0 10 0;
-#X connect 10 0 0 0;
-#X connect 12 0 0 0;
-#X connect 14 0 16 0;
-#X connect 15 0 0 0;
-#X connect 16 0 0 0;
-#X connect 17 0 0 0;
+#X connect 4 0 5 0;
+#X connect 5 0 0 0;
+#X connect 6 0 7 0;
+#X connect 7 0 0 0;
#X restore 26 542 pd win;
#X text 92 542 manipulating the edit window;
-#X msg 412 135 getpname 2;
-#X msg 440 236 param gain 0;
-#X text 503 133 get parameter name;
-#X msg 550 236 getparam gain;
-#X msg 545 283 getptext gain;
-#X text 451 300 get value in textual representation;
-#X msg 440 283 getptext 2;
-#X text 466 211 set/get parameter (0-based);
-#X text 469 496 set/get program (0-based);
-#X text 487 254 NOT IMPLEMENTED;
-#X text 484 315 NOT IMPLEMENTED;
+#X msg 470 242 param gain 0;
+#X text 542 144 get parameter name;
+#X text 484 312 get value in textual representation;
+#X text 495 217 set/get parameter (0-based);
+#X text 463 497 set/get program (0-based);
#X msg 28 296 plug \$1;
#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 461 281 486 331 midi 0;
+#N canvas 461 281 490 335 midi 0;
#X obj 20 279 s \$0-vst;
#X msg 238 147 ctlchg 3 123;
#X text 116 28 note on;
@@ -167,27 +144,49 @@ #X connect 18 0 17 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 msg 409 434 getprogcats;
+#X text 504 431 get number of program categories;
#X text 134 33 based on the work of Jarno Seppanen and Mark Williamson
;
#X text 133 14 VST plugins for PD \, (C)2003-04 Thomas Grill;
-#X obj 26 140 vst~ 1 2;
-#X obj 685 548 loadbang;
-#X msg 685 575 \; pd dsp 1;
-#X obj 233 367 tgl 15 0 empty empty empty 0 -6 0 8 -225271 -1 -1 0
+#X obj 26 140 vst~ 1 2 @pnames 100;
+#X obj 741 569 loadbang;
+#X msg 741 596 \; pd dsp 1;
+#X obj 228 339 tgl 15 0 empty empty empty 0 -6 0 8 -225271 -1 -1 0
1;
-#X obj 231 416 s \$0-vst;
-#X msg 232 389 bypass \$1;
-#X msg 314 389 getbypass;
-#X text 258 366 bypass plugin;
-#X obj 237 264 tgl 15 0 empty empty empty 0 -6 0 8 -225271 -1 -1 1
+#X obj 226 388 s \$0-vst;
+#X msg 227 361 bypass \$1;
+#X msg 309 361 getbypass;
+#X text 253 338 bypass plugin;
+#X obj 228 245 tgl 15 0 empty empty empty 0 -6 0 8 -225271 -1 -1 0
1;
-#X obj 235 313 s \$0-vst;
-#X text 262 263 mute output;
-#X msg 236 286 mute \$1;
-#X msg 318 286 getmute;
-#X connect 1 0 56 0;
+#X obj 226 294 s \$0-vst;
+#X text 253 244 mute output;
+#X msg 227 267 mute \$1;
+#X msg 309 267 getmute;
+#X msg 429 478 program \$1;
+#X obj 430 462 nbx 5 14 0 10000 0 0 empty empty empty 0 -6 0 10 -225271
+-1 -1 0 256;
+#X msg 471 290 getptext \$1;
+#X obj 471 273 nbx 5 14 0 10000 0 0 empty empty empty 0 -6 0 10 -225271
+-1 -1 0 256;
+#X obj 450 128 nbx 5 14 0 10000 0 0 empty empty empty 0 -6 0 10 -225271
+-1 -1 0 256;
+#X msg 450 146 getpname \$1;
+#X msg 576 290 getptext gain;
+#X msg 580 242 getparam gain;
+#X obj 434 516 nbx 5 14 0 10000 0 0 empty empty empty 0 -6 0 10 -225271
+-1 -1 0 256;
+#X msg 432 533 getprogname \$1;
+#X text 552 530 get program name;
+#X obj 433 567 nbx 5 14 0 10000 0 0 empty empty empty 0 -6 0 10 -225271
+-1 -1 0 256;
+#X text 569 582 get program name;
+#X msg 431 584 getprogname 2 \$1;
+#X text 571 596 (with category);
+#X text 480 328 (may be ambigous!);
+#X text 568 544 (no category);
+#X connect 1 0 49 0;
#X connect 2 0 3 0;
#X connect 3 0 17 0;
#X connect 5 0 6 0;
@@ -196,29 +195,36 @@ #X connect 8 0 13 0;
#X connect 9 0 13 0;
#X connect 10 0 14 0;
-#X connect 12 0 56 0;
+#X connect 12 0 49 0;
#X connect 19 0 18 0;
-#X connect 20 0 18 0;
-#X connect 21 0 17 0;
-#X connect 24 0 18 0;
-#X connect 25 0 17 0;
-#X connect 26 0 27 0;
-#X connect 36 0 17 0;
-#X connect 37 0 17 0;
-#X connect 39 0 17 0;
-#X connect 40 0 17 0;
-#X connect 42 0 17 0;
-#X connect 47 0 27 0;
-#X connect 48 0 49 0;
-#X connect 49 0 47 0;
-#X connect 52 0 18 0;
-#X connect 56 0 0 0;
-#X connect 56 1 0 1;
-#X connect 56 2 4 0;
-#X connect 57 0 58 0;
-#X connect 59 0 61 0;
-#X connect 61 0 60 0;
-#X connect 62 0 60 0;
-#X connect 64 0 67 0;
-#X connect 67 0 65 0;
-#X connect 68 0 65 0;
+#X connect 20 0 17 0;
+#X connect 23 0 18 0;
+#X connect 24 0 17 0;
+#X connect 25 0 26 0;
+#X connect 35 0 17 0;
+#X connect 40 0 26 0;
+#X connect 41 0 42 0;
+#X connect 42 0 40 0;
+#X connect 45 0 18 0;
+#X connect 49 0 0 0;
+#X connect 49 1 0 1;
+#X connect 49 2 4 0;
+#X connect 50 0 51 0;
+#X connect 52 0 54 0;
+#X connect 54 0 53 0;
+#X connect 55 0 53 0;
+#X connect 57 0 60 0;
+#X connect 60 0 58 0;
+#X connect 61 0 58 0;
+#X connect 62 0 18 0;
+#X connect 63 0 62 0;
+#X connect 64 0 17 0;
+#X connect 65 0 64 0;
+#X connect 66 0 67 0;
+#X connect 67 0 17 0;
+#X connect 68 0 17 0;
+#X connect 69 0 17 0;
+#X connect 70 0 71 0;
+#X connect 71 0 18 0;
+#X connect 73 0 75 0;
+#X connect 75 0 18 0;
diff --git a/externals/grill/vst/readme.txt b/externals/grill/vst/readme.txt index 9d96e2cb..68917404 100644 --- a/externals/grill/vst/readme.txt +++ b/externals/grill/vst/readme.txt @@ -31,10 +31,6 @@ pd - darwin (MacOSX): --------------------- o GCC: edit "config-pd-darwin.txt" & run "sh build-pd-darwin.sh" -Max/MSP - MacOS9/X: -------------------- -o CodeWarrior: edit "vst.cw" and build - ---------------------------------------------------------------------------- @@ -50,7 +46,8 @@ Version history: - fixed crash on destroying vst~ with open editor window - stripped all MFC code - fixed DSP initialization, zero dangling audio vectors -- added "bypass" and "mute" attributes +- pre12: added "bypass" and "mute" attributes +- pre13: with flext 0.4.7 no more interruptions on window close 0.0.0: - version of mark@junklight.com @@ -62,6 +59,9 @@ features: - include necessary Steinberg license stuff BUGS: -- Quadrafuzz crashes on closing editor window - Waveshell crashes on load +- mouse interaction in editor can cause audio dropouts +TODO: +- do name scanning in the background +- translate special characters in strings (like ° as param_label) into system-digestible form diff --git a/externals/grill/vst/src/VstHost.cpp b/externals/grill/vst/src/VstHost.cpp index 041acb76..bd686716 100644 --- a/externals/grill/vst/src/VstHost.cpp +++ b/externals/grill/vst/src/VstHost.cpp @@ -11,7 +11,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include "VstHost.h" #include "AEffectx.h" -using namespace std; +#include <ctype.h> static VstTimeInfo _timeInfo; @@ -21,7 +21,8 @@ typedef AEffect *(VSTCALLBACK *PVSTMAIN)(audioMasterCallback audioMaster); VSTPlugin::VSTPlugin(): h_dll(NULL),hwnd(NULL),_pEffect(NULL), posx(0),posy(0), - _midichannel(0),queue_size(0) + _midichannel(0),queue_size(0), + paramnamecnt(0) {} VSTPlugin::~VSTPlugin() @@ -62,39 +63,36 @@ int VSTPlugin::Instance(const char *dllname) ret = Dispatch( effIdentify); FLEXT_ASSERT(ret == 'NvEf'); - if (!Dispatch( effGetProductString, 0, 0, &_sProductName, 0.0f)) { + *_sProductName = 0; + Dispatch( effGetProductString, 0, 0, &_sProductName, 0.0f); + if(_sProductName) { // no product name given by plugin -> extract it from the filename - string str1(dllname); - string::size_type slpos = str1.rfind('\\'); - if(slpos == string::npos) { + std::string str1(dllname); + std::string::size_type slpos = str1.rfind('\\'); + if(slpos == std::string::npos) { slpos = str1.rfind('/'); - if(slpos == string::npos) + if(slpos == std::string::npos) slpos = 0; else ++slpos; } else ++slpos; - string str2 = str1.substr(slpos); + std::string str2 = str1.substr(slpos); int snip = str2.find('.'); - if( snip != string::npos ) + if( snip != std::string::npos ) str1 = str2.substr(0,snip); else str1 = str2; strcpy(_sProductName,str1.c_str()); } - if(!Dispatch( effGetVendorString, 0, 0, &_sVendorName, 0.0f)) - strcpy(_sVendorName, "Unknown vendor"); + *_sVendorName = 0; + Dispatch( effGetVendorString, 0, 0, &_sVendorName, 0.0f); _sDllName = dllname; -/* - Dispatch( effMainsChanged, 0, 1); - Dispatch( effSetSampleRate, 0, 0,NULL,44100.); - Dispatch( effSetBlockSize, 0, 64); -*/ return VSTINSTANCE_NO_ERROR; } @@ -140,19 +138,30 @@ void VSTPlugin::Free() // Called also in destruction void VSTPlugin::DspInit(float samplerate,int blocksize) { -// sample_rate = samplerate; - - Dispatch(effMainsChanged, 0, 1); + // sample rate and block size must _first_ be set Dispatch(effSetSampleRate, 0, 0,NULL,samplerate); Dispatch(effSetBlockSize, 0, blocksize); + // than signal that mains have changed! + Dispatch(effMainsChanged, 0, 1); +} + +static void striptrail(char *txt) +{ + // strip trailing whitespace + for(int i = strlen(txt)-1; i >= 0; --i) + // cast to unsigned char since isspace functions don't want characters like 0x80 = -128 + if(isspace(((unsigned char *)txt)[i])) txt[i] = 0; } void VSTPlugin::GetParamName(int numparam,char *name) const { - if(numparam < GetNumParams()) + if(numparam < GetNumParams()) { + name[0] = 0; Dispatch(effGetParamName,numparam,0,name,0.0f); + striptrail(name); + } else - strcpy(name,"Index out of Range"); + name[0] = 0; } bool VSTPlugin::SetParamFloat(int parameter,float value) @@ -169,14 +178,17 @@ 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); + // how many chars needed? + char par_display[64]; par_display[0] = 0; 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); +// if(par_display[7]) par_display[8] = 0; // set trailing zero + + // how many chars needed? + char par_label[64]; par_label[0] = 0; + Dispatch(effGetParamLabel,numparam,0,par_label,0.0f); + striptrail(par_label); +// if(par_label[7]) par_label[8] = 0; // set trailing zero + sprintf(parval,"%s%s",par_display,par_label); } else @@ -194,6 +206,26 @@ float VSTPlugin::GetParamValue(int numparam) const return -1.0; } +void VSTPlugin::ScanParams(int cnt) +{ + if(cnt < 0) cnt = GetNumParams(); + if(paramnamecnt >= cnt) return; + if(cnt >= GetNumParams()) cnt = GetNumParams(); + + char name[64]; + for(int i = paramnamecnt; i < cnt; ++i) { + GetParamName(i,name); + if(*name) paramnames[std::string(name)] = i; + } + paramnamecnt = cnt; +} + +int VSTPlugin::GetParamIx(const char *p) const +{ + NameMap::const_iterator it = paramnames.find(std::string(p)); + return it == paramnames.end()?-1:it->second; +} + void VSTPlugin::Edit(bool open) { if(Is()) { @@ -308,9 +340,11 @@ void VSTPlugin::AddControlChange(int control, int value) bool VSTPlugin::GetProgramName( int cat , int p, char *buf) const { + buf[0] = 0; int parameter = p; - if(parameter < GetNumPrograms()) { + if(parameter < GetNumPrograms() && cat < GetNumCategories()) { Dispatch(effGetProgramNameIndexed,parameter,cat,buf,0.0f); + striptrail(buf); return true; } else diff --git a/externals/grill/vst/src/VstHost.h b/externals/grill/vst/src/VstHost.h index bbbebe1f..00b5164f 100644 --- a/externals/grill/vst/src/VstHost.h +++ b/externals/grill/vst/src/VstHost.h @@ -72,6 +72,13 @@ public: void GetParamValue(int numparam,char *parval) const; float GetParamValue(int numparam) const; + // scan plugin names (can take a _long_ time!!) + void ScanParams(int i = -1); + // get number of scanned parameters + int ScannedParams() const { return paramnamecnt; } + // get index of named (scanned) parameter... -1 if not found + int GetParamIx(const char *p) const; + bool SetParamFloat(int parameter, float value); bool SetParamInt(int parameter, int value) { return SetParamFloat(parameter,value/65535.0f); } @@ -143,6 +150,16 @@ protected: char _sVendorName[64]; std::string _sDllName; // Contains dll name + struct NameCmp: + std::less<std::string> + { + bool operator()(const std::string &a,const std::string &b) const { return a.compare(b) < 0; } + }; + + typedef std::map<std::string,int,NameCmp> NameMap; + int paramnamecnt; + NameMap paramnames; + /* float *inputs[MAX_INOUTS]; float *outputs[MAX_INOUTS]; diff --git a/externals/grill/vst/src/main.cpp b/externals/grill/vst/src/main.cpp index 2467e1bd..13205a4d 100644 --- a/externals/grill/vst/src/main.cpp +++ b/externals/grill/vst/src/main.cpp @@ -17,10 +17,9 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include <io.h> #include <string> -using namespace std; -#define VST_VERSION "0.1.0pre12" +#define VST_VERSION "0.1.0pre13" class vst: @@ -67,7 +66,18 @@ protected: V ms_program(I p); V mg_program(I &p) const { p = plug?plug->GetCurrentProgram():0; } + V mg_progname(int argc,const t_atom *argv) const; + V m_pname(I pnum); + V ms_paramnames(int cnt) { paramnames = cnt; if(plug) plug->ScanParams(cnt); } + + V ms_param(I pnum,F val); + V ms_params(int argc,const t_atom *argv); + V mg_param(I pnum); + V mg_params(int argc,const t_atom *argv); + V m_ptext(I pnum); + V m_ptexts(int argc,const t_atom *argv); + // V m_control(const S *ctrl_name,I ctrl_value); V m_pitchbend(I ctrl_value); V m_programchange(I ctrl_value); @@ -76,17 +86,13 @@ protected: V m_note(I note,I vel); inline V m_noteoff(I note) { m_note(note,0); } - V ms_param(I pnum,F val); - V mg_param(I pnum); - V m_pname(I pnum); - V m_ptext(I pnum); - private: V display_parameter(I param,BL showparams); VSTPlugin *plug; - string plugname; - BL echoparam,visible,bypass,mute; + std::string plugname; + bool echoparam,visible,bypass,mute; + int paramnames; I blsz; V (VSTPlugin::*vstfun)(R **insigs,R **outsigs,L n); @@ -119,10 +125,17 @@ private: FLEXT_CALLBACK_II(m_ctrlchange) FLEXT_CALLVAR_I(mg_program,ms_program) + FLEXT_CALLBACK_V(mg_progname) + + FLEXT_CALLBACK_I(m_pname) + FLEXT_ATTRGET_I(paramnames) + FLEXT_CALLSET_I(ms_paramnames) FLEXT_CALLBACK_2(ms_param,int,float) + FLEXT_CALLBACK_V(ms_params) FLEXT_CALLBACK_I(mg_param) - FLEXT_CALLBACK_I(m_pname) + FLEXT_CALLBACK_V(mg_params) FLEXT_CALLBACK_I(m_ptext) + FLEXT_CALLBACK_V(m_ptexts) FLEXT_CALLBACK_II(m_note) FLEXT_CALLBACK_I(m_noteoff) @@ -141,11 +154,15 @@ private: FLEXT_CALLGET_S(mg_plugdll) FLEXT_CALLGET_I(mg_plugversion) FLEXT_CALLGET_B(mg_issynth) + + static const t_symbol *sym_progname,*sym_pname,*sym_param,*sym_ptext; }; FLEXT_NEW_DSP_V("vst~",vst); +const t_symbol *vst::sym_progname,*vst::sym_pname,*vst::sym_param,*vst::sym_ptext; + V vst::Setup(t_classid c) { post(""); @@ -170,11 +187,16 @@ V vst::Setup(t_classid c) FLEXT_CADDMETHOD_(c,0,"progchg",m_programchange); FLEXT_CADDATTR_VAR(c,"program",mg_program,ms_program); + FLEXT_CADDMETHOD_(c,0,"getprogname",mg_progname); + FLEXT_CADDMETHOD_I(c,0,"getpname",m_pname); + FLEXT_CADDATTR_VAR(c,"pnames",paramnames,ms_paramnames); FLEXT_CADDMETHOD_2(c,0,"param",ms_param,int,float); + FLEXT_CADDMETHOD_2(c,0,"param",ms_params,t_symptr,float); FLEXT_CADDMETHOD_(c,0,"getparam",mg_param); - FLEXT_CADDMETHOD_I(c,0,"getpname",m_pname); - FLEXT_CADDMETHOD_I(c,0,"getptext",m_ptext); + FLEXT_CADDMETHOD_(c,0,"getparam",mg_params); + FLEXT_CADDMETHOD_(c,0,"getptext",m_ptext); + FLEXT_CADDMETHOD_(c,0,"getptext",m_ptexts); FLEXT_CADDATTR_VAR1(c,"echo",echoparam); FLEXT_CADDATTR_VAR(c,"x",mg_winx,ms_winx); @@ -191,6 +213,11 @@ V vst::Setup(t_classid c) FLEXT_CADDATTR_GET(c,"version",mg_plugversion); FLEXT_CADDATTR_GET(c,"synth",mg_issynth); + sym_progname = MakeSymbol("progname"); + sym_pname = MakeSymbol("pname"); + sym_param = MakeSymbol("param"); + sym_ptext = MakeSymbol("ptext"); + SetupEditor(); } @@ -199,7 +226,7 @@ vst::vst(I argc,const A *argv): plug(NULL),visible(false), blsz(0), vstfun(NULL),vstin(NULL),vstout(NULL),tmpin(NULL),tmpout(NULL), - echoparam(false),bypass(false),mute(false) + echoparam(false),bypass(false),mute(false),paramnames(0) { if(argc >= 2 && CanbeInt(argv[0]) && CanbeInt(argv[1])) { AddInSignal(GetAInt(argv[0])); @@ -234,6 +261,8 @@ V vst::InitPlug() InitPlugDSP(); InitBuf(); + + plug->ScanParams(paramnames); } V vst::InitPlugDSP() @@ -276,7 +305,7 @@ V vst::InitBuf() for(i = 0; i < outputs; ++i) vstout[i] = new R[Blocksize()]; } -static string findFilePath(const string &path,const string &dllname) +static std::string findFilePath(const std::string &path,const std::string &dllname) { _chdir( path.c_str() ); #if FLEXT_OS == FLEXT_OS_WIN @@ -308,7 +337,7 @@ static string findFilePath(const string &path,const string &dllname) } */ - return string(); + return std::string(); } @@ -322,6 +351,17 @@ BL vst::ms_plug(I argc,const A *argv) if(i > 0) plugname += ' '; GetAString(argv[i],buf,sizeof buf); strlwr(buf); + +#if FLEXT_SYS == FLEXT_SYS_PD + // strip char escapes (only in newer/devel PD version) + char *cs = buf,*cd = cs; + while(*cs) { + if(*cs != '\\') *(cd++) = *cs; + ++cs; + } + *cd = 0; +#endif + plugname += buf; } @@ -353,7 +393,7 @@ BL vst::ms_plug(I argc,const A *argv) // if dir is current working directory... name points to dir if(dir == name) strcpy(dir,"."); - string dllname(dir); + std::string dllname(dir); dllname += "\\"; dllname += name; @@ -362,9 +402,9 @@ BL vst::ms_plug(I argc,const A *argv) } if(!lf) { // try finding it on the VST path - C *vst_path = getenv ("VST_PATH"); + C *vst_path = getenv("VST_PATH"); - string dllname(plugname); + std::string dllname(plugname); if(dllname.find(".dll") == -1) dllname += ".dll"; if(vst_path) { @@ -373,12 +413,12 @@ BL vst::ms_plug(I argc,const A *argv) strcpy( tok_path , vst_path); char *tok = strtok( tok_path , ";" ); while( tok != NULL ) { - string abpath( tok ); + std::string abpath( tok ); if( abpath[abpath.length()-1] != '\\' ) abpath += "\\"; FLEXT_LOG1("trying VST_PATH %s",(const C *)abpath.c_str()); - string realpath = findFilePath( abpath , dllname ); + std::string realpath = findFilePath( abpath , dllname ); //post( "findFilePath( %s , %s ) = %s\n" , abpath , dllname , realpath ); if ( realpath.length() ) { realpath += plugname; @@ -444,13 +484,14 @@ V vst::m_signal(I n,R *const *insigs,R *const *outsigs) if(sigmatch) (plug->*vstfun)(const_cast<R **>(insigs),const_cast<R **>(outsigs),n); else { + const int cntin = CntInSig(),cntout = CntOutSig(); R **inv,**outv; - if(inputs <= CntInSig()) + if(inputs <= cntin) inv = const_cast<R **>(insigs); else { // more plug inputs than inlets I i; - for(i = 0; i < CntInSig(); ++i) tmpin[i] = const_cast<R *>(insigs[i]); + for(i = 0; i < cntin; ++i) tmpin[i] = const_cast<R *>(insigs[i]); // set dangling inputs to zero // according to mode... (e.g. set zero) @@ -459,24 +500,25 @@ V vst::m_signal(I n,R *const *insigs,R *const *outsigs) inv = tmpin; } - const BL more = outputs <= CntOutSig(); + const BL more = outputs <= cntout; 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 = 0; i < cntout; ++i) tmpout[i] = outsigs[i]; for(; i < outputs; ++i) tmpout[i] = vstout[i]; outv = tmpout; } + // call plugin DSP function (plug->*vstfun)(inv,outv,n); if(more) { // according to mode set dangling output vectors // currently simply clear them.... - for(int i = outputs; i < CntOutSig(); ++i) + for(int i = outputs; i < cntout; ++i) ZeroSamples(outsigs[i],n); } } @@ -531,6 +573,33 @@ V vst::ms_program(I p) if(plug && p >= 0) plug->SetCurrentProgram(p); } +void vst::mg_progname(int argc,const t_atom *argv) const +{ + if(plug) { + int cat,pnum; + if(argc == 1 && CanbeInt(argv[0])) { + cat = -1,pnum = GetAInt(argv[0]); + } + else if(argc == 2 && CanbeInt(argv[0]) && CanbeInt(argv[1])) { + cat = GetAInt(argv[0]),pnum = GetAInt(argv[1]); + } + else pnum = -1; + + if(pnum >= 0) { + char str[256]; + plug->GetProgramName(cat,pnum,str); + + A at[3]; + SetInt(at[0],cat); + SetInt(at[1],pnum); + SetString(at[2],str); + ToOutAnything(GetOutAttr(),sym_progname,3,at); + } + else + post("%s - Syntax: %s [category] program",thisName(),GetString(thisTag())); + } +} + V vst::m_ctrlchange(I control,I ctrl_value) { if(plug) plug->AddControlChange(control,ctrl_value ); @@ -639,7 +708,7 @@ 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); @@ -651,6 +720,18 @@ V vst::display_parameter(I param,BL showparams) } } +V vst::m_pname(I pnum) +{ + if(!plug || pnum < 0 || pnum >= plug->GetNumParams()) return; + + char name[256]; // how many chars needed? + plug->GetParamName(pnum,name); + + A at[2]; + SetInt(at[0],pnum); + SetString(at[1],name); + ToOutAnything(GetOutAttr(),sym_pname,2,at); +} // set the value of a parameter V vst::ms_param(I pnum,F val) @@ -668,6 +749,25 @@ V vst::ms_param(I pnum,F val) FLEXT_ASSERT(false); } +void vst::ms_params(int argc,const t_atom *argv) +{ + if(plug) { + char str[255]; *str = 0; + if(argc && CanbeFloat(argv[argc-1])) + PrintList(argc-1,argv,str,sizeof str); + + if(*str) { + int ix = plug->GetParamIx(str); + if(ix >= 0) + ms_param(ix,GetAFloat(argv[argc-1])); + else + post("%s %s - Parameter not found",thisName(),GetString(thisTag()),str); + } + else + post("%s - Syntax: %s name value",thisName(),GetString(thisTag())); + } +} + V vst::mg_param(I pnum) { if(!plug || pnum < 0 || pnum >= plug->GetNumParams()) return; @@ -675,37 +775,57 @@ V vst::mg_param(I pnum) A at[2]; SetInt(at[0],pnum); SetFloat(at[1],plug->GetParamValue(pnum)); - ToOutAnything(GetOutAttr(),MakeSymbol("param"),2,at); + ToOutAnything(GetOutAttr(),sym_param,2,at); } -V vst::m_pname(I pnum) +V vst::mg_params(int argc,const t_atom *argv) { - if(!plug || pnum < 0 || pnum >= plug->GetNumParams()) return; - - C name[109]; /* the Steinberg(tm) way... */ - - memset(name,0,sizeof(name)); - plug->GetParamName(pnum,name); - - A at[2]; - SetInt(at[0],pnum); - SetString(at[1],name); - ToOutAnything(GetOutAttr(),MakeSymbol("pname"),2,at); + if(plug) { + char str[255]; + PrintList(argc,argv,str,sizeof str); + + if(*str) { + int ix = plug->GetParamIx(str); + if(ix >= 0) + mg_param(ix); + else + post("%s %s - Parameter not found",thisName(),GetString(thisTag()),str); + } + else + post("%s - Syntax: %s name value",thisName(),GetString(thisTag())); + } } V vst::m_ptext(I pnum) { if(!plug || pnum < 0 || pnum >= plug->GetNumParams()) return; - C display[164]; /* the Steinberg(tm) way... */ - + char display[256]; // how many chars needed? memset(display,0,sizeof(display)); plug->GetParamValue(pnum,display); A at[2]; SetInt(at[0],pnum); SetString(at[1],display); - ToOutAnything(GetOutAttr(),MakeSymbol("ptext"),2,at); + ToOutAnything(GetOutAttr(),sym_ptext,2,at); +} + +V vst::m_ptexts(int argc,const t_atom *argv) +{ + if(plug) { + char str[255]; + PrintList(argc,argv,str,sizeof str); + + if(*str) { + int ix = plug->GetParamIx(str); + if(ix >= 0) + m_ptext(ix); + else + post("%s %s - Parameter not found",thisName(),GetString(thisTag()),str); + } + else + post("%s - Syntax: %s name value",thisName(),GetString(thisTag())); + } } V vst::m_note(I note,I velocity) |