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.

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