summaryrefslogtreecommitdiff
path: root/muse_qt4_evolution/synti/zynaddsubfx/UI/PADnoteUI.fl
blob: 45c1f9a858742edbe46f18f8cfe567652bb31fb6 (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
# data file for the Fltk User Interface Designer (fluid)
version 1.0106 
header_name {.h} 
code_name {.cc}
decl {\#include "../Params/PADnoteParameters.h"} {public
} 

decl {\#include "../Misc/Util.h"} {public
} 

decl {\#include "../Misc/Master.h"} {public
} 

decl {\#include "ResonanceUI.h"} {public
} 

decl {\#include <FL/Fl_Box.H>} {public
} 

decl {\#include <FL/Fl_Group.H>} {public
} 

decl {\#include <math.h>} {} 

decl {\#include <stdio.h>} {} 

decl {\#include <stdlib.h>} {} 

decl {\#include <string.h>} {} 

decl {\#include "WidgetPDial.h"} {public
} 

decl {\#include "EnvelopeUI.h"} {public
} 

decl {\#include "LFOUI.h"} {public
} 

decl {\#include "FilterUI.h"} {public
} 

decl {\#include "OscilGenUI.h"} {public
} 

decl {\#include "PresetsUI.h"} {public
} 

class PADnoteHarmonicProfile {: {public Fl_Box}
} {
  Function {PADnoteHarmonicProfile(int x,int y, int w, int h, const char *label=0):Fl_Box(x,y,w,h,label)} {} {
    code {pars=NULL;} {}
  }
  Function {init(PADnoteParameters *pars,Master *master_)} {} {
    code {master=master_;
this->pars=pars;} {}
  }
  Function {draw()} {} {
    code {int ox=x(),oy=y(),lx=w(),ly=h();
if (!visible()) return;
REALTYPE smps[lx];

REALTYPE realbw=pars->getprofile(smps,lx);
bool active=active_r();

//draw the equivalent bandwidth
if (active) fl_color(220,220,220);
 else fl_color(160,165,165);
fl_line_style(0);
int rbw=(int)(realbw*(lx-1.0)/2.0);
for (int i=lx/2-rbw;i<(lx/2+rbw);i++) fl_line(ox+i,oy,ox+i,oy+ly-1);

fl_line_style(0);
if (active) fl_color(200,200,200);
 else  fl_color(160,160,160);
for (int i=1;i<10;i++){
	int kx=(int)(lx/10.0*i);
	fl_line(ox+kx,oy,ox+kx,oy+ly-1);
};
for (int i=1;i<5;i++){
	int ky=(int)(ly/5.0*i);
	fl_line(ox,oy+ly-ky,ox+lx,oy+ly-ky-1);
};


fl_color(120,120,120);
fl_line_style(FL_DOT);
fl_line(ox+lx/2,oy,ox+lx/2,oy+ly);

//draw the graph
fl_line_style(0);
int old=0;
for (int i=0;i<lx;i++){
   int val=(int) ((ly-2)*smps[i]);
   if (active) fl_color(180,210,240);
      else fl_color(150,150,155);
   fl_line(ox+i,oy+ly-1,ox+i,oy+ly-1-val);
   if (active) fl_color(0,0,100);
       else fl_color(150,150,150);
   if (i>0) fl_line(ox+i-1,oy+ly-2-old,ox+i,oy+ly-2-val);
   old=val;   
};


fl_line_style(FL_DASH);
if (active) fl_color(0,100,220);
    else fl_color(150,160,170);
fl_line(ox+lx/2-rbw,oy,ox+lx/2-rbw,oy+ly-1);
fl_line(ox+lx/2+rbw,oy,ox+lx/2+rbw,oy+ly-1);

fl_line_style(0);} {}
  }
  decl {Master *master;} {}
  decl {PADnoteParameters *pars;} {public
  }
} 

class PADnoteOvertonePosition {: {public Fl_Box}
} {
  Function {PADnoteOvertonePosition(int x,int y, int w, int h, const char *label=0):Fl_Box(x,y,w,h,label)} {} {
    code {pars=NULL;} {}
  }
  Function {init(PADnoteParameters *pars,Master *master_)} {} {
    code {master=master_;
this->pars=pars;} {}
  }
  Function {draw()} {} {
    code {if (!visible()) return;
const int maxdb=60;

int ox=x(),oy=y(),lx=w(),ly=h();
const int maxharmonic=64;


for (int i=1;i<maxharmonic;i++){
	fl_color(200,200,200);
	fl_line_style(FL_DOT);
	if (i%5==0) fl_line_style(0);
	if (i%10==0) fl_color(160,160,160);
	int kx=(int)(lx/(REALTYPE)maxharmonic*i);
	fl_line(ox+kx,oy,ox+kx,oy+ly);
};



int n=OSCIL_SIZE/2;
REALTYPE spc[n];
for (int i=0;i<n;i++) spc[i]=0.0;

master->busy=true;
pars->oscilgen->getspectrum(n,spc,0);
master->busy=false;


//normalize
REALTYPE max=0;
for (int i=0;i<n;i++){
   REALTYPE x=fabs(spc[i]);
   if (max<x) max=x;
}
if (max<0.000001) max=1.0;
max=max*1.05;

REALTYPE spectrum[lx];
for (int i=0;i<lx;i++) spectrum[i]=0;


for (int i=1;i<n;i++){
	REALTYPE nhr=pars->getNhr(i);
	int kx=(int)(lx/(REALTYPE)maxharmonic*nhr);
	if ((kx<0)||(kx>lx)) continue;

        spectrum[kx]=spc[i-1]/max+1e-9;

};

fl_color(180,0,0);
fl_line_style(0);

if (pars->Pmode==2){
   int old=0;
   for (int i=1;i<lx;i++){
	if ((spectrum[i]>1e-10)||(i==(lx-1))){
		int delta=i-old;
		REALTYPE val1=spectrum[old];
		REALTYPE val2=spectrum[i];

		REALTYPE idelta=1.0/delta;
		for (int j=0;j<delta;j++){
			REALTYPE x=idelta*j;
			spectrum[old+j]=val1*(1.0-x)+val2*x;
		};
		old=i;
	};
      
   };
};

for (int i=0;i<lx;i++){
	REALTYPE x=spectrum[i];
        if (x>dB2rap(-maxdb)) x=rap2dB(x)/maxdb+1;
             else continue;
       	int yy=(int)(x*ly);
	fl_line(ox+i,oy+ly-1-yy,ox+i,oy+ly-1);
      
};} {}
  }
  decl {Master *master;} {}
  decl {PADnoteParameters *pars;} {public
  }
} 

class PADnoteUI {open : {public PresetsUI_}
} {
  Function {PADnoteUI(PADnoteParameters *parameters,Master *master_)} {open
  } {
    code {pars=parameters;
master=master_;
oscui=NULL;
resui=new ResonanceUI(pars->resonance);
make_window();} {}
  }
  Function {make_window()} {open
  } {
    Fl_Window padnotewindow {
      label {PAD synth Parameters} selected
      xywh {76 165 535 450} type Double hide
    } {
      Fl_Tabs {} {
        callback {if (o->value()!=harmonicstructuregroup) applybutton->hide();
	else applybutton->show();}
        xywh {0 0 535 395}
      } {
        Fl_Group harmonicstructuregroup {
          label {Harmonic Structure}
          xywh {0 20 535 375} box ENGRAVED_BOX
        } {
          Fl_Group bwprofilegroup {
            xywh {5 30 90 260} box ENGRAVED_BOX
            code0 {if (pars->Pmode!=0) o->deactivate();}
          } {
            Fl_Dial hpbasepar1 {
              label Width
              callback {pars->Php.base.par1=(int) o->value();
hprofile->redraw();
cbwidget->do_callback();}
              xywh {20 75 25 25} box ROUND_UP_BOX labelsize 11 align 1 maximum 127 step 1
              code0 {o->value(pars->Php.base.par1);}
              class WidgetPDial
            }
            Fl_Choice hpbasetype {
              label {Base Type}
              callback {pars->Php.base.type=o->value();
hprofile->redraw();
cbwidget->do_callback();}
              xywh {15 45 75 15} down_box BORDER_BOX labelsize 10 align 5 textsize 10
              code0 {o->value(pars->Php.base.type);}
            } {
              menuitem {} {
                label Gauss
                xywh {15 15 100 20} labelfont 1 labelsize 10
              }
              menuitem {} {
                label Square
                xywh {25 25 100 20} labelfont 1 labelsize 10
              }
              menuitem {} {
                label DoubleExp
                xywh {35 35 100 20} labelfont 1 labelsize 10
              }
            }
            Fl_Dial hpfreqmult {
              label FreqMlt
              callback {pars->Php.freqmult=(int) o->value();
hprofile->redraw();
cbwidget->do_callback();}
              xywh {55 75 25 25} box ROUND_UP_BOX labelsize 11 align 1 maximum 127 step 1
              code0 {o->value(pars->Php.freqmult);}
              class WidgetPDial
            }
            Fl_Dial hpmpar1 {
              label Str
              callback {pars->Php.modulator.par1=(int) o->value();
hprofile->redraw();
cbwidget->do_callback();}
              xywh {15 115 20 20} box ROUND_UP_BOX labelsize 11 align 1 maximum 127 step 1
              code0 {o->value(pars->Php.modulator.par1);}
              class WidgetPDial
            }
            Fl_Dial hpmfreq {
              label SFreq
              callback {pars->Php.modulator.freq=(int) o->value();
hprofile->redraw();
cbwidget->do_callback();}
              xywh {40 115 20 20} box ROUND_UP_BOX labelsize 11 align 1 maximum 127 step 1
              code0 {o->value(pars->Php.modulator.freq);}
              class WidgetPDial
            }
            Fl_Group {} {
              xywh {10 160 80 105} box BORDER_BOX
            } {
              Fl_Choice hpamptype {
                label AmpMultiplier
                callback {pars->Php.amp.type=o->value();
hprofile->redraw();
cbwidget->do_callback();}
                xywh {15 175 70 15} down_box BORDER_BOX labelsize 10 align 5 textsize 10
                code0 {o->value(pars->Php.amp.type);}
              } {
                menuitem {} {
                  label OFF
                  xywh {45 45 100 20} labelfont 1 labelsize 10
                }
                menuitem {} {
                  label Gauss
                  xywh {55 55 100 20} labelfont 1 labelsize 10
                }
                menuitem {} {
                  label Sine
                  xywh {65 65 100 20} labelfont 1 labelsize 10
                }
                menuitem {} {
                  label Flat
                  xywh {75 75 100 20} labelfont 1 labelsize 10
                }
              }
              Fl_Choice hpampmode {
                label AmpMode
                callback {pars->Php.amp.mode=o->value();
hprofile->redraw();
cbwidget->do_callback();}
                xywh {15 205 70 15} down_box BORDER_BOX labelsize 10 align 5 textsize 10
                code0 {o->value(pars->Php.amp.mode);}
              } {
                menuitem {} {
                  label Sum
                  xywh {60 60 100 20} labelfont 1 labelsize 10
                }
                menuitem {} {
                  label Mult
                  xywh {70 70 100 20} labelfont 1 labelsize 10
                }
                menuitem {} {
                  label Div1
                  xywh {80 80 100 20} labelfont 1 labelsize 10
                }
                menuitem {} {
                  label Div2
                  xywh {90 90 100 20} labelfont 1 labelsize 10
                }
              }
              Fl_Dial hpamppar1 {
                label Par1
                callback {pars->Php.amp.par1=(int) o->value();
hprofile->redraw();
cbwidget->do_callback();}
                xywh {15 235 25 25} box ROUND_UP_BOX labelsize 11 align 1 maximum 127 step 1
                code0 {o->value(pars->Php.amp.par1);}
                class WidgetPDial
              }
              Fl_Dial hpamppar2 {
                label Par2
                callback {pars->Php.amp.par2=(int) o->value();
hprofile->redraw();
cbwidget->do_callback();}
                xywh {55 235 25 25} box ROUND_UP_BOX labelsize 11 align 1 maximum 127 step 1
                code0 {o->value(pars->Php.amp.par2);}
                class WidgetPDial
              }
            }
            Fl_Check_Button hpautoscale {
              label autoscale
              callback {pars->Php.autoscale=(int) o->value();
hprofile->redraw();
cbwidget->do_callback();}
              xywh {10 270 60 15} down_box DOWN_BOX labelsize 10
              code0 {o->value(pars->Php.autoscale);}
            }
            Fl_Choice hponehalf {
              callback {pars->Php.onehalf=o->value();
hprofile->redraw();
cbwidget->do_callback();}
              xywh {10 143 80 15} down_box BORDER_BOX labelsize 10 align 5 textsize 10
              code0 {o->value(pars->Php.onehalf);}
            } {
              menuitem {} {
                label Full
                xywh {25 25 100 20} labelfont 1 labelsize 10
              }
              menuitem {} {
                label {Upper Half}
                xywh {45 45 100 20} labelfont 1 labelsize 10
              }
              menuitem {} {
                label {Lower Half}
                xywh {35 35 100 20} labelfont 1 labelsize 10
              }
            }
            Fl_Dial hpwidth {
              label Size
              callback {pars->Php.width=(int) o->value();
hprofile->redraw();
cbwidget->do_callback();}
              xywh {65 115 20 20} box ROUND_UP_BOX labelsize 11 align 1 maximum 127 step 1
              code0 {o->value(pars->Php.width);}
              class WidgetPDial
            }
          }
          Fl_Group {} {
            xywh {100 155 270 135} box THIN_DOWN_BOX color 32 selection_color 71 labelcolor 179 align 6
            code0 {osc=new Oscilloscope(o->x(),o->y(),o->w(),o->h(),"");}
            code1 {osc->init(pars->oscilgen,master);}
          } {}
          Fl_Button {} {
            label Change
            callback {if (oscui!=NULL) delete (oscui);
oscui=new OscilEditor(pars->oscilgen,osc,cbwidget,applybutton,master);}
            xywh {375 270 60 20} box THIN_UP_BOX labelfont 1 labelsize 12
          }
          Fl_Box cbwidget {
            label {Harmonic Content}
            callback {overtonepos->redraw();
applybutton->color(FL_RED);
applybutton->redraw();}
            xywh {125 135 205 20} align 16
          }
          Fl_Button {} {
            label Resonance
            callback {resui->resonancewindow->redraw();
resui->resonancewindow->show();
resui->setcbwidget(cbwidget,applybutton);}
            xywh {375 225 80 20} box THIN_UP_BOX
          }
          Fl_Dial bwdial {
            label BandWidth
            callback {bwcents->value(pars->setPbandwidth((int) o->value()));
cbwidget->do_callback();}
            xywh {15 295 35 35} box ROUND_UP_BOX labelsize 11 maximum 1000 step 1
            code0 {o->value(pars->Pbandwidth);}
            code1 {if (pars->Pmode!=0) o->deactivate();}
            class WidgetPDial
          }
          Fl_Value_Output bwcents {
            label cents
            xywh {55 305 55 15} labelsize 10 align 6 maximum 10000 step 0.1
            code0 {o->value(pars->setPbandwidth(pars->Pbandwidth));}
            code1 {if (pars->Pmode!=0) o->deactivate();}
          }
          Fl_Group {} {
            xywh {315 295 215 45} box ENGRAVED_BOX
          } {
            Fl_Choice hrpostype {
              label OvertonesPosition
              callback {pars->Phrpos.type=o->value();
overtonepos->redraw();
cbwidget->do_callback();}
              xywh {325 310 80 20} down_box BORDER_BOX labelsize 10 align 5 textsize 12
              code0 {o->value(pars->Phrpos.type);}
            } {
              menuitem {} {
                label Harmonic
                xywh {70 70 100 20} labelfont 1 labelsize 12
              }
              menuitem {} {
                label ShiftU
                xywh {80 80 100 20} labelfont 1 labelsize 12
              }
              menuitem {} {
                label ShiftL
                xywh {90 90 100 20} labelfont 1 labelsize 12
              }
              menuitem {} {
                label PowerU
                xywh {90 90 100 20} labelfont 1 labelsize 12
              }
              menuitem {} {
                label PowerL
                xywh {100 100 100 20} labelfont 1 labelsize 12
              }
              menuitem {} {
                label Sine
                xywh {110 110 100 20} labelfont 1 labelsize 12
              }
              menuitem {} {
                label Power
                xywh {120 120 100 20} labelfont 1 labelsize 12
              }
            }
            Fl_Dial hrpospar1 {
              label Par1
              callback {pars->Phrpos.par1=(int) o->value();
overtonepos->redraw();
cbwidget->do_callback();}
              xywh {425 310 25 25} box ROUND_UP_BOX labelsize 11 align 1 maximum 255 step 1
              code0 {o->value(pars->Phrpos.par1);}
              class WidgetPDial
            }
            Fl_Dial hrpospar2 {
              label Par2
              callback {pars->Phrpos.par2=(int) o->value();
overtonepos->redraw();
cbwidget->do_callback();}
              xywh {460 310 25 25} box ROUND_UP_BOX labelsize 11 align 1 maximum 255 step 1
              code0 {o->value(pars->Phrpos.par2);}
              class WidgetPDial
            }
            Fl_Dial hrpospar3 {
              label ForceH
              callback {pars->Phrpos.par3=(int) o->value();
overtonepos->redraw();
cbwidget->do_callback();}
              xywh {495 310 25 25} box ROUND_UP_BOX labelsize 11 align 1 maximum 255 step 1
              code0 {o->value(pars->Phrpos.par3);}
              class WidgetPDial
            }
          }
          Fl_Choice bwscale {
            label {Bandwidth Scale}
            callback {pars->Pbwscale=(int) o->value();
cbwidget->do_callback();}
            xywh {120 305 80 20} down_box BORDER_BOX labelsize 10 align 5 textsize 12
            code0 {o->value(pars->Pbwscale);}
            code1 {if (pars->Pmode!=0) o->deactivate();}
          } {
            menuitem {} {
              label Normal
              xywh {95 95 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label EqualHz
              xywh {105 105 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label Quater
              xywh {115 115 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label Half
              xywh {125 125 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label {75%}
              xywh {135 135 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label {150%}
              xywh {145 145 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label Double
              xywh {145 145 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label {Inv.Half}
              xywh {155 155 100 20} labelfont 1 labelsize 12
            }
          }
          Fl_Group overtonepos {
            xywh {5 345 525 45} box FLAT_BOX color 54 selection_color 218 labelcolor 63
            code0 {PADnoteOvertonePosition *opui=new PADnoteOvertonePosition(o->x(),o->y(),o->w(),o->h(),"");}
            code1 {opui->init(pars,master);}
          } {}
          Fl_Choice qsamplesize {
            label {Sample Size}
            callback {pars->Pquality.samplesize=(int) o->value();
cbwidget->do_callback();}
            xywh {375 190 115 20} down_box BORDER_BOX labelsize 10 align 5 textsize 12
            code0 {o->value(pars->Pquality.samplesize);}
          } {
            menuitem {} {
              label {16k (Tiny)}
              xywh {155 155 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label 32k
              xywh {165 165 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label {64k (Small)}
              xywh {175 175 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label 128k
              xywh {185 185 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label {256k (Normal)}
              xywh {205 205 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label 512k
              xywh {200 200 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label {1M (Big)}
              xywh {205 205 100 20} labelfont 1 labelsize 12
            }
          }
          Fl_Choice qsmpoct {
            label {smp/oct}
            callback {pars->Pquality.smpoct=(int) o->value();
cbwidget->do_callback();}
            xywh {430 155 45 20} down_box BORDER_BOX labelsize 12 align 5 textsize 12
            code0 {o->value(pars->Pquality.smpoct);}
          } {
            menuitem {} {
              label {0.5}
              xywh {10 10 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label 1
              xywh {0 0 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label 2
              xywh {10 10 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label 3
              xywh {20 20 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label 4
              xywh {30 30 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label 6
              xywh {40 40 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label 12
              xywh {50 50 100 20} labelfont 1 labelsize 12
            }
          }
          Fl_Choice qoct {
            label {no.oct}
            callback {pars->Pquality.oct=(int) o->value();
cbwidget->do_callback();}
            xywh {480 155 45 20} down_box BORDER_BOX labelsize 12 align 5 textsize 12
            code0 {o->value(pars->Pquality.oct);}
          } {
            menuitem {} {
              label 1
              xywh {10 10 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label 2
              xywh {20 20 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label 3
              xywh {30 30 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label 4
              xywh {40 40 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label 5
              xywh {50 50 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label 6
              xywh {60 60 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label 7
              xywh {70 70 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label 8
              xywh {80 80 100 20} labelfont 1 labelsize 12
            }
          }
          Fl_Choice qbasenote {
            label base
            callback {pars->Pquality.basenote=(int) o->value();
cbwidget->do_callback();}
            xywh {375 155 50 20} down_box BORDER_BOX labelsize 12 align 5 textsize 12
            code0 {o->value(pars->Pquality.basenote);}
          } {
            menuitem {} {
              label {C-2}
              xywh {10 10 100 20} labelfont 1
            }
            menuitem {} {
              label {G-2}
              xywh {20 20 100 20} labelfont 1
            }
            menuitem {} {
              label {C-3}
              xywh {20 20 100 20} labelfont 1
            }
            menuitem {} {
              label {G-3}
              xywh {30 30 100 20} labelfont 1
            }
            menuitem {} {
              label {C-4}
              xywh {30 30 100 20} labelfont 1
            }
            menuitem {} {
              label {G-4}
              xywh {40 40 100 20} labelfont 1
            }
            menuitem {} {
              label {C-5}
              xywh {40 40 100 20} labelfont 1
            }
            menuitem {} {
              label {G-5}
              xywh {50 50 100 20} labelfont 1
            }
            menuitem {} {
              label {G-6}
              xywh {60 60 100 20} labelfont 1
            }
          }
          Fl_Group hprofile {
            xywh {100 45 430 90} box FLAT_BOX color 54 selection_color 218 labelcolor 63
            code0 {PADnoteHarmonicProfile *hpui=new PADnoteHarmonicProfile(o->x(),o->y(),o->w(),o->h(),"");}
            code1 {hpui->init(pars,master);}
            code2 {if (pars->Pmode!=0) { o->deactivate(); o->color(48);};}
          } {}
          Fl_Box {} {
            label {Profile of One Harmonic (Frequency Distribution)}
            xywh {160 25 315 20}
          }
          Fl_Choice spectrummode {
            label {Spectrum Mode}
            callback {pars->Pmode=(int) o->value();

if (pars->Pmode==0){
   bwprofilegroup->activate();
   bwdial->activate();
   bwcents->activate();
   hprofile->activate();
   hprofile->color(54);
   bwscale->activate();
} else {
   bwprofilegroup->deactivate();
   bwdial->deactivate();
   bwcents->deactivate();
   hprofile->deactivate();
   hprofile->color(48);
   bwscale->deactivate();
};

cbwidget->do_callback();}
            xywh {220 305 90 20} down_box BORDER_BOX labelfont 1 labelsize 10 labelcolor 0 align 5 textsize 12
            code0 {o->value(pars->Pmode);}
          } {
            menuitem {} {
              label Bandwidth
              xywh {105 105 100 20} labelfont 1 labelsize 12
            }
            menuitem {} {
              label Discrete
              xywh {125 125 100 20} labelfont 1 labelsize 12 labelcolor 0
            }
            menuitem {} {
              label Continous
              xywh {115 115 100 20} labelfont 1 labelsize 12 labelcolor 0
            }
          }
        }
        Fl_Group {} {
          label {Envelopes&LFOs}
          xywh {0 20 535 375} box ENGRAVED_BOX hide
        } {
          Fl_Group {} {
            label FREQUENCY
            xywh {5 275 525 115} box THIN_UP_BOX labeltype EMBOSSED_LABEL labelfont 1 labelsize 16 align 17
          } {
            Fl_Group freqenv {
              label {PADSynth - Frequency Envelope} open
              xywh {10 315 205 70} box FLAT_BOX color 51 align 144
              code0 {o->init(pars->FreqEnvelope);}
              class EnvelopeUI
            } {}
            Fl_Counter octave {
              label Octave
              callback {int k=(int) o->value();
if (k<0) k+=16;
pars->PCoarseDetune = k*1024+
   pars->PCoarseDetune%1024;}
              tooltip Octave xywh {470 295 45 15} type Simple labelsize 10 align 1 minimum -8 maximum 7 step 1 textfont 1 textsize 12
              code0 {int k=pars->PCoarseDetune/1024;}
              code1 {if (k>=8) k-=16;}
              code2 {o->value(k);}
            }
            Fl_Counter coarsedet {
              label {Coarse det.}
              callback {int k=(int) o->value();
if (k<0) k+=1024;
pars->PCoarseDetune = k+
   (pars->PCoarseDetune/1024)*1024;}
              tooltip {Coarse Detune} xywh {455 365 60 20} labelsize 10 align 5 minimum -64 maximum 63 step 1 textfont 1 textsize 12
              code0 {int k=pars->PCoarseDetune%1024;}
              code1 {if (k>=512) k-=1024;}
              code2 {o->value(k);}
              code3 {o->lstep(10);}
            }
            Fl_Group freqlfo {
              label {Frequency LFO     } open
              xywh {215 315 230 70} box FLAT_BOX color 47 align 144
              code0 {o->init(pars->FreqLfo);}
              class LFOUI
            } {}
            Fl_Slider detune {
              callback {pars->PDetune=(int)o->value()+8192;
detunevalueoutput->do_callback();}
              tooltip {Fine Detune (cents)} xywh {60 295 295 15} type {Horz Knob} box FLAT_BOX minimum -8192 maximum 8191 step 1
              code0 {o->value(pars->PDetune-8192);}
            }
            Fl_Value_Output detunevalueoutput {
              label Detune
              callback {o->value(getdetune(pars->PDetuneType,0,pars->PDetune));}
              xywh {12 295 45 15} labelsize 10 align 5 minimum -5000 maximum 5000 step 0.01 textfont 1 textsize 10
              code0 {o->value(getdetune(pars->PDetuneType,0,pars->PDetune));}
            }
            Fl_Choice detunetype {
              label {Detune Type}
              callback {pars->PDetuneType=(int) o->value()+1;
detunevalueoutput->do_callback();} open
              xywh {450 335 75 15} down_box BORDER_BOX labelsize 10 align 5 textfont 1 textsize 10
              code0 {o->add("L35cents");o->add("L10cents");o->add("E100cents");o->add("E1200cents");}
              code1 {o->value(pars->PDetuneType-1);}
            } {}
            Fl_Check_Button hz440 {
              label 440Hz
              callback {int x=(int) o->value();
pars->Pfixedfreq=x;
if (x==0) fixedfreqetdial->deactivate();
   else fixedfreqetdial->activate();}
              tooltip {set the base frequency to 440Hz} xywh {365 295 50 15} down_box DOWN_BOX labelfont 1 labelsize 11
              code0 {o->value(pars->Pfixedfreq);}
            }
            Fl_Dial fixedfreqetdial {
              label {Eq.T.}
              callback {pars->PfixedfreqET=(int) o->value();}
              tooltip {How the frequency varies acording to the keyboard (leftmost for fixed frequency)} xywh {420 295 15 15} box ROUND_UP_BOX labelsize 10 align 8 maximum 127 step 1
              code0 {o->value(pars->PfixedfreqET);}
              code1 {if (pars->Pfixedfreq==0) o->deactivate();}
              class WidgetPDial
            }
          }
          Fl_Group {} {
            label AMPLITUDE
            xywh {5 25 240 250} box THIN_UP_FRAME labeltype EMBOSSED_LABEL labelfont 1 labelsize 16 align 17
          } {
            Fl_Value_Slider volume {
              label Vol
              callback {pars->PVolume=(int)o->value();}
              tooltip Volume xywh {10 50 160 15} type {Horz Knob} box FLAT_BOX labelsize 12 align 8 maximum 127 step 1
              code0 {o->value(pars->PVolume);}
            }
            Fl_Value_Slider vsns {
              label {V.Sns}
              callback {pars->PAmpVelocityScaleFunction=(int) o->value();}
              tooltip {Velocity Sensing Function (rightmost to disable)} xywh {10 70 160 15} type {Horz Knob} box FLAT_BOX labelsize 12 align 8 maximum 127 step 1
              code0 {o->value(pars->PAmpVelocityScaleFunction);}
            }
            Fl_Dial pan {
              label Pan
              callback {pars->PPanning=(int) o->value();}
              tooltip {Panning (leftmost is Random)} xywh {210 45 30 30} box ROUND_UP_BOX labelsize 11 maximum 127 step 1
              code0 {o->value(pars->PPanning);}
              class WidgetPDial
            }
            Fl_Dial pstr {
              label {P.Str.}
              callback {pars->PPunchStrength=(int) o->value();}
              tooltip {Punch Strength} xywh {125 247 25 25} box ROUND_UP_BOX labelsize 11 align 1 maximum 127 step 1
              code0 {o->value(pars->PPunchStrength);}
              class WidgetPDial
            }
            Fl_Dial pt {
              label {P.t.}
              callback {pars->PPunchTime=(int) o->value();}
              tooltip {Punch Time (duration)} xywh {155 247 25 25} box ROUND_UP_BOX labelsize 11 align 1 maximum 127 step 1
              code0 {o->value(pars->PPunchTime);}
              class WidgetPDial
            }
            Fl_Dial pstc {
              label {P.Stc.}
              callback {pars->PPunchStretch=(int) o->value();}
              tooltip {Punch Stretch} xywh {185 247 25 25} box ROUND_UP_BOX labelsize 11 align 1 maximum 127 step 1
              code0 {o->value(pars->PPunchStretch);}
              class WidgetPDial
            }
            Fl_Dial pvel {
              label {P.Vel.}
              callback {pars->PPunchVelocitySensing=(int) o->value();}
              tooltip {Punch Velocity Sensing} xywh {215 247 25 25} box ROUND_UP_BOX labelsize 11 align 1 maximum 127 step 1
              code0 {o->value(pars->PPunchVelocitySensing);}
              class WidgetPDial
            }
            Fl_Group ampenv {
              label {PADSynth - Amplitude Envelope} open
              xywh {10 95 205 70} box FLAT_BOX color 51 align 144
              code0 {o->init(pars->AmpEnvelope);}
              class EnvelopeUI
            } {}
            Fl_Group amplfo {
              label {Amplitude LFO     } open
              xywh {10 165 230 70} box FLAT_BOX color 47 align 144
              code0 {o->init(pars->AmpLfo);}
              class LFOUI
            } {}
            Fl_Check_Button stereo {
              label Stereo
              callback {pars->PStereo=(int) o->value();
hprofile->redraw();}
              xywh {15 245 70 25} down_box DOWN_BOX
              code0 {o->value(pars->PStereo);}
            }
          }
          Fl_Group {} {
            label FILTER
            xywh {245 25 285 250} box THIN_UP_BOX labeltype EMBOSSED_LABEL labelfont 1 labelsize 16 align 17
          } {
            Fl_Group filterenv {
              label {PADSynth - Filter Envelope} open
              xywh {250 130 275 70} box FLAT_BOX color 51 align 144
              code0 {o->init(pars->FilterEnvelope);}
              class EnvelopeUI
            } {}
            Fl_Group filterlfo {
              label {Filter LFO     } open
              xywh {250 200 230 70} box FLAT_BOX color 47 align 144
              code0 {o->init(pars->FilterLfo);}
              class LFOUI
            } {}
            Fl_Group filterui {
              label {PADsynth - Filter} open
              xywh {250 55 275 75} box FLAT_BOX color 50 align 144
              code0 {o->init(pars->GlobalFilter,&pars->PFilterVelocityScale,&pars->PFilterVelocityScaleFunction);}
              class FilterUI
            } {}
          }
        }
      }
      Fl_Button applybutton {
        label {Apply Changes}
        callback {pars->applyparameters(true);
o->color(FL_GRAY);
if (oscui!=NULL) {
	oscui->applybutton->color(FL_GRAY);
	oscui->applybutton->redraw();
};
if (resui!=NULL) {
	resui->applybutton->color(FL_GRAY);
	resui->applybutton->redraw();
};}
        xywh {45 405 185 40} box THIN_UP_BOX labelfont 1 labelsize 23
        code0 {o->color(FL_RED);}
      }
      Fl_Button {} {
        label Close
        callback {padnotewindow->hide();}
        xywh {320 405 175 40} box THIN_UP_BOX labelsize 20
      }
      Fl_Button {} {
        label C
        callback {presetsui->copy(pars);}
        xywh {240 430 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 12 labelcolor 7
      }
      Fl_Button {} {
        label P
        callback {presetsui->paste(pars,this);}
        xywh {270 430 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 12 labelcolor 7
      }
    }
  }
  Function {refresh()} {} {
    code {volume->value(pars->PVolume);
vsns->value(pars->PAmpVelocityScaleFunction);
pan->value(pars->PPanning);

stereo->value(pars->PStereo);


pstr->value(pars->PPunchStrength);
pt->value(pars->PPunchTime);
pstc->value(pars->PPunchStretch);
pvel->value(pars->PPunchVelocitySensing);

detunevalueoutput->value(getdetune(pars->PDetuneType,0,pars->PDetune));
detune->value(pars->PDetune-8192);

int k=pars->PCoarseDetune/1024;if (k>=8) k-=16;
octave->value(k);

detunetype->value(pars->PDetuneType-1);
k=pars->PCoarseDetune%1024;if (k>=512) k-=1024;
coarsedet->value(k);

hz440->value(pars->Pfixedfreq);
fixedfreqetdial->value(pars->PfixedfreqET);

amplfo->refresh();
freqlfo->refresh();
filterlfo->refresh();

ampenv->refresh();
freqenv->refresh();
filterenv->refresh();
filterui->refresh();


/* harmonic structure parametrs */

resui->refresh();
if (oscui!=NULL) oscui->refresh();

hpbasetype->value(pars->Php.base.type);
hpbasepar1->value(pars->Php.base.par1);
hpfreqmult->value(pars->Php.freqmult);

hpmpar1->value(pars->Php.modulator.par1);
hpmfreq->value(pars->Php.modulator.freq);
hpwidth->value(pars->Php.width);

hponehalf->value(pars->Php.onehalf);
hpamptype->value(pars->Php.amp.type);
hpampmode->value(pars->Php.amp.mode);
hpamppar1->value(pars->Php.amp.par1);
hpamppar2->value(pars->Php.amp.par2);
hpautoscale->value(pars->Php.autoscale);

bwdial->value(pars->Pbandwidth);
if (pars->Pmode==0){
   bwprofilegroup->activate();
   bwdial->activate();
   bwcents->activate();
   hprofile->activate();
   hprofile->color(54);
   bwscale->activate();
} else {
   bwprofilegroup->deactivate();
   bwdial->deactivate();
   bwcents->deactivate();
   hprofile->deactivate();
   hprofile->color(48);
   bwscale->activate();
};

spectrummode->value(pars->Pmode);

qbasenote->value(pars->Pquality.basenote);
qsmpoct->value(pars->Pquality.smpoct);
qoct->value(pars->Pquality.oct);
qsamplesize->value(pars->Pquality.samplesize);

hrpostype->value(pars->Phrpos.type);
hrpospar1->value(pars->Phrpos.par1);
hrpospar2->value(pars->Phrpos.par2);
hrpospar3->value(pars->Phrpos.par3);

hprofile->redraw();
overtonepos->redraw();

osc->redraw();
pars->applyparameters(true);
applybutton->color(FL_GRAY);
applybutton->parent()->redraw();} {}
  }
  Function {~PADnoteUI()} {} {
    code {delete(oscui);
delete(resui);

padnotewindow->hide();
delete(padnotewindow);} {}
  }
  decl {PADnoteParameters *pars;} {public
  }
  decl {Master *master;} {public
  }
  decl {OscilEditor *oscui;} {public
  }
  decl {Oscilloscope *osc;} {public
  }
  decl {ResonanceUI *resui;} {public
  }
}