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.

EnvelopeUI.fl 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907
  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 "WidgetPDial.h"} {public
  8. }
  9. decl {\#include <stdio.h>} {public
  10. }
  11. decl {\#include <stdlib.h>} {public
  12. }
  13. decl {\#include "../globals.h"} {public
  14. }
  15. decl {\#include <FL/Fl_Group.H>} {public
  16. }
  17. decl {\#include "../Params/EnvelopeParams.h"} {public
  18. }
  19. decl {\#include <FL/Fl_Box.H>} {public
  20. }
  21. decl {\#include <FL/fl_draw.H>} {public
  22. }
  23. decl {\#include <FL/fl_ask.H>} {public
  24. }
  25. decl {\#include "PresetsUI.h"} {public
  26. }
  27. decl {\#include "common.H"} {public
  28. }
  29. class EnvelopeFreeEdit {: {public Fl_Box}
  30. } {
  31. Function {EnvelopeFreeEdit(int x,int y, int w, int h, const char *label=0):Fl_Box(x,y,w,h,label)} {} {
  32. code {env=NULL;
  33. pair=NULL;} {}
  34. }
  35. Function {init(EnvelopeParams *env_)} {} {
  36. code {env=env_;
  37. oldx=-1;
  38. currentpoint=-1;
  39. cpx=0;
  40. lastpoint=-1;
  41. ctrldown=false;} {}
  42. }
  43. Function {setpair(Fl_Box *pair_)} {} {
  44. code {pair=pair_;} {}
  45. }
  46. Function {getpointx(int n)} {return_type int
  47. } {
  48. code {int lx=w()-10;
  49. int npoints=env->Penvpoints;
  50. float sum=0;
  51. for (int i=1;i<npoints;i++) sum+=env->getdt(i)+1;
  52. float sumbefore=0;//the sum of all points before the computed point
  53. for (int i=1;i<=n;i++) sumbefore+=env->getdt(i)+1;
  54. return((int) (sumbefore/(float) sum*lx));} {}
  55. }
  56. Function {getpointy(int n)} {return_type int
  57. } {
  58. code {int ly=h()-10;
  59. return((int) ((1.0-env->Penvval[n]/127.0)*ly));} {}
  60. }
  61. Function {getnearest(int x,int y)} {return_type int
  62. } {
  63. code {x-=5;y-=5;
  64. int nearestpoint=0;
  65. int nearestval=1000000;//a big value
  66. for (int i=0;i<env->Penvpoints;i++){
  67. int distance=abs(x-getpointx(i))+abs(y-getpointy(i));
  68. if (distance<nearestval) {
  69. nearestpoint=i;
  70. nearestval=distance;
  71. };
  72. };
  73. return(nearestpoint);} {}
  74. }
  75. Function {draw()} {private
  76. } {
  77. code {int ox=x(),oy=y(),lx=w(),ly=h();
  78. if (env->Pfreemode==0) env->converttofree();
  79. int npoints=env->Penvpoints;
  80. if (active_r()) fl_color(FL_BLACK);
  81. else fl_color(90,90,90);
  82. if (!active_r()) currentpoint=-1;
  83. fl_rectf(ox,oy,lx,ly);
  84. ox+=5;oy+=5;lx-=10;ly-=10;
  85. //draw the lines
  86. fl_color(FL_GRAY);
  87. fl_line_style(FL_SOLID);
  88. fl_line(ox+2,oy+ly/2,ox+lx-2,oy+ly/2);
  89. //draws the evelope points and lines
  90. Fl_Color alb=FL_WHITE;
  91. if (!active_r()) alb=fl_rgb_color(180,180,180);
  92. fl_color(alb);
  93. int oldxx=0,xx=0,oldyy=0,yy=getpointy(0);
  94. fl_rectf(ox-3,oy+yy-3,6,6);
  95. for (int i=1;i<npoints;i++){
  96. oldxx=xx;oldyy=yy;
  97. xx=getpointx(i);yy=getpointy(i);
  98. if (i==currentpoint) fl_color(FL_RED);
  99. else fl_color(alb);
  100. fl_line(ox+oldxx,oy+oldyy,ox+xx,oy+yy);
  101. fl_rectf(ox+xx-3,oy+yy-3,6,6);
  102. };
  103. //draw the last moved point point (if exists)
  104. if (lastpoint>=0){
  105. fl_color(FL_CYAN);
  106. fl_rectf(ox+getpointx(lastpoint)-5,oy+getpointy(lastpoint)-5,10,10);
  107. };
  108. //draw the sustain position
  109. if (env->Penvsustain>0){
  110. fl_color(FL_YELLOW);
  111. xx=getpointx(env->Penvsustain);
  112. fl_line(ox+xx,oy+0,ox+xx,oy+ly);
  113. };
  114. //Show the envelope duration and the current line duration
  115. fl_font(FL_HELVETICA|FL_BOLD,10);
  116. float time=0.0;
  117. if (currentpoint<=0 && (!ctrldown||lastpoint <= 0)){
  118. fl_color(alb);
  119. for (int i=1;i<npoints;i++) time+=env->getdt(i);
  120. } else {
  121. fl_color(255,0,0);
  122. time=env->getdt(lastpoint);
  123. };
  124. char tmpstr[20];
  125. if (time<1000.0) snprintf((char *)&tmpstr,20,"%.1fms",time);
  126. else snprintf((char *)&tmpstr,20,"%.2fs",time/1000.0);
  127. fl_draw(tmpstr,ox+lx-20,oy+ly-10,20,10,FL_ALIGN_RIGHT,NULL,0);
  128. if (lastpoint>=0){
  129. snprintf((char *)&tmpstr,20,"%d", env->Penvval[lastpoint]);
  130. fl_draw(tmpstr,ox+lx-20,oy+ly-23,20,10,FL_ALIGN_RIGHT,NULL,0);
  131. }} {}
  132. }
  133. Function {handle(int event)} {return_type int
  134. } {
  135. code {int x_=Fl::event_x()-x();
  136. int y_=Fl::event_y()-y();
  137. // Some window magic makes us lose focus, so reassert it.
  138. if (event==FL_ENTER)
  139. Fl::focus(this);
  140. if ((event==FL_KEYDOWN || event==FL_KEYUP)){
  141. int key = Fl::event_key();
  142. if (key==FL_Control_L || key==FL_Control_R){
  143. ctrldown = (event==FL_KEYDOWN);
  144. redraw();
  145. if (pair!=NULL) pair->redraw();
  146. }
  147. }
  148. if (event==FL_MOUSEWHEEL && lastpoint>=0) {
  149. if (!ctrldown) {
  150. int ny=env->Penvval[lastpoint] - Fl::event_dy();
  151. env->Penvval[lastpoint]=ny < 0 ? 0 : ny > 127 ? 127 : ny;
  152. } else if (lastpoint > 0) {
  153. int newdt = Fl::event_dy() + env->Penvdt[lastpoint];
  154. env->Penvdt[lastpoint] = newdt < 0 ? 0 : newdt > 127 ? 127 : newdt;
  155. }
  156. redraw();
  157. if (pair!=NULL) pair->redraw();
  158. }
  159. if (event==FL_PUSH) {
  160. currentpoint=getnearest(x_,y_);
  161. cpx=x_;
  162. cpdt=env->Penvdt[currentpoint];
  163. lastpoint=currentpoint;
  164. redraw();
  165. if (pair!=NULL) pair->redraw();
  166. };
  167. if (event==FL_RELEASE){
  168. currentpoint=-1;
  169. redraw();
  170. if (pair!=NULL) pair->redraw();
  171. };
  172. if ((event==FL_DRAG)&&(currentpoint>=0)){
  173. int ny=127-(int) (y_*127.0/h());
  174. if (ny<0) ny=0;if (ny>127) ny=127;
  175. env->Penvval[currentpoint]=ny;
  176. int dx=(int)((x_-cpx)*0.1);
  177. int newdt=cpdt+dx;
  178. if (newdt<0) newdt=0;if (newdt>127) newdt=127;
  179. if (currentpoint!=0) env->Penvdt[currentpoint]=newdt;
  180. else env->Penvdt[currentpoint]=0;
  181. redraw();
  182. if (pair!=NULL) pair->redraw();
  183. };
  184. return(1);} {}
  185. }
  186. decl {Fl_Box *pair;} {}
  187. decl {EnvelopeParams *env;} {}
  188. decl {int oldx,oldy;} {}
  189. decl {int currentpoint,cpx,cpdt;} {}
  190. decl {int lastpoint;} {public
  191. }
  192. decl {bool ctrldown;} {}
  193. }
  194. class EnvelopeUI {open : {public Fl_Group,PresetsUI_}
  195. } {
  196. Function {EnvelopeUI(int x,int y, int w, int h, const char *label=0):Fl_Group(x,y,w,h,label)} {} {
  197. code {env=NULL;
  198. freemodeeditwindow=NULL;
  199. envADSR=NULL;
  200. envASR=NULL;
  201. envADSRfilter=NULL;
  202. envASRbw=NULL;
  203. envfree=NULL;} {}
  204. }
  205. Function {~EnvelopeUI()} {} {
  206. code {envwindow->hide();
  207. hide();
  208. freemodeeditwindow->hide();
  209. delete (freemodeeditwindow);} {}
  210. }
  211. Function {make_freemode_edit_window()} {open
  212. } {
  213. Fl_Window freemodeeditwindow {
  214. label Envelope
  215. xywh {702 269 575 180} type Double visible
  216. } {
  217. Fl_Box freeedit {
  218. label Envelope
  219. xywh {5 5 565 145} box FLAT_BOX color 0
  220. code0 {o->init(env);}
  221. class EnvelopeFreeEdit
  222. }
  223. Fl_Button addpoint {
  224. label {Add point}
  225. callback {int curpoint=freeedit->lastpoint;
  226. if (curpoint<0) return;
  227. //if (curpoint>=env->Penvpoints-1) return;
  228. if (env->Penvpoints>=MAX_ENVELOPE_POINTS) return;
  229. for (int i=env->Penvpoints;i>=curpoint+1;i--){
  230. env->Penvdt[i]=env->Penvdt[i-1];
  231. env->Penvval[i]=env->Penvval[i-1];
  232. };
  233. if (curpoint==0) {
  234. env->Penvdt[1]=64;
  235. };
  236. env->Penvpoints++;
  237. if (curpoint<=env->Penvsustain) env->Penvsustain++;
  238. freeedit->lastpoint+=1;
  239. freeedit->redraw();
  240. envfree->redraw();
  241. sustaincounter->value(env->Penvsustain);
  242. sustaincounter->maximum(env->Penvpoints-2);}
  243. xywh {115 155 80 20} box THIN_UP_BOX labelsize 11
  244. code0 {if (env->Pfreemode==0) o->hide();}
  245. }
  246. Fl_Button deletepoint {
  247. label {Delete point}
  248. callback {int curpoint=freeedit->lastpoint;
  249. if (curpoint<1) return;
  250. if (curpoint>=env->Penvpoints-1) return;
  251. if (env->Penvpoints<=3) return;
  252. for (int i=curpoint+1;i<env->Penvpoints;i++){
  253. env->Penvdt[i-1]=env->Penvdt[i];
  254. env->Penvval[i-1]=env->Penvval[i];
  255. };
  256. env->Penvpoints--;
  257. if (curpoint<=env->Penvsustain) env->Penvsustain--;
  258. freeedit->lastpoint-=1;
  259. freeedit->redraw();
  260. envfree->redraw();
  261. sustaincounter->value(env->Penvsustain);
  262. sustaincounter->maximum(env->Penvpoints-2);}
  263. xywh {200 155 80 20} box THIN_UP_BOX labelsize 11
  264. code0 {if (env->Pfreemode==0) o->hide();}
  265. }
  266. Fl_Check_Button freemodebutton {
  267. label FreeMode
  268. callback {reinit();
  269. freeedit->lastpoint=-1;
  270. freeedit->redraw();}
  271. tooltip {Enable or disable the freemode} xywh {10 155 95 20} labelsize 11
  272. }
  273. Fl_Check_Button forcedreleasecheck {
  274. label frcR
  275. callback {env->Pforcedrelease=(int)o->value();}
  276. tooltip {Forced Relase} xywh {410 165 40 15} down_box DOWN_BOX labelsize 10
  277. code0 {o->value(env->Pforcedrelease);}
  278. code1 {if (env->Pfreemode==0) o->hide();}
  279. }
  280. Fl_Dial envstretchdial {
  281. label {Str.}
  282. callback {env->Penvstretch=(int)o->value();}
  283. tooltip {Envelope stretch (on lower notes make the envelope longer)} xywh {380 155 25 25} box ROUND_UP_BOX labelsize 10 align 4 maximum 127 step 1
  284. code0 {o->value(env->Penvstretch);}
  285. code1 {if (env->Pfreemode==0) o->hide();}
  286. class WidgetPDial
  287. }
  288. Fl_Button {} {
  289. label Close
  290. callback {freemodeeditwindow->hide();}
  291. xywh {510 155 60 20} box THIN_UP_BOX
  292. }
  293. Fl_Check_Button linearenvelopecheck {
  294. label L
  295. callback {env->Plinearenvelope=(int)o->value();}
  296. tooltip {Linear Envelope} xywh {410 151 30 15} down_box DOWN_BOX labelsize 10
  297. code0 {o->value(env->Plinearenvelope);}
  298. code1 {if ((env->Pfreemode==0)||(env->Envmode>2)) o->hide();}
  299. }
  300. Fl_Counter sustaincounter {
  301. label Sust
  302. callback {env->Penvsustain=(int) o->value();
  303. freeedit->redraw();
  304. envfree->redraw();}
  305. tooltip {Sustain (0 is disabled)} xywh {315 155 40 15} type Simple labelsize 11 align 4 minimum 0 maximum 127 step 1
  306. code0 {o->value(env->Penvsustain);}
  307. code1 {if (env->Pfreemode==0) o->hide();}
  308. code2 {o->maximum(env->Penvpoints-2);}
  309. }
  310. Fl_Button {} {
  311. label C
  312. callback {presetsui->copy(env);}
  313. xywh {465 160 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
  314. }
  315. Fl_Button {} {
  316. label P
  317. callback {presetsui->paste(env,this);}
  318. xywh {482 160 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
  319. }
  320. }
  321. }
  322. Function {make_ADSR_window()} {open
  323. } {
  324. Fl_Window envADSR {open
  325. xywh {344 788 205 70} type Double color 50 labelfont 1
  326. class Fl_Group visible
  327. } {
  328. Fl_Group {} {
  329. label {Amplitude Envelope}
  330. xywh {0 0 205 70} box UP_BOX color 223 labeltype ENGRAVED_LABEL labelsize 10 align 17
  331. code0 {set_module_parameters(o);}
  332. } {
  333. Fl_Dial e1adt {
  334. label {A.dt}
  335. callback {env->PA_dt=(int)o->value();
  336. freeedit->redraw();}
  337. tooltip {Attack time} xywh {5 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
  338. code0 {o->value(env->PA_dt);}
  339. class WidgetPDial
  340. }
  341. Fl_Dial e1ddt {
  342. label {D.dt}
  343. callback {env->PD_dt=(int)o->value();
  344. freeedit->redraw();}
  345. tooltip {Decay time} xywh {40 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
  346. code0 {o->value(env->PD_dt);}
  347. class WidgetPDial
  348. }
  349. Fl_Dial e1rdt {
  350. label {R.dt}
  351. callback {env->PR_dt=(int)o->value();
  352. freeedit->redraw();}
  353. tooltip {Release time} xywh {110 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
  354. code0 {o->value(env->PR_dt);}
  355. class WidgetPDial
  356. }
  357. Fl_Dial e1sval {
  358. label {S.val}
  359. callback {env->PS_val=(int)o->value();
  360. freeedit->redraw();}
  361. tooltip {Sustain value} xywh {75 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
  362. code0 {o->value(env->PS_val);}
  363. class WidgetPDial
  364. }
  365. Fl_Check_Button e1forcedrelease {
  366. label frcR
  367. callback {env->Pforcedrelease=(int)o->value();}
  368. tooltip {Forced Relase} xywh {180 35 20 15} down_box DOWN_BOX labelsize 10 align 6
  369. code0 {o->value(env->Pforcedrelease);}
  370. }
  371. Fl_Dial e1envstretch {
  372. label Stretch
  373. callback {env->Penvstretch=(int)o->value();}
  374. tooltip {Envelope stretch (on lower notes makes the envelope longer)} xywh {145 25 25 25} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
  375. code0 {o->value(env->Penvstretch);}
  376. class WidgetPDial
  377. }
  378. Fl_Button {} {
  379. label E
  380. callback {freemodeeditwindow->show();}
  381. tooltip {Envelope window} xywh {185 5 15 15} labelfont 1 labelsize 10
  382. }
  383. Fl_Check_Button e1linearenvelope {
  384. label L
  385. callback {env->Plinearenvelope=(int)o->value();}
  386. tooltip {The evelope is linear} xywh {180 20 15 15} down_box DOWN_BOX labelsize 10 align 4
  387. code0 {o->value(env->Plinearenvelope);}
  388. }
  389. Fl_Button {} {
  390. label C
  391. callback {presetsui->copy(env);}
  392. xywh {150 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
  393. }
  394. Fl_Button {} {
  395. label P
  396. callback {presetsui->paste(env,this);}
  397. xywh {167 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
  398. }
  399. }
  400. }
  401. }
  402. Function {make_ASR_window()} {open
  403. } {
  404. Fl_Window envASR {open
  405. xywh {648 667 210 70} type Double
  406. class Fl_Group visible
  407. } {
  408. Fl_Group {} {
  409. label {Frequency Envelope}
  410. xywh {0 0 210 70} box UP_BOX color 223 labeltype ENGRAVED_LABEL labelsize 10 align 17
  411. code0 {set_module_parameters(o);}
  412. } {
  413. Fl_Dial e2aval {
  414. label {A.val}
  415. callback {env->PA_val=(int)o->value();
  416. freeedit->redraw();}
  417. tooltip {Starting value} xywh {5 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
  418. code0 {o->value(env->PA_val);}
  419. class WidgetPDial
  420. }
  421. Fl_Dial e2adt {
  422. label {A.dt}
  423. callback {env->PA_dt=(int)o->value();
  424. freeedit->redraw();}
  425. tooltip {Attack time} xywh {40 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
  426. code0 {o->value(env->PA_dt);}
  427. class WidgetPDial
  428. }
  429. Fl_Dial e2rval {
  430. label {R.val}
  431. callback {env->PR_val=(int)o->value();
  432. freeedit->redraw();}
  433. tooltip {Release value} xywh {110 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
  434. code0 {o->value(env->PR_val);}
  435. class WidgetPDial
  436. }
  437. Fl_Dial e2rdt {
  438. label {R.dt}
  439. callback {env->PR_dt=(int)o->value();
  440. freeedit->redraw();}
  441. tooltip {Release time} xywh {75 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
  442. code0 {o->value(env->PR_dt);}
  443. class WidgetPDial
  444. }
  445. Fl_Dial e2envstretch {
  446. label Stretch
  447. callback {env->Penvstretch=(int)o->value();}
  448. tooltip {Envelope stretch (on lower notes makes the envelope longer)} xywh {145 25 25 25} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
  449. code0 {o->value(env->Penvstretch);}
  450. class WidgetPDial
  451. }
  452. Fl_Check_Button e2forcedrelease {
  453. label frcR
  454. callback {env->Pforcedrelease=(int)o->value();}
  455. tooltip {Forced release} xywh {180 25 15 25} down_box DOWN_BOX labelsize 10 align 6
  456. code0 {o->value(env->Pforcedrelease);}
  457. }
  458. Fl_Button {} {
  459. label C
  460. callback {presetsui->copy(env);}
  461. xywh {155 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
  462. }
  463. Fl_Button {} {
  464. label P
  465. callback {presetsui->paste(env,this);}
  466. xywh {172 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
  467. }
  468. }
  469. Fl_Button {} {
  470. label E
  471. callback {freemodeeditwindow->show();}
  472. tooltip {Envelope window} xywh {190 5 15 15} labelfont 1 labelsize 10
  473. }
  474. }
  475. }
  476. Function {make_ADSRfilter_window()} {open
  477. } {
  478. Fl_Window envADSRfilter {open selected
  479. xywh {627 569 275 70} type Double color 50 labelfont 1
  480. class Fl_Group visible
  481. } {
  482. Fl_Group {} {
  483. label {Filter Envelope}
  484. xywh {0 0 275 70} box UP_BOX color 223 labeltype ENGRAVED_LABEL labelsize 10 align 17
  485. code0 {set_module_parameters(o);}
  486. } {
  487. Fl_Dial e3aval {
  488. label {A.val}
  489. callback {env->PA_val=(int)o->value();
  490. freeedit->redraw();}
  491. tooltip {Starting value} xywh {5 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
  492. code0 {o->value(env->PA_val);}
  493. class WidgetPDial
  494. }
  495. Fl_Dial e3adt {
  496. label {A.dt}
  497. callback {env->PA_dt=(int)o->value();
  498. freeedit->redraw();}
  499. tooltip {Attack time} xywh {40 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
  500. code0 {o->value(env->PA_dt);}
  501. class WidgetPDial
  502. }
  503. Fl_Dial e3dval {
  504. label {D.val}
  505. callback {env->PD_val=(int)o->value();
  506. freeedit->redraw();}
  507. tooltip {decay value} xywh {75 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
  508. code0 {o->value(env->PD_val);}
  509. class WidgetPDial
  510. }
  511. Fl_Dial e3ddt {
  512. label {D.dt}
  513. callback {env->PD_dt=(int)o->value();
  514. freeedit->redraw();}
  515. tooltip {decay time} xywh {110 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
  516. code0 {o->value(env->PD_dt);}
  517. class WidgetPDial
  518. }
  519. Fl_Dial e3rdt {
  520. label {R.dt}
  521. callback {env->PR_dt=(int)o->value();
  522. freeedit->redraw();}
  523. tooltip {Release time} xywh {145 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
  524. code0 {o->value(env->PR_dt);}
  525. class WidgetPDial
  526. }
  527. Fl_Dial e3rval {
  528. label {R.val}
  529. callback {env->PR_val=(int)o->value();
  530. freeedit->redraw();}
  531. tooltip {Release value} xywh {180 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
  532. code0 {o->value(env->PR_val);}
  533. class WidgetPDial
  534. }
  535. Fl_Dial e3envstretch {
  536. label Stretch
  537. callback {env->Penvstretch=(int)o->value();}
  538. tooltip {Envelope stretch (on lower notes makes the envelope longer)} xywh {215 25 25 25} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
  539. code0 {o->value(env->Penvstretch);}
  540. class WidgetPDial
  541. }
  542. Fl_Check_Button e3forcedrelease {
  543. label frcR
  544. callback {env->Pforcedrelease=(int)o->value();}
  545. tooltip {Forced Relase} xywh {250 30 15 20} down_box DOWN_BOX labelsize 10 align 6
  546. code0 {o->value(env->Pforcedrelease);}
  547. }
  548. Fl_Button {} {
  549. label E
  550. callback {freemodeeditwindow->show();}
  551. xywh {255 5 15 15} labelfont 1 labelsize 10
  552. }
  553. Fl_Button {} {
  554. label C
  555. callback {presetsui->copy(env);}
  556. xywh {220 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
  557. }
  558. Fl_Button {} {
  559. label P
  560. callback {presetsui->paste(env,this);}
  561. xywh {237 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
  562. }
  563. }
  564. }
  565. }
  566. Function {make_ASRbw_window()} {open
  567. } {
  568. Fl_Window envASRbw {open
  569. xywh {362 642 210 70} type Double
  570. code0 {set_module_parameters(o);}
  571. class Fl_Group visible
  572. } {
  573. Fl_Group {} {
  574. label {BandWidth Envelope}
  575. xywh {0 0 210 70} box UP_BOX color 223 labeltype ENGRAVED_LABEL labelsize 10 align 17
  576. code0 {set_module_parameters(o);}
  577. } {
  578. Fl_Dial e4aval {
  579. label {A.val}
  580. callback {env->PA_val=(int)o->value();
  581. freeedit->redraw();}
  582. tooltip {Starting value} xywh {5 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
  583. code0 {o->value(env->PA_val);}
  584. class WidgetPDial
  585. }
  586. Fl_Dial e4adt {
  587. label {A.dt}
  588. callback {env->PA_dt=(int)o->value();
  589. freeedit->redraw();}
  590. tooltip {Attack time} xywh {40 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
  591. code0 {o->value(env->PA_dt);}
  592. class WidgetPDial
  593. }
  594. Fl_Dial e4rval {
  595. label {R.val}
  596. callback {env->PR_val=(int)o->value();
  597. freeedit->redraw();}
  598. tooltip {Release value} xywh {110 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
  599. code0 {o->value(env->PR_val);}
  600. class WidgetPDial
  601. }
  602. Fl_Dial e4rdt {
  603. label {R.dt}
  604. callback {env->PR_dt=(int)o->value();
  605. freeedit->redraw();}
  606. tooltip {Release time} xywh {75 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
  607. code0 {o->value(env->PR_dt);}
  608. class WidgetPDial
  609. }
  610. Fl_Dial e4envstretch {
  611. label Stretch
  612. callback {env->Penvstretch=(int)o->value();}
  613. tooltip {Envelope stretch (on lower notes makes the envelope longer)} xywh {145 25 25 25} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
  614. code0 {o->value(env->Penvstretch);}
  615. class WidgetPDial
  616. }
  617. Fl_Check_Button e4forcedrelease {
  618. label frcR
  619. callback {env->Pforcedrelease=(int)o->value();}
  620. tooltip {Forced release} xywh {180 25 15 25} down_box DOWN_BOX labelsize 10 align 6
  621. code0 {o->value(env->Pforcedrelease);}
  622. }
  623. Fl_Button {} {
  624. label C
  625. callback {presetsui->copy(env);}
  626. xywh {155 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
  627. }
  628. Fl_Button {} {
  629. label P
  630. callback {presetsui->paste(env,this);}
  631. xywh {172 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
  632. }
  633. }
  634. Fl_Button {} {
  635. label E
  636. callback {freemodeeditwindow->show();}
  637. xywh {190 5 15 15} labelfont 1 labelsize 10
  638. }
  639. }
  640. }
  641. Function {make_free_window()} {open
  642. } {
  643. Fl_Window envfree {open
  644. xywh {376 436 205 70} type Double color 50 labelfont 1 resizable
  645. code0 {set_module_parameters(o);}
  646. class Fl_Group visible
  647. } {
  648. Fl_Group envfreegroup {
  649. label {Amplitude Envelope}
  650. xywh {0 0 205 70} box UP_BOX color 223 labeltype ENGRAVED_LABEL labelsize 10 align 17 resizable
  651. code0 {set_module_parameters(o);}
  652. } {
  653. Fl_Box freeeditsmall {
  654. label Envelope
  655. callback {envfree->redraw();}
  656. xywh {5 20 195 45} box FLAT_BOX color 0 resizable
  657. code0 {o->init(env);}
  658. class EnvelopeFreeEdit
  659. }
  660. Fl_Button {} {
  661. label E
  662. callback {freemodeeditwindow->show();}
  663. xywh {185 5 15 15} labelfont 1 labelsize 10
  664. }
  665. Fl_Button {} {
  666. label C
  667. callback {presetsui->copy(env);}
  668. xywh {150 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
  669. }
  670. Fl_Button {} {
  671. label P
  672. callback {presetsui->paste(env,this);}
  673. xywh {167 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
  674. }
  675. }
  676. }
  677. }
  678. Function {init(EnvelopeParams *env_)} {open
  679. } {
  680. code {env=env_;
  681. make_ADSR_window();
  682. make_ASR_window();
  683. make_ADSRfilter_window();
  684. make_ASRbw_window();
  685. make_free_window();
  686. make_freemode_edit_window();
  687. envwindow=NULL;
  688. if (env->Envmode==3) envfreegroup->label("Frequency Envelope");
  689. if (env->Envmode==4) envfreegroup->label("Filter Envelope");
  690. if (env->Envmode==5) envfreegroup->label("Bandwidth Envelope");
  691. freemodeeditwindow->label(this->label());
  692. freeeditsmall->setpair(freeedit);
  693. freeedit->setpair(freeeditsmall);
  694. refresh();} {}
  695. }
  696. Function {reinit()} {} {
  697. code {if (env->Pfreemode!=0){
  698. int answer=fl_choice("Disable the free mode of the Envelope?","No","Yes",NULL);
  699. if (env->Pfreemode!=0) freemodebutton->value(1);
  700. else freemodebutton->value(0);
  701. if (answer==0) return;
  702. };
  703. if (env->Pfreemode==0) env->Pfreemode=1;
  704. else env->Pfreemode=0;
  705. hide();
  706. int winx=freemodeeditwindow->x();
  707. int winy=freemodeeditwindow->y();
  708. freemodeeditwindow->hide();
  709. envwindow->hide();
  710. Fl_Group *par=envwindow->parent();
  711. par->hide();
  712. refresh();
  713. envwindow->show();
  714. par->redraw();
  715. par->show();
  716. show();
  717. freemodeeditwindow->position(winx,winy);
  718. freemodeeditwindow->show();
  719. if (env->Pfreemode!=0) {
  720. freemodebutton->value(1);
  721. addpoint->show();
  722. deletepoint->show();
  723. forcedreleasecheck->show();
  724. }else{
  725. freemodebutton->value(0);
  726. addpoint->hide();
  727. deletepoint->hide();
  728. forcedreleasecheck->hide();
  729. };} {}
  730. }
  731. Function {refresh()} {open
  732. } {
  733. code {freemodebutton->value(env->Pfreemode);
  734. sustaincounter->value(env->Penvsustain);
  735. if (env->Pfreemode==0) sustaincounter->hide();
  736. else sustaincounter->show();
  737. sustaincounter->maximum(env->Penvpoints-2);
  738. envstretchdial->value(env->Penvstretch);
  739. if (env->Pfreemode==0) envstretchdial->hide();
  740. else envstretchdial->show();
  741. linearenvelopecheck->value(env->Plinearenvelope);
  742. if ((env->Pfreemode==0)||(env->Envmode>2)) linearenvelopecheck->hide();
  743. else linearenvelopecheck->show();
  744. forcedreleasecheck->value(env->Pforcedrelease);
  745. if (env->Pfreemode==0) forcedreleasecheck->hide();
  746. else forcedreleasecheck->show();
  747. if (env->Pfreemode==0){
  748. addpoint->hide();
  749. deletepoint->hide();
  750. } else {
  751. addpoint->show();
  752. deletepoint->show();
  753. }
  754. freeedit->redraw();
  755. if (env->Pfreemode==0){
  756. switch(env->Envmode){
  757. case(1):
  758. case(2):
  759. e1adt->value(env->PA_dt);
  760. e1ddt->value(env->PD_dt);
  761. e1sval->value(env->PS_val);
  762. e1rdt->value(env->PR_dt);
  763. e1envstretch->value(env->Penvstretch);
  764. e1linearenvelope->value(env->Plinearenvelope);
  765. e1forcedrelease->value(env->Pforcedrelease);
  766. break;
  767. case(3):
  768. e2aval->value(env->PA_val);
  769. e2adt->value(env->PA_dt);
  770. e2rdt->value(env->PR_dt);
  771. e2rval->value(env->PR_val);
  772. e2envstretch->value(env->Penvstretch);
  773. e2forcedrelease->value(env->Pforcedrelease);
  774. break;
  775. case(4):
  776. e3aval->value(env->PA_val);
  777. e3adt->value(env->PA_dt);
  778. e3dval->value(env->PD_val);
  779. e3ddt->value(env->PD_dt);
  780. e3rdt->value(env->PR_dt);
  781. e3rval->value(env->PR_val);
  782. e3envstretch->value(env->Penvstretch);
  783. e3forcedrelease->value(env->Pforcedrelease);
  784. break;
  785. case(5):
  786. e4aval->value(env->PA_val);
  787. e4adt->value(env->PA_dt);
  788. e4rdt->value(env->PR_dt);
  789. e4rval->value(env->PR_val);
  790. e4envstretch->value(env->Penvstretch);
  791. e4forcedrelease->value(env->Pforcedrelease);
  792. break;
  793. default:
  794. break;
  795. };
  796. }else{
  797. envfree->redraw();
  798. };
  799. envADSR->hide();
  800. envASR->hide();
  801. envADSRfilter->hide();
  802. envASRbw->hide();
  803. envfree->hide();
  804. if (env->Pfreemode==0){
  805. switch(env->Envmode){
  806. case(1):
  807. case(2):
  808. envwindow=envADSR;
  809. break;
  810. case(3):
  811. envwindow=envASR;
  812. break;
  813. case(4):
  814. envwindow=envADSRfilter;
  815. break;
  816. case(5):
  817. envwindow=envASRbw;
  818. break;
  819. default:
  820. break;
  821. };
  822. }else{
  823. envwindow=envfree;
  824. };
  825. envwindow->resize(this->x(),this->y(),this->w(),this->h());
  826. envwindow->show();} {}
  827. }
  828. decl {EnvelopeParams *env;} {}
  829. decl {Fl_Group *envwindow;} {}
  830. }