Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

481 lines
14KB

  1. # data file for the Fltk User Interface Designer (fluid)
  2. version 1.0110
  3. header_name {.h}
  4. code_name {.cc}
  5. decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {}
  6. decl {//License: GNU GPL version 2 or later} {}
  7. decl {\#include <stdlib.h>} {public
  8. }
  9. decl {\#include <FL/fl_draw.H>} {public
  10. }
  11. decl {\#include <FL/Fl_Box.H>} {public
  12. }
  13. decl {\#include "../globals.h"} {public
  14. }
  15. decl {\#include "../Misc/Master.h"} {public
  16. }
  17. decl {\#include "../Misc/Util.h"} {public
  18. }
  19. decl {\#include "WidgetPDial.h"} {public
  20. }
  21. decl {\#include "common.H"} {public
  22. }
  23. decl {\#ifdef NTK_GUI
  24. \#include "FL/Fl_Shared_Image.H"
  25. \#endif} {public
  26. }
  27. decl {const int keyspos[12]={0,-1,1,-2,2,3,-4,4,-5,5,-6,6};} {}
  28. decl {const int keysoct1qwerty[]={'q','2','w','3','e','r','5','t','6','y','7','u','i','9','o','0','p','[','=',']','\\\\',FL_Enter,0};} {}
  29. decl {const int keysoct2qwerty[]={'z','s','x','d','c','v','g','b','h','n','j','m',',','l','.',';','/',0};} {}
  30. decl {const int keysoct1dw[]={'\\'','2',',','3','.','p','5','y','6','f','7','g','c','9','r','0','l','/',']','=','\\\\',FL_Enter,0};} {}
  31. decl {const int keysoct2dw[]={';','o','q','e','j','k','i','x','d','b','h','m','w','n','v','s','z',0};} {}
  32. decl {const int keysoct1qwertz[]={'q','2','w','3','e','r','5','t','6','z','7','u','i','9','o','0','p',252,'\\'','+','\\\\',FL_Enter,0};} {}
  33. decl {const int keysoct2qwertz[]={'y','s','x','d','c','v','g','b','h','n','j','m',',','l','.',246,'-',0};} {}
  34. decl {const int keysoct1az[]={'a',233,'z','\\"','e','r','(','t','-','y',232,'u','i',231,'o',224,'p',65106,'=','$',0};} {}
  35. decl {const int keysoct2az[]={'w','s','x','d','c','v','g','b','h','n','j',',',';','l',':','m','!',0};} {}
  36. class VirKeys {: {public Fl_Box}
  37. } {
  38. decl {static const int N_OCT=6;} {}
  39. decl {static const int SIZE_WHITE=14;} {}
  40. decl {static const int SIZE_BLACK=8;} {}
  41. Function {VirKeys(int x,int y, int w, int h, const char *label=0):Fl_Box(x,y,w,h,label)} {} {
  42. code {master=NULL;} {}
  43. }
  44. Function {init(Master *master_)} {} {
  45. code {master=master_;
  46. for (int i=0;i<N_OCT*12+1;i++) pressed[i]=0;
  47. midich=0;
  48. midivel=100;
  49. midioct=2;
  50. keyoct1=3;
  51. keyoct2=2;
  52. rndvelocity=0;} {}
  53. }
  54. Function {draw()} {} {
  55. code {int ox=x(),oy=y(),lx=w(),ly=h()-1,i;
  56. \#ifdef NTK_GUI
  57. Fl_Image *white_up = Fl_Shared_Image::get( gUiPixmapPath + "white_key.png" );
  58. Fl_Image *white_down = Fl_Shared_Image::get( gUiPixmapPath + "white_key_pressed.png" );
  59. Fl_Image *black_up = Fl_Shared_Image::get( gUiPixmapPath + "black_key.png" );
  60. Fl_Image *black_down = Fl_Shared_Image::get( gUiPixmapPath + "black_key_pressed.png" );
  61. //On error fetch everything from source directory
  62. if(!(white_up&&white_down&&black_up&&black_down)) {
  63. white_up = Fl_Shared_Image::get(SOURCE_DIR "/../../pixmaps/white_key.png");
  64. white_down = Fl_Shared_Image::get(SOURCE_DIR "/../../pixmaps/white_key_pressed.png");
  65. black_up = Fl_Shared_Image::get(SOURCE_DIR "/../../pixmaps/black_key.png");
  66. black_down = Fl_Shared_Image::get(SOURCE_DIR "/../../pixmaps/black_key_pressed.png");
  67. }
  68. Fl_Image *key;
  69. for (i=0;i<N_OCT*12;i++) {
  70. int noct=i/12;
  71. int kv=keyspos[i%12];
  72. if (kv>=0){//white keys
  73. if (pressed[i]==0)
  74. key = white_up;
  75. else
  76. key = white_down;
  77. key->draw( ox + (kv + 7 * noct ) * white_up->w() + 3, oy );
  78. }
  79. }
  80. for (i=0;i<N_OCT*12;i++){
  81. int noct=i/12;
  82. int kv=keyspos[i%12];
  83. if ( kv < 0 ) {
  84. kv=keyspos[(i+1)%12];
  85. if (pressed[i]==0)
  86. key = black_up;
  87. else
  88. key = black_down;
  89. key->draw( ox + (kv + 7 * noct ) * white_up->w() - black_up->w() / 2 + 2, oy );
  90. }
  91. }
  92. \#else
  93. if (damage()!=1){
  94. fl_color(250,240,230);
  95. fl_rectf(ox,oy,lx,ly);
  96. fl_color(FL_BLACK);
  97. fl_line(ox,oy,ox+lx,oy);
  98. fl_line(ox,oy+ly,ox+lx,oy+ly);
  99. for (i=0;i<N_OCT*7+1;i++){
  100. fl_line(ox+i*SIZE_WHITE,oy,ox+i*SIZE_WHITE,oy+ly);
  101. int ik=i%7;
  102. if ((ik==1)||(ik==2)||(ik==4)||(ik==5)||(ik==6))
  103. fl_rectf(ox+i*SIZE_WHITE-SIZE_BLACK/2,oy,
  104. SIZE_BLACK+1,ly*3/5);
  105. }
  106. }
  107. for (i=0;i<N_OCT*12;i++){
  108. // if (pressed[i]==0) continue;
  109. int noct=i/12;
  110. int kv=keyspos[i%12];
  111. if (kv>=0){//white keys
  112. if (pressed[i]==0) fl_color(250,240,230);
  113. else fl_color(FL_BLUE);
  114. fl_rectf(ox+(kv+7*noct)*SIZE_WHITE+3,oy+ly*3/5+2,
  115. SIZE_WHITE-4,ly*2/5-3);
  116. } else {//black keys
  117. kv=keyspos[(i+1)%12];
  118. if (pressed[i]==0) fl_color(FL_BLACK);
  119. else fl_color(FL_BLUE);
  120. fl_rectf(ox+(kv+7*noct)*SIZE_WHITE-SIZE_BLACK/2+2,oy+2,
  121. SIZE_BLACK-3,ly*3/5-5);
  122. }
  123. }
  124. \#endif} {}
  125. }
  126. Function {handle(int event)} {return_type int
  127. } {
  128. code {int i;
  129. int ly=h();
  130. int x_=Fl::event_x()-x();
  131. int y_=Fl::event_y()-y();
  132. if ( (x_<0)&&(x_>w()) && (y_<0)&&(y_>h())){
  133. return(0);
  134. };
  135. if ((event==FL_PUSH)||(event==FL_DRAG)||(event==FL_RELEASE)){
  136. int kpos=-1;
  137. if (y_>ly*3/5){//white keys
  138. int pos=x_/SIZE_WHITE;
  139. if (pos<0) return(1);
  140. for (i=0;i<12;i++) {
  141. if (pos%7==keyspos[i]) {
  142. kpos=pos/7*12+i;
  143. break;
  144. };
  145. };
  146. } else {//black keys
  147. int pos=(x_+SIZE_WHITE/2)/SIZE_WHITE;
  148. if (pos<0) return(1);
  149. for (i=1;i<12;i++) {
  150. if (pos%7==-keyspos[i]) {
  151. kpos=pos/7*12+i;
  152. break;
  153. };
  154. };
  155. };
  156. if ((kpos!=-1)&&((event==FL_PUSH)||(event==FL_DRAG))&&
  157. (Fl::event_shift()==0)) {
  158. presskey(kpos,1,1);
  159. };
  160. if ((event==FL_PUSH)&&(Fl::event_shift()!=0)) {
  161. if (pressed[kpos]==0) presskey(kpos,0,1);
  162. else relasekey(kpos,1);
  163. };
  164. if ((event==FL_RELEASE)&&(Fl::event_shift()==0))
  165. relaseallkeys(1);
  166. take_focus();
  167. };
  168. const int *keysoct1=keysoct1qwerty;
  169. const int *keysoct2=keysoct2qwerty;
  170. if (config.cfg.VirKeybLayout==2) {
  171. keysoct1=keysoct1dw;
  172. keysoct2=keysoct2dw;
  173. }else if (config.cfg.VirKeybLayout==3) {
  174. keysoct1=keysoct1qwertz;
  175. keysoct2=keysoct2qwertz;
  176. }else if (config.cfg.VirKeybLayout==4) {
  177. keysoct1=keysoct1az;
  178. keysoct2=keysoct2az;
  179. };
  180. if ((event==FL_KEYDOWN)||(event==FL_KEYUP)){
  181. int key=Fl::event_key();
  182. int kpos=-1;
  183. for (i=0;keysoct1[i]!=0;i++) if (key==keysoct1[i]) kpos=i+12*keyoct1;
  184. for (i=0;keysoct2[i]!=0;i++) if (key==keysoct2[i]) kpos=i+12*keyoct2;
  185. if (kpos==-1) return(0);
  186. if ((event==FL_KEYUP) && (Fl::event_key(key)==0) && (Fl::get_key(key)!=0)) return(0);
  187. if (event==FL_KEYDOWN) presskey(kpos,0,2);
  188. else relasekey(kpos,2);
  189. };
  190. return(1);} {}
  191. }
  192. Function {presskey(int nk,int exclusive,int type)} {} {
  193. code {//Exclusive means that multiple keys can be pressed at once
  194. //when the user uses the shift key
  195. if (nk>=N_OCT*12) return;
  196. if ((nk<0)&&(exclusive==0)) {
  197. relaseallkeys(type);
  198. return;
  199. };
  200. if (nk<0) return;
  201. if (pressed[nk]!=0) return;//the key is already pressed
  202. if (exclusive!=0) relaseallkeys(type);
  203. pressed[nk]=type;
  204. damage(1);
  205. float vel=midivel;
  206. if (rndvelocity!=0){
  207. vel=midivel*(127.0-rndvelocity)/127.0+RND*rndvelocity;
  208. };
  209. pthread_mutex_lock(&master->mutex);
  210. master->noteOn(midich,nk+midioct*12,(int)vel);
  211. pthread_mutex_unlock(&master->mutex);} {}
  212. }
  213. Function {relasekey(int nk,int type)} {} {
  214. code {if ((nk<0)||(nk>=N_OCT*12)) return;
  215. if (pressed[nk]==0) return;//the key is not pressed
  216. if ((type!=0)&&(pressed[nk]!=type)) return;
  217. pressed[nk]=0;
  218. damage(1);
  219. pthread_mutex_lock(&master->mutex);
  220. master->noteOff(midich,nk+12*midioct);
  221. pthread_mutex_unlock(&master->mutex);} {}
  222. }
  223. Function {relaseallkeys(int type)} {} {
  224. code {for (int i=0;i<N_OCT*12;i++) relasekey(i,type);} {}
  225. }
  226. decl {Master *master;} {}
  227. decl {int pressed[N_OCT*12+1];} {}
  228. decl {unsigned char midich;} {public
  229. }
  230. decl {unsigned char midivel;} {public
  231. }
  232. decl {char midioct,keyoct1,keyoct2;} {public
  233. }
  234. decl {unsigned char rndvelocity;} {public
  235. }
  236. }
  237. class VirKeyboard {open
  238. } {
  239. Function {make_window()} {open
  240. } {
  241. Fl_Window virkeyboardwindow {
  242. label {Virtual Keyboard - ZynAddSubFX}
  243. callback {relaseallkeys();
  244. virkeyboardwindow->hide();} open
  245. xywh {100 597 650 130} type Double visible
  246. } {
  247. Fl_Box virkeys {
  248. label Keyboard
  249. xywh {10 10 590 80} box FLAT_BOX color 17
  250. code0 {o->init(master);}
  251. class VirKeys
  252. }
  253. Fl_Counter {} {
  254. label {"qwer.." Oct}
  255. callback {relaseallkeys();
  256. virkeys->keyoct1=(int) o->value();
  257. virkeys->take_focus();}
  258. tooltip {keys "q2w3er5t6y..." octave} xywh {380 95 45 15} type Simple labelsize 10 align 4 when 6 minimum 0 maximum 5 step 1 textfont 1 textsize 10
  259. code0 {o->value(virkeys->keyoct1);}
  260. }
  261. Fl_Counter {} {
  262. label {"zxcv.." Oct}
  263. callback {relaseallkeys();
  264. virkeys->keyoct2=(int) o->value();
  265. virkeys->take_focus();}
  266. tooltip {keys "zsxdcvgbh..." octave} xywh {380 110 45 15} type Simple labelsize 10 align 4 when 6 minimum 0 maximum 5 step 1 textfont 1 textsize 10
  267. code0 {o->value(virkeys->keyoct2);}
  268. }
  269. Fl_Value_Slider {} {
  270. label Vel
  271. callback {virkeys->midivel=(int) o->value();
  272. virkeys->take_focus();} selected
  273. tooltip Velocity xywh {95 105 100 15} type {Horz Knob} box NO_BOX labelsize 10 align 5 minimum 1 maximum 127 step 1
  274. code0 {o->value(virkeys->midivel);}
  275. }
  276. Fl_Counter {} {
  277. label {Oct.}
  278. callback {relaseallkeys();
  279. virkeys->midioct=(int) o->value();
  280. virkeys->take_focus();}
  281. tooltip {Midi Octave} xywh {255 100 55 20} type Simple labelsize 11 align 4 when 6 minimum 0 maximum 5 step 1 textfont 1 textsize 11
  282. code0 {o->value(virkeys->midioct);}
  283. }
  284. Fl_Button {} {
  285. label Close
  286. callback {relaseallkeys();
  287. virkeyboardwindow->hide();}
  288. xywh {545 105 55 20} box THIN_UP_BOX
  289. }
  290. Fl_Value_Slider {} {
  291. label Cval
  292. callback {int ctl=midictl;
  293. pthread_mutex_lock(&master->mutex);
  294. master->setController(virkeys->midich,ctl,(int) o->value());
  295. pthread_mutex_unlock(&master->mutex);
  296. virkeys->take_focus();}
  297. tooltip {Controller value} xywh {605 10 15 115} type {Vert Fill} box ENGRAVED_BOX selection_color 229 labelsize 8 align 5 minimum 127 maximum 0 step 1 value 64 textsize 7
  298. }
  299. Fl_Choice {} {
  300. label Controller
  301. callback {switch((int) o->value()+1){
  302. case 1: midictl=C_modwheel; break;
  303. case 2: midictl=C_volume; break;
  304. case 3: midictl=C_panning; break;
  305. case 4: midictl=C_expression; break;
  306. case 5: midictl=C_sustain; break;
  307. case 6: midictl=C_portamento; break;
  308. case 7: midictl=C_filterq; break;
  309. case 8: midictl=C_filtercutoff; break;
  310. case 9: midictl=C_bandwidth; break;
  311. case 10: midictl=C_fmamp; break;
  312. case 11: midictl=C_resonance_center; break;
  313. case 12: midictl=C_resonance_bandwidth; break;
  314. default: midictl=C_NULL; break;
  315. };
  316. virkeys->take_focus();}
  317. xywh {435 105 100 15} down_box BORDER_BOX labelsize 10 align 5 when 6 textfont 1 textsize 10
  318. code0 {midictl=C_filtercutoff;o->value(7);}
  319. } {
  320. MenuItem {} {
  321. label {01: Mod.Wheel}
  322. xywh {0 0 100 20} labelfont 1 labelsize 10
  323. }
  324. MenuItem {} {
  325. label {07: Volume}
  326. xywh {10 10 100 20} labelfont 1 labelsize 10
  327. }
  328. MenuItem {} {
  329. label {10: Panning}
  330. xywh {20 20 100 20} labelfont 1 labelsize 10
  331. }
  332. MenuItem {} {
  333. label {11: Expression}
  334. xywh {30 30 100 20} labelfont 1 labelsize 10
  335. }
  336. MenuItem {} {
  337. label {64: Sustain}
  338. xywh {40 40 100 20} labelfont 1 labelsize 10
  339. }
  340. MenuItem {} {
  341. label {65: Portamento}
  342. xywh {50 50 100 20} labelfont 1 labelsize 10
  343. }
  344. MenuItem {} {
  345. label {71: Filter Q}
  346. xywh {60 60 100 20} labelfont 1 labelsize 10
  347. }
  348. MenuItem {} {
  349. label {74: Filter Freq.}
  350. xywh {70 70 100 20} labelfont 1 labelsize 10
  351. }
  352. MenuItem {} {
  353. label {75: Bandwidth}
  354. xywh {80 80 100 20} labelfont 1 labelsize 10
  355. }
  356. MenuItem {} {
  357. label {76: FM Gain}
  358. xywh {90 90 100 20} labelfont 1 labelsize 10
  359. }
  360. MenuItem {} {
  361. label {77: Res. c. freq}
  362. xywh {100 100 100 20} labelfont 1 labelsize 10
  363. }
  364. MenuItem {} {
  365. label {78: Res. bw.}
  366. xywh {110 110 100 20} labelfont 1 labelsize 10
  367. }
  368. }
  369. Fl_Roller pitchwheelroller {
  370. label Pwh
  371. callback {pthread_mutex_lock(&master->mutex);
  372. master->setController(virkeys->midich,C_pitchwheel,-(int) o->value());
  373. pthread_mutex_unlock(&master->mutex);
  374. virkeys->take_focus();}
  375. tooltip {Pitch Wheel} xywh {625 10 20 95} labelsize 8 align 1 when 3 minimum -8192 maximum 8192 step 64
  376. }
  377. Fl_Button {} {
  378. label R
  379. callback {pitchwheelroller->value(0);
  380. pitchwheelroller->do_callback();}
  381. tooltip {Reset Pitch Bend} xywh {625 110 20 15} box THIN_UP_BOX labelfont 1
  382. }
  383. Fl_Dial {} {
  384. label Vrnd
  385. callback {virkeys->rndvelocity=(int) o->value();}
  386. tooltip {Velocity Randomness} xywh {205 105 20 20} box ROUND_UP_BOX labelsize 10 align 129 maximum 127 step 1
  387. code0 {o->value(virkeys->rndvelocity);}
  388. class WidgetPDial
  389. }
  390. Fl_Choice partrcv {
  391. label {MIDI Ch.}
  392. callback {relaseallkeys();
  393. virkeys->midich=(int) o->value();
  394. virkeys->take_focus();} open
  395. tooltip {Send to Midi Channel} xywh {20 105 65 20} down_box BORDER_BOX labelsize 10 align 5 textfont 1 textsize 10
  396. code0 {char nrstr[10]; for(int i=0;i<NUM_MIDI_CHANNELS;i++){sprintf(nrstr,"Chn%d",i+1);if (i!=9) o->add(nrstr); else o->add("Drum10");};}
  397. code1 {o->value(virkeys->midich);}
  398. } {}
  399. }
  400. }
  401. Function {VirKeyboard(Master *master_)} {} {
  402. code {master=master_;
  403. midictl=75;
  404. make_window();} {}
  405. }
  406. Function {~VirKeyboard()} {} {
  407. code {delete virkeyboardwindow;} {}
  408. }
  409. Function {show()} {} {
  410. code {virkeyboardwindow->show();} {}
  411. }
  412. Function {relaseallkeys()} {} {
  413. code {virkeys->relaseallkeys(0);} {}
  414. }
  415. decl {Master *master;} {}
  416. decl {int midictl;} {}
  417. }