forked from Yoshimi/yoshimi
/
EnvelopeUI.fl
1225 lines (1136 loc) · 35.2 KB
/
EnvelopeUI.fl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# data file for the Fltk User Interface Designer (fluid)
version 1.0303
header_name {.h}
code_name {.cc}
comment {Envelope.h} {not_in_source in_header
}
comment {Envelope.cc} {in_source not_in_header
}
comment {Original ZynAddSubFX author Nasca Octavian Paul
Copyright (C) 2002-2005 Nasca Octavian Paul
Copyright 2009, Alan Calvert
Copyright 2016 Will Godfrey
This file is part of yoshimi, which is free software: you can redistribute
it and/or modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
yoshimi is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License (version 2 or
later) for more details.
You should have received a copy of the GNU General Public License along with
yoshimi; if not, write to the Free Software Foundation, Inc., 51 Franklin
Street, Fifth Floor, Boston, MA 02110-1301, USA.
This file is a derivative of the ZynAddSubFX original, modified November 2016
} {in_source in_header
}
decl {\#include "UI/MiscGui.h"} {public local
}
decl {\#include "WidgetPDialUI.h"} {public local
}
decl {\#include <FL/Fl_Group.H>} {public local
}
decl {\#include <FL/Fl_Box.H>} {public local
}
decl {\#include <FL/fl_draw.H>} {public local
}
decl {\#include <FL/fl_ask.H>} {public local
}
decl {\#include "Params/EnvelopeParams.h"} {public local
}
decl {\#include "PresetsUI.h"} {public local
}
decl {\#include "Misc/SynthEngine.h"} {public global
}
decl {\#include "MasterUI.h"} {private global
}
class EnvelopeFreeEdit {: {public Fl_Box}
} {
Function {EnvelopeFreeEdit(int x,int y, int w, int h, const char *label=0):Fl_Box(x,y,w,h,label)} {} {
code {env=NULL;
pair=NULL;} {}
}
Function {send_data(int control, int par2, float value, int type)} {} {
code {//
collect_data(synth, value, (Fl::event_button() | type), control, npart, kititem, engine, 4, group, par2);} {}
}
Function {init(EnvelopeParams *env_, int npart_, int kititem_, int engine_, int group_)} {} {
code {//
env=env_;
oldx=-1;
currentpoint=-1;
cpx=0;
lastpoint=-1;
synth = env->getSynthEngine();
npart = npart_;
kititem = kititem_;
engine = engine_;
group = group_;} {}
}
Function {setpair(Fl_Box *pair_)} {} {
code {pair=pair_;} {}
}
Function {getpointx(int n)} {return_type int
} {
code {int lx=w()-10;
int npoints=env->Penvpoints;
float sum=0;
for (int i=1;i<npoints;i++) sum+=env->getdt(i)+1;
float sumbefore=0;//the sum of all points before the computed point
for (int i=1;i<=n;i++) sumbefore+=env->getdt(i)+1;
return((int) (sumbefore/(float) sum*lx));} {}
}
Function {getpointy(int n)} {return_type int
} {
code {int ly=h()-10;
return((int) ((1.0-env->Penvval[n]/127.0)*ly));} {}
}
Function {getnearest(int x,int y)} {return_type int
} {
code {x-=5;y-=5;
int nearestpoint=0;
int nearestval=1000000;//a big value
for (int i=0;i<env->Penvpoints;i++)
{
int distance=abs(x-getpointx(i))+abs(y-getpointy(i));
if (distance<nearestval)
{
nearestpoint=i;
nearestval=distance;
};
};
return(nearestpoint);} {}
}
Function {draw()} {open private
} {
code {int ox=x(),oy=y(),lx=w(),ly=h();
if (env->Pfreemode==0)
env->converttofree();
int npoints=env->Penvpoints;
if (active_r())
fl_color(FL_BLACK);
else
fl_color(90,90,90);
if (!active_r()) currentpoint=-1;
fl_rectf(ox,oy,lx,ly);
ox+=5;oy+=5;lx-=10;ly-=10;
//draw the lines
fl_color(FL_GRAY);
fl_line_style(FL_SOLID);
fl_line(ox+2,oy+ly/2,ox+lx-2,oy+ly/2);
//draws the evelope points and lines
Fl_Color alb=FL_WHITE;
if (!active_r())
alb=fl_rgb_color(180,180,180);
fl_color(alb);
int oldxx=0,xx=0,oldyy=0,yy=getpointy(0);
fl_rectf(ox-3,oy+yy-3,6,6);
for (int i=1;i<npoints;i++)
{
oldxx=xx;oldyy=yy;
xx=getpointx(i);yy=getpointy(i);
if (i==currentpoint)
fl_color(FL_RED);
else
fl_color(alb);
fl_line(ox+oldxx,oy+oldyy,ox+xx,oy+yy);
fl_rectf(ox+xx-3,oy+yy-3,6,6);
};
//draw the last moved point point (if exists)
if (lastpoint>=0)
{
fl_color(FL_CYAN);
fl_rectf(ox+getpointx(lastpoint)-5,oy+getpointy(lastpoint)-5,10,10);
};
//draw the sustain position
if (env->Penvsustain>0)
{
fl_color(FL_YELLOW);
xx=getpointx(env->Penvsustain);
fl_line(ox+xx,oy+0,ox+xx,oy+ly);
};
//Show the envelope duration and the current line duration
fl_font(FL_HELVETICA|FL_BOLD,10);
float time=0.0;
if (currentpoint<=0)
{
fl_color(alb);
for (int i=1;i<npoints;i++)
time+=env->getdt(i);
}
else
{
fl_color(255,0,0);
time=env->getdt(currentpoint);
};
char tmpstr[20];
if (time<1000.0)
snprintf((char *)&tmpstr,20,"%.1fms",time);
else
snprintf((char *)&tmpstr,20,"%.2fs",time/1000.0);
fl_draw(tmpstr,ox+lx-20,oy+ly-10,20,10,FL_ALIGN_RIGHT,NULL,0);} {}
}
Function {handle(int event)} {return_type int
} {
code {int x_ = Fl::event_x() - x();
int y_ = Fl::event_y() - y();
if (event == FL_PUSH)
{
currentpoint = getnearest(x_, y_);
cpx = x_;
cpdt = env->Penvdt[currentpoint];
lastpoint = currentpoint;
redraw();
if (pair != NULL)
pair->redraw();
}
if (event == FL_RELEASE)
{
currentpoint = -1;
redraw();
if (pair != NULL)
pair->redraw();
}
if ((event == FL_DRAG) && (currentpoint >= 0))
{
int ny = 127 - (int) (y_ * 127.0 / h());
if (ny < 0)
ny = 0;
if ( ny> 127)
ny = 127;
env->Penvval[currentpoint] = ny;
int dx = (int)((x_- cpx) * 0.1);
int newdt = cpdt + dx;
if (newdt < 0)
newdt = 0;
if (newdt > 127)
newdt = 127;
if (currentpoint!=0)
env->Penvdt[currentpoint] = newdt;
else
env->Penvdt[currentpoint] = 0;
redraw();
send_data(currentpoint, newdt, ny, 0xc0);
if (pair!=NULL)
pair->redraw();
}
return(1);} {}
}
decl {Fl_Box *pair;} {private local
}
decl {EnvelopeParams *env;} {private local
}
decl {int oldx,oldy;} {private local
}
decl {int currentpoint,cpx,cpdt;} {private local
}
decl {int lastpoint;} {public local
}
decl {SynthEngine *synth;} {private local
}
decl {int npart;} {private local
}
decl {int kititem;} {private local
}
decl {int engine;} {private local
}
decl {int group;} {private local
}
}
class EnvelopeUI {selected : {public Fl_Group,PresetsUI_}
} {
Function {EnvelopeUI(int x,int y, int w, int h, const char *label=0):Fl_Group(x,y,w,h,label)} {} {
code {synth = NULL;
env=NULL;
freemodeeditwindow=NULL;
envADSR=NULL;
envASR=NULL;
envADSRfilter=NULL;
envASRbw=NULL;
envfree=NULL;} {}
}
Function {~EnvelopeUI()} {} {
code {envwindow->hide();
hide();
freemodeeditwindow->hide();
delete (freemodeeditwindow);} {}
}
Function {make_freemode_edit_window()} {} {
Fl_Window freemodeeditwindow {
label Envelope
xywh {813 22 575 180} type Double hide
} {
Fl_Box freeedit {
label Envelope
xywh {5 5 565 145} box FLAT_BOX color 0
code0 {o->init(env, npart, kititem, engine, group);}
class EnvelopeFreeEdit
}
Fl_Button addpoint {
label {Add point}
callback {int curpoint=freeedit->lastpoint;
if (curpoint<0) return;
if (env->Penvpoints>=MAX_ENVELOPE_POINTS) return;
for (int i=env->Penvpoints;i>=curpoint+1;i--){
env->Penvdt[i]=env->Penvdt[i-1];
env->Penvval[i]=env->Penvval[i-1];
};
if (curpoint==0) {
env->Penvdt[1]=64;
};
env->Penvpoints++;
if (curpoint<=env->Penvsustain) env->Penvsustain++;
freeedit->lastpoint+=1;
freeedit->redraw();
envfree->redraw();
sustaincounter->value(env->Penvsustain);
sustaincounter->maximum(env->Penvpoints-2);
send_data(group, curpoint | 64, env->Penvval[curpoint], 0xc0, env->Penvdt[curpoint]);}
xywh {115 155 80 20} box THIN_UP_BOX labelsize 11
code0 {if (env->Pfreemode==0) o->hide();}
}
Fl_Button deletepoint {
label {Delete point}
callback {int curpoint=freeedit->lastpoint;
if (curpoint<1) return;
if (curpoint>=env->Penvpoints-1) return;
if (env->Penvpoints<=3) return;
for (int i=curpoint+1;i<env->Penvpoints;i++){
env->Penvdt[i-1]=env->Penvdt[i];
env->Penvval[i-1]=env->Penvval[i];
};
env->Penvpoints--;
if (curpoint<=env->Penvsustain) env->Penvsustain--;
freeedit->lastpoint-=1;
freeedit->redraw();
envfree->redraw();
sustaincounter->value(env->Penvsustain);
sustaincounter->maximum(env->Penvpoints-2);
send_data(group, curpoint, 0, 0xc0, env->Penvpoints - 1);}
xywh {200 155 80 20} box THIN_UP_BOX labelsize 11
code0 {if (env->Pfreemode==0) o->hide();}
}
Fl_Light_Button freemodebutton {
label FreeMode
callback {reinit();
freeedit->lastpoint=-1;
freeedit->redraw();
send_data(group, 32, o->value(), 0xc0);}
tooltip {Enable or disable the freemode} xywh {10 154 95 22} box PLASTIC_UP_BOX labelsize 11
}
Fl_Check_Button forcedreleasecheck {
label frcR
callback {env->Pforcedrelease=(int)o->value();
send_data(group, 16, o->value(), 0xc0);}
tooltip {Forced Release} xywh {410 165 40 15} down_box DOWN_BOX labelsize 10
code0 {o->value(env->Pforcedrelease);}
code1 {if (env->Pfreemode==0) o->hide();}
}
Fl_Dial envstretchdial {
label {Str.}
callback {env->Penvstretch=(int)o->value();
send_data(group, 7, o->value(), 0xc8);}
tooltip {Envelope stretch (on lower notes make the envelope longer)} xywh {380 153 25 25} box ROUND_UP_BOX labelsize 10 align 4 maximum 127 step 1
code0 {o->value(env->Penvstretch);}
code1 {if (env->Pfreemode==0) o->hide();}
code2 {if (group == 0 || ( engine == 1 && group == 1)) o->init(64); else o->init(0);}
class WidgetPDial
}
Fl_Button {} {
label Close
callback {freemodeeditwindow->hide();}
xywh {519 155 44 20} box THIN_UP_BOX labelsize 12
}
Fl_Check_Button linearenvelopecheck {
label L
callback {env->Plinearenvelope=(int)o->value();
send_data(group, 17, o->value(), 0xc0);}
tooltip {Linear Envelope} xywh {410 151 30 15} down_box DOWN_BOX labelsize 10
code0 {o->value(env->Plinearenvelope);}
code1 {if ((env->Pfreemode==0)||(env->Envmode>2)) o->hide();}
}
Fl_Counter sustaincounter {
label Sust
callback {env->Penvsustain=(int) o->value();
freeedit->redraw();
envfree->redraw();
send_data(group, 35, o->value(), 0xc0);}
tooltip {Sustain (0 is disabled)} xywh {315 155 40 15} type Simple labelsize 11 align 4 minimum 0 maximum 127 step 1
code0 {o->value(env->Penvsustain);}
code1 {if (env->Pfreemode==0) o->hide();}
code2 {o->maximum(env->Penvpoints-2);}
}
Fl_Button {} {
label C
callback {synth->getGuiMaster()->getPresetsUi()->copy(env);}
xywh {465 160 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 7
}
Fl_Button {} {
label P
callback {synth->getGuiMaster()->getPresetsUi()->paste(env,this);}
xywh {482 160 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 7
}
}
}
Function {make_ADSR_window()} {} {
Fl_Window envADSR {
xywh {1185 87 205 70} type Double color 50 labelfont 1 hide
class Fl_Group
} {
Fl_Group {} {
label {Amplitude Env}
xywh {0 0 205 70} box PLASTIC_UP_BOX color 223 labelfont 1 labelsize 10 align 17
} {
Fl_Dial e1adt {
label {A.dt}
callback {env->PA_dt=(int)o->value();
freeedit->redraw();
show_dt_value(o);
send_data(group, 1, o->value(), 0xc8);}
tooltip {Attack time} xywh {5 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
code0 {o->value(env->PA_dt);}
code1 {if (engine >= 0xc0) o->init(80); else o->init(0);}
class WidgetPDial
}
Fl_Dial e1ddt {
label {D.dt}
callback {env->PD_dt=(int)o->value();
freeedit->redraw();
show_dt_value(o);
send_data(group, 3, o->value(), 0xc8);}
tooltip {Decay time} xywh {40 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
code0 {o->value(env->PD_dt);}
code1 {if (engine >= 0xc0) o->init(90); else if (engine >= 0x80) o->init(100); else o->init(40);}
class WidgetPDial
}
Fl_Dial e1rdt {
label {R.dt}
callback {env->PR_dt=(int)o->value();
freeedit->redraw();
show_dt_value(o);
send_data(group, 5, o->value(), 0xc8);}
tooltip {Release time} xywh {110 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
code0 {o->value(env->PR_dt);}
code1 {if (engine >= 0x80) o->init(100); else o->init(25);}
class WidgetPDial
}
Fl_Dial e1sval {
label {S.val}
callback {env->PS_val=(int)o->value();
freeedit->redraw();
o->show_percent_value();
send_data(group, 4, o->value(), 0xc8);}
tooltip {Sustain value} xywh {75 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
code0 {o->value(env->PS_val);}
code1 {o->init(127);}
class WidgetPDial
}
Fl_Check_Button e1forcedrelease {
label frcR
callback {env->Pforcedrelease=(int)o->value();
send_data(group, 16, o->value(), 0xc0);}
tooltip {Forced Release} xywh {180 35 20 15} down_box DOWN_BOX labelsize 10 align 6
code0 {o->value(env->Pforcedrelease);}
}
Fl_Dial e1envstretch {
label Stretch
callback {env->Penvstretch=(int)o->value();
send_data(group, 7, o->value(), 0xc8);}
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
code0 {o->value(env->Penvstretch);}
code1 {o->init(64);}
class WidgetPDial
}
Fl_Button {} {
label E
callback {freemodeeditwindow->show();
send_data(group, 24, o->value(), 0xc0);}
tooltip {Envelope window} xywh {185 5 15 15} box PLASTIC_UP_BOX labelfont 1 labelsize 10
}
Fl_Check_Button e1linearenvelope {
label L
callback {env->Plinearenvelope=(int)o->value();
send_data(group, 17, o->value(), 0xc0);}
tooltip {The evelope is linear} xywh {180 20 15 15} down_box DOWN_BOX labelsize 10 align 4
code0 {o->value(env->Plinearenvelope);}
}
Fl_Button {} {
label C
callback {synth->getGuiMaster()->getPresetsUi()->copy(env);}
xywh {150 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 7
}
Fl_Button {} {
label P
callback {synth->getGuiMaster()->getPresetsUi()->paste(env,this);}
xywh {167 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 7
}
}
}
}
Function {make_ASR_window()} {} {
Fl_Window envASR {
xywh {1183 190 210 70} type Double hide
class Fl_Group
} {
Fl_Group {} {
label {Frequency Env}
xywh {0 0 210 70} box PLASTIC_UP_BOX color 223 labelfont 1 labelsize 10 align 17
} {
Fl_Dial e2aval {
label {A.val}
callback {env->PA_val=(int)o->value();
freeedit->redraw();
send_data(group, 0, o->value(), 0xc8);}
tooltip {Starting value} xywh {5 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
code0 {o->value(env->PA_val);}
code1 {if (engine >= 0xc0) o->init(20); else if (engine >= 0x80 || engine == 1) o->init(30); else o->init(64);}
class WidgetPDial
}
Fl_Dial e2adt {
label {A.dt}
callback {env->PA_dt=(int)o->value();
freeedit->redraw();
show_dt_value(o);
send_data(group, 1, o->value(), 0xc8);}
tooltip {Attack time} xywh {40 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
code0 {o->value(env->PA_dt);}
code1 {if (engine >= 0xc0) o->init(90); else if (engine >= 0x80) o->init(40); else o->init(50);}
class WidgetPDial
}
Fl_Dial e2rval {
label {R.val}
callback {env->PR_val=(int)o->value();
freeedit->redraw();
send_data(group, 6, o->value(), 0xc8);}
tooltip {Release value} xywh {110 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
code0 {o->value(env->PR_val);}
code1 {if (engine >= 0xc0) o->init(40); else o->init(64);}
class WidgetPDial
}
Fl_Dial e2rdt {
label {R.dt}
callback {env->PR_dt=(int)o->value();
freeedit->redraw();
show_dt_value(o);
send_data(group, 5, o->value(), 0xc8);}
tooltip {Release time} xywh {75 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
code0 {o->value(env->PR_dt);}
code1 {if (engine >= 0xc0) o->init(80); else o->init(60);}
class WidgetPDial
}
Fl_Dial e2envstretch {
label Stretch
callback {env->Penvstretch=(int)o->value();
send_data(group, 7, o->value(), 0xc8);}
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
code0 {o->value(env->Penvstretch);}
code1 {if (engine == 1) o->init(64); else o->init(0);}
class WidgetPDial
}
Fl_Check_Button e2forcedrelease {
label frcR
callback {env->Pforcedrelease=(int)o->value();
send_data(group, 16, o->value(), 0xc0);}
tooltip {Forced release} xywh {180 25 15 25} down_box DOWN_BOX labelsize 10 align 6
code0 {o->value(env->Pforcedrelease);}
}
Fl_Button {} {
label C
callback {synth->getGuiMaster()->getPresetsUi()->copy(env);}
xywh {155 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 7
}
Fl_Button {} {
label P
callback {synth->getGuiMaster()->getPresetsUi()->paste(env,this);}
xywh {172 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 7
}
}
Fl_Button {} {
label E
callback {freemodeeditwindow->show();
send_data(group, 24, o->value(), 0xc0);}
tooltip {Envelope window} xywh {190 5 15 15} box PLASTIC_UP_BOX labelfont 1 labelsize 10
}
}
}
Function {make_ADSRfilter_window()} {} {
Fl_Window envADSRfilter {
xywh {1121 294 275 70} type Double color 50 labelfont 1 hide
class Fl_Group
} {
Fl_Group {} {
label {Filter Env}
xywh {0 0 275 70} box PLASTIC_UP_BOX color 223 labelfont 1 labelsize 10 align 17
} {
Fl_Dial e3aval {
label {A.val}
callback {env->PA_val=(int)o->value();
freeedit->redraw();
send_data(group, 0, o->value(), 0xc8);}
tooltip {Starting value} xywh {5 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
code0 {o->value(env->PA_val);}
code1 {if (engine < 0x80) o->init(64); else o->init(90);}
class WidgetPDial
}
Fl_Dial e3adt {
label {A.dt}
callback {env->PA_dt=(int)o->value();
freeedit->redraw();
show_dt_value(o);
send_data(group, 1, o->value(), 0xc8);}
tooltip {Attack time} xywh {40 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
code0 {o->value(env->PA_dt);}
code1 {if (engine < 0x80) o->init(40); else o->init(70);}
class WidgetPDial
}
Fl_Dial e3dval {
label {D.val}
callback {env->PD_val=(int)o->value();
freeedit->redraw();
send_data(group, 2, o->value(), 0xc8);}
tooltip {decay value} xywh {75 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
code0 {o->value(env->PD_val);}
code1 {if (engine < 0x80) o->init(64); else o->init(40);}
class WidgetPDial
}
Fl_Dial e3ddt {
label {D.dt}
callback {env->PD_dt=(int)o->value();
freeedit->redraw();
show_dt_value(o);
send_data(group, 3, o->value(), 0xc8);}
tooltip {decay time} xywh {110 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
code0 {o->value(env->PD_dt);}
code1 {o->init(70);}
class WidgetPDial
}
Fl_Dial e3rdt {
label {R.dt}
callback {env->PR_dt=(int)o->value();
freeedit->redraw();
show_dt_value(o);
send_data(group, 5, o->value(), 0xc8);}
tooltip {Release time} xywh {145 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
code0 {o->value(env->PR_dt);}
code1 {if (engine < 0x80) o->init(60); else o->init(10);}
class WidgetPDial
}
Fl_Dial e3rval {
label {R.val}
callback {env->PR_val=(int)o->value();
freeedit->redraw();
send_data(group, 6, o->value(), 0xc8);}
tooltip {Release value} xywh {180 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
code0 {o->value(env->PR_val);}
code1 {if (engine < 0x80) o->init(64); else o->init(40);}
class WidgetPDial
}
Fl_Dial e3envstretch {
label Stretch
callback {env->Penvstretch=(int)o->value();
send_data(group, 7, o->value(), 0xc8);}
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
code0 {o->value(env->Penvstretch);}
code1 {o->init(0);}
class WidgetPDial
}
Fl_Check_Button e3forcedrelease {
label frcR
callback {env->Pforcedrelease=(int)o->value();
send_data(group, 16, o->value(), 0xc0);}
tooltip {Forced Release} xywh {250 30 15 20} down_box DOWN_BOX labelsize 10 align 6
code0 {o->value(env->Pforcedrelease);}
}
Fl_Button {} {
label E
callback {freemodeeditwindow->show();
send_data(group, 24, o->value(), 0xc0);}
xywh {255 5 15 15} box PLASTIC_UP_BOX labelfont 1 labelsize 10
}
Fl_Button {} {
label C
callback {synth->getGuiMaster()->getPresetsUi()->copy(env);}
xywh {220 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 7
}
Fl_Button {} {
label P
callback {synth->getGuiMaster()->getPresetsUi()->paste(env,this);}
xywh {237 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 7
}
}
}
}
Function {make_ASRbw_window()} {} {
Fl_Window envASRbw {
xywh {1186 399 210 70} type Double hide
class Fl_Group
} {
Fl_Group {} {
label {BandWidth Env}
xywh {0 0 210 70} box PLASTIC_UP_BOX color 223 labelfont 1 labelsize 10 align 17
} {
Fl_Dial e4aval {
label {A.val}
callback {env->PA_val=(int)o->value();
freeedit->redraw();
send_data(group, 0, o->value(), 0xc8);}
tooltip {Starting value} xywh {5 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
code0 {o->value(env->PA_val);}
code1 {o->init(100);}
class WidgetPDial
}
Fl_Dial e4adt {
label {A.dt}
callback {env->PA_dt=(int)o->value();
freeedit->redraw();
show_dt_value(o);
send_data(group, 1, o->value(), 0xc8);}
tooltip {Attack time} xywh {40 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
code0 {o->value(env->PA_dt);}
code1 {o->init(70);}
class WidgetPDial
}
Fl_Dial e4rval {
label {R.val}
callback {env->PR_val=(int)o->value();
freeedit->redraw();
send_data(group, 6, o->value(), 0xc8);}
tooltip {Release value} xywh {110 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
code0 {o->value(env->PR_val);}
code1 {o->init(64);}
class WidgetPDial
}
Fl_Dial e4rdt {
label {R.dt}
callback {env->PR_dt=(int)o->value();
freeedit->redraw();
show_dt_value(o);
send_data(group, 5, o->value(), 0xc8);}
tooltip {Release time} xywh {75 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
code0 {o->value(env->PR_dt);}
code1 {o->init(60);}
class WidgetPDial
}
Fl_Dial e4envstretch {
label Stretch
callback {env->Penvstretch=(int)o->value();
send_data(group, 7, o->value(), 0xc8);}
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
code0 {o->value(env->Penvstretch);}
code1 {o->init(64);}
class WidgetPDial
}
Fl_Check_Button e4forcedrelease {
label frcR
callback {env->Pforcedrelease=(int)o->value();
send_data(group, 16, o->value(), 0xc0);}
tooltip {Forced release} xywh {180 25 15 25} down_box DOWN_BOX labelsize 10 align 6
code0 {o->value(env->Pforcedrelease);}
}
Fl_Button {} {
label C
callback {synth->getGuiMaster()->getPresetsUi()->copy(env);}
xywh {155 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 7
}
Fl_Button {} {
label P
callback {synth->getGuiMaster()->getPresetsUi()->paste(env,this);}
xywh {172 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 7
}
}
Fl_Button {} {
label E
callback {freemodeeditwindow->show();
send_data(group, 24, o->value(), 0xc0);}
xywh {190 5 15 15} box PLASTIC_UP_BOX labelfont 1 labelsize 10
}
}
}
Function {make_free_window()} {} {
Fl_Window envfree {
xywh {874 240 205 70} type Double color 50 labelfont 1 hide resizable
class Fl_Group
} {
Fl_Group envfreegroup {
label {Amplitude Env}
xywh {0 0 205 70} box PLASTIC_UP_BOX color 223 labelfont 1 labelsize 10 align 17 resizable
} {
Fl_Box freeeditsmall {
label Envelope
callback {envfree->redraw();}
xywh {5 20 195 45} box FLAT_BOX color 0 resizable
code0 {o->init(env, npart, kititem, engine, group);}
class EnvelopeFreeEdit
}
Fl_Button {} {
label E
callback {freemodeeditwindow->show();
send_data(group, 24, o->value(), 0xc0);}
xywh {185 5 15 15} box PLASTIC_UP_BOX labelfont 1 labelsize 10
}
Fl_Button {} {
label C
callback {synth->getGuiMaster()->getPresetsUi()->copy(env);}
xywh {150 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 7
}
Fl_Button {} {
label P
callback {synth->getGuiMaster()->getPresetsUi()->paste(env,this);}
xywh {167 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 7
}
}
}
}
Function {send_data(int group, int control, float value, int type, int par2 = 255)} {} {
code {//
int insert = 2;
if (par2 != 255)
insert = 3;
collect_data(synth, value, (Fl::event_button() | type), control, npart, kititem, engine, insert, group, par2);} {}
}
Function {returns_update(CommandBlock *getData)} {} {
code {//
float value = getData->data.value;
//unsigned char type = getData->data.type;
unsigned char control = getData->data.control;
unsigned char part = getData->data.part;
unsigned char eng = getData->data.engine;
unsigned char insert = getData->data.insert;
unsigned char par = getData->data.parameter;
if (part != npart || (eng >= 128 && eng != engine))
return;
if (insert ==3 && insert == 4)
{
Fl::check();
return;
}
switch(control)
{
case 0:
switch (par)
{
case 1:
e2aval->value(value);
break;
case 2:
e3aval->value(value);
break;
case 3:
e4aval->value(value);
break;
}
break;
case 1:
switch (par)
{
case 0:
e1adt->value(value);
break;
case 1:
e2adt->value(value);
break;
case 2:
e3adt->value(value);
break;
case 3:
e4adt->value(value);
break;
}
break;
case 2:
if (par == 2)
e3dval->value(value);
break;
case 3:
switch (par)
{
case 0:
e1ddt->value(value);
break;
case 2:
e3ddt->value(value);
break;
}
break;
case 4:
if (par == 0)
e1sval->value(value);
break;
case 5:
switch (par)
{
case 0:
e1rdt->value(value);
break;
case 1:
e2rdt->value(value);
break;
case 2:
e3rdt->value(value);
break;
case 3:
e4rdt->value(value);
break;
}
break;
case 6:
switch (par)
{
case 1:
e2rval->value(value);
break;
case 2:
e3rval->value(value);
break;
case 3:
e4rval->value(value);
break;
}
break;
case 7:
switch (par)
{
case 0:
e1envstretch->value(value);
break;
case 1:
e2envstretch->value(value);
break;
case 2:
e3envstretch->value(value);
break;
case 3:
e4envstretch->value(value);
break;
}
break;
case 16:
switch (par)
{
case 0:
e1forcedrelease->value(value != 0);
break;
case 1:
e2forcedrelease->value(value != 0);
break;
case 2:
e3forcedrelease->value(value != 0);
break;
case 3:
e4forcedrelease->value(value != 0);
break;
}
break;
case 17:
if (par == 0)
e1linearenvelope->value(value != 0);
break;
case 32:
freemodebutton->value(value != 0); // not working :(
reinit();
freeedit->lastpoint=-1;
freeedit->redraw();
freemodebutton->value(value != 0);
break;
}
Fl::check();} {}
}
Function {init(EnvelopeParams *env_, int npart_, int kititem_, int engine_, int group_)} {} {