summaryrefslogtreecommitdiff
path: root/muse_qt4_evolution/synti/zynaddsubfx/UI/OscilGenUI.fl
blob: 0bd394ece48e4b9129a3cce748ce935623945faf (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
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
# data file for the Fltk User Interface Designer (fluid)
version 1.0106 
header_name {.h} 
code_name {.cc}
decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {} 

decl {//License: GNU GPL version 2} {} 

decl {\#include "../Synth/OscilGen.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 <FL/Fl_Slider.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 "PresetsUI.h"} {public
} 

class OscilSpectrum {: {public Fl_Box}
} {
  Function {OscilSpectrum(int x,int y, int w, int h, const char *label=0):Fl_Box(x,y,w,h,label)} {} {
    code {oscil=NULL;} {}
  }
  Function {init(OscilGen *oscil_,int oscbase_,Master *master_)} {} {
    code {oscil=oscil_;
oscbase=oscbase_;
master=master_;} {}
  }
  Function {draw()} {} {
    code {int ox=x(),oy=y(),lx=w(),ly=h(),i;
const int maxdb=60;//must be multiple of 10
int GX=2;
int n=lx/GX-1;
if (n>OSCIL_SIZE/2) n=OSCIL_SIZE/2;

REALTYPE x;
REALTYPE spc[n];
for (i=0;i<n;i++) spc[i]=0.0;

master->lock();
if (oscbase==0) oscil->getspectrum(n,spc,0);
    else oscil->getspectrum(n,spc,1);
master->unlock();

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

//draw

if (this->active_r()) fl_color(this->parent()->selection_color());
    else fl_color(this->parent()->color());
fl_line_style(FL_DOT);

for (i=1;i<maxdb/10;i++){
  int ky=(int)((REALTYPE)i*ly*10.0/maxdb)/2;
  ky*=2;
  fl_line(ox,oy+ky-1,ox+lx-2,oy+ky-1);
};

for (i=2;i<n;i++){
    int tmp=i*GX-2;
    if (i%10==1) fl_line_style(0);
       else fl_line_style(FL_DOT);
    fl_line(ox+tmp,oy+2,ox+tmp,oy+ly-2);
}

if (this->active_r()) fl_color(this->parent()->labelcolor());
    else fl_color(this->parent()->color());
fl_line_style(0);

//draws the spectrum
for (i=0;i<n;i++){
   int tmp=i*GX+2;
   x=spc[i]/max;
   
   if (x>dB2rap(-maxdb)) x=rap2dB(x)/maxdb+1;
       else x=0;

   int val=(int) ((ly-2)*x);
   if (val>0) fl_line(ox+tmp,oy+ly-2-val,ox+tmp,oy+ly-2);
};} {}
  }
  decl {OscilGen *oscil;} {}
  decl {int oscbase;} {}
  decl {Master *master;} {}
} 

class PSlider {: {public Fl_Slider}
} {
  Function {PSlider(int x,int y, int w, int h, const char *label=0):Fl_Slider(x,y,w,h,label)} {} {}
  Function {handle(int event)} {return_type int
  } {
    code {int X=x(),Y=y(),W=w(),H=h();

if ((!Fl::event_buttons())|| (event==0)||(Fl::event_shift()==0)) return(Fl_Slider::handle(event));

if (!Fl::event_inside(X,Y,W,H)) {
	if (event==FL_DRAG){
		Fl_Slider::handle(FL_RELEASE);
		Fl_Slider::handle(FL_LEAVE);
		deactivate();
		activate();
		return(1);	
	}else{
		return(Fl_Slider::handle(event));
	};
} else {
	//Fl_Slider::handle(FL_FOCUS);
	Fl_Slider::handle(FL_PUSH);
};

return(1);} {}
  }
} 

class Oscilloscope {: {public Fl_Box}
} {
  Function {Oscilloscope(int x,int y, int w, int h, const char *label=0):Fl_Box(x,y,w,h,label)} {} {
    code {oscil=NULL;
phase=64;
oscbase=0;} {}
  }
  Function {init(OscilGen *oscil_,Master *master_)} {} {
    code {oscil=oscil_;
master=master_;} {}
  }
  Function {init(OscilGen *oscil_,int oscbase_,Master *master_)} {} {
    code {oscil=oscil_;
oscbase=oscbase_;
master=master_;} {}
  }
  Function {init(OscilGen *oscil_,int oscbase_,int phase_,Master *master_)} {} {
    code {oscil=oscil_;
oscbase=oscbase_;
phase=phase_;
master=master_;} {}
  }
  Function {draw()} {} {
    code {int ox=x(),oy=y(),lx=w(),ly=h()-1,i;
REALTYPE smps[OSCIL_SIZE];
master->lock();
if (oscbase==0) oscil->get(smps,-1.0);
    else oscil->getcurrentbasefunction(smps);
master->unlock();

if (damage()!=1){
 fl_color(0,0,0);
 fl_rectf(ox,oy,lx,ly);
};

//normalize
REALTYPE max=0;
for (i=0;i<OSCIL_SIZE;i++)
   if (max<fabs(smps[i])) max=fabs(smps[i]);
//fprintf(stderr,"%.4f\\n",max);
if (max<0.00001) max=1.0;
max=-max*1.05;

//draw
fl_line_style(FL_DASH);
if (this->active_r()) fl_color(this->parent()->labelcolor());
    else fl_color(this->parent()->color());
int GX=16;if (lx<GX*3) GX=-1;
for (i=1;i<GX;i++){
   int tmp=(int)(lx/(REALTYPE)GX*i);
   fl_line(ox+tmp,oy+2,ox+tmp,oy+ly-2);
};
int GY=8;if (ly<GY*3) GY=-1;
for (i=1;i<GY;i++){
   int tmp=(int)(ly/(REALTYPE)GY*i);
   fl_line(ox+2,oy+tmp,ox+lx-2,oy+tmp);
};

//draw the function
fl_line_style(0,1);
fl_line(ox+2,oy+ly/2,ox+lx-2,oy+ly/2);
if (this->active_r()) fl_color(this->parent()->selection_color());
    else fl_color(this->parent()->labelcolor());
int lw=1;
//if ((lx<135)||(ly<135)) lw=1;
fl_line_style(0,lw);
int ph=(int)((phase-64.0)/128.0*OSCIL_SIZE+OSCIL_SIZE);
for (i=1;i<lx;i++){
   int k1=(int)((REALTYPE)OSCIL_SIZE*(i-1)/lx)+ph;
   int k2=(int)((REALTYPE)OSCIL_SIZE*i/lx)+ph;
   REALTYPE y1=smps[k1%OSCIL_SIZE]/max;
   REALTYPE y2=smps[k2%OSCIL_SIZE]/max;
   fl_line(i-1+ox,(int)(y1*ly/2.0)+oy+ly/2,i+ox,(int)(y2*ly/2.0)+oy+ly/2);
};} {}
  }
  decl {OscilGen *oscil;} {}
  decl {int oscbase;} {}
  decl {int phase;} {public
  }
  decl {Master *master;} {}
} 

class Oscilharmonic {: {public Fl_Group}
} {
  Function {make_window()} {private
  } {
    Fl_Window harmonic {
      private xywh {328 166 90 225} type Double hide
      class Fl_Group
    } {
      Fl_Slider mag {
        callback {int x=64;
if (Fl::event_button3()) o->value(x);
   else x=127-(int)o->value();
if (x==64) o->selection_color(0);
    else o->selection_color(222);

master->lock();
 oscil->Phmag[n]=x;
 if (x==64) {
    oscil->Phphase[n]=64;
    phase->value(64);
 };
 oscil->prepare();
master->unlock();

display->redraw();
oldosc->redraw();
if (cbwidget!=NULL) {
	cbwidget->do_callback();
	applybutton->color(FL_RED);
	applybutton->redraw();
};}
        xywh {0 15 15 115} type {Vert Knob} box FLAT_BOX selection_color 222 labelcolor 0 maximum 127 step 1 value 64
        code0 {o->value(127-oscil->Phmag[n]);}
        code1 {if (oscil->Phmag[n]==64) o->selection_color(0);}
        class PSlider
      }
      Fl_Slider phase {
        callback {int x=64;
if (Fl::event_button3()) o->value(x);
   else x=(int)o->value();

master->lock();
 oscil->Phphase[n]=x;
 oscil->prepare();
master->unlock();

display->redraw();
oldosc->redraw();
if (cbwidget!=NULL) {
	cbwidget->do_callback();
	applybutton->color(FL_RED);
	applybutton->redraw();
};}
        xywh {0 135 15 75} type {Vert Knob} box FLAT_BOX selection_color 222 maximum 127 step 1 value 64
        code0 {o->value(oscil->Phphase[n]);}
        class PSlider
      }
      Fl_Box {} {
        xywh {15 70 5 5} box FLAT_BOX color 45
      }
      Fl_Box {} {
        xywh {15 170 5 5} box FLAT_BOX color 45
      }
      Fl_Box {} {
        label 01
        xywh {0 210 20 15} labelfont 1 labelsize 9 align 20
        code0 {char tmp[10];snprintf(tmp,10,"%d",n+1);o->label(strdup(tmp));}
      }
      Fl_Box {} {
        label 01
        xywh {0 0 20 15} labelfont 1 labelsize 9 align 20
        code0 {char tmp[10];snprintf(tmp,10,"%d",n+1);o->label(strdup(tmp));}
      }
    }
  }
  Function {Oscilharmonic(int x,int y, int w, int h, const char *label=0):Fl_Group(x,y,w,h,label)} {} {
    code {n=0;
oscil=NULL;
display=NULL;
applybutton=NULL;
cbwidget=NULL;} {}
  }
  Function {init(OscilGen *oscil_,int n_,Fl_Group *display_,Fl_Widget *oldosc_,Fl_Widget *cbwidget_,Fl_Widget *applybutton_, Master *master_)} {} {
    code {oscil=oscil_;
n=n_;
display=display_;
master=master_;
oldosc=oldosc_;
cbwidget=cbwidget_;
applybutton=applybutton_;
make_window();
end();
harmonic->show();} {}
  }
  Function {refresh()} {} {
    code {mag->value(127-oscil->Phmag[n]);
phase->value(oscil->Phphase[n]);

if (oscil->Phmag[n]==64) mag->selection_color(0);
    else mag->selection_color(222);} {}
  }
  Function {~Oscilharmonic()} {} {
    code {harmonic->hide();
//delete(harmonic);} {}
  }
  decl {OscilGen *oscil;} {}
  decl {Fl_Group *display;} {}
  decl {int n;} {}
  decl {Fl_Widget *oldosc,*cbwidget,*applybutton;} {}
  decl {Master *master;} {}
} 

class OscilEditor {: {public PresetsUI_}
} {
  Function {make_window()} {} {
    Fl_Window osceditUI {
      label {ADsynth Oscillator Editor}
      xywh {131 90 735 595} type Double hide
      code0 {if (oscil->ADvsPAD) o->label("PADsynth Harmonic Content Editor");}
    } {
      Fl_Button applybutton {
        label Apply
        callback {applybutton->color(FL_GRAY);
applybutton->redraw();
if (cbapplywidget!=NULL) {
	cbapplywidget->do_callback();
	cbapplywidget->color(FL_GRAY);
	cbapplywidget->redraw();
};} selected
        xywh {300 280 60 20} box THIN_UP_BOX labelfont 1
        code0 {if (!oscil->ADvsPAD) o->hide();}
      }
      Fl_Group oscildisplaygroup {
        xywh {5 5 360 300} box ENGRAVED_FRAME
      } {
        Fl_Group {} {open
          xywh {10 85 350 190} box THIN_DOWN_BOX color 32 selection_color 71 labelcolor 179
          code0 {Oscilloscope *osc=new Oscilloscope(o->x(),o->y(),o->w(),o->h(),"");}
          code1 {osc->init(oscil,master);}
        } {}
        Fl_Box {} {
          label Oscillator
          xywh {120 10 110 20} box FLAT_BOX labelfont 1
        }
        Fl_Value_Slider rndslider {
          label rnd
          callback {oscil->Prand=(int)o->value()+64;
oscildisplaygroup->redraw();
oldosc->redraw();}
          tooltip {Oscilator Phase Randomness: smaller than 0 is "group", larger than 0 is for each harmonic} xywh {140 285 100 10} type {Horz Knob} box FLAT_BOX labelsize 10 align 5 minimum -64 maximum 63 step 1
          code0 {if (oscil->ADvsPAD) o->hide();}
        }
        Fl_Group {} {open
          xywh {10 30 350 50} box THIN_DOWN_BOX color 32 selection_color 218 labelcolor 63
          code0 {OscilSpectrum *spc=new OscilSpectrum(o->x(),o->y(),o->w(),o->h(),"");}
          code1 {spc->init(oscil,0,master);}
        } {}
        Fl_Group {} {
          xywh {246 277 115 25} box ENGRAVED_BOX
          code0 {if (oscil->ADvsPAD) o->hide();}
        } {
          Fl_Choice hrndtype {
            label {H.rnd}
            callback {oscil->Pamprandtype=(int) o->value();}
            tooltip {Harmonic Amplitude Randomness} xywh {281 282 50 15} down_box BORDER_BOX labelsize 10 textsize 10
          } {
            menuitem {} {
              label None
              xywh {60 60 100 20} labelfont 1 labelsize 10
            }
            menuitem {} {
              label Pow
              xywh {70 70 100 20} labelfont 1 labelsize 10
            }
            menuitem {} {
              label Sin
              xywh {80 80 100 20} labelfont 1 labelsize 10
            }
          }
          Fl_Dial hrnddial {
            callback {oscil->Pamprandpower=(int) o->value();}
            tooltip {Oscillator's spectrum adjust parameter} xywh {338 280 18 18} maximum 127 step 1
            class WidgetPDial
          }
        }
      }
      Fl_Box {} {
        label {Base Func.}
        xywh {495 15 110 20} box FLAT_BOX labelfont 1
      }
      Fl_Group basefuncdisplaygroup {
        xywh {365 5 360 300} box ENGRAVED_FRAME
      } {
        Fl_Group {} {
          xywh {370 85 350 190} box THIN_DOWN_BOX color 32 selection_color 71 labelcolor 179
          code0 {Oscilloscope *osc=new Oscilloscope(o->x(),o->y(),o->w(),o->h(),"");}
          code1 {osc->init(oscil,1,master);}
        } {}
        Fl_Dial bfslider {
          callback {oscil->Pbasefuncpar=(int)o->value()+64;
basefuncdisplaygroup->redraw();
bfparval->value(oscil->Pbasefuncpar-64);

redrawoscil();}
          tooltip {Base Function Parameter} xywh {520 280 20 20} minimum -64 maximum 63 step 1
          class WidgetPDial
        }
        Fl_Choice bftype {
          label {Base.F..}
          callback {oscil->Pcurrentbasefunc=(int) o->value();

basefuncdisplaygroup->redraw();
redrawoscil();

if ((oscil->Pcurrentbasefunc==0)||(oscil->Pcurrentbasefunc==127)) basefuncmodulation->deactivate();
      else basefuncmodulation->activate();}
          xywh {370 285 90 15} down_box BORDER_BOX labelsize 10 align 5 textsize 12
        } {
          menuitem {} {
            label Sine
            xywh {10 10 100 20} labelfont 1 labelsize 12
          }
          menuitem {} {
            label Triangle
            xywh {20 20 100 20} labelfont 1 labelsize 12
          }
          menuitem {} {
            label Pulse
            xywh {30 30 100 20} labelfont 1 labelsize 12
          }
          menuitem {} {
            label Saw
            xywh {40 40 100 20} labelfont 1 labelsize 12
          }
          menuitem {} {
            label Power
            xywh {50 50 100 20} labelfont 1 labelsize 12
          }
          menuitem {} {
            label Gauss
            xywh {50 50 100 20} labelfont 1 labelsize 12
          }
          menuitem {} {
            label Diode
            xywh {60 60 100 20} labelfont 1 labelsize 12
          }
          menuitem {} {
            label AbsSine
            xywh {70 70 100 20} labelfont 1 labelsize 12
          }
          menuitem {} {
            label PulseSine
            xywh {80 80 100 20} labelfont 1 labelsize 12
          }
          menuitem {} {
            label StrchSine
            xywh {90 90 100 20} labelfont 1 labelsize 12
          }
          menuitem {} {
            label Chirp
            xywh {100 100 100 20} labelfont 1 labelsize 12
          }
          menuitem {} {
            label AbsStrSine
            xywh {102 102 100 20} labelfont 1 labelsize 12
          }
          menuitem {} {
            label Chebyshev
            xywh {112 112 100 20} labelfont 1 labelsize 12
          }
          menuitem {} {
            label Sqr
            xywh {122 122 100 20} labelfont 1 labelsize 12
          }
        }
        Fl_Box {} {
          label {Base Func.}
          xywh {480 10 110 20} box FLAT_BOX labelfont 1
        }
        Fl_Group {} {open
          xywh {370 30 350 50} box THIN_DOWN_BOX color 32 selection_color 218 labelcolor 63
          code0 {OscilSpectrum *spc=new OscilSpectrum (o->x(),o->y(),o->w(),o->h(),"");}
          code1 {spc->init(oscil,1,master);}
        } {}
        Fl_Value_Output bfparval {
          label {Par.}
          xywh {490 285 25 15} labelsize 13 minimum -63 maximum 63 step 1
        }
        Fl_Group basefuncmodulation {
          xywh {550 276 169 25} box ENGRAVED_BOX
          code0 {if ((oscil->Pcurrentbasefunc==0)||(oscil->Pcurrentbasefunc==127)) basefuncmodulation->deactivate();}
        } {
          Fl_Choice bfmodtype {
            label {B.F.Mod.}
            callback {oscil->Pbasefuncmodulation=(int) o->value();
basefuncdisplaygroup->redraw();
redrawoscil();}
            tooltip {Base function modulation} xywh {599 281 50 15} down_box BORDER_BOX labelsize 10 textsize 10
          } {
            menuitem {} {
              label None
              xywh {50 50 100 20} labelfont 1 labelsize 10
            }
            menuitem {} {
              label Rev
              xywh {60 60 100 20} labelfont 1 labelsize 10
            }
            menuitem {} {
              label Sine
              xywh {70 70 100 20} labelfont 1 labelsize 10
            }
            menuitem {} {
              label Pow
              xywh {80 80 100 20} labelfont 1 labelsize 10
            }
          }
          Fl_Dial bfmodpar1 {
            callback {oscil->Pbasefuncmodulationpar1=(int)o->value();
basefuncdisplaygroup->redraw();
redrawoscil();}
            tooltip {Oscillator's modulation parameter 1} xywh {659 281 15 15} maximum 127 step 1
            class WidgetPDial
          }
          Fl_Dial bfmodpar2 {
            callback {oscil->Pbasefuncmodulationpar2=(int)o->value();
basefuncdisplaygroup->redraw();
redrawoscil();}
            tooltip {Oscillator's modulation parameter 2} xywh {679 281 15 15} maximum 127 step 1
            class WidgetPDial
          }
          Fl_Dial bfmodpar3 {
            callback {oscil->Pbasefuncmodulationpar3=(int)o->value();
basefuncdisplaygroup->redraw();
redrawoscil();}
            tooltip {Oscillator's modulation parameter 3} xywh {699 281 15 15} maximum 127 step 1
            class WidgetPDial
          }
        }
      }
      Fl_Choice magtype {
        label {Mag.Type}
        callback {oscil->Phmagtype=(int) o->value();
basefuncdisplaygroup->redraw();

redrawoscil();}
        xywh {70 280 65 20} down_box BORDER_BOX labelsize 12 textsize 12
      } {
        menuitem {} {
          label Linear
          xywh {0 0 100 20} labelfont 1 labelsize 12
        }
        menuitem {} {
          label {-40dB}
          xywh {10 10 100 20} labelfont 1 labelsize 12
        }
        menuitem {} {
          label {-60dB}
          xywh {20 20 100 20} labelfont 1 labelsize 12
        }
        menuitem {} {
          label {-80dB}
          xywh {30 30 100 20} labelfont 1 labelsize 12
        }
        menuitem {} {
          label {-100dB}
          xywh {40 40 100 20} labelfont 1 labelsize 12
        }
      }
      Fl_Button {} {
        label {Use as base}
        callback {oscil->useasbase();
if (autoclearbutton->value()){
   for (int i=0;i<MAX_AD_HARMONICS;i++){
      h[i]->mag->value(64);
      oscil->Phmag[i]=64;
      h[i]->phase->value(64);
      oscil->Phphase[i]=64;
   };
   oscil->Phmag[0]=127;

   oscil->Pharmonicshift=0;
   harmonicshiftcounter->value(0);

   h[0]->mag->value(0);
   wshbutton->value(0);
   wshbutton->do_callback();
   fltbutton->value(0);
   fltbutton->do_callback();
   sabutton->value(0);
   sabutton->do_callback();
};

master->lock();
 for (int i=0;i<MAX_AD_HARMONICS;i++){
   if (oscil->Phmag[i]==64) h[i]->mag->selection_color(0);
      else h[i]->mag->selection_color(222);
 };
 oscil->prepare();
master->unlock();

basefuncdisplaygroup->redraw();
redrawoscil();}
        tooltip {Use this Oscillator as base function} xywh {5 313 85 20} box THIN_UP_BOX labelfont 1 labelsize 12
      }
      Fl_Button {} {
        label Close
        callback {osceditUI->hide();}
        xywh {668 565 62 25} box THIN_UP_BOX
      }
      Fl_Button {} {
        label Clear
        callback {if (!fl_ask("Clear the harmonics settings?")) return;

for (int i=0;i<MAX_AD_HARMONICS;i++){
    h[i]->mag->value(64);
    oscil->Phmag[i]=64;
    h[i]->phase->value(64);
    oscil->Phphase[i]=64;
};
oscil->Phmag[0]=127;
h[0]->mag->value(0);

for (int i=0;i<MAX_AD_HARMONICS;i++){
  if (oscil->Phmag[i]==64) h[i]->mag->selection_color(0);
     else h[i]->mag->selection_color(222);
};

//harmonics->redraw();

master->lock();
 oscil->prepare();
master->unlock();

redrawoscil();}
        xywh {670 505 55 15} box THIN_UP_BOX labelfont 1 labelsize 12
      }
      Fl_Group {} {
        xywh {135 308 150 30} box ENGRAVED_BOX
      } {
        Fl_Choice wshbutton {
          label {Wsh.}
          callback {oscil->Pwaveshapingfunction=(int) o->value();
basefuncdisplaygroup->redraw();
redrawoscil();} open
          tooltip {Waveshaping function} xywh {165 313 55 20} down_box BORDER_BOX labelsize 10 textsize 10
        } {
          menuitem {} {
            label None
            xywh {25 25 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label Atan
            xywh {35 35 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label Asym1
            xywh {45 45 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label Pow
            xywh {55 55 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label Sine
            xywh {65 65 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label Qnts
            xywh {75 75 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label Zigzg
            xywh {85 85 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label Lmt
            xywh {95 95 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label LmtU
            xywh {105 105 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label LmtL
            xywh {115 115 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label ILmt
            xywh {127 127 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label Clip
            xywh {137 137 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label Asym2
            xywh {85 85 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label Pow2
            xywh {95 95 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label Sgm
            xywh {90 90 100 20} labelfont 1 labelsize 10
          }
        }
        Fl_Dial wshpar {
          callback {oscil->Pwaveshaping=(int)o->value()+64;
wsparval->value(oscil->Pwaveshaping-64);
redrawoscil();}
          tooltip {Waveshaping Parameter} xywh {260 313 20 20} minimum -64 maximum 63 step 1
          class WidgetPDial
        }
        Fl_Value_Output wsparval {
          xywh {228 316 25 15} labelsize 13 minimum -63 maximum 63 step 1
        }
      }
      Fl_Light_Button autoclearbutton {
        label {Clr.}
        tooltip {Auto clear when using the oscillator as base function} xywh {95 313 35 20} box THIN_UP_BOX value 1 labelfont 1 labelsize 10
      }
      Fl_Group {} {
        xywh {285 308 155 30} box ENGRAVED_BOX
      } {
        Fl_Choice fltbutton {
          label Filter
          callback {oscil->Pfiltertype=(int) o->value();

redrawoscil();}
          tooltip {Oscillator's filter type} xywh {315 313 50 20} down_box BORDER_BOX labelsize 10 textsize 10
        } {
          menuitem {} {
            label None
            xywh {35 35 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label LP1
            xywh {45 45 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label HP1a
            xywh {55 55 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label HP1b
            xywh {65 65 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label BP1
            xywh {75 75 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label BS1
            xywh {85 85 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label LP2
            xywh {55 55 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label HP2
            xywh {65 65 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label BP2
            xywh {65 65 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label BS2
            xywh {75 75 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label Cos
            xywh {75 75 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label Sin
            xywh {85 85 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label LSh
            xywh {95 95 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label S
            xywh {105 105 100 20} labelfont 1 labelsize 10
          }
        }
        Fl_Dial filtervalue1 {
          callback {oscil->Pfilterpar1=(int)o->value();

redrawoscil();}
          tooltip {Oscillator's filter parameter1} xywh {367 313 20 20} maximum 127 step 1
          class WidgetPDial
        }
        Fl_Check_Button filterpref {
          label p
          callback {oscil->Pfilterbeforews=(int)o->value();

redrawoscil();}
          tooltip {Apply the filter before the waveshaping} xywh {415 313 20 20} down_box DOWN_BOX labelsize 10 align 24
        }
        Fl_Dial filtervalue2 {
          callback {oscil->Pfilterpar2=(int)o->value();

redrawoscil();}
          tooltip {Oscillator's filter parameter2} xywh {392 313 20 20} maximum 127 step 1
          class WidgetPDial
        }
      }
      Fl_Group {} {
        xywh {590 308 135 30} box ENGRAVED_BOX
      } {
        Fl_Choice sabutton {
          label {Sp.adj.}
          callback {oscil->Psatype=(int) o->value();
redrawoscil();}
          tooltip {Oscillator's spectrum adjust} xywh {630 313 60 20} down_box BORDER_BOX labelsize 10 textsize 10
        } {
          menuitem {} {
            label None
            xywh {55 55 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label Pow
            xywh {65 65 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label ThrsD
            xywh {75 75 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label ThrsU
            xywh {85 85 100 20} labelfont 1 labelsize 10
          }
        }
        Fl_Dial sadjpar {
          callback {oscil->Psapar=(int)o->value();
redrawoscil();}
          tooltip {Oscillator's spectrum adjust parameter} xywh {695 313 20 20} maximum 127 step 1
          class WidgetPDial
        }
      }
      Fl_Group {} {
        xywh {665 340 65 65} box ENGRAVED_BOX
      } {
        Fl_Counter harmonicshiftcounter {
          label {Harmonic Shift}
          callback {oscil->Pharmonicshift=(int)o->value();
redrawoscil();}
          xywh {670 365 55 15} type Simple labelsize 10 align 129 minimum -64 maximum 64 step 1 textfont 1 textsize 10
        }
        Fl_Check_Button harmonicshiftpre {
          label preH
          callback {oscil->Pharmonicshiftfirst=(int)o->value();
redrawoscil();}
          tooltip {Apply the harmonic shift before the waveshaping and filtering} xywh {690 385 34 15} down_box DOWN_BOX labelsize 10 align 24
        }
        Fl_Button {} {
          label R
          callback {oscil->Pharmonicshift=0;
harmonicshiftcounter->value(0);
redrawoscil();}
          xywh {670 385 20 15} box THIN_UP_BOX labelfont 1 labelsize 10
        }
      }
      Fl_Group {} {
        xywh {665 410 65 90} box ENGRAVED_FRAME
      } {
        Fl_Choice adhrtype {
          label {Adpt.Harm.}
          callback {oscil->Padaptiveharmonics=(int) o->value();
redrawoscil();}
          tooltip {The type of the addaptive harmonics} xywh {670 425 55 15} down_box BORDER_BOX labelsize 10 align 129 when 6 textsize 10
        } {
          menuitem {} {
            label OFF
            xywh {80 80 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label ON
            xywh {90 90 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label Square
            xywh {100 100 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label 2xSub
            xywh {110 110 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label 2xAdd
            xywh {120 120 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label 3xSub
            xywh {120 120 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label 3xAdd
            xywh {130 130 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label 4xSub
            xywh {130 130 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label 4xAdd
            xywh {140 140 100 20} labelfont 1 labelsize 10
          }
        }
        Fl_Dial adhrpow {
          label pow
          callback {oscil->Padaptiveharmonicspower=(int)o->value();
redrawoscil();}
          tooltip {Adaptive harmonics power} xywh {700 460 25 25} labelsize 10 maximum 200 step 1
          class WidgetPDial
        }
        Fl_Dial adhrbf {
          label baseF
          callback {oscil->Padaptiveharmonicsbasefreq=(int)o->value();
redrawoscil();}
          tooltip {Adaptive harmonics base frequency} xywh {670 460 25 25} labelsize 10 maximum 255 step 1
          class WidgetPDial
        }
        Fl_Slider adhrpar {
          callback {oscil->Padaptiveharmonicspar=(int)o->value();
redrawoscil();}
          xywh {670 445 55 10} type {Horz Knob} box FLAT_BOX maximum 100 step 1 value 50
        }
      }
      Fl_Group {} {
        xywh {440 308 150 30} box ENGRAVED_BOX
      } {
        Fl_Choice modtype {
          label {Mod.}
          callback {oscil->Pmodulation=(int) o->value();

redrawoscil();}
          tooltip modulation xywh {470 315 50 15} down_box BORDER_BOX labelsize 10 textsize 10
        } {
          menuitem {} {
            label None
            xywh {60 60 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label Rev
            xywh {70 70 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label Sine
            xywh {80 80 100 20} labelfont 1 labelsize 10
          }
          menuitem {} {
            label Pow
            xywh {90 90 100 20} labelfont 1 labelsize 10
          }
        }
        Fl_Dial modpar1 {
          callback {oscil->Pmodulationpar1=(int)o->value();

redrawoscil();}
          tooltip {Oscillator's modulation parameter 1} xywh {530 315 15 15} maximum 127 step 1
          class WidgetPDial
        }
        Fl_Dial modpar2 {
          callback {oscil->Pmodulationpar2=(int)o->value();

redrawoscil();}
          tooltip {Oscillator's modulation parameter 2} xywh {550 315 15 15} maximum 127 step 1
          class WidgetPDial
        }
        Fl_Dial modpar3 {
          callback {oscil->Pmodulationpar3=(int)o->value();
redrawoscil();}
          tooltip {Oscillator's modulation parameter 3} xywh {570 315 15 15} maximum 127 step 1
          class WidgetPDial
        }
      }
      Fl_Button {} {
        label Sine
        callback {if (!fl_ask("Convert to SINE?")) return;

master->lock();
 oscil->convert2sine(0);
master->unlock();

redrawoscil();
refresh();}
        xywh {670 525 55 15} box THIN_UP_BOX labelfont 1 labelsize 12
      }
      Fl_Button {} {
        label C
        callback {presetsui->copy(oscil);}
        xywh {670 545 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 12 labelcolor 7
      }
      Fl_Button {} {
        label P
        callback {presetsui->paste(oscil,this);}
        xywh {700 545 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 12 labelcolor 7
      }
      Fl_Scroll _this_has_to_be_the_last {
        xywh {5 340 660 250} type HORIZONTAL box ENGRAVED_BOX
      } {
        Fl_Pack harmonics {open
          xywh {10 345 650 225} type HORIZONTAL
          code0 {for (int i=0;i<MAX_AD_HARMONICS;i++){h[i]=new Oscilharmonic(0,0,20,o->h(),"");h[i]->init(oscil,i,oscildisplaygroup,oldosc,cbwidget,applybutton,master);}}
        } {}
      }
    }
  }
  Function {OscilEditor(OscilGen *oscil_,Fl_Widget *oldosc_,Fl_Widget *cbwidget_,Fl_Widget *cbapplywidget_,Master *master_)} {} {
    code {oscil=oscil_;
oldosc=oldosc_;
cbwidget=cbwidget_;
cbapplywidget=cbapplywidget_;
master=master_;

make_window();

refresh();
osceditUI->show();} {}
  }
  Function {~OscilEditor()} {} {
    code {osceditUI->hide();
//for (int i=0;i<MAX_AD_HARMONICS;i++) delete (h[i]);
delete (osceditUI);} {}
  }
  Function {refresh()} {} {
    code {magtype->value(oscil->Phmagtype);
rndslider->value(oscil->Prand-64);

hrndtype->value(oscil->Pamprandtype);
hrnddial->value(oscil->Pamprandpower);

bftype->value(oscil->Pcurrentbasefunc);
bfparval->value(oscil->Pbasefuncpar-64);
bfslider->value(oscil->Pbasefuncpar-64);

bfmodtype->value(oscil->Pbasefuncmodulation);
bfmodpar1->value(oscil->Pbasefuncmodulationpar1);
bfmodpar2->value(oscil->Pbasefuncmodulationpar2);
bfmodpar3->value(oscil->Pbasefuncmodulationpar3);

wshbutton->value(oscil->Pwaveshapingfunction);
wsparval->value(oscil->Pwaveshaping-64);
wshpar->value(oscil->Pwaveshaping-64);

fltbutton->value(oscil->Pfiltertype);
filtervalue1->value(oscil->Pfilterpar1);
filtervalue2->value(oscil->Pfilterpar2);
filterpref->value(oscil->Pfilterbeforews);

modtype->value(oscil->Pmodulation);
modpar1->value(oscil->Pmodulationpar1);
modpar2->value(oscil->Pmodulationpar2);
modpar3->value(oscil->Pmodulationpar3);

sabutton->value(oscil->Psatype);
sadjpar->value(oscil->Psapar);

harmonicshiftcounter->value(oscil->Pharmonicshift);
harmonicshiftpre->value(oscil->Pharmonicshiftfirst);

adhrtype->value(oscil->Padaptiveharmonics);
adhrbf->value(oscil->Padaptiveharmonicsbasefreq);
adhrpow->value(oscil->Padaptiveharmonicspower);
adhrtype->value(oscil->Padaptiveharmonicspar);

for (int i=0;i<MAX_AD_HARMONICS;i++) h[i]->refresh();

master->lock();
 oscil->prepare();
master->unlock();

basefuncdisplaygroup->redraw();
redrawoscil();} {}
  }
  Function {redrawoscil()} {} {
    code {oscildisplaygroup->redraw();
oldosc->redraw();
if (cbwidget!=NULL) {
      cbwidget->do_callback();
      applybutton->color(FL_RED);
      applybutton->redraw();
};} {}
  }
  decl {OscilGen *oscil;} {}
  decl {Fl_Widget *oldosc,*cbwidget,*cbapplywidget;} {}
  decl {Oscilharmonic *h[MAX_AD_HARMONICS];} {}
  decl {Master *master;} {}
}