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.

OscilGenUI.fl 33KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150
  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 "../Synth/OscilGen.h"} {public
  8. }
  9. decl {\#include "../Misc/Util.h"} {public
  10. }
  11. decl {\#include "../Misc/Master.h"} {public
  12. }
  13. decl {\#include "ResonanceUI.h"} {public
  14. }
  15. decl {\#include <FL/Fl_Box.H>} {public
  16. }
  17. decl {\#include <FL/Fl_Group.H>} {public
  18. }
  19. decl {\#include <FL/Fl_Slider.H>} {public
  20. }
  21. decl {\#include <math.h>} {}
  22. decl {\#include <stdio.h>} {}
  23. decl {\#include <stdlib.h>} {}
  24. decl {\#include <string.h>} {}
  25. decl {\#include "WidgetPDial.h"} {public
  26. }
  27. decl {\#include "EnvelopeUI.h"} {public
  28. }
  29. decl {\#include "LFOUI.h"} {public
  30. }
  31. decl {\#include "FilterUI.h"} {public
  32. }
  33. decl {\#include "PresetsUI.h"} {public
  34. }
  35. decl {\#include <FL/fl_draw.H>} {public
  36. }
  37. class OscilSpectrum {: {public Fl_Box}
  38. } {
  39. Function {OscilSpectrum(int x,int y, int w, int h, const char *label=0):Fl_Box(x,y,w,h,label)} {} {
  40. code {oscil=NULL;} {}
  41. }
  42. Function {init(OscilGen *oscil_,int oscbase_,Master *master_)} {} {
  43. code {oscil=oscil_;
  44. oscbase=oscbase_;
  45. master=master_;} {}
  46. }
  47. Function {draw()} {} {
  48. code {int ox=x(),oy=y(),lx=w(),ly=h(),i;
  49. const int maxdb=60;//must be multiple of 10
  50. int GX=2;
  51. int n=lx/GX-1;
  52. if (n>synth->oscilsize/2) n=synth->oscilsize/2;
  53. float x;
  54. float* spc=new float[n];
  55. for (i=0;i<n;i++) spc[i]=0.0;
  56. pthread_mutex_lock(&master->mutex);
  57. if (oscbase==0) oscil->getspectrum(n,spc,0);
  58. else oscil->getspectrum(n,spc,1);
  59. pthread_mutex_unlock(&master->mutex);
  60. //normalize
  61. float max=0;
  62. for (i=0;i<n;i++){
  63. x=fabs(spc[i]);
  64. if (max<x) max=x;
  65. }
  66. if (max<0.000001) max=1.0;
  67. max=max*1.05;
  68. //draw
  69. if (this->active_r()) fl_color(this->parent()->selection_color());
  70. else fl_color(this->parent()->color());
  71. fl_line_style(FL_DOT);
  72. for (i=1;i<maxdb/10;i++){
  73. int ky=(int)((float)i*ly*10.0/maxdb)/2;
  74. ky*=2;
  75. fl_line(ox,oy+ky-1,ox+lx-2,oy+ky-1);
  76. };
  77. for (i=2;i<n;i++){
  78. int tmp=i*GX-2;
  79. if (i%10==1) fl_line_style(0);
  80. else fl_line_style(FL_DOT);
  81. fl_line(ox+tmp,oy+2,ox+tmp,oy+ly-2);
  82. }
  83. if (this->active_r()) fl_color(this->parent()->labelcolor());
  84. else fl_color(this->parent()->color());
  85. fl_line_style(0);
  86. //draws the spectrum
  87. for (i=0;i<n;i++){
  88. int tmp=i*GX+2;
  89. x=spc[i]/max;
  90. if (x>dB2rap(-maxdb)) x=rap2dB(x)/maxdb+1;
  91. else x=0;
  92. int val=(int) ((ly-2)*x);
  93. if (val>0) fl_line(ox+tmp,oy+ly-2-val,ox+tmp,oy+ly-2);
  94. }
  95. delete [] spc;} {}
  96. }
  97. decl {OscilGen *oscil;} {}
  98. decl {int oscbase;} {}
  99. decl {Master *master;} {}
  100. }
  101. class PSlider {: {public Fl_Slider}
  102. } {
  103. Function {PSlider(int x,int y, int w, int h, const char *label=0):Fl_Slider(x,y,w,h,label)} {} {
  104. code {;} {}
  105. }
  106. Function {handle(int event)} {return_type int
  107. } {
  108. code {int X=x(),Y=y(),W=w(),H=h();
  109. if ((!Fl::event_buttons())|| (event==0)||(Fl::event_shift()==0)) return(Fl_Slider::handle(event));
  110. if (!Fl::event_inside(X,Y,W,H)) {
  111. if (event==FL_DRAG){
  112. Fl_Slider::handle(FL_RELEASE);
  113. Fl_Slider::handle(FL_LEAVE);
  114. deactivate();
  115. activate();
  116. return(1);
  117. }else{
  118. return(Fl_Slider::handle(event));
  119. };
  120. } else {
  121. //Fl_Slider::handle(FL_FOCUS);
  122. Fl_Slider::handle(FL_PUSH);
  123. };
  124. return(1);} {}
  125. }
  126. }
  127. class Oscilloscope {open : {public Fl_Box}
  128. } {
  129. Function {Oscilloscope(int x,int y, int w, int h, const char *label=0):Fl_Box(x,y,w,h,label)} {open
  130. } {
  131. code {oscil=NULL;
  132. phase=64;
  133. oscbase=0;
  134. box(FL_FLAT_BOX);} {}
  135. }
  136. Function {init(OscilGen *oscil_,Master *master_)} {} {
  137. code {oscil=oscil_;
  138. master=master_;} {}
  139. }
  140. Function {init(OscilGen *oscil_,int oscbase_,Master *master_)} {} {
  141. code {oscil=oscil_;
  142. oscbase=oscbase_;
  143. master=master_;} {}
  144. }
  145. Function {init(OscilGen *oscil_,int oscbase_,int phase_,Master *master_)} {} {
  146. code {oscil=oscil_;
  147. oscbase=oscbase_;
  148. phase=phase_;
  149. master=master_;} {}
  150. }
  151. Function {draw()} {open
  152. } {
  153. code {int ox=x(),oy=y(),lx=w(),ly=h()-1,i;
  154. float smps[synth->oscilsize];
  155. pthread_mutex_lock(&master->mutex);
  156. if (oscbase==0) oscil->get(smps,-1.0);
  157. else oscil->getcurrentbasefunction(smps);
  158. pthread_mutex_unlock(&master->mutex);
  159. if (damage()!=1){
  160. fl_color( fl_color_average( FL_BLACK, FL_BACKGROUND_COLOR, 0.5 ));
  161. fl_rectf(ox,oy,lx,ly);
  162. };
  163. //normalize
  164. float max=0;
  165. for (i=0;i<synth->oscilsize;i++)
  166. if (max<fabs(smps[i])) max=fabs(smps[i]);
  167. //fprintf(stderr,"%.4f\\n",max);
  168. if (max<0.00001) max=1.0;
  169. max=-max*1.05;
  170. //draw
  171. fl_line_style(FL_DASH);
  172. if (this->active_r()) fl_color(this->parent()->labelcolor());
  173. else fl_color(this->parent()->color());
  174. int GX=16;if (lx<GX*3) GX=-1;
  175. for (i=1;i<GX;i++){
  176. int tmp=(int)(lx/(float)GX*i);
  177. fl_line(ox+tmp,oy+2,ox+tmp,oy+ly-2);
  178. };
  179. int GY=8;if (ly<GY*3) GY=-1;
  180. for (i=1;i<GY;i++){
  181. int tmp=(int)(ly/(float)GY*i);
  182. fl_line(ox+2,oy+tmp,ox+lx-2,oy+tmp);
  183. };
  184. //draw the function
  185. fl_line_style(0,1);
  186. fl_line(ox+2,oy+ly/2,ox+lx-2,oy+ly/2);
  187. if (this->active_r()) fl_color(this->parent()->selection_color());
  188. else fl_color(this->parent()->labelcolor());
  189. fl_color( fl_color_add_alpha( fl_color(), 127 ) );
  190. int lw=2;
  191. //if ((lx<135)||(ly<135)) lw=1;
  192. fl_line_style(FL_SOLID,lw);
  193. fl_begin_line();
  194. double ph=((phase-64.0)/128.0*synth->oscilsize+synth->oscilsize);
  195. for (i=1;i<lx;i++){
  196. int k2=(synth->oscilsize*i/lx)+ph;
  197. double y2=smps[k2%synth->oscilsize]/max;
  198. fl_vertex(i+ox,y2*ly/2.0+oy+ly/2);
  199. };
  200. fl_end_line();
  201. fl_line_style(FL_SOLID,0);} {}
  202. }
  203. decl {OscilGen *oscil;} {}
  204. decl {int oscbase;} {}
  205. decl {int phase;} {public
  206. }
  207. decl {Master *master;} {}
  208. }
  209. class Oscilharmonic {: {public Fl_Group}
  210. } {
  211. Function {make_window()} {open private
  212. } {
  213. Fl_Window harmonic {open
  214. private xywh {338 259 100 225} type Double box NO_BOX
  215. class Fl_Group visible
  216. } {
  217. Fl_Slider mag {
  218. callback {int x=64;
  219. if (Fl::event_button3()) o->value(x);
  220. else x=127-(int)o->value();
  221. if (x==64) o->selection_color(0);
  222. else o->selection_color(222);
  223. pthread_mutex_lock(&master->mutex);
  224. oscil->Phmag[n]=x;
  225. if (x==64) {
  226. oscil->Phphase[n]=64;
  227. phase->value(64);
  228. };
  229. oscil->prepare();
  230. pthread_mutex_unlock(&master->mutex);
  231. display->redraw();
  232. oldosc->redraw();
  233. if (cbwidget!=NULL) {
  234. cbwidget->do_callback();
  235. applybutton->color(FL_RED);
  236. applybutton->redraw();
  237. };}
  238. xywh {0 15 15 115} type {Vert Knob} box NO_BOX selection_color 222 maximum 127 step 1 value 64
  239. code0 {o->value(127-oscil->Phmag[n]);}
  240. code1 {if (oscil->Phmag[n]==64) o->selection_color(0);}
  241. class PSlider
  242. }
  243. Fl_Slider phase {
  244. callback {int x=64;
  245. if (Fl::event_button3()) o->value(x);
  246. else x=(int)o->value();
  247. pthread_mutex_lock(&master->mutex);
  248. oscil->Phphase[n]=x;
  249. oscil->prepare();
  250. pthread_mutex_unlock(&master->mutex);
  251. display->redraw();
  252. oldosc->redraw();
  253. if (cbwidget!=NULL) {
  254. cbwidget->do_callback();
  255. applybutton->color(FL_RED);
  256. applybutton->redraw();
  257. };}
  258. xywh {0 135 15 75} type {Vert Knob} box NO_BOX selection_color 222 maximum 127 step 1 value 64
  259. code0 {o->value(oscil->Phphase[n]);}
  260. class PSlider
  261. }
  262. Fl_Box {} {
  263. xywh {15 70 5 5} box FLAT_BOX color 45
  264. }
  265. Fl_Box {} {
  266. xywh {15 170 5 5} box FLAT_BOX color 45
  267. }
  268. Fl_Box {} {
  269. label 01
  270. xywh {0 210 20 15} labelfont 1 labelsize 9 align 20
  271. code0 {char tmp[10];snprintf(tmp,10,"%d",n+1);o->label(strdup(tmp));}
  272. }
  273. Fl_Box {} {
  274. label 01
  275. xywh {0 0 20 15} labelfont 1 labelsize 9 align 20
  276. code0 {char tmp[10];snprintf(tmp,10,"%d",n+1);o->label(strdup(tmp));}
  277. }
  278. }
  279. }
  280. Function {Oscilharmonic(int x,int y, int w, int h, const char *label=0):Fl_Group(x,y,w,h,label)} {} {
  281. code {n=0;
  282. oscil=NULL;
  283. display=NULL;
  284. applybutton=NULL;
  285. cbwidget=NULL;} {}
  286. }
  287. Function {init(OscilGen *oscil_,int n_,Fl_Group *display_,Fl_Widget *oldosc_,Fl_Widget *cbwidget_,Fl_Widget *applybutton_, Master *master_)} {} {
  288. code {oscil=oscil_;
  289. n=n_;
  290. display=display_;
  291. master=master_;
  292. oldosc=oldosc_;
  293. cbwidget=cbwidget_;
  294. applybutton=applybutton_;
  295. make_window();
  296. end();
  297. harmonic->show();} {}
  298. }
  299. Function {refresh()} {} {
  300. code {mag->value(127-oscil->Phmag[n]);
  301. phase->value(oscil->Phphase[n]);
  302. if (oscil->Phmag[n]==64) mag->selection_color(0);
  303. else mag->selection_color(222);} {}
  304. }
  305. Function {~Oscilharmonic()} {} {
  306. code {harmonic->hide();
  307. //delete(harmonic);} {}
  308. }
  309. decl {OscilGen *oscil;} {}
  310. decl {Fl_Group *display;} {}
  311. decl {int n;} {}
  312. decl {Fl_Widget *oldosc,*cbwidget,*applybutton;} {}
  313. decl {Master *master;} {}
  314. }
  315. class OscilEditor {open : {public PresetsUI_}
  316. } {
  317. Function {make_window()} {open
  318. } {
  319. Fl_Window osceditUI {
  320. label {ADsynth Oscillator Editor} open
  321. xywh {542 193 735 595} type Double
  322. code0 {if (oscil->ADvsPAD) o->label("PADsynth Harmonic Content Editor");} visible
  323. } {
  324. Fl_Button applybutton {
  325. label Apply
  326. callback {applybutton->color(FL_GRAY);
  327. applybutton->redraw();
  328. if (cbapplywidget!=NULL) {
  329. cbapplywidget->do_callback();
  330. cbapplywidget->color(FL_GRAY);
  331. cbapplywidget->redraw();
  332. };}
  333. xywh {300 280 60 20} box THIN_UP_BOX labelfont 1
  334. code0 {if (!oscil->ADvsPAD) o->hide();}
  335. }
  336. Fl_Group oscildisplaygroup {
  337. xywh {5 5 360 300} box UP_FRAME
  338. } {
  339. Fl_Group {} {open
  340. xywh {10 85 350 190} box THIN_DOWN_BOX color 32 selection_color 71 labelcolor 179
  341. code0 {Oscilloscope *osc=new Oscilloscope(o->x(),o->y(),o->w(),o->h(),"");}
  342. code1 {osc->init(oscil,master);}
  343. } {}
  344. Fl_Box {} {
  345. label Oscillator
  346. xywh {120 10 110 20} labelfont 1
  347. }
  348. Fl_Value_Slider rndslider {
  349. label rnd
  350. callback {oscil->Prand=(int)o->value()+64;
  351. oscildisplaygroup->redraw();
  352. oldosc->redraw();}
  353. tooltip {Oscilator Phase Randomness: smaller than 0 is "group", larger than 0 is for each harmonic} xywh {140 285 100 10} type {Horz Knob} box NO_BOX labelsize 10 align 5 minimum -64 maximum 63 step 1
  354. code0 {if (oscil->ADvsPAD) o->hide();}
  355. }
  356. Fl_Group {} {open
  357. xywh {10 30 350 50} box THIN_DOWN_BOX color 32 selection_color 218 labelcolor 63
  358. code0 {OscilSpectrum *spc=new OscilSpectrum(o->x(),o->y(),o->w(),o->h(),"");}
  359. code1 {spc->init(oscil,0,master);}
  360. } {}
  361. Fl_Group {} {
  362. xywh {246 277 115 25} box UP_FRAME
  363. code0 {if (oscil->ADvsPAD) o->hide();}
  364. } {
  365. Fl_Choice hrndtype {
  366. label {H.rnd}
  367. callback {oscil->Pamprandtype=(int) o->value();}
  368. tooltip {Harmonic Amplitude Randomness} xywh {281 282 50 15} down_box BORDER_BOX labelsize 10 textsize 10
  369. } {
  370. MenuItem {} {
  371. label None
  372. xywh {60 60 100 20} labelfont 1 labelsize 10
  373. }
  374. MenuItem {} {
  375. label Pow
  376. xywh {70 70 100 20} labelfont 1 labelsize 10
  377. }
  378. MenuItem {} {
  379. label Sin
  380. xywh {80 80 100 20} labelfont 1 labelsize 10
  381. }
  382. }
  383. Fl_Dial hrnddial {
  384. callback {oscil->Pamprandpower=(int) o->value();}
  385. tooltip {Oscillator's spectrum adjust parameter} xywh {338 280 18 18} maximum 127 step 1
  386. class WidgetPDial
  387. }
  388. }
  389. }
  390. Fl_Group basefuncdisplaygroup {open selected
  391. xywh {365 5 360 300} box UP_FRAME
  392. } {
  393. Fl_Group {} {
  394. xywh {370 85 350 190} box THIN_DOWN_BOX color 32 selection_color 71 labelcolor 179
  395. code0 {Oscilloscope *osc=new Oscilloscope(o->x(),o->y(),o->w(),o->h(),"");}
  396. code1 {osc->init(oscil,1,master);}
  397. } {}
  398. Fl_Dial bfslider {
  399. callback {oscil->Pbasefuncpar=(int)o->value()+64;
  400. basefuncdisplaygroup->redraw();
  401. bfparval->value(oscil->Pbasefuncpar-64);
  402. redrawoscil();}
  403. tooltip {Base Function Parameter} xywh {520 280 20 20} minimum -64 maximum 63 step 1
  404. class WidgetPDial
  405. }
  406. Fl_Choice bftype {
  407. label {Base.F..}
  408. callback {oscil->Pcurrentbasefunc=(int) o->value();
  409. basefuncdisplaygroup->redraw();
  410. redrawoscil();
  411. if ((oscil->Pcurrentbasefunc==0)||(oscil->Pcurrentbasefunc==127)) basefuncmodulation->deactivate();
  412. else basefuncmodulation->activate();}
  413. xywh {370 285 90 15} down_box BORDER_BOX labelsize 10 align 5 textsize 11
  414. } {
  415. MenuItem {} {
  416. label Sine
  417. xywh {10 10 100 20} labelfont 1 labelsize 11
  418. }
  419. MenuItem {} {
  420. label Triangle
  421. xywh {20 20 100 20} labelfont 1 labelsize 11
  422. }
  423. MenuItem {} {
  424. label Pulse
  425. xywh {30 30 100 20} labelfont 1 labelsize 11
  426. }
  427. MenuItem {} {
  428. label Saw
  429. xywh {40 40 100 20} labelfont 1 labelsize 11
  430. }
  431. MenuItem {} {
  432. label Power
  433. xywh {50 50 100 20} labelfont 1 labelsize 11
  434. }
  435. MenuItem {} {
  436. label Gauss
  437. xywh {50 50 100 20} labelfont 1 labelsize 11
  438. }
  439. MenuItem {} {
  440. label Diode
  441. xywh {60 60 100 20} labelfont 1 labelsize 11
  442. }
  443. MenuItem {} {
  444. label AbsSine
  445. xywh {70 70 100 20} labelfont 1 labelsize 11
  446. }
  447. MenuItem {} {
  448. label PulseSine
  449. xywh {80 80 100 20} labelfont 1 labelsize 11
  450. }
  451. MenuItem {} {
  452. label StrchSine
  453. xywh {90 90 100 20} labelfont 1 labelsize 11
  454. }
  455. MenuItem {} {
  456. label Chirp
  457. xywh {100 100 100 20} labelfont 1 labelsize 11
  458. }
  459. MenuItem {} {
  460. label AbsStrSine
  461. xywh {102 102 100 20} labelfont 1 labelsize 11
  462. }
  463. MenuItem {} {
  464. label Chebyshev
  465. xywh {112 112 100 20} labelfont 1 labelsize 11
  466. }
  467. MenuItem {} {
  468. label Sqr
  469. xywh {122 122 100 20} labelfont 1 labelsize 11
  470. }
  471. MenuItem {} {
  472. label Spike
  473. xywh {122 122 100 20} labelfont 1 labelsize 11
  474. }
  475. MenuItem {} {
  476. label Circle
  477. xywh {122 122 100 20} labelfont 1 labelsize 11
  478. }
  479. }
  480. Fl_Box {} {
  481. label {Base Func.}
  482. xywh {480 10 110 20} labelfont 1
  483. }
  484. Fl_Group {} {open
  485. xywh {370 30 350 50} box THIN_DOWN_BOX color 32 selection_color 218 labelcolor 63
  486. code0 {OscilSpectrum *spc=new OscilSpectrum (o->x(),o->y(),o->w(),o->h(),"");}
  487. code1 {spc->init(oscil,1,master);}
  488. } {}
  489. Fl_Value_Output bfparval {
  490. label {Par.}
  491. xywh {490 285 25 15} labelsize 12 minimum -63 maximum 63 step 1
  492. }
  493. Fl_Group basefuncmodulation {
  494. xywh {550 276 169 25} box UP_FRAME
  495. code0 {if ((oscil->Pcurrentbasefunc==0)||(oscil->Pcurrentbasefunc==127)) basefuncmodulation->deactivate();}
  496. } {
  497. Fl_Choice bfmodtype {
  498. label {B.F.Mod.}
  499. callback {oscil->Pbasefuncmodulation=(int) o->value();
  500. basefuncdisplaygroup->redraw();
  501. redrawoscil();}
  502. tooltip {Base function modulation} xywh {599 281 50 15} down_box BORDER_BOX labelsize 10 textsize 10
  503. } {
  504. MenuItem {} {
  505. label None
  506. xywh {50 50 100 20} labelfont 1 labelsize 10
  507. }
  508. MenuItem {} {
  509. label Rev
  510. xywh {60 60 100 20} labelfont 1 labelsize 10
  511. }
  512. MenuItem {} {
  513. label Sine
  514. xywh {70 70 100 20} labelfont 1 labelsize 10
  515. }
  516. MenuItem {} {
  517. label Pow
  518. xywh {80 80 100 20} labelfont 1 labelsize 10
  519. }
  520. }
  521. Fl_Dial bfmodpar1 {
  522. callback {oscil->Pbasefuncmodulationpar1=(int)o->value();
  523. basefuncdisplaygroup->redraw();
  524. redrawoscil();}
  525. tooltip {Oscillator's modulation parameter 1} xywh {659 281 15 15} maximum 127 step 1
  526. class WidgetPDial
  527. }
  528. Fl_Dial bfmodpar2 {
  529. callback {oscil->Pbasefuncmodulationpar2=(int)o->value();
  530. basefuncdisplaygroup->redraw();
  531. redrawoscil();}
  532. tooltip {Oscillator's modulation parameter 2} xywh {679 281 15 15} maximum 127 step 1
  533. class WidgetPDial
  534. }
  535. Fl_Dial bfmodpar3 {
  536. callback {oscil->Pbasefuncmodulationpar3=(int)o->value();
  537. basefuncdisplaygroup->redraw();
  538. redrawoscil();}
  539. tooltip {Oscillator's modulation parameter 3} xywh {699 281 15 15} maximum 127 step 1
  540. class WidgetPDial
  541. }
  542. }
  543. }
  544. Fl_Choice magtype {
  545. label {Mag.Type}
  546. callback {oscil->Phmagtype=(int) o->value();
  547. basefuncdisplaygroup->redraw();
  548. redrawoscil();}
  549. xywh {70 280 65 20} down_box BORDER_BOX labelsize 11 textsize 11
  550. } {
  551. MenuItem {} {
  552. label Linear
  553. xywh {0 0 100 20} labelfont 1 labelsize 11
  554. }
  555. MenuItem {} {
  556. label {-40dB}
  557. xywh {10 10 100 20} labelfont 1 labelsize 11
  558. }
  559. MenuItem {} {
  560. label {-60dB}
  561. xywh {20 20 100 20} labelfont 1 labelsize 11
  562. }
  563. MenuItem {} {
  564. label {-80dB}
  565. xywh {30 30 100 20} labelfont 1 labelsize 11
  566. }
  567. MenuItem {} {
  568. label {-100dB}
  569. xywh {40 40 100 20} labelfont 1 labelsize 11
  570. }
  571. }
  572. Fl_Button {} {
  573. label {Use as base}
  574. callback {oscil->useasbase();
  575. if (autoclearbutton->value()){
  576. for (int i=0;i<MAX_AD_HARMONICS;i++){
  577. h[i]->mag->value(64);
  578. oscil->Phmag[i]=64;
  579. h[i]->phase->value(64);
  580. oscil->Phphase[i]=64;
  581. };
  582. oscil->Phmag[0]=127;
  583. oscil->Pharmonicshift=0;
  584. harmonicshiftcounter->value(0);
  585. h[0]->mag->value(0);
  586. wshbutton->value(0);
  587. wshbutton->do_callback();
  588. fltbutton->value(0);
  589. fltbutton->do_callback();
  590. sabutton->value(0);
  591. sabutton->do_callback();
  592. };
  593. pthread_mutex_lock(&master->mutex);
  594. for (int i=0;i<MAX_AD_HARMONICS;i++){
  595. if (oscil->Phmag[i]==64) h[i]->mag->selection_color(0);
  596. else h[i]->mag->selection_color(222);
  597. };
  598. oscil->prepare();
  599. pthread_mutex_unlock(&master->mutex);
  600. basefuncdisplaygroup->redraw();
  601. redrawoscil();}
  602. tooltip {Use this Oscillator as base function} xywh {5 313 85 20} box THIN_UP_BOX labelfont 1 labelsize 11
  603. }
  604. Fl_Button {} {
  605. label Close
  606. callback {osceditUI->hide();}
  607. xywh {668 565 62 25} box THIN_UP_BOX
  608. }
  609. Fl_Button {} {
  610. label Clear
  611. callback {if (!fl_choice("Clear the harmonics settings?","No","Yes",NULL)) return;
  612. for (int i=0;i<MAX_AD_HARMONICS;i++){
  613. h[i]->mag->value(64);
  614. oscil->Phmag[i]=64;
  615. h[i]->phase->value(64);
  616. oscil->Phphase[i]=64;
  617. };
  618. oscil->Phmag[0]=127;
  619. h[0]->mag->value(0);
  620. for (int i=0;i<MAX_AD_HARMONICS;i++){
  621. if (oscil->Phmag[i]==64) h[i]->mag->selection_color(0);
  622. else h[i]->mag->selection_color(222);
  623. };
  624. //harmonics->redraw();
  625. pthread_mutex_lock(&master->mutex);
  626. oscil->prepare();
  627. pthread_mutex_unlock(&master->mutex);
  628. redrawoscil();}
  629. xywh {670 505 55 15} box THIN_UP_BOX labelfont 1 labelsize 11
  630. }
  631. Fl_Group {} {
  632. xywh {135 308 150 30} box UP_FRAME
  633. } {
  634. Fl_Choice wshbutton {
  635. label {Wsh.}
  636. callback {oscil->Pwaveshapingfunction=(int) o->value();
  637. basefuncdisplaygroup->redraw();
  638. redrawoscil();} open
  639. tooltip {Waveshaping function} xywh {165 313 55 20} down_box BORDER_BOX labelsize 10 textsize 10
  640. } {
  641. MenuItem {} {
  642. label None
  643. xywh {25 25 100 20} labelfont 1 labelsize 10
  644. }
  645. MenuItem {} {
  646. label Atan
  647. xywh {35 35 100 20} labelfont 1 labelsize 10
  648. }
  649. MenuItem {} {
  650. label Asym1
  651. xywh {45 45 100 20} labelfont 1 labelsize 10
  652. }
  653. MenuItem {} {
  654. label Pow
  655. xywh {55 55 100 20} labelfont 1 labelsize 10
  656. }
  657. MenuItem {} {
  658. label Sine
  659. xywh {65 65 100 20} labelfont 1 labelsize 10
  660. }
  661. MenuItem {} {
  662. label Qnts
  663. xywh {75 75 100 20} labelfont 1 labelsize 10
  664. }
  665. MenuItem {} {
  666. label Zigzg
  667. xywh {85 85 100 20} labelfont 1 labelsize 10
  668. }
  669. MenuItem {} {
  670. label Lmt
  671. xywh {95 95 100 20} labelfont 1 labelsize 10
  672. }
  673. MenuItem {} {
  674. label LmtU
  675. xywh {105 105 100 20} labelfont 1 labelsize 10
  676. }
  677. MenuItem {} {
  678. label LmtL
  679. xywh {115 115 100 20} labelfont 1 labelsize 10
  680. }
  681. MenuItem {} {
  682. label ILmt
  683. xywh {127 127 100 20} labelfont 1 labelsize 10
  684. }
  685. MenuItem {} {
  686. label Clip
  687. xywh {137 137 100 20} labelfont 1 labelsize 10
  688. }
  689. MenuItem {} {
  690. label Asym2
  691. xywh {85 85 100 20} labelfont 1 labelsize 10
  692. }
  693. MenuItem {} {
  694. label Pow2
  695. xywh {95 95 100 20} labelfont 1 labelsize 10
  696. }
  697. MenuItem {} {
  698. label Sgm
  699. xywh {90 90 100 20} labelfont 1 labelsize 10
  700. }
  701. }
  702. Fl_Dial wshpar {
  703. callback {oscil->Pwaveshaping=(int)o->value()+64;
  704. wsparval->value(oscil->Pwaveshaping-64);
  705. redrawoscil();}
  706. tooltip {Waveshaping Parameter} xywh {260 313 20 20} minimum -64 maximum 63 step 1
  707. class WidgetPDial
  708. }
  709. Fl_Value_Output wsparval {
  710. xywh {228 316 25 15} labelsize 12 minimum -63 maximum 63 step 1
  711. }
  712. }
  713. Fl_Light_Button autoclearbutton {
  714. label {Clr.}
  715. tooltip {Auto clear when using the oscillator as base function} xywh {95 313 35 20} box THIN_UP_BOX value 1 labelfont 1 labelsize 10
  716. }
  717. Fl_Group {} {
  718. xywh {285 308 155 30} box UP_FRAME
  719. } {
  720. Fl_Choice fltbutton {
  721. label Filter
  722. callback {oscil->Pfiltertype=(int) o->value();
  723. redrawoscil();}
  724. tooltip {Oscillator's filter type} xywh {315 313 50 20} down_box BORDER_BOX labelsize 10 textsize 10
  725. } {
  726. MenuItem {} {
  727. label None
  728. xywh {35 35 100 20} labelfont 1 labelsize 10
  729. }
  730. MenuItem {} {
  731. label LP1
  732. xywh {45 45 100 20} labelfont 1 labelsize 10
  733. }
  734. MenuItem {} {
  735. label HP1a
  736. xywh {55 55 100 20} labelfont 1 labelsize 10
  737. }
  738. MenuItem {} {
  739. label HP1b
  740. xywh {65 65 100 20} labelfont 1 labelsize 10
  741. }
  742. MenuItem {} {
  743. label BP1
  744. xywh {75 75 100 20} labelfont 1 labelsize 10
  745. }
  746. MenuItem {} {
  747. label BS1
  748. xywh {85 85 100 20} labelfont 1 labelsize 10
  749. }
  750. MenuItem {} {
  751. label LP2
  752. xywh {55 55 100 20} labelfont 1 labelsize 10
  753. }
  754. MenuItem {} {
  755. label HP2
  756. xywh {65 65 100 20} labelfont 1 labelsize 10
  757. }
  758. MenuItem {} {
  759. label BP2
  760. xywh {65 65 100 20} labelfont 1 labelsize 10
  761. }
  762. MenuItem {} {
  763. label BS2
  764. xywh {75 75 100 20} labelfont 1 labelsize 10
  765. }
  766. MenuItem {} {
  767. label Cos
  768. xywh {75 75 100 20} labelfont 1 labelsize 10
  769. }
  770. MenuItem {} {
  771. label Sin
  772. xywh {85 85 100 20} labelfont 1 labelsize 10
  773. }
  774. MenuItem {} {
  775. label LSh
  776. xywh {95 95 100 20} labelfont 1 labelsize 10
  777. }
  778. MenuItem {} {
  779. label S
  780. xywh {105 105 100 20} labelfont 1 labelsize 10
  781. }
  782. }
  783. Fl_Dial filtervalue1 {
  784. callback {oscil->Pfilterpar1=(int)o->value();
  785. redrawoscil();}
  786. tooltip {Oscillator's filter parameter1} xywh {367 313 20 20} maximum 127 step 1
  787. class WidgetPDial
  788. }
  789. Fl_Check_Button filterpref {
  790. label p
  791. callback {oscil->Pfilterbeforews=(int)o->value();
  792. redrawoscil();}
  793. tooltip {Apply the filter before the waveshaping} xywh {415 313 20 20} down_box DOWN_BOX labelsize 10 align 24
  794. }
  795. Fl_Dial filtervalue2 {
  796. callback {oscil->Pfilterpar2=(int)o->value();
  797. redrawoscil();}
  798. tooltip {Oscillator's filter parameter2} xywh {392 313 20 20} maximum 127 step 1
  799. class WidgetPDial
  800. }
  801. }
  802. Fl_Group {} {
  803. xywh {590 308 135 30} box UP_FRAME
  804. } {
  805. Fl_Choice sabutton {
  806. label {Sp.adj.}
  807. callback {oscil->Psatype=(int) o->value();
  808. redrawoscil();}
  809. tooltip {Oscillator's spectrum adjust} xywh {630 313 60 20} down_box BORDER_BOX labelsize 10 textsize 10
  810. } {
  811. MenuItem {} {
  812. label None
  813. xywh {55 55 100 20} labelfont 1 labelsize 10
  814. }
  815. MenuItem {} {
  816. label Pow
  817. xywh {65 65 100 20} labelfont 1 labelsize 10
  818. }
  819. MenuItem {} {
  820. label ThrsD
  821. xywh {75 75 100 20} labelfont 1 labelsize 10
  822. }
  823. MenuItem {} {
  824. label ThrsU
  825. xywh {85 85 100 20} labelfont 1 labelsize 10
  826. }
  827. }
  828. Fl_Dial sadjpar {
  829. callback {oscil->Psapar=(int)o->value();
  830. redrawoscil();}
  831. tooltip {Oscillator's spectrum adjust parameter} xywh {695 313 20 20} maximum 127 step 1
  832. class WidgetPDial
  833. }
  834. }
  835. Fl_Group {} {
  836. xywh {665 340 65 65} box UP_FRAME
  837. } {
  838. Fl_Counter harmonicshiftcounter {
  839. label {Harmonic Shift}
  840. callback {oscil->Pharmonicshift=(int)o->value();
  841. redrawoscil();}
  842. xywh {670 365 55 15} type Simple labelsize 10 align 129 minimum -64 maximum 64 step 1 textfont 1 textsize 10
  843. }
  844. Fl_Check_Button harmonicshiftpre {
  845. label preH
  846. callback {oscil->Pharmonicshiftfirst=(int)o->value();
  847. redrawoscil();}
  848. tooltip {Apply the harmonic shift before the waveshaping and filtering} xywh {690 385 34 15} down_box DOWN_BOX labelsize 10 align 24
  849. }
  850. Fl_Button {} {
  851. label R
  852. callback {oscil->Pharmonicshift=0;
  853. harmonicshiftcounter->value(0);
  854. redrawoscil();}
  855. xywh {670 385 20 15} box THIN_UP_BOX labelfont 1 labelsize 10
  856. }
  857. }
  858. Fl_Group {} {open
  859. xywh {665 410 65 90} box UP_FRAME
  860. } {
  861. Fl_Choice adhrtype {
  862. label {Adpt.Harm.}
  863. callback {oscil->Padaptiveharmonics=(int) o->value();
  864. redrawoscil();}
  865. tooltip {The type of the addaptive harmonics} xywh {670 425 55 15} down_box BORDER_BOX labelsize 10 align 129 when 6 textsize 10
  866. } {
  867. MenuItem {} {
  868. label OFF
  869. xywh {80 80 100 20} labelfont 1 labelsize 10
  870. }
  871. MenuItem {} {
  872. label ON
  873. xywh {90 90 100 20} labelfont 1 labelsize 10
  874. }
  875. MenuItem {} {
  876. label Square
  877. xywh {100 100 100 20} labelfont 1 labelsize 10
  878. }
  879. MenuItem {} {
  880. label 2xSub
  881. xywh {110 110 100 20} labelfont 1 labelsize 10
  882. }
  883. MenuItem {} {
  884. label 2xAdd
  885. xywh {120 120 100 20} labelfont 1 labelsize 10
  886. }
  887. MenuItem {} {
  888. label 3xSub
  889. xywh {120 120 100 20} labelfont 1 labelsize 10
  890. }
  891. MenuItem {} {
  892. label 3xAdd
  893. xywh {130 130 100 20} labelfont 1 labelsize 10
  894. }
  895. MenuItem {} {
  896. label 4xSub
  897. xywh {130 130 100 20} labelfont 1 labelsize 10
  898. }
  899. MenuItem {} {
  900. label 4xAdd
  901. xywh {140 140 100 20} labelfont 1 labelsize 10
  902. }
  903. }
  904. Fl_Dial adhrpow {
  905. label pow
  906. callback {oscil->Padaptiveharmonicspower=(int)o->value();
  907. redrawoscil();}
  908. tooltip {Adaptive harmonics power} xywh {700 460 25 25} labelsize 10 maximum 200 step 1
  909. class WidgetPDial
  910. }
  911. Fl_Dial adhrbf {
  912. label baseF
  913. callback {oscil->Padaptiveharmonicsbasefreq=(int)o->value();
  914. redrawoscil();}
  915. tooltip {Adaptive harmonics base frequency} xywh {670 460 25 25} labelsize 10 maximum 255 step 1
  916. class WidgetPDial
  917. }
  918. Fl_Slider adhrpar {
  919. callback {oscil->Padaptiveharmonicspar=(int)o->value();
  920. redrawoscil();}
  921. xywh {670 445 55 10} type {Horz Knob} box NO_BOX maximum 100 step 1 value 50
  922. }
  923. }
  924. Fl_Group {} {
  925. xywh {440 308 150 30} box UP_FRAME
  926. } {
  927. Fl_Choice modtype {
  928. label {Mod.}
  929. callback {oscil->Pmodulation=(int) o->value();
  930. redrawoscil();}
  931. tooltip modulation xywh {470 315 50 15} down_box BORDER_BOX labelsize 10 textsize 10
  932. } {
  933. MenuItem {} {
  934. label None
  935. xywh {60 60 100 20} labelfont 1 labelsize 10
  936. }
  937. MenuItem {} {
  938. label Rev
  939. xywh {70 70 100 20} labelfont 1 labelsize 10
  940. }
  941. MenuItem {} {
  942. label Sine
  943. xywh {80 80 100 20} labelfont 1 labelsize 10
  944. }
  945. MenuItem {} {
  946. label Pow
  947. xywh {90 90 100 20} labelfont 1 labelsize 10
  948. }
  949. }
  950. Fl_Dial modpar1 {
  951. callback {oscil->Pmodulationpar1=(int)o->value();
  952. redrawoscil();}
  953. tooltip {Oscillator's modulation parameter 1} xywh {530 315 15 15} maximum 127 step 1
  954. class WidgetPDial
  955. }
  956. Fl_Dial modpar2 {
  957. callback {oscil->Pmodulationpar2=(int)o->value();
  958. redrawoscil();}
  959. tooltip {Oscillator's modulation parameter 2} xywh {550 315 15 15} maximum 127 step 1
  960. class WidgetPDial
  961. }
  962. Fl_Dial modpar3 {
  963. callback {oscil->Pmodulationpar3=(int)o->value();
  964. redrawoscil();}
  965. tooltip {Oscillator's modulation parameter 3} xywh {570 315 15 15} maximum 127 step 1
  966. class WidgetPDial
  967. }
  968. }
  969. Fl_Button {} {
  970. label Sine
  971. callback {if (!fl_choice("Convert to SINE?","No","Yes",NULL)) return;
  972. pthread_mutex_lock(&master->mutex);
  973. oscil->convert2sine();
  974. pthread_mutex_unlock(&master->mutex);
  975. redrawoscil();
  976. refresh();}
  977. xywh {670 525 55 15} box THIN_UP_BOX labelfont 1 labelsize 11
  978. }
  979. Fl_Button {} {
  980. label C
  981. callback {presetsui->copy(oscil);}
  982. xywh {670 545 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 7
  983. }
  984. Fl_Button {} {
  985. label P
  986. callback {presetsui->paste(oscil,this);}
  987. xywh {700 545 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 7
  988. }
  989. Fl_Scroll _this_has_to_be_the_last {
  990. xywh {5 340 660 250} type HORIZONTAL box FLAT_BOX
  991. } {
  992. Fl_Pack harmonics {open
  993. xywh {10 345 650 225} type HORIZONTAL
  994. code0 {for (int i=0;i<MAX_AD_HARMONICS;i++){h[i]=new Oscilharmonic(0,0,20,o->h(),"");h[i]->init(oscil,i,oscildisplaygroup,oldosc,cbwidget,applybutton,master);}}
  995. } {}
  996. }
  997. }
  998. }
  999. Function {OscilEditor(OscilGen *oscil_,Fl_Widget *oldosc_,Fl_Widget *cbwidget_,Fl_Widget *cbapplywidget_,Master *master_)} {} {
  1000. code {oscil=oscil_;
  1001. oldosc=oldosc_;
  1002. cbwidget=cbwidget_;
  1003. cbapplywidget=cbapplywidget_;
  1004. master=master_;
  1005. make_window();
  1006. refresh();
  1007. osceditUI->show();} {}
  1008. }
  1009. Function {~OscilEditor()} {} {
  1010. code {osceditUI->hide();
  1011. //for (int i=0;i<MAX_AD_HARMONICS;i++) delete (h[i]);
  1012. delete (osceditUI);} {}
  1013. }
  1014. Function {refresh()} {} {
  1015. code {magtype->value(oscil->Phmagtype);
  1016. rndslider->value(oscil->Prand-64);
  1017. hrndtype->value(oscil->Pamprandtype);
  1018. hrnddial->value(oscil->Pamprandpower);
  1019. bftype->value(oscil->Pcurrentbasefunc);
  1020. bfparval->value(oscil->Pbasefuncpar-64);
  1021. bfslider->value(oscil->Pbasefuncpar-64);
  1022. bfmodtype->value(oscil->Pbasefuncmodulation);
  1023. bfmodpar1->value(oscil->Pbasefuncmodulationpar1);
  1024. bfmodpar2->value(oscil->Pbasefuncmodulationpar2);
  1025. bfmodpar3->value(oscil->Pbasefuncmodulationpar3);
  1026. wshbutton->value(oscil->Pwaveshapingfunction);
  1027. wsparval->value(oscil->Pwaveshaping-64);
  1028. wshpar->value(oscil->Pwaveshaping-64);
  1029. fltbutton->value(oscil->Pfiltertype);
  1030. filtervalue1->value(oscil->Pfilterpar1);
  1031. filtervalue2->value(oscil->Pfilterpar2);
  1032. filterpref->value(oscil->Pfilterbeforews);
  1033. modtype->value(oscil->Pmodulation);
  1034. modpar1->value(oscil->Pmodulationpar1);
  1035. modpar2->value(oscil->Pmodulationpar2);
  1036. modpar3->value(oscil->Pmodulationpar3);
  1037. sabutton->value(oscil->Psatype);
  1038. sadjpar->value(oscil->Psapar);
  1039. harmonicshiftcounter->value(oscil->Pharmonicshift);
  1040. harmonicshiftpre->value(oscil->Pharmonicshiftfirst);
  1041. adhrtype->value(oscil->Padaptiveharmonics);
  1042. adhrbf->value(oscil->Padaptiveharmonicsbasefreq);
  1043. adhrpow->value(oscil->Padaptiveharmonicspower);
  1044. adhrtype->value(oscil->Padaptiveharmonicspar);
  1045. for (int i=0;i<MAX_AD_HARMONICS;i++) h[i]->refresh();
  1046. pthread_mutex_lock(&master->mutex);
  1047. oscil->prepare();
  1048. pthread_mutex_unlock(&master->mutex);
  1049. basefuncdisplaygroup->redraw();
  1050. redrawoscil();} {}
  1051. }
  1052. Function {redrawoscil()} {} {
  1053. code {oscildisplaygroup->redraw();
  1054. oldosc->redraw();
  1055. if (cbwidget!=NULL) {
  1056. cbwidget->do_callback();
  1057. applybutton->color(FL_RED);
  1058. applybutton->redraw();
  1059. };} {}
  1060. }
  1061. decl {OscilGen *oscil;} {}
  1062. decl {Fl_Widget *oldosc,*cbwidget,*cbapplywidget;} {}
  1063. decl {Oscilharmonic *h[MAX_AD_HARMONICS];} {}
  1064. decl {Master *master;} {}
  1065. }