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.

399 lines
11KB

  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 <FL/Fl_Box.H>} {public
  8. }
  9. decl {\#include <FL/fl_draw.H>} {public
  10. }
  11. decl {\#include <FL/Fl_Value_Output.H>} {public
  12. }
  13. decl {\#include <math.h>} {}
  14. decl {\#include <stdio.h>} {}
  15. decl {\#include <stdlib.h>} {}
  16. decl {\#include <string.h>} {}
  17. decl {\#include "../Synth/Resonance.h"} {public
  18. }
  19. decl {\#include "WidgetPDial.h"} {public
  20. }
  21. decl {\#include "PresetsUI.h"} {public
  22. }
  23. class ResonanceGraph {open : {public Fl_Box}
  24. } {
  25. Function {ResonanceGraph(int x,int y, int w, int h, const char *label=0):Fl_Box(x,y,w,h,label)} {} {
  26. code {respar=NULL;
  27. cbwidget=NULL;
  28. applybutton=NULL;} {}
  29. }
  30. Function {init(Resonance *respar_,Fl_Value_Output *khzvalue_,Fl_Value_Output *dbvalue_)} {} {
  31. code {respar=respar_;
  32. khzvalue=khzvalue_;
  33. dbvalue=dbvalue_;
  34. oldx=-1;
  35. khzval=-1;} {}
  36. }
  37. Function {draw_freq_line(float freq,int type)} {open
  38. } {
  39. code {float freqx=respar->getfreqpos(freq);
  40. switch(type){
  41. case 0:fl_line_style(FL_SOLID);break;
  42. case 1:fl_line_style(FL_DOT);break;
  43. case 2:fl_line_style(FL_DASH);break;
  44. };
  45. if ((freqx>0.0)&&(freqx<1.0))
  46. fl_line(x()+(int) (freqx*w()),y(),
  47. x()+(int) (freqx*w()),y()+h());} {}
  48. }
  49. Function {draw()} {open
  50. } {
  51. code {int ox=x(),oy=y(),lx=w(),ly=h(),i,ix,iy,oiy;
  52. float freqx;
  53. fl_color(FL_DARK1);
  54. fl_rectf(ox,oy,lx,ly);
  55. //draw the lines
  56. fl_color(FL_GRAY);
  57. fl_line_style(FL_SOLID);
  58. fl_line(ox+2,oy+ly/2,ox+lx-2,oy+ly/2);
  59. freqx=respar->getfreqpos(1000.0);
  60. if ((freqx>0.0)&&(freqx<1.0))
  61. fl_line(ox+(int) (freqx*lx),oy,
  62. ox+(int) (freqx*lx),oy+ly);
  63. for (i=1;i<10;i++){
  64. if(i==1){
  65. draw_freq_line(i*100.0,0);
  66. draw_freq_line(i*1000.0,0);
  67. }else
  68. if (i==5){
  69. draw_freq_line(i*100.0,2);
  70. draw_freq_line(i*1000.0,2);
  71. }else{
  72. draw_freq_line(i*100.0,1);
  73. draw_freq_line(i*1000.0,1);
  74. };
  75. };
  76. draw_freq_line(10000.0,0);
  77. draw_freq_line(20000.0,1);
  78. fl_line_style(FL_DOT);
  79. int GY=10;if (ly<GY*3) GY=-1;
  80. for (i=1;i<GY;i++){
  81. int tmp=(int)(ly/(float)GY*i);
  82. fl_line(ox+2,oy+tmp,ox+lx-2,oy+tmp);
  83. };
  84. //draw the data
  85. fl_color(FL_RED);
  86. fl_line_style(FL_SOLID,2);
  87. fl_begin_line();
  88. oiy=(int)(respar->Prespoints[0]/128.0*ly);
  89. for (i=1;i<N_RES_POINTS;i++){
  90. ix=(int)(i*1.0/N_RES_POINTS*lx);
  91. iy=(respar->Prespoints[i]/128.0*ly);
  92. fl_vertex(ox+ix,oy+ly-oiy);
  93. oiy=iy;
  94. };
  95. fl_end_line();
  96. fl_line_style(FL_SOLID,0);} {selected
  97. }
  98. }
  99. Function {handle(int event)} {return_type int
  100. } {
  101. code {int x_=Fl::event_x()-x();
  102. int y_=Fl::event_y()-y();
  103. if ( (x_>=0)&&(x_<w()) && (y_>=0)&&(y_<h())){
  104. khzvalue->value(respar->getfreqx(x_*1.0/w())/1000.0);
  105. dbvalue->value((1.0-y_*2.0/h())*respar->PmaxdB);
  106. };
  107. if ((event==FL_PUSH)||(event==FL_DRAG)){
  108. int leftbutton=1;
  109. if (Fl::event_button()==FL_RIGHT_MOUSE) leftbutton=0;
  110. if (x_<0) x_=0;if (y_<0) y_=0;
  111. if (x_>=w()) x_=w();if (y_>=h()-1) y_=h()-1;
  112. if ((oldx<0)||(oldx==x_)){
  113. int sn=(int)(x_*1.0/w()*N_RES_POINTS);
  114. int sp=127-(int)(y_*1.0/h()*127);
  115. if (leftbutton!=0) respar->setpoint(sn,sp);
  116. else respar->setpoint(sn,64);
  117. } else {
  118. int x1=oldx;
  119. int x2=x_;
  120. int y1=oldy;
  121. int y2=y_;
  122. if (oldx>x_){
  123. x1=x_;y1=y_;
  124. x2=oldx;y2=oldy;
  125. };
  126. for (int i=0;i<x2-x1;i++){
  127. int sn=(int)((i+x1)*1.0/w()*N_RES_POINTS);
  128. float yy=(y2-y1)*1.0/(x2-x1)*i;
  129. int sp=127-(int)((y1+yy)/h()*127);
  130. if (leftbutton!=0) respar->setpoint(sn,sp);
  131. else respar->setpoint(sn,64);
  132. };
  133. };
  134. oldx=x_;oldy=y_;
  135. redraw();
  136. };
  137. if (event==FL_RELEASE) {
  138. oldx=-1;
  139. if (cbwidget!=NULL) {
  140. cbwidget->do_callback();
  141. if (applybutton!=NULL) {
  142. applybutton->color(FL_RED);
  143. applybutton->redraw();
  144. };
  145. };
  146. };
  147. return(1);} {}
  148. }
  149. Function {setcbwidget(Fl_Widget *cbwidget,Fl_Widget *applybutton)} {} {
  150. code {this->cbwidget=cbwidget;
  151. this->applybutton=applybutton;} {}
  152. }
  153. decl {Fl_Value_Output *khzvalue;} {}
  154. decl {Fl_Value_Output *dbvalue;} {}
  155. decl {Resonance *respar;} {}
  156. decl {int oldx,oldy;} {}
  157. decl {float khzval;} {public
  158. }
  159. decl {Fl_Widget *cbwidget,*applybutton;} {}
  160. }
  161. class ResonanceUI {open : PresetsUI_
  162. } {
  163. Function {make_window()} {open
  164. } {
  165. Fl_Window resonancewindow {
  166. label Resonance open
  167. xywh {120 70 780 305} type Double hide
  168. } {
  169. Fl_Value_Output khzvalue {
  170. label kHz
  171. xywh {415 264 45 18} labelsize 12 align 8 minimum 0.001 maximum 48 step 0.01 textfont 1 textsize 12
  172. code0 {//this widget must be before the calling widgets}
  173. }
  174. Fl_Value_Output dbvalue {
  175. label dB
  176. xywh {415 282 45 18} labelsize 12 align 8 minimum -150 maximum 150 step 0.1 textfont 1 textsize 12
  177. code0 {//this widget must be before the calling widgets}
  178. }
  179. Fl_Group {} {
  180. xywh {6 5 768 256} box BORDER_BOX
  181. code0 {rg=new ResonanceGraph(o->x(),o->y(),o->w(),o->h(),"");}
  182. code1 {rg->init(respar,khzvalue,dbvalue);}
  183. code2 {rg->show();}
  184. } {}
  185. Fl_Button {} {
  186. label Close
  187. callback {resonancewindow->hide();}
  188. xywh {690 283 84 17} box THIN_UP_BOX
  189. }
  190. Fl_Button {} {
  191. label Zero
  192. callback {for (int i=0;i<N_RES_POINTS;i++)
  193. respar->setpoint(i,64);
  194. resonancewindow->redraw();
  195. redrawPADnoteApply();}
  196. tooltip {Clear the resonance function} xywh {491 264 66 15} box THIN_UP_BOX labelfont 1 labelsize 12
  197. }
  198. Fl_Button {} {
  199. label Smooth
  200. callback {respar->smooth();
  201. resonancewindow->redraw();
  202. redrawPADnoteApply();}
  203. tooltip {Smooth the resonance function} xywh {491 282 66 18} box THIN_UP_BOX labelfont 1 labelsize 12
  204. }
  205. Fl_Check_Button enabled {
  206. label Enable
  207. callback {respar->Penabled=(int) o->value();
  208. redrawPADnoteApply();}
  209. xywh {6 270 78 27} box THIN_UP_BOX down_box DOWN_BOX
  210. code0 {o->value(respar->Penabled);}
  211. }
  212. Fl_Roller maxdb {
  213. callback {maxdbvo->value(o->value());
  214. respar->PmaxdB=(int) o->value();
  215. redrawPADnoteApply();}
  216. xywh {90 282 84 15} type Horizontal minimum 1 maximum 90 step 1 value 30
  217. }
  218. Fl_Value_Output maxdbvo {
  219. label {Max.}
  220. callback {o->value(respar->PmaxdB);}
  221. tooltip {The Maximum amplitude (dB)} xywh {126 264 24 18} labelsize 12 minimum 1 maximum 127 step 1 value 30 textfont 1 textsize 12
  222. code0 {o->value(respar->PmaxdB);}
  223. }
  224. Fl_Box {} {
  225. label dB
  226. xywh {150 264 24 18}
  227. }
  228. Fl_Value_Output centerfreqvo {
  229. label {C.f.}
  230. callback {o->value(respar->getcenterfreq()/1000.0);}
  231. tooltip {Center Frequency (kHz)} xywh {210 264 33 18} labelsize 12 when 3 minimum 1 maximum 10 step 0.01 value 1 textfont 1 textsize 12
  232. code0 {o->value(respar->getcenterfreq()/1000.0);}
  233. }
  234. Fl_Value_Output octavesfreqvo {
  235. label {Oct.}
  236. callback {o->value(respar->getoctavesfreq());}
  237. tooltip {No. of octaves} xywh {210 282 33 18} labelsize 12 when 3 minimum 1 maximum 127 step 1 value 30 textfont 1 textsize 12
  238. code0 {o->value(respar->getoctavesfreq());}
  239. }
  240. Fl_Button {} {
  241. label RND2
  242. callback {respar->randomize(1);
  243. resonancewindow->redraw();
  244. redrawPADnoteApply();}
  245. tooltip {Randomize the resonance function} xywh {566 276 42 12} box THIN_UP_BOX labelfont 1 labelsize 10
  246. }
  247. Fl_Button {} {
  248. label RND1
  249. callback {respar->randomize(0);
  250. resonancewindow->redraw();
  251. redrawPADnoteApply();}
  252. tooltip {Randomize the resonance function} xywh {566 264 42 12} box THIN_UP_BOX labelfont 1 labelsize 10
  253. }
  254. Fl_Button {} {
  255. label RND3
  256. callback {respar->randomize(2);
  257. resonancewindow->redraw();
  258. redrawPADnoteApply();}
  259. tooltip {Randomize the resonance function} xywh {566 288 42 12} box THIN_UP_BOX labelfont 1 labelsize 10
  260. }
  261. Fl_Check_Button p1st {
  262. label {P.1st}
  263. callback {respar->Pprotectthefundamental=(int) o->value();
  264. redrawPADnoteApply();}
  265. tooltip {Protect the fundamental frequency (do not damp the first harmonic)} xywh {365 285 45 15} down_box DOWN_BOX labelsize 10
  266. code0 {o->value(respar->Pprotectthefundamental);}
  267. }
  268. Fl_Button {} {
  269. label InterpP
  270. callback {int type;
  271. if (Fl::event_button()==FL_LEFT_MOUSE) type=0;
  272. else type=1;
  273. respar->interpolatepeaks(type);
  274. resonancewindow->redraw();
  275. redrawPADnoteApply();}
  276. tooltip {Interpolate the peaks} xywh {365 265 46 15} box THIN_UP_BOX labelfont 1 labelsize 10
  277. }
  278. Fl_Dial centerfreq {
  279. label {C.f.}
  280. callback {respar->Pcenterfreq=(int)o->value();
  281. centerfreqvo->do_callback();
  282. rg->redraw();
  283. redrawPADnoteApply();}
  284. xywh {245 265 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
  285. code0 {o->value(respar->Pcenterfreq);}
  286. class WidgetPDial
  287. }
  288. Fl_Dial octavesfreq {
  289. label {Oct.}
  290. callback {respar->Poctavesfreq=(int)o->value();
  291. octavesfreqvo->do_callback();
  292. rg->redraw();
  293. redrawPADnoteApply();}
  294. xywh {280 265 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
  295. code0 {o->value(respar->Poctavesfreq);}
  296. class WidgetPDial
  297. }
  298. Fl_Button {} {
  299. label C
  300. callback {presetsui->copy(respar);}
  301. xywh {625 275 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 7
  302. }
  303. Fl_Button {} {
  304. label P
  305. callback {presetsui->paste(respar,this);}
  306. xywh {655 275 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 7
  307. }
  308. Fl_Button applybutton {
  309. label Apply
  310. callback {applybutton->color(FL_GRAY);
  311. applybutton->redraw();
  312. if (cbapplywidget!=NULL) {
  313. cbapplywidget->do_callback();
  314. cbapplywidget->color(FL_GRAY);
  315. cbapplywidget->redraw();
  316. };}
  317. xywh {690 265 85 15} box THIN_UP_BOX labelfont 1 labelsize 11
  318. }
  319. }
  320. }
  321. Function {ResonanceUI(Resonance *respar_)} {} {
  322. code {respar=respar_;
  323. cbwidget=NULL;
  324. cbapplywidget=NULL;
  325. make_window();
  326. applybutton->hide();} {}
  327. }
  328. Function {~ResonanceUI()} {} {
  329. code {resonancewindow->hide();} {}
  330. }
  331. Function {redrawPADnoteApply()} {} {
  332. code {if (cbwidget!=NULL) {
  333. cbwidget->do_callback();
  334. applybutton->color(FL_RED);
  335. applybutton->redraw();
  336. };} {}
  337. }
  338. Function {setcbwidget(Fl_Widget *cbwidget,Fl_Widget *cbapplywidget)} {} {
  339. code {this->cbwidget=cbwidget;
  340. this->cbapplywidget=cbapplywidget;
  341. rg->setcbwidget(cbwidget,applybutton);
  342. applybutton->show();} {}
  343. }
  344. Function {refresh()} {} {
  345. code {redrawPADnoteApply();
  346. enabled->value(respar->Penabled);
  347. maxdb->value(respar->PmaxdB);
  348. maxdbvo->value(respar->PmaxdB);
  349. centerfreqvo->value(respar->getcenterfreq()/1000.0);
  350. octavesfreqvo->value(respar->getoctavesfreq());
  351. centerfreq->value(respar->Pcenterfreq);
  352. octavesfreq->value(respar->Poctavesfreq);
  353. p1st->value(respar->Pprotectthefundamental);
  354. rg->redraw();} {}
  355. }
  356. decl {Resonance *respar;} {public
  357. }
  358. decl {ResonanceGraph *rg;} {}
  359. decl {Fl_Widget *cbwidget,*cbapplywidget;} {}
  360. }