External plugins for 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.

553 lines
17KB

  1. // generated by Fast Light User Interface Designer (fluid) version 1.0300
  2. #include "external/zynaddsubfx/UI/VirKeyboard.h"
  3. //Copyright (c) 2002-2005 Nasca Octavian Paul
  4. //License: GNU GPL version 2 or later
  5. static const int keyspos[12]={0,-1,1,-2,2,3,-4,4,-5,5,-6,6};
  6. static const int keysoct1qwerty[]={'q','2','w','3','e','r','5','t','6','y','7','u','i','9','o','0','p','[','=',']','\\',FL_Enter,0};
  7. static const int keysoct2qwerty[]={'z','s','x','d','c','v','g','b','h','n','j','m',',','l','.',';','/',0};
  8. static const int keysoct1dw[]={'\'','2',',','3','.','p','5','y','6','f','7','g','c','9','r','0','l','/',']','=','\\',FL_Enter,0};
  9. static const int keysoct2dw[]={';','o','q','e','j','k','i','x','d','b','h','m','w','n','v','s','z',0};
  10. static const int keysoct1qwertz[]={'q','2','w','3','e','r','5','t','6','z','7','u','i','9','o','0','p',252,'\'','+','\\',FL_Enter,0};
  11. static const int keysoct2qwertz[]={'y','s','x','d','c','v','g','b','h','n','j','m',',','l','.',246,'-',0};
  12. static const int keysoct1az[]={'a',233,'z','\"','e','r','(','t','-','y',232,'u','i',231,'o',224,'p',65106,'=','$',0};
  13. static const int keysoct2az[]={'w','s','x','d','c','v','g','b','h','n','j',',',';','l',':','m','!',0};
  14. VirKeys::VirKeys(int x,int y, int w, int h, const char *label):Fl_Box(x,y,w,h,label),Fl_Osc_Widget() {
  15. }
  16. void VirKeys::OSC_value(int layout) {
  17. keylayout = layout;
  18. }
  19. void VirKeys::init(Fl_Osc_Interface *osc_, std::string loc_) {
  20. osc=osc_;
  21. osc->createLink("/config/cfg.VirKeybLayout", this);
  22. osc->requestValue("/config/cfg.VirKeybLayout");
  23. loc=loc_;
  24. for (int i=0;i<N_OCT*12+1;i++) pressed[i]=0;
  25. keylayout=0;
  26. midich=0;
  27. midivel=100;
  28. midioct=2;
  29. keyoct1=3;
  30. keyoct2=2;
  31. rndvelocity=0;
  32. }
  33. void VirKeys::draw() {
  34. int ox=x(),oy=y(),lx=w(),ly=h()-1,i;
  35. #ifdef NTK_GUI
  36. #ifdef CARLA_VERSION_STRING
  37. Fl_Image *white_up = Fl_Shared_Image::get( gUiPixmapPath + "/white_key.png" );
  38. Fl_Image *white_down = Fl_Shared_Image::get( gUiPixmapPath + "/white_key_pressed.png" );
  39. Fl_Image *black_up = Fl_Shared_Image::get( gUiPixmapPath + "/black_key.png" );
  40. Fl_Image *black_down = Fl_Shared_Image::get( gUiPixmapPath + "/black_key_pressed.png" );
  41. #else
  42. Fl_Image *white_up = Fl_Shared_Image::get( PIXMAP_PATH "white_key.png" );
  43. Fl_Image *white_down = Fl_Shared_Image::get( PIXMAP_PATH "white_key_pressed.png" );
  44. Fl_Image *black_up = Fl_Shared_Image::get( PIXMAP_PATH "black_key.png" );
  45. Fl_Image *black_down = Fl_Shared_Image::get( PIXMAP_PATH "black_key_pressed.png" );
  46. #endif
  47. //On error fetch everything from source directory
  48. if(!(white_up&&white_down&&black_up&&black_down)) {
  49. white_up = Fl_Shared_Image::get(SOURCE_DIR "/pixmaps/white_key.png");
  50. white_down = Fl_Shared_Image::get(SOURCE_DIR "/pixmaps/white_key_pressed.png");
  51. black_up = Fl_Shared_Image::get(SOURCE_DIR "/pixmaps/black_key.png");
  52. black_down = Fl_Shared_Image::get(SOURCE_DIR "/pixmaps/black_key_pressed.png");
  53. }
  54. Fl_Image *key;
  55. for (i=0;i<N_OCT*12;i++) {
  56. int noct=i/12;
  57. int kv=keyspos[i%12];
  58. if (kv>=0){//white keys
  59. if (pressed[i]==0)
  60. key = white_up;
  61. else
  62. key = white_down;
  63. key->draw( ox + (kv + 7 * noct ) * white_up->w() + 3, oy );
  64. }
  65. }
  66. for (i=0;i<N_OCT*12;i++){
  67. int noct=i/12;
  68. int kv=keyspos[i%12];
  69. if ( kv < 0 ) {
  70. kv=keyspos[(i+1)%12];
  71. if (pressed[i]==0)
  72. key = black_up;
  73. else
  74. key = black_down;
  75. key->draw( ox + (kv + 7 * noct ) * white_up->w() - black_up->w() / 2 + 2, oy );
  76. }
  77. }
  78. #else
  79. if (damage()!=1){
  80. fl_color(250,240,230);
  81. fl_rectf(ox,oy,lx,ly);
  82. fl_color(FL_BLACK);
  83. fl_line(ox,oy,ox+lx,oy);
  84. fl_line(ox,oy+ly,ox+lx,oy+ly);
  85. for (i=0;i<N_OCT*7+1;i++){
  86. fl_line(ox+i*SIZE_WHITE,oy,ox+i*SIZE_WHITE,oy+ly);
  87. int ik=i%7;
  88. if ((ik==1)||(ik==2)||(ik==4)||(ik==5)||(ik==6))
  89. fl_rectf(ox+i*SIZE_WHITE-SIZE_BLACK/2,oy,
  90. SIZE_BLACK+1,ly*3/5);
  91. }
  92. }
  93. for (i=0;i<N_OCT*12;i++){
  94. // if (pressed[i]==0) continue;
  95. int noct=i/12;
  96. int kv=keyspos[i%12];
  97. if (kv>=0){//white keys
  98. if (pressed[i]==0) fl_color(250,240,230);
  99. else fl_color(FL_BLUE);
  100. fl_rectf(ox+(kv+7*noct)*SIZE_WHITE+3,oy+ly*3/5+2,
  101. SIZE_WHITE-4,ly*2/5-3);
  102. } else {//black keys
  103. kv=keyspos[(i+1)%12];
  104. if (pressed[i]==0) fl_color(FL_BLACK);
  105. else fl_color(FL_BLUE);
  106. fl_rectf(ox+(kv+7*noct)*SIZE_WHITE-SIZE_BLACK/2+2,oy+2,
  107. SIZE_BLACK-3,ly*3/5-5);
  108. }
  109. }
  110. #endif
  111. }
  112. int VirKeys::handle(int event) {
  113. int i;
  114. int ly=h();
  115. int x_=Fl::event_x()-x();
  116. int y_=Fl::event_y()-y();
  117. if ( (x_<0)&&(x_>w()) && (y_<0)&&(y_>h())){
  118. return(0);
  119. };
  120. if ((event==FL_PUSH)||(event==FL_DRAG)||(event==FL_RELEASE)){
  121. int kpos=-1;
  122. if (y_>ly*3/5){//white keys
  123. int pos=x_/SIZE_WHITE;
  124. if (pos<0) return(1);
  125. for (i=0;i<12;i++) {
  126. if (pos%7==keyspos[i]) {
  127. kpos=pos/7*12+i;
  128. break;
  129. };
  130. };
  131. } else {//black keys
  132. int pos=(x_+SIZE_WHITE/2)/SIZE_WHITE;
  133. if (pos<0) return(1);
  134. for (i=1;i<12;i++) {
  135. if (pos%7==-keyspos[i]) {
  136. kpos=pos/7*12+i;
  137. break;
  138. };
  139. };
  140. };
  141. if ((kpos!=-1)&&((event==FL_PUSH)||(event==FL_DRAG))&&
  142. (Fl::event_shift()==0)) {
  143. presskey(kpos,1,1);
  144. };
  145. if ((event==FL_PUSH)&&(Fl::event_shift()!=0)) {
  146. if (pressed[kpos]==0) presskey(kpos,0,1);
  147. else releasekey(kpos,1);
  148. };
  149. if ((event==FL_RELEASE)&&(Fl::event_shift()==0))
  150. releaseallkeys(1);
  151. take_focus();
  152. };
  153. const int *keysoct1=keysoct1qwerty;
  154. const int *keysoct2=keysoct2qwerty;
  155. if (keylayout==2) {
  156. keysoct1=keysoct1dw;
  157. keysoct2=keysoct2dw;
  158. }else if (keylayout==3) {
  159. keysoct1=keysoct1qwertz;
  160. keysoct2=keysoct2qwertz;
  161. }else if (keylayout==4) {
  162. keysoct1=keysoct1az;
  163. keysoct2=keysoct2az;
  164. };
  165. if ((event==FL_KEYDOWN)||(event==FL_KEYUP)){
  166. int key=Fl::event_key();
  167. int kpos=-1;
  168. for (i=0;keysoct1[i]!=0;i++) if (key==keysoct1[i]) kpos=i+12*keyoct1;
  169. for (i=0;keysoct2[i]!=0;i++) if (key==keysoct2[i]) kpos=i+12*keyoct2;
  170. if (kpos==-1) return(0);
  171. if ((event==FL_KEYUP) && (Fl::event_key(key)==0) && (Fl::get_key(key)!=0)) return(0);
  172. if (event==FL_KEYDOWN) presskey(kpos,0,2);
  173. else releasekey(kpos,2);
  174. };
  175. return(1);
  176. }
  177. void VirKeys::presskey(int nk,int exclusive,int type) {
  178. //Exclusive means that multiple keys can be pressed at once
  179. //when the user uses the shift key
  180. if (nk>=N_OCT*12) return;
  181. if ((nk<0)&&(exclusive==0)) {
  182. releaseallkeys(type);
  183. return;
  184. };
  185. if (nk<0) return;
  186. if (pressed[nk]!=0) return;//the key is already pressed
  187. if (exclusive!=0) releaseallkeys(type);
  188. pressed[nk]=type;
  189. damage(1);
  190. float vel=midivel;
  191. if (rndvelocity!=0){
  192. vel=midivel*(127.0-rndvelocity)/127.0+(rand()/RAND_MAX)*rndvelocity;
  193. };
  194. osc->write(loc+"noteOn", "iii", midich,nk+midioct*12,(int)vel);
  195. }
  196. void VirKeys::releasekey(int nk,int type) {
  197. if ((nk<0)||(nk>=N_OCT*12)) return;
  198. if (pressed[nk]==0) return;//the key is not pressed
  199. if ((type!=0)&&(pressed[nk]!=type)) return;
  200. pressed[nk]=0;
  201. damage(1);
  202. osc->write(loc+"noteOff", "ii", midich,nk+12*midioct);
  203. }
  204. void VirKeys::releaseallkeys(int type) {
  205. for (int i=0;i<N_OCT*12;i++) releasekey(i,type);
  206. }
  207. void VirKeyboard::cb_virkeyboardwindow_i(Fl_Double_Window*, void*) {
  208. releaseallkeys();
  209. virkeyboardwindow->hide();
  210. }
  211. void VirKeyboard::cb_virkeyboardwindow(Fl_Double_Window* o, void* v) {
  212. ((VirKeyboard*)(o->user_data()))->cb_virkeyboardwindow_i(o,v);
  213. }
  214. void VirKeyboard::cb_qwer_i(Fl_Counter* o, void*) {
  215. releaseallkeys();
  216. virkeys->keyoct1=(int) o->value();
  217. virkeys->take_focus();
  218. }
  219. void VirKeyboard::cb_qwer(Fl_Counter* o, void* v) {
  220. ((VirKeyboard*)(o->parent()->user_data()))->cb_qwer_i(o,v);
  221. }
  222. void VirKeyboard::cb_zxcv_i(Fl_Counter* o, void*) {
  223. releaseallkeys();
  224. virkeys->keyoct2=(int) o->value();
  225. virkeys->take_focus();
  226. }
  227. void VirKeyboard::cb_zxcv(Fl_Counter* o, void* v) {
  228. ((VirKeyboard*)(o->parent()->user_data()))->cb_zxcv_i(o,v);
  229. }
  230. void VirKeyboard::cb_Vel_i(Fl_Value_Slider* o, void*) {
  231. virkeys->midivel=(int) o->value();
  232. virkeys->take_focus();
  233. }
  234. void VirKeyboard::cb_Vel(Fl_Value_Slider* o, void* v) {
  235. ((VirKeyboard*)(o->parent()->user_data()))->cb_Vel_i(o,v);
  236. }
  237. void VirKeyboard::cb_Oct_i(Fl_Counter* o, void*) {
  238. releaseallkeys();
  239. virkeys->midioct=(int) o->value();
  240. virkeys->take_focus();
  241. }
  242. void VirKeyboard::cb_Oct(Fl_Counter* o, void* v) {
  243. ((VirKeyboard*)(o->parent()->user_data()))->cb_Oct_i(o,v);
  244. }
  245. void VirKeyboard::cb_Close_i(Fl_Button*, void*) {
  246. releaseallkeys();
  247. virkeyboardwindow->hide();
  248. }
  249. void VirKeyboard::cb_Close(Fl_Button* o, void* v) {
  250. ((VirKeyboard*)(o->parent()->user_data()))->cb_Close_i(o,v);
  251. }
  252. void VirKeyboard::cb_Cval_i(Fl_Value_Slider* o, void*) {
  253. int ctl=midictl;
  254. osc->write("/setController", "iii", virkeys->midich,ctl,(int) o->value());
  255. virkeys->take_focus();
  256. }
  257. void VirKeyboard::cb_Cval(Fl_Value_Slider* o, void* v) {
  258. ((VirKeyboard*)(o->parent()->user_data()))->cb_Cval_i(o,v);
  259. }
  260. void VirKeyboard::cb_Controller_i(Fl_Choice* o, void*) {
  261. switch((int) o->value()+1){
  262. case 1: midictl=C_modwheel; break;
  263. case 2: midictl=C_volume; break;
  264. case 3: midictl=C_panning; break;
  265. case 4: midictl=C_expression; break;
  266. case 5: midictl=C_sustain; break;
  267. case 6: midictl=C_portamento; break;
  268. case 7: midictl=C_filterq; break;
  269. case 8: midictl=C_filtercutoff; break;
  270. case 9: midictl=C_bandwidth; break;
  271. case 10: midictl=C_fmamp; break;
  272. case 11: midictl=C_resonance_center; break;
  273. case 12: midictl=C_resonance_bandwidth; break;
  274. default: midictl=C_NULL; break;
  275. };
  276. virkeys->take_focus();
  277. }
  278. void VirKeyboard::cb_Controller(Fl_Choice* o, void* v) {
  279. ((VirKeyboard*)(o->parent()->user_data()))->cb_Controller_i(o,v);
  280. }
  281. Fl_Menu_Item VirKeyboard::menu_Controller[] = {
  282. {"01: Mod.Wheel", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 10, 0},
  283. {"07: Volume", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 10, 0},
  284. {"10: Panning", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 10, 0},
  285. {"11: Expression", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 10, 0},
  286. {"64: Sustain", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 10, 0},
  287. {"65: Portamento", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 10, 0},
  288. {"71: Filter Q", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 10, 0},
  289. {"74: Filter Freq.", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 10, 0},
  290. {"75: Bandwidth", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 10, 0},
  291. {"76: FM Gain", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 10, 0},
  292. {"77: Res. c. freq", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 10, 0},
  293. {"78: Res. bw.", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 10, 0},
  294. {0,0,0,0,0,0,0,0,0}
  295. };
  296. void VirKeyboard::cb_pitchwheelroller_i(Fl_Roller* o, void*) {
  297. osc->write("/setController", "iii", virkeys->midich,C_pitchwheel,-(int) o->value());
  298. virkeys->take_focus();
  299. }
  300. void VirKeyboard::cb_pitchwheelroller(Fl_Roller* o, void* v) {
  301. ((VirKeyboard*)(o->parent()->user_data()))->cb_pitchwheelroller_i(o,v);
  302. }
  303. void VirKeyboard::cb_R_i(Fl_Button*, void*) {
  304. pitchwheelroller->value(0);
  305. pitchwheelroller->do_callback();
  306. }
  307. void VirKeyboard::cb_R(Fl_Button* o, void* v) {
  308. ((VirKeyboard*)(o->parent()->user_data()))->cb_R_i(o,v);
  309. }
  310. void VirKeyboard::cb_Vrnd_i(WidgetPDial* o, void*) {
  311. virkeys->rndvelocity=(int) o->value();
  312. }
  313. void VirKeyboard::cb_Vrnd(WidgetPDial* o, void* v) {
  314. ((VirKeyboard*)(o->parent()->user_data()))->cb_Vrnd_i(o,v);
  315. }
  316. void VirKeyboard::cb_partrcv_i(Fl_Choice* o, void*) {
  317. releaseallkeys();
  318. virkeys->midich=(int) o->value();
  319. virkeys->take_focus();
  320. }
  321. void VirKeyboard::cb_partrcv(Fl_Choice* o, void* v) {
  322. ((VirKeyboard*)(o->parent()->user_data()))->cb_partrcv_i(o,v);
  323. }
  324. Fl_Double_Window* VirKeyboard::make_window() {
  325. { virkeyboardwindow = new Fl_Double_Window(650, 130, "Virtual Keyboard - ZynAddSubFX");
  326. virkeyboardwindow->callback((Fl_Callback*)cb_virkeyboardwindow, (void*)(this));
  327. { VirKeys* o = virkeys = new VirKeys(10, 10, 590, 80, "Keyboard");
  328. virkeys->box(FL_FLAT_BOX);
  329. virkeys->color((Fl_Color)17);
  330. virkeys->selection_color(FL_BACKGROUND_COLOR);
  331. virkeys->labeltype(FL_NORMAL_LABEL);
  332. virkeys->labelfont(0);
  333. virkeys->labelsize(14);
  334. virkeys->labelcolor(FL_FOREGROUND_COLOR);
  335. virkeys->align(Fl_Align(FL_ALIGN_CENTER));
  336. virkeys->when(FL_WHEN_RELEASE);
  337. o->init(osc,loc);
  338. } // VirKeys* virkeys
  339. { Fl_Counter* o = new Fl_Counter(380, 95, 45, 15, "\"qwer..\" Oct");
  340. o->tooltip("keys \"q2w3er5t6y...\" octave");
  341. o->type(1);
  342. o->labelsize(10);
  343. o->minimum(0);
  344. o->maximum(5);
  345. o->step(1);
  346. o->textfont(1);
  347. o->textsize(10);
  348. o->callback((Fl_Callback*)cb_qwer);
  349. o->align(Fl_Align(FL_ALIGN_LEFT));
  350. o->when(FL_WHEN_RELEASE_ALWAYS);
  351. o->value(virkeys->keyoct1);
  352. } // Fl_Counter* o
  353. { Fl_Counter* o = new Fl_Counter(380, 110, 45, 15, "\"zxcv..\" Oct");
  354. o->tooltip("keys \"zsxdcvgbh...\" octave");
  355. o->type(1);
  356. o->labelsize(10);
  357. o->minimum(0);
  358. o->maximum(5);
  359. o->step(1);
  360. o->textfont(1);
  361. o->textsize(10);
  362. o->callback((Fl_Callback*)cb_zxcv);
  363. o->align(Fl_Align(FL_ALIGN_LEFT));
  364. o->when(FL_WHEN_RELEASE_ALWAYS);
  365. o->value(virkeys->keyoct2);
  366. } // Fl_Counter* o
  367. { Fl_Value_Slider* o = new Fl_Value_Slider(95, 105, 100, 15, "Vel");
  368. o->tooltip("Velocity");
  369. o->type(5);
  370. o->box(FL_NO_BOX);
  371. o->labelsize(10);
  372. o->minimum(1);
  373. o->maximum(127);
  374. o->step(1);
  375. o->callback((Fl_Callback*)cb_Vel);
  376. o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
  377. o->value(virkeys->midivel);
  378. } // Fl_Value_Slider* o
  379. { Fl_Counter* o = new Fl_Counter(255, 100, 55, 20, "Oct.");
  380. o->tooltip("Midi Octave");
  381. o->type(1);
  382. o->labelsize(11);
  383. o->minimum(0);
  384. o->maximum(5);
  385. o->step(1);
  386. o->textfont(1);
  387. o->textsize(11);
  388. o->callback((Fl_Callback*)cb_Oct);
  389. o->align(Fl_Align(FL_ALIGN_LEFT));
  390. o->when(FL_WHEN_RELEASE_ALWAYS);
  391. o->value(virkeys->midioct);
  392. } // Fl_Counter* o
  393. { Fl_Button* o = new Fl_Button(545, 105, 55, 20, "Close");
  394. o->box(FL_THIN_UP_BOX);
  395. o->callback((Fl_Callback*)cb_Close);
  396. } // Fl_Button* o
  397. { Fl_Value_Slider* o = new Fl_Value_Slider(605, 10, 15, 115, "Cval");
  398. o->tooltip("Controller value");
  399. o->type(2);
  400. o->box(FL_ENGRAVED_BOX);
  401. o->selection_color((Fl_Color)229);
  402. o->labelsize(8);
  403. o->minimum(127);
  404. o->maximum(0);
  405. o->step(1);
  406. o->value(64);
  407. o->textsize(7);
  408. o->callback((Fl_Callback*)cb_Cval);
  409. o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
  410. } // Fl_Value_Slider* o
  411. { Fl_Choice* o = new Fl_Choice(435, 105, 100, 15, "Controller");
  412. o->down_box(FL_BORDER_BOX);
  413. o->labelsize(10);
  414. o->textfont(1);
  415. o->textsize(10);
  416. o->callback((Fl_Callback*)cb_Controller);
  417. o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
  418. o->when(FL_WHEN_RELEASE_ALWAYS);
  419. o->menu(menu_Controller);
  420. midictl=C_filtercutoff;o->value(7);
  421. } // Fl_Choice* o
  422. { pitchwheelroller = new Fl_Roller(625, 10, 20, 95, "Pwh");
  423. pitchwheelroller->tooltip("Pitch Wheel");
  424. pitchwheelroller->labelsize(8);
  425. pitchwheelroller->minimum(-8192);
  426. pitchwheelroller->maximum(8192);
  427. pitchwheelroller->step(64);
  428. pitchwheelroller->callback((Fl_Callback*)cb_pitchwheelroller);
  429. pitchwheelroller->align(Fl_Align(FL_ALIGN_TOP));
  430. pitchwheelroller->when(3);
  431. } // Fl_Roller* pitchwheelroller
  432. { Fl_Button* o = new Fl_Button(625, 110, 20, 15, "R");
  433. o->tooltip("Reset Pitch Bend");
  434. o->box(FL_THIN_UP_BOX);
  435. o->labelfont(1);
  436. o->callback((Fl_Callback*)cb_R);
  437. } // Fl_Button* o
  438. { WidgetPDial* o = new WidgetPDial(205, 105, 20, 20, "Vrnd");
  439. o->tooltip("Velocity Randomness");
  440. o->box(FL_ROUND_UP_BOX);
  441. o->color(FL_BACKGROUND_COLOR);
  442. o->selection_color(FL_INACTIVE_COLOR);
  443. o->labeltype(FL_NORMAL_LABEL);
  444. o->labelfont(0);
  445. o->labelsize(10);
  446. o->labelcolor(FL_FOREGROUND_COLOR);
  447. o->maximum(127);
  448. o->step(1);
  449. o->callback((Fl_Callback*)cb_Vrnd);
  450. o->align(Fl_Align(129));
  451. o->when(FL_WHEN_CHANGED);
  452. o->value(virkeys->rndvelocity);
  453. } // WidgetPDial* o
  454. { Fl_Choice* o = partrcv = new Fl_Choice(20, 105, 65, 20, "MIDI Ch.");
  455. partrcv->tooltip("Send to Midi Channel");
  456. partrcv->down_box(FL_BORDER_BOX);
  457. partrcv->labelsize(10);
  458. partrcv->textfont(1);
  459. partrcv->textsize(10);
  460. partrcv->callback((Fl_Callback*)cb_partrcv);
  461. partrcv->align(Fl_Align(FL_ALIGN_TOP_LEFT));
  462. 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");};
  463. o->value(virkeys->midich);
  464. } // Fl_Choice* partrcv
  465. virkeyboardwindow->end();
  466. } // Fl_Double_Window* virkeyboardwindow
  467. return virkeyboardwindow;
  468. }
  469. VirKeyboard::VirKeyboard(Fl_Osc_Interface *osc_, std::string loc_) {
  470. osc=osc_;
  471. loc=loc_;
  472. midictl=75;
  473. make_window();
  474. }
  475. VirKeyboard::~VirKeyboard() {
  476. delete virkeyboardwindow;
  477. }
  478. void VirKeyboard::show() {
  479. virkeyboardwindow->show();
  480. }
  481. void VirKeyboard::releaseallkeys() {
  482. virkeys->releaseallkeys(0);
  483. }