summaryrefslogtreecommitdiff
path: root/muse_qt4_evolution/synti/zynaddsubfx/UI/MasterUI.fl
blob: 15a6fcc1c3bf7380806a4f386ae31d1dc6cc296d (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
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
# 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 <stdlib.h>} {public
} 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

decl {\#include "../globals.h"} {public
} 

class VUMeter {: {public Fl_Box}
} {
  Function {VUMeter(int x,int y, int w, int h, const char *label=0):Fl_Box(x,y,w,h,label)} {} {
    code {master=NULL;
npart=-1;} {}
  }
  Function {init(Master *master_,int part_)} {} {
    code {//the "part_" parameters sets the part (if it is >=0), else it sets the master
master=master_;
label(NULL);
npart=part_;
olddbl=0.0;
olddbr=0.0;
oldrmsdbl=0.0;
oldrmsdbr=0.0;} {}
  }
  Function {draw_master()} {} {
    code {\#define MIN_DB (-48)

int ox=x(); int oy=y(); int lx=w(); int ly=h();

master->lock();
REALTYPE dbl=rap2dB(master->vuoutpeakl);
REALTYPE dbr=rap2dB(master->vuoutpeakr);
REALTYPE rmsdbl=rap2dB(master->vurmspeakl);
REALTYPE rmsdbr=rap2dB(master->vurmspeakr);
REALTYPE maxdbl=rap2dB(master->vumaxoutpeakl);
REALTYPE maxdbr=rap2dB(master->vumaxoutpeakr);
int clipped=master->vuclipped;
master->unlock();

dbl=(MIN_DB-dbl)/MIN_DB; 
if (dbl<0.0) dbl=0.0;
  else if (dbl>1.0)dbl=1.0;

dbr=(MIN_DB-dbr)/MIN_DB; 
if (dbr<0.0) dbr=0.0;
  else if (dbr>1.0) dbr=1.0; 

dbl=dbl*0.4+olddbl*0.6;
dbr=dbr*0.4+olddbr*0.6;

olddbl=dbl;
olddbr=dbr;

\#define VULENX (lx-35)
\#define VULENY (ly/2-3)

dbl*=VULENX;dbr*=VULENX;

int idbl=(int) dbl;
int idbr=(int) dbr;

//compute RMS - start
rmsdbl=(MIN_DB-rmsdbl)/MIN_DB; 
if (rmsdbl<0.0) rmsdbl=0.0;
  else if (rmsdbl>1.0) rmsdbl=1.0;

rmsdbr=(MIN_DB-rmsdbr)/MIN_DB; 
if (rmsdbr<0.0) rmsdbr=0.0;
  else if (rmsdbr>1.0) rmsdbr=1.0; 

rmsdbl=rmsdbl*0.4+oldrmsdbl*0.6;
rmsdbr=rmsdbr*0.4+oldrmsdbr*0.6;

oldrmsdbl=rmsdbl;
oldrmsdbr=rmsdbr;


rmsdbl*=VULENX;rmsdbr*=VULENX;

int irmsdbl=(int) rmsdbl;
int irmsdbr=(int) rmsdbr;
//compute RMS - end



//draw the vu-meter lines
//db
fl_rectf(ox,oy,idbr,VULENY,0,200,255);
fl_rectf(ox,oy+ly/2,idbl,VULENY,0,200,255);
//black
fl_rectf(ox+idbr,oy,VULENX-idbr,VULENY,0,0,0);
fl_rectf(ox+idbl,oy+ly/2,VULENX-idbl,VULENY,0,0,0);

//draw the scales
REALTYPE  tmp=VULENX*1.0/MIN_DB;
for (int i=1;i<1-MIN_DB;i++){
   int tx=VULENX+(int) (tmp*i);
   fl_rectf(ox+tx,oy,1,VULENY+ly/2,0,160,200);
   if (i%5==0) fl_rectf(ox+tx,oy,1,VULENY+ly/2,0,230,240);
   if (i%10==0) fl_rectf(ox+tx-1,oy,2,VULENY+ly/2,0,225,255);
};

//rms
if (irmsdbr>2) fl_rectf(ox+irmsdbr-1,oy,3,VULENY,255,255,0);
if (irmsdbl>2) fl_rectf(ox+irmsdbl-1,oy+ly/2,3,VULENY,255,255,0);


//draw the red box if clipping has occured
if (clipped==0) fl_rectf(ox+VULENX+2,oy+1,lx-VULENX-3,ly-4,0,0,10);
           else fl_rectf(ox+VULENX+2,oy+1,lx-VULENX-3,ly-4,250,10,10);

//draw the maxdB 
fl_font(FL_HELVETICA|FL_BOLD,10);
fl_color(255,255,255);
char tmpstr[10];
if ((maxdbl>MIN_DB-20)){
  snprintf((char *)&tmpstr,10,"%ddB",(int)maxdbr);
  fl_draw(tmpstr,ox+VULENX+1,oy+1,lx-VULENX-1,VULENY,FL_ALIGN_RIGHT,NULL,0);
};
if ((maxdbr>MIN_DB-20)){
  snprintf((char *)&tmpstr,10,"%ddB",(int)maxdbl);
  fl_draw(tmpstr,ox+VULENX+1,oy+ly/2+1,lx-VULENX-1,VULENY,FL_ALIGN_RIGHT,NULL,0);
};} {}
  }
  Function {draw_part()} {} {
    code {\#define MIN_DB (-48)
int ox=x(); int oy=y(); int lx=w(); int ly=h();

if (!active_r()){
  master->lock();
   int fakedb=master->fakepeakpart[npart];
  master->unlock();
  fl_rectf(ox,oy,lx,ly,140,140,140);
  if (fakedb>0){
    fakedb=(int)(fakedb/255.0*ly)+4;
    fl_rectf(ox+2,oy+ly-fakedb,lx-4,fakedb,0,0,0);
  };
  
  return;
};

//draw the vu lines
master->lock();
 REALTYPE db=rap2dB(master->vuoutpeakpart[npart]);
master->unlock();

db=(MIN_DB-db)/MIN_DB; 
if (db<0.0) db=0.0;
  else if (db>1.0) db=1.0;

db*=ly-2;

int idb=(int) db;

fl_rectf(ox,oy+ly-idb,lx,idb,0,200,255);
fl_rectf(ox,oy,lx,ly-idb,0,0,0);


//draw the scales
REALTYPE  tmp=ly*1.0/MIN_DB;
 for (int i=1;i<1-MIN_DB;i++){
    int ty=ly+(int) (tmp*i);
    if (i%5==0) fl_rectf(ox,oy+ly-ty,lx,1,0,160,200);
    if (i%10==0) fl_rectf(ox,oy+ly-ty,lx,1,0,230,240);
};} {}
  }
  Function {draw()} {} {
    code {if (npart>=0) draw_part();
   else draw_master();} {}
  }
  Function {tickdraw(VUMeter *o)} {return_type {static void}
  } {
    code {o->redraw();} {}
  }
  Function {tick(void *v)} {return_type {static void}
  } {
    code {tickdraw((VUMeter *) v);
Fl::add_timeout(1.0/25.0,tick,v);//25 fps} {}
  }
  Function {handle(int event)} {return_type int
  } {
    code {switch(event){
   case FL_SHOW:
             tick(this);
             break;
   case FL_HIDE:
             Fl::remove_timeout(tick,this);
             break;
   case FL_PUSH:
             if (npart>=0) break;
             master->lock();
             master->vuresetpeaks();
             master->unlock();
             break;
};
return(1);} {}
  }
  decl {Master *master;} {}
  decl {int npart;} {}
  decl {float olddbl,olddbr;} {}
  decl {float oldrmsdbl,oldrmsdbr;} {}
} 

class SysEffSend {: {public WidgetPDial}
} {
  Function {SysEffSend(int x,int y, int w, int h, const char *label=0):WidgetPDial(x,y,w,h,label)} {} {
    code {master=NULL;
neff1=0;
neff2=0;} {}
  }
  Function {init(Master *master_,int neff1_,int neff2_)} {} {
    code {neff1=neff1_;
neff2=neff2_;
master=master_;
minimum(0);
maximum(127);
step(1);
labelfont(1);
labelsize(10);
align(FL_ALIGN_TOP);

value(master->Psysefxsend[neff1][neff2]);
char tmp[20];snprintf(tmp,20,"%d->%d",neff1+1,neff2+1);this->label(strdup(tmp));} {}
  }
  Function {~SysEffSend()} {} {
    code {hide();} {}
  }
  Function {handle(int event)} {return_type int
  } {
    code {if ((event==FL_PUSH) || (event==FL_DRAG)){
   master->setPsysefxsend(neff1,neff2,(int) value());
};

return(WidgetPDial::handle(event));} {}
  }
  decl {Master *master;} {}
  decl {int neff1;} {}
  decl {int neff2;} {}
} 

class Panellistitem {: {public Fl_Group}
} {
  Function {make_window()} {private
  } {
    Fl_Window panellistitem {
      private xywh {315 213 70 260} type Double hide
      class Fl_Group
    } {
      Fl_Group panellistitemgroup {
        private xywh {0 20 70 240} box PLASTIC_THIN_UP_BOX
        code0 {if (master->part[npart]->Penabled==0) o->deactivate();}
      } {
        Fl_Group {} {
          xywh {45 65 15 110} box ENGRAVED_FRAME
        } {
          Fl_Box {} {
            label {V U}
            xywh {45 65 15 110} box FLAT_BOX color 0 selection_color 75 labelcolor 55 align 128
            code0 {o->init(master,npart);}
            class VUMeter
          }
        }
        Fl_Button partname {
          label {  }
          callback {if ((int)bankui->cbwig->value()!=(npart+1)){
   bankui->cbwig->value(npart+1);
   bankui->cbwig->do_callback();
};
bankui->show();}
          xywh {5 27 60 30} box THIN_DOWN_BOX down_box FLAT_BOX labelfont 1 labelsize 10 align 208
        }
        Fl_Slider partvolume {
          callback {master->part[npart]->setPvolume((int) o->value());}
          xywh {10 65 30 110} type {Vert Knob} box FLAT_BOX minimum 127 maximum 0 step 1 value 127
          code0 {o->value(master->part[npart]->Pvolume);}
        }
        Fl_Dial partpanning {
          callback {master->part[npart]->setPpanning((int) o->value());}
          xywh {20 180 30 30} maximum 127 step 1
          code0 {o->value(master->part[npart]->Ppanning);}
          class WidgetPDial
        }
        Fl_Button {} {
          label edit
          callback {if ((int)bankui->cbwig->value()!=(npart+1)){
   bankui->cbwig->value(npart+1);
   bankui->cbwig->do_callback();
};}
          xywh {15 235 40 20} box PLASTIC_UP_BOX labelsize 10
        }
        Fl_Choice partrcv {
          callback {master->part[npart]->Prcvchn=(int) o->value();} open
          tooltip {receive from Midi channel} xywh {10 213 50 15} down_box BORDER_BOX labelsize 10 align 5 textfont 1 textsize 10
          code0 {char nrstr[10]; for(int i=0;i<NUM_MIDI_CHANNELS;i++){sprintf(nrstr,"Ch%d",i+1);if (i!=9) o->add(nrstr); else o->add("Dr10");};}
          code1 {o->value(master->part[npart]->Prcvchn);}
        } {}
      }
      Fl_Check_Button partenabled {
        label 01
        callback {master->lock();
 master->partonoff(npart,(int) o->value());
master->unlock();

if ((int) o->value()==0) panellistitemgroup->deactivate();
  else {
    panellistitemgroup->activate();
    if ((int)bankui->cbwig->value()!=(npart+1)){
       bankui->cbwig->value(npart+1);
       bankui->cbwig->do_callback();
    };
};

o->redraw();}
        private xywh {5 0 45 20} down_box DOWN_BOX labeltype EMBOSSED_LABEL labelfont 1 labelsize 16 align 24
        code0 {char tmp[10];snprintf(tmp,10,"%d",npart+1);o->label(strdup(tmp));}
        code1 {o->value(master->part[npart]->Penabled);}
      }
    }
  }
  Function {Panellistitem(int x,int y, int w, int h, const char *label=0):Fl_Group(x,y,w,h,label)} {} {
    code {npart=0;
master=NULL;
bankui=NULL;} {}
  }
  Function {init(Master *master_, int npart_,BankUI *bankui_)} {} {
    code {npart=npart_;
master=master_;
bankui=bankui_;

make_window();
panellistitem->show();
end();} {}
  }
  Function {refresh()} {open
  } {
    code {partenabled->value(master->part[npart]->Penabled);
if (master->part[npart]->Penabled!=0) panellistitemgroup->activate();
     else panellistitemgroup->deactivate();

partvolume->value(master->part[npart]->Pvolume);
partpanning->value(master->part[npart]->Ppanning);
partrcv->value(master->part[npart]->Prcvchn);

partname->label((char *)master->part[npart]->Pname);

if ((int)bankui->cbwig->value()!=(npart+1))
   panellistitemgroup->color(fl_rgb_color(160,160,160));
else 
   panellistitemgroup->color(fl_rgb_color(50,190,240));

panellistitemgroup->redraw();} {}
  }
  Function {~Panellistitem()} {} {
    code {panellistitem->hide();
//delete(panellistitem);} {}
  }
  decl {int npart;} {}
  decl {Master *master;} {}
  decl {BankUI *bankui;} {}
} 

class MasterUI {} {
  Function {make_window()} {} {
    Fl_Window masterwindow {
      label zynaddsubfx
      callback {\#ifdef VSTAUDIOOUT
fl_alert("ZynAddSubFX could not be closed this way, because it's a VST plugin. Please use the host aplication to close it.");
\#else
if (fl_ask("Exit and leave the unsaved data?")) {
    config.save();
    *exitprogram=1;
};
\#endif} selected
      xywh {353 127 390 465} type Double hide
    } {
      Fl_Menu_Bar mastermenu {
        xywh {-5 0 690 25}
      } {
        submenu {} {
          label {&File}
          xywh {0 0 100 20}
        } {
          menuitem {} {
            label {&New (erase all)...}
            callback {do_new_master();}
            xywh {20 20 100 20}
          }
          menuitem {} {
            label {&Open Parameters...}
            callback {do_load_master();}
            xywh {20 20 100 20}
          }
          menuitem {} {
            label {&Save All Parameters...}
            callback {do_save_master();}
            xywh {10 10 100 20} divider
          }
          menuitem {} {
            label {&Load Scale Settings...}
            callback {char *filename;
filename=fl_file_chooser("Open:","({*.xsz})",NULL,0);
if (filename==NULL) return;

master->lock();
  //clear all parameters
  master->microtonal.defaults();

  //load the data
  int result=master->microtonal.loadXML(filename);
master->unlock();


 delete microtonalui;  
 microtonalui=new MicrotonalUI(&master->microtonal);

if (result==-10) fl_alert("Error: Could not load the file\\nbecause it is not a scale file.");
      else if (result<0) fl_alert("Error: Could not load the file.");}
            xywh {35 35 100 20}
          }
          menuitem {} {
            label {Save Sc&ale Settings ..}
            callback {char *filename;
int result=0;

filename=fl_file_chooser("Save:","({*.xsz})",NULL,0);
if (filename==NULL) return;
filename=fl_filename_setext(filename,".xsz");

result=fileexists(filename);
if (result) {
    result=0;
   if (!fl_ask("The file exists. \\nOverwrite it?")) return;
       
};


master->lock();
result=master->microtonal.saveXML(filename);
master->unlock();

if (result<0) fl_alert("Error: Could not save the file.");


updatepanel();}
            xywh {25 25 100 20}
          }
          menuitem {} {
            label {Show Scale Settings...}
            callback {microtonalui->show();}
            xywh {0 0 100 20} divider
          }
          menuitem {} {
            label {&Settings...}
            callback {configui->show();}
            xywh {25 25 100 20} divider
          }
          menuitem {} {
            label {&Copyright...}
            callback {aboutwindow->show();}
            xywh {15 15 100 20} divider
          }
          menuitem {} {
            label {E&xit}
            callback {masterwindow->do_callback();}
            xywh {10 10 100 20}
          }
        }
        submenu {} {
          label {&Instrument}
          xywh {10 10 100 20}
        } {
          menuitem {} {
            label {&Clear Instrument...}
            callback {if (fl_ask("Clear instrument's parameters ?")){
//       int npart=(int)npartcounter->value()-1;
       master->lock();
       master->part[npart]->defaultsinstrument();
       master->unlock();

       npartcounter->do_callback();
};

updatepanel();}
            xywh {35 35 100 20}
          }
          menuitem {} {
            label {&Open Instrument...}
            callback {const char *filename;
filename=fl_file_chooser("Load:","({*.xiz})",NULL,0);
if (filename==NULL) return;


master->lock();
//  int npart=(int)npartcounter->value()-1;

  //clear all instrument parameters, first
  master->part[npart]->defaultsinstrument();

  //load the instr. parameters
  int result=master->part[npart]->loadXMLinstrument(filename);

master->unlock();
master->part[npart]->applyparameters();

npartcounter->do_callback();
updatepanel();

if (result==-10) fl_alert("Error: Could not load the file\\nbecause it is not an instrument file.");
      else if (result<0) fl_alert("Error: Could not load the file.");}
            xywh {30 30 100 20}
          }
          menuitem {} {
            label {&Save Instrument ...}
            callback {char *filename;

filename=fl_file_chooser("Save:","({*.xiz})",NULL,0);
if (filename==NULL) return;
filename=fl_filename_setext(filename,".xiz");

int result=fileexists(filename);
if (result) {
    result=0;
   if (!fl_ask("The file exists. \\nOverwrite it?")) return;
       
};


master->lock();
result=master->part[npart]->saveXML(filename);
master->unlock();

if (result<0) fl_alert("Error: Could not save the file.");

updatepanel();}
            xywh {20 20 100 20} divider
          }
          menuitem {} {
            label {Show Instrument &Bank...}
            callback {bankui->show();}
            xywh {0 0 100 20} divider
          }
          menuitem {} {
            label {&Virtual Keyboard...}
            callback {virkeyboard->show();}
            xywh {10 10 100 20}
          }
        }
        submenu recordmenu {
          label {&Record}
          xywh {0 0 100 20}
        } {
          menuitem {} {
            label {&Choose WAV file...}
            callback {char *filename;
recordbutton->deactivate();
pausebutton->deactivate();
pauselabel->deactivate();
stopbutton->deactivate();
filename=fl_file_chooser("Record to audio file:","(*.wav)",NULL,0);
if (filename==NULL) return;
fl_filename_setext(filename,".wav");

int result=master->HDDRecorder.preparefile(filename,0);
if (result==1) {
    result=0;
   if (fl_ask("The file exists. \\nOverwrite it?"))
       master->HDDRecorder.preparefile(filename,1);
};
if (result==0) recordbutton->activate();

if (result!=0) fl_alert("Error: Could not save the file.");}
            xywh {0 0 100 20}
          }
        }
        submenu {} {
          label {&Sequencer}
          xywh {0 0 100 20} hide
        } {
          menuitem {} {
            label {Show &Sequencer...}
            callback {sequi->show();}
            xywh {0 0 100 20}
          }
        }
        submenu {} {
          label Misc
          xywh {10 10 100 20}
        } {
          menuitem {} {
            label {Switch User Interface Mode}
            callback {if (fl_ask("Switch the User Interface to Beginner mode ?")){
	masterwindow->hide();
	refresh_master_ui();
	simplemasterwindow->show();
	config.cfg.UserInterfaceMode=2;
};}
            xywh {10 10 100 20}
          }
        }
      }
      Fl_Dial mastervolumedial {
        label {M.Vol}
        callback {master->setPvolume((int) o->value());}
        tooltip {Master Volume} xywh {5 30 30 30} box ROUND_UP_BOX labelfont 1 labelsize 12 align 130 maximum 127 step 1
        code0 {o->value(master->Pvolume);}
        class WidgetPDial
      }
      Fl_Counter masterkeyshiftcounter {
        label {Master KeyShift}
        callback {master->setPkeyshift((int) o->value()+64);}
        xywh {45 31 90 20} labelsize 12 minimum -64 maximum 64 step 1
        code0 {o->lstep(12);}
        code1 {o->value(master->Pkeyshift-64);}
      }
      Fl_Button {} {
        label {Panic!}
        callback {virkeyboard->relaseallkeys();
master->lock();
master->shutup=1;
master->unlock();}
        xywh {293 29 92 31} box PLASTIC_UP_BOX color 231 labelfont 1
      }
      Fl_Group partuigroup {
        xywh {0 242 390 183} box ENGRAVED_FRAME
      } {
        Fl_Group partui {
          xywh {4 245 383 175} box FLAT_BOX
          code0 {o->init(master->part[0],master,0,bankui);}
          code1 {o->show();}
          class PartUI
        } {}
      }
      Fl_Tabs {} {
        xywh {0 80 390 160}
      } {
        Fl_Group {} {
          label {System Effects} open
          xywh {0 100 390 140} box ENGRAVED_FRAME labeltype EMBOSSED_LABEL labelsize 18 align 25
        } {
          Fl_Counter syseffnocounter {
            label {Sys.Effect No.}
            callback {nsyseff=(int) o->value()-1;
sysefftype->value(master->sysefx[nsyseff]->geteffect());
syseffectui->refresh(master->sysefx[nsyseff]);}
            xywh {5 120 80 20} type Simple labelfont 1 labelsize 11 align 1 minimum 0 maximum 127 step 1 value 1 textfont 1
            code0 {o->bounds(1,NUM_SYS_EFX);}
            code1 {o->value(nsyseff+1);}
          }
          Fl_Choice sysefftype {
            label EffType
            callback {master->lock();
master->sysefx[nsyseff]->changeeffect((int) o->value());
master->unlock();
syseffectui->refresh(master->sysefx[nsyseff]);}
            xywh {315 125 70 15} down_box BORDER_BOX labelsize 11
            code0 {o->value(master->sysefx[nsyseff]->geteffect());}
          } {
            menuitem {} {
              label {No Effect}
              xywh {10 10 100 20} labelfont 1 labelsize 11
            }
            menuitem {} {
              label Reverb
              xywh {20 20 100 20} labelfont 1 labelsize 11
            }
            menuitem {} {
              label Echo
              xywh {30 30 100 20} labelfont 1 labelsize 11
            }
            menuitem {} {
              label Chorus
              xywh {40 40 100 20} labelfont 1 labelsize 11
            }
            menuitem {} {
              label Phaser
              xywh {50 50 100 20} labelfont 1 labelsize 11
            }
            menuitem {} {
              label AlienWah
              xywh {60 60 100 20} labelfont 1 labelsize 11
            }
            menuitem {} {
              label Distortion
              xywh {70 70 100 20} labelfont 1 labelsize 11
            }
            menuitem {} {
              label EQ
              xywh {80 80 100 20} labelfont 1 labelsize 11
            }
            menuitem {} {
              label DynFilter
              xywh {90 90 100 20} labelfont 1 labelsize 11
            }
          }
          Fl_Group syseffectuigroup {
            xywh {5 140 380 95} box FLAT_BOX color 48
          } {
            Fl_Group syseffectui {
              xywh {5 140 380 95}
              code0 {o->init(master->sysefx[nsyseff]);}
              class EffUI
            } {}
          }
          Fl_Button {} {
            label {Send to...}
            callback {syseffsendwindow->show();}
            xywh {95 120 75 20} box THIN_UP_BOX labelfont 1 labelsize 12
          }
          Fl_Button {} {
            label C
            callback {presetsui->copy(master->sysefx[nsyseff]);}
            xywh {215 124 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 12 labelcolor 7
          }
          Fl_Button {} {
            label P
            callback {master->lock();
presetsui->paste(master->sysefx[nsyseff],syseffectui);
master->unlock();}
            xywh {245 124 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 12 labelcolor 7
          }
        }
        Fl_Group {} {
          label {Insertion Effects}
          xywh {0 100 390 140} box ENGRAVED_FRAME labeltype EMBOSSED_LABEL labelsize 18 align 25 hide
        } {
          Fl_Counter inseffnocounter {
            label {Ins.Effect No.}
            callback {ninseff=(int) o->value()-1;
insefftype->value(master->insefx[ninseff]->geteffect());
inseffpart->value(master->Pinsparts[ninseff]+2);
inseffectui->refresh(master->insefx[ninseff]);

if (master->Pinsparts[ninseff]!=-1) {
        insefftype->activate();
	inseffectui->activate();
        inseffectuigroup->activate();
} else {
	insefftype->deactivate();
 	inseffectui->deactivate();
        inseffectuigroup->deactivate();
};}
            xywh {5 120 80 20} type Simple labelfont 1 labelsize 11 align 1 minimum 0 maximum 127 step 1 value 1 textfont 1
            code0 {o->bounds(1,NUM_INS_EFX);}
            code1 {o->value(ninseff+1);}
          }
          Fl_Choice insefftype {
            label EffType
            callback {master->lock();
master->insefx[ninseff]->changeeffect((int) o->value());
master->unlock();
inseffectui->refresh(master->insefx[ninseff]);
inseffectui->show();}
            xywh {315 125 70 15} down_box BORDER_BOX labelsize 11
            code0 {o->value(master->insefx[ninseff]->geteffect());}
            code1 {if (master->Pinsparts[ninseff]== -1) o->deactivate();}
          } {
            menuitem {} {
              label {No Effect}
              xywh {25 25 100 20} labelfont 1 labelsize 11
            }
            menuitem {} {
              label Reverb
              xywh {35 35 100 20} labelfont 1 labelsize 11
            }
            menuitem {} {
              label Echo
              xywh {45 45 100 20} labelfont 1 labelsize 11
            }
            menuitem {} {
              label Chorus
              xywh {55 55 100 20} labelfont 1 labelsize 11
            }
            menuitem {} {
              label Phaser
              xywh {60 60 100 20} labelfont 1 labelsize 11
            }
            menuitem {} {
              label AlienWah
              xywh {70 70 100 20} labelfont 1 labelsize 11
            }
            menuitem {} {
              label Distortion
              xywh {80 80 100 20} labelfont 1 labelsize 11
            }
            menuitem {} {
              label EQ
              xywh {90 90 100 20} labelfont 1 labelsize 11
            }
            menuitem {} {
              label DynFilter
              xywh {100 100 100 20} labelfont 1 labelsize 11
            }
          }
          Fl_Group inseffectuigroup {
            xywh {5 140 380 95} box FLAT_BOX color 48
          } {
            Fl_Group inseffectui {
              xywh {5 140 380 95}
              code0 {o->init(master->insefx[ninseff]);}
              code1 {if (master->Pinsparts[ninseff]== -1) o->deactivate();}
              class EffUI
            } {}
          }
          Fl_Choice inseffpart {
            label {Insert To.}
            callback {master->Pinsparts[ninseff]=(int) o->value()-2;
if ((int) o->value()==1){
    inseffectuigroup->deactivate();
    insefftype->deactivate();
    inseffectui->deactivate();
} else {
    inseffectuigroup->activate();
    insefftype->activate();
    inseffectui->activate();
};
master->insefx[ninseff]->cleanup();} open
            xywh {95 120 80 20} down_box BORDER_BOX labelfont 1 labelsize 10 align 5 textsize 10
            code0 {o->add("Master Out");o->add("Off");}
            code1 {char tmp[50]; for (int i=0;i<NUM_MIDI_PARTS;i++) {sprintf(tmp,"Part %2d",i+1);o->add(tmp);};}
            code3 {o->value(master->Pinsparts[ninseff]+2);}
          } {}
          Fl_Button {} {
            label C
            callback {presetsui->copy(master->insefx[ninseff]);}
            xywh {215 124 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 12 labelcolor 7
          }
          Fl_Button {} {
            label P
            callback {master->lock();
presetsui->paste(master->insefx[ninseff],inseffectui);
master->unlock();}
            xywh {245 124 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 12 labelcolor 7
          }
        }
      }
      Fl_Button {} {
        label Scales
        callback {microtonalui->show();}
        xywh {330 80 56 19} box PLASTIC_UP_BOX color 231 labeltype ENGRAVED_LABEL labelfont 1
      }
      Fl_Group {} {
        xywh {172 30 117 45} box ENGRAVED_BOX
      } {
        Fl_Button recordbutton {
          label {Rec.}
          callback {o->deactivate();
recordmenu->deactivate();
recordmenu->label("&Record(*)");
stopbutton->activate();
pausebutton->activate();
pauselabel->activate();
master->HDDRecorder.start();
master->vuresetpeaks();
mastermenu->redraw();}
          tooltip {Start Recording} xywh {181 36 21 21} box ROUND_UP_BOX color 88 labelfont 1 labelsize 10 align 2 deactivate
        }
        Fl_Button stopbutton {
          label Stop
          callback {o->deactivate();
master->HDDRecorder.stop();
recordbutton->deactivate();
pausebutton->deactivate();
pauselabel->deactivate();
recordmenu->activate();
recordmenu->label("&Record");
mastermenu->redraw();}
          tooltip {Stop Recording and close the audio file} xywh {259 36 21 21} box THIN_UP_BOX color 4 labelfont 1 labelsize 10 align 2 deactivate
        }
        Fl_Button pausebutton {
          label {@||}
          callback {o->deactivate();
master->HDDRecorder.pause();
recordbutton->activate();
mastermenu->redraw();}
          tooltip {Pause Recording} xywh {220 36 21 21} box THIN_UP_BOX color 4 selection_color 4 labelfont 1 labelcolor 3 align 16 deactivate
        }
        Fl_Box pauselabel {
          label Pause
          xywh {214 56 30 15} labelfont 1 labelsize 10 deactivate
        }
      }
      Fl_Group {} {
        xywh {1 427 389 33} box ENGRAVED_FRAME
      } {
        Fl_Box {} {
          label {VU-Meter}
          xywh {4 430 384 30} box FLAT_BOX color 48 selection_color 75
          code0 {o->init(master,-1);}
          class VUMeter
        }
      }
      Fl_Check_Button nrpnbutton {
        label NRPN
        callback {master->ctl.NRPN.receive=(int) o->value();}
        tooltip {Receive NRPNs} xywh {45 65 47 10} down_box DOWN_BOX labelsize 10
        code0 {o->value(master->ctl.NRPN.receive);}
      }
      Fl_Counter npartcounter {
        callback {int nval=(int) o->value()-1;
partuigroup->remove(partui);
delete partui;
partui=new PartUI(0,0,765,525);
partuigroup->add(partui);
partui->init(master->part[nval],master,nval,bankui);
partui->redraw();
o->redraw();
npart=nval;

updatepanel();
simplenpartcounter->value(nval+1);
simplenpartcounter->do_callback();}
        tooltip {The part number} xywh {5 247 70 23} type Simple labelfont 1 minimum 0 maximum 127 step 1 value 1 textfont 1
        code0 {o->bounds(1,NUM_MIDI_PARTS);}
        code1 {bankui->init(o);}
      }
      Fl_Button {} {
        label vK
        callback {virkeyboard->show();}
        tooltip {Virtual Keyboard} xywh {292 80 35 19} box PLASTIC_UP_BOX color 231 labeltype ENGRAVED_LABEL labelfont 1
      }
      Fl_Button {} {
        label {R.D.}
        callback {globalfinedetuneslider->value(64.0);
globalfinedetuneslider->do_callback();}
        tooltip {Master fine detune reset} xywh {140 65 30 10} box THIN_UP_BOX labelfont 1 labelsize 10
      }
      Fl_Dial globalfinedetuneslider {
        label {F.Det.}
        callback {master->microtonal.Pglobalfinedetune=(int) o->value();}
        tooltip {global fine detune} xywh {143 30 20 20} box ROUND_UP_BOX labelsize 10 align 130 maximum 127 step 1 value 64
        code0 {o->value(master->microtonal.Pglobalfinedetune);}
        class WidgetPDial
      }
      Fl_Button {} {
        label {Panel Window}
        callback {updatepanel();
panelwindow->show();}
        tooltip {Panel Window} xywh {293 62 92 16} box PLASTIC_UP_BOX color 183 labelfont 1 labelsize 10
      }
    }
    Fl_Window aboutwindow {
      label {Copyright...}
      xywh {629 278 330 210} type Double hide
    } {
      Fl_Box {} {
        label {Copyright (c) 2002-2005 Nasca O. Paul}
        xywh {5 35 320 25} labeltype EMBOSSED_LABEL labelsize 18 align 16
      }
      Fl_Box {} {
        label {This is free software; you may redistribute it and/or modify it under the terms of the 
version 2 of the GNU General Public License as published by the Free Software Fundation.
  This program comes with
 ABSOLUTELY NO WARRANTY. 
 See the version 2 of the 
GNU General Public License for details.}
        xywh {0 60 325 115} labelfont 1 labelsize 12 align 144
      }
      Fl_Button {} {
        label {Close this window}
        callback {aboutwindow->hide();}
        xywh {80 180 180 25} box THIN_UP_BOX labelsize 12
      }
      Fl_Box {} {
        label ZynAddSubFX
        xywh {5 5 325 30} labeltype EMBOSSED_LABEL labelfont 1 labelsize 24 labelcolor 0 align 16
      }
    }
    Fl_Window syseffsendwindow {
      label {System Effects Send}
      xywh {171 234 120 250} type Double hide resizable
    } {
      Fl_Scroll {} {open
        xywh {0 45 120 170} box FLAT_BOX resizable
        code0 {for (int neff1=0;neff1<NUM_SYS_EFX;neff1++) for (int neff2=neff1+1;neff2<NUM_SYS_EFX;neff2++)}
        code1 {{syseffsend[neff1][neff2]=new SysEffSend(o->x()+(neff2-1)*35,o->y()+15+neff1*50,30,30);syseffsend[neff1][neff2]->label("aaa");syseffsend[neff1][neff2]->init(master,neff1,neff2);};}
      } {}
      Fl_Button {} {
        label Close
        callback {syseffsendwindow->hide();}
        xywh {25 220 80 25} box THIN_UP_BOX
      }
      Fl_Box {} {
        label {Send system effect's output to other system effects}
        xywh {5 5 110 35} labelsize 10 align 192
      }
    }
    Fl_Window panelwindow {
      label {ZynAddSubFX Panel}
      xywh {72 60 630 635} type Double hide
    } {
      Fl_Scroll {} {open
        xywh {0 5 570 310} type HORIZONTAL box THIN_UP_BOX
      } {
        Fl_Pack {} {open
          xywh {5 10 560 285} type HORIZONTAL
          code0 {for (int i=0;i<NUM_MIDI_PARTS/2;i++){panellistitem[i]=new Panellistitem(0,0,70,260,"");panellistitem[i]->init(master,i,bankui);}}
        } {}
      }
      Fl_Scroll {} {open
        xywh {0 320 570 310} type HORIZONTAL box THIN_UP_BOX
      } {
        Fl_Pack {} {open
          xywh {5 325 560 285} type HORIZONTAL
          code0 {for (int i=NUM_MIDI_PARTS/2;i<NUM_MIDI_PARTS;i++){panellistitem[i]=new Panellistitem(0,0,70,260,"");panellistitem[i]->init(master,i,bankui);}}
        } {}
      }
      Fl_Button {} {
        label Close
        callback {panelwindow->hide();
updatepanel();}
        xywh {575 605 50 25} box THIN_UP_BOX
      }
      Fl_Button {} {
        label Refresh
        callback {updatepanel();}
        xywh {575 570 55 25} box THIN_UP_BOX
      }
    }
    Fl_Window simplemasterwindow {
      label ZynAddSubFX
      callback {\#ifdef VSTAUDIOOUT
fl_alert("ZynAddSubFX could not be closed this way, because it's a VST plugin. Please use the host aplication to close it.");
\#else
if (fl_ask("Exit and leave the unsaved data?")) {
	config.save();
	*exitprogram=1;
};
\#endif}
      xywh {135 383 600 335} type Double hide
    } {
      Fl_Menu_Bar {} {
        xywh {0 0 690 25}
      } {
        submenu {} {
          label {&File}
          xywh {10 10 100 20}
        } {
          menuitem {} {
            label {&New (erase all)...}
            callback {do_new_master();}
            xywh {30 30 100 20}
          }
          menuitem {} {
            label {&Open Parameters...}
            callback {do_load_master();}
            xywh {30 30 100 20}
          }
          menuitem {} {
            label {&Save All Parameters...}
            callback {do_save_master();}
            xywh {20 20 100 20} divider
          }
          menuitem {} {
            label {&Settings...}
            callback {configui->show();}
            xywh {35 35 100 20} divider
          }
          menuitem {} {
            label {&Copyright...}
            callback {aboutwindow->show();}
            xywh {25 25 100 20} divider
          }
          menuitem {} {
            label {E&xit}
            callback {masterwindow->do_callback();}
            xywh {20 20 100 20}
          }
        }
        submenu {} {
          label {&Instrument}
          xywh {20 20 100 20}
        } {
          menuitem {} {
            label {&Open Instrument...}
            callback {const char *filename;
filename=fl_file_chooser("Load:","({*.xiz})",NULL,0);
if (filename==NULL) return;


master->lock();
//  int npart=(int)npartcounter->value()-1;

  //clear all instrument parameters, first
  master->part[npart]->defaultsinstrument();

  //load the instr. parameters
  int result=master->part[npart]->loadXMLinstrument(filename);

master->unlock();
master->part[npart]->applyparameters();

simplenpartcounter->do_callback();

if (result==-10) fl_alert("Error: Could not load the file\\nbecause it is not an instrument file.");
      else if (result<0) fl_alert("Error: Could not load the file.");}
            xywh {40 40 100 20}
          }
          menuitem {} {
            label {Show Instrument &Bank...}
            callback {bankui->show();}
            xywh {10 10 100 20} divider
          }
        }
        submenu {} {
          label Misc
          xywh {0 0 100 20}
        } {
          menuitem {} {
            label {Switch User Interface Mode}
            callback {if (fl_ask("Switch the User Interface to Advanced mode ?")){
	simplemasterwindow->hide();
	refresh_master_ui();
	masterwindow->show();
	config.cfg.UserInterfaceMode=1;
};}
            xywh {0 0 100 20}
          }
        }
      }
      Fl_Group simplelistitemgroup {
        private xywh {125 65 215 150} box ENGRAVED_BOX
        code0 {if (master->part[npart]->Penabled==0) o->deactivate();}
      } {
        Fl_Button partname {
          callback {if ((int)bankui->cbwig->value()!=(npart+1)){
   bankui->cbwig->value(npart+1);
   bankui->cbwig->do_callback();
};
bankui->show();}
          xywh {130 72 205 18} box PLASTIC_THIN_DOWN_BOX down_box FLAT_BOX color 247 labelfont 1 labelsize 12 align 208
        }
        Fl_Slider partpanning {
          label Pan
          callback {master->part[npart]->setPpanning((int) o->value());}
          xywh {185 95 70 15} type {Horz Knob} box FLAT_BOX maximum 127 step 1 value 64
          code0 {o->value(master->part[npart]->Ppanning);}
        }
        Fl_Choice partrcv {
          label {Midi Channel Receive}
          callback {virkeys->relaseallkeys(0);
master->part[npart]->Prcvchn=(int) o->value();
virkeys->midich=(int) o->value();} open
          tooltip {receive from Midi channel} xywh {140 157 65 18} down_box BORDER_BOX labelsize 11 align 130 textfont 1
          code0 {char nrstr[10]; for(int i=0;i<NUM_MIDI_CHANNELS;i++){sprintf(nrstr,"Ch%d",i+1);if (i!=9) o->add(nrstr); else o->add("Dr10");};}
          code1 {o->value(master->part[npart]->Prcvchn);}
        } {}
        Fl_Dial partvolume {
          callback {master->part[npart]->setPvolume((int) o->value());}
          xywh {145 95 30 30} maximum 127 step 1
          code0 {o->value(master->part[npart]->Pvolume);}
          class WidgetPDial
        }
        Fl_Box {} {
          label Volume
          xywh {130 125 60 15}
        }
        Fl_Check_Button simplepartportamento {
          label Portamento
          callback {master->part[npart]->ctl.portamento.portamento=(int) o->value();}
          tooltip {Enable/Disable the portamento} xywh {260 95 75 20} down_box DOWN_BOX labelfont 1 labelsize 10
          code0 {o->value(master->part[npart]->ctl.portamento.portamento);}
        }
        Fl_Counter simpleminkcounter {
          label {Min.key}
          callback {master->part[npart]->Pminkey=(int) o->value();
if (master->part[npart]->Pminkey>master->part[npart]->Pmaxkey) o->textcolor(FL_RED);
 else o->textcolor(FL_BLACK);}
          tooltip {Minimum key (that the part receives NoteOn messages)} xywh {210 158 40 15} type Simple labelfont 1 labelsize 10 minimum 0 maximum 127 step 1 textsize 10
          code0 {o->value(master->part[npart]->Pminkey);}
        }
        Fl_Counter simplemaxkcounter {
          label {Max.key}
          callback {master->part[npart]->Pmaxkey=(int) o->value();

if (master->part[npart]->Pminkey>master->part[npart]->Pmaxkey) o->textcolor(FL_RED);
 else o->textcolor(FL_BLACK);}
          tooltip {Maximum key (that the part receives NoteOn messages)} xywh {255 158 40 15} type Simple labelfont 1 labelsize 10 minimum 0 maximum 127 step 1 textsize 10
          code0 {o->value(master->part[npart]->Pmaxkey);}
        }
        Fl_Button {} {
          label m
          callback {if (master->part[npart]->lastnote>=0) simpleminkcounter->value(master->part[npart]->lastnote);
simpleminkcounter->do_callback();
simplemaxkcounter->do_callback();}
          tooltip {set the minimum key to the last pressed key} xywh {230 188 15 12} box THIN_UP_BOX labelsize 10
        }
        Fl_Button {} {
          label M
          callback {if (master->part[npart]->lastnote>=0) simplemaxkcounter->value(master->part[npart]->lastnote);
simplemaxkcounter->do_callback();
simpleminkcounter->do_callback();}
          tooltip {set the maximum key to the last pressed key} xywh {260 188 15 12} box THIN_UP_BOX labelsize 10
        }
        Fl_Button {} {
          label R
          callback {simpleminkcounter->value(0);
simpleminkcounter->do_callback();
simplemaxkcounter->value(127);
simplemaxkcounter->do_callback();}
          tooltip {reset the minimum key to 0 and maximum key to 127} xywh {245 188 15 12} box THIN_UP_BOX labelfont 1 labelsize 10
        }
        Fl_Counter simplepartkeyshiftcounter {
          label KeyShift
          callback {master->part[npart]->Pkeyshift=(int) o->value()+64;}
          xywh {240 120 90 20} labelsize 12 minimum -64 maximum 64 step 1
          code0 {o->lstep(12);}
          code1 {o->value(master->part[npart]->Pkeyshift-64);}
        }
        Fl_Dial simplesyseffsend {
          callback {master->setPsysefxvol(npart,nsyseff,(int) o->value());}
          xywh {300 160 30 30} maximum 127 step 1
          class WidgetPDial
        }
        Fl_Box {} {
          label Effect
          xywh {295 190 40 15}
        }
      }
      Fl_Check_Button partenabled {
        label Enabled
        callback {master->lock();
 master->partonoff(npart,(int) o->value());
master->unlock();

if ((int) o->value()==0) simplelistitemgroup->deactivate();
  else {
    simplelistitemgroup->activate();
    if ((int)bankui->cbwig->value()!=(npart+1)){
       bankui->cbwig->value(npart+1);
       bankui->cbwig->do_callback();
    };
};

o->redraw();}
        private xywh {250 40 85 20} down_box DOWN_BOX labeltype EMBOSSED_LABEL labelfont 1 labelsize 16 align 24
        code0 {//char tmp[10];snprintf(tmp,10,"%d",npart+1);o->label(strdup(tmp));}
        code1 {o->value(master->part[npart]->Penabled);}
      }
      Fl_Box virkeys {
        label Keyboard
        xywh {5 215 590 80} box BORDER_BOX color 17
        code0 {o->init(master);}
        class VirKeys
      }
      Fl_Group {} {
        xywh {340 30 255 185} box ENGRAVED_BOX
      } {
        Fl_Tabs {} {
          xywh {345 35 245 175} align 18
        } {
          Fl_Group {} {
            label {System Effects}
            xywh {345 55 245 155} box ENGRAVED_FRAME labelfont 1 align 18
          } {
            Fl_Counter simplesyseffnocounter {
              label {Sys.Effect No.}
              callback {nsyseff=(int) o->value()-1;
simplesysefftype->value(master->sysefx[nsyseff]->geteffect());
simplesyseffectui->refresh(master->sysefx[nsyseff]);
simplerefresh();}
              xywh {350 75 80 20} type Simple labelfont 1 labelsize 11 align 1 minimum 0 maximum 127 step 1 value 1 textfont 1
              code0 {o->bounds(1,NUM_SYS_EFX);}
              code1 {o->value(nsyseff+1);}
            }
            Fl_Choice simplesysefftype {
              label EffType
              callback {master->lock();
master->sysefx[nsyseff]->changeeffect((int) o->value());
master->unlock();
simplesyseffectui->refresh(master->sysefx[nsyseff]);}
              xywh {515 80 70 15} down_box BORDER_BOX labelsize 11 align 5
              code0 {o->value(master->sysefx[nsyseff]->geteffect());}
            } {
              menuitem {} {
                label {No Effect}
                xywh {20 20 100 20} labelfont 1 labelsize 11
              }
              menuitem {} {
                label Reverb
                xywh {30 30 100 20} labelfont 1 labelsize 11
              }
              menuitem {} {
                label Echo
                xywh {40 40 100 20} labelfont 1 labelsize 11
              }
              menuitem {} {
                label Chorus
                xywh {50 50 100 20} labelfont 1 labelsize 11
              }
              menuitem {} {
                label Phaser
                xywh {60 60 100 20} labelfont 1 labelsize 11
              }
              menuitem {} {
                label AlienWah
                xywh {70 70 100 20} labelfont 1 labelsize 11
              }
              menuitem {} {
                label Distortion
                xywh {80 80 100 20} labelfont 1 labelsize 11
              }
              menuitem {} {
                label EQ
                xywh {90 90 100 20} labelfont 1 labelsize 11
              }
              menuitem {} {
                label DynFilter
                xywh {100 100 100 20} labelfont 1 labelsize 11
              }
            }
            Fl_Group simplesyseffectuigroup {
              xywh {350 95 235 95} box FLAT_BOX color 48
            } {
              Fl_Group simplesyseffectui {
                xywh {350 95 234 95}
                code0 {o->init(master->sysefx[nsyseff]);}
                class SimpleEffUI
              } {}
            }
            Fl_Button {} {
              label {Send to...}
              callback {syseffsendwindow->show();}
              xywh {435 75 75 20} box THIN_UP_BOX labelfont 1 labelsize 12
            }
            Fl_Button {} {
              label P
              callback {master->lock();
presetsui->paste(master->sysefx[nsyseff],simplesyseffectui);
master->unlock();}
              xywh {560 65 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 12 labelcolor 7
            }
          }
          Fl_Group {} {
            label {Insertion Effects}
            xywh {345 55 245 155} box ENGRAVED_FRAME labelfont 1 align 18 hide
          } {
            Fl_Counter simpleinseffnocounter {
              label {Ins.Effect No.}
              callback {ninseff=(int) o->value()-1;
simpleinsefftype->value(master->insefx[ninseff]->geteffect());
simpleinseffpart->value(master->Pinsparts[ninseff]+2);
simpleinseffectui->refresh(master->insefx[ninseff]);

if (master->Pinsparts[ninseff]!=-1) {
        simpleinsefftype->activate();
	simpleinseffectui->activate();
        simpleinseffectuigroup->activate();
} else {
	simpleinsefftype->deactivate();
 	simpleinseffectui->deactivate();
        simpleinseffectuigroup->deactivate();
};}
              xywh {350 75 80 20} type Simple labelfont 1 labelsize 11 align 1 minimum 0 maximum 127 step 1 value 1 textfont 1
              code0 {o->bounds(1,NUM_INS_EFX);}
              code1 {o->value(ninseff+1);}
            }
            Fl_Choice simpleinsefftype {
              label EffType
              callback {master->lock();
master->insefx[ninseff]->changeeffect((int) o->value());
master->unlock();
simpleinseffectui->refresh(master->insefx[ninseff]);
simpleinseffectui->show();}
              xywh {515 80 70 15} down_box BORDER_BOX labelsize 11 align 5
              code0 {o->value(master->insefx[ninseff]->geteffect());}
              code1 {if (master->Pinsparts[ninseff]== -1) o->deactivate();}
            } {
              menuitem {} {
                label {No Effect}
                xywh {35 35 100 20} labelfont 1 labelsize 11
              }
              menuitem {} {
                label Reverb
                xywh {45 45 100 20} labelfont 1 labelsize 11
              }
              menuitem {} {
                label Echo
                xywh {55 55 100 20} labelfont 1 labelsize 11
              }
              menuitem {} {
                label Chorus
                xywh {65 65 100 20} labelfont 1 labelsize 11
              }
              menuitem {} {
                label Phaser
                xywh {70 70 100 20} labelfont 1 labelsize 11
              }
              menuitem {} {
                label AlienWah
                xywh {80 80 100 20} labelfont 1 labelsize 11
              }
              menuitem {} {
                label Distortion
                xywh {90 90 100 20} labelfont 1 labelsize 11
              }
              menuitem {} {
                label EQ
                xywh {100 100 100 20} labelfont 1 labelsize 11
              }
              menuitem {} {
                label DynFilter
                xywh {110 110 100 20} labelfont 1 labelsize 11
              }
            }
            Fl_Group simpleinseffectuigroup {
              xywh {350 95 234 95} box FLAT_BOX color 48
            } {
              Fl_Group simpleinseffectui {
                xywh {350 95 234 95}
                code0 {o->init(master->insefx[ninseff]);}
                code1 {if (master->Pinsparts[ninseff]== -1) o->deactivate();}
                class SimpleEffUI
              } {}
            }
            Fl_Choice simpleinseffpart {
              label {Insert To.}
              callback {master->Pinsparts[ninseff]=(int) o->value()-2;
if ((int) o->value()==1){
    simpleinseffectuigroup->deactivate();
    simpleinsefftype->deactivate();
    simpleinseffectui->deactivate();
} else {
    simpleinseffectuigroup->activate();
    simpleinsefftype->activate();
    simpleinseffectui->activate();
};
master->insefx[ninseff]->cleanup();} open
              xywh {435 75 80 20} down_box BORDER_BOX labelfont 1 labelsize 10 align 5 textsize 10
              code0 {o->add("Master Out");o->add("Off");}
              code1 {char tmp[50]; for (int i=0;i<NUM_MIDI_PARTS;i++) {sprintf(tmp,"Part %2d",i+1);o->add(tmp);};}
              code3 {o->value(master->Pinsparts[ninseff]+2);}
            } {}
            Fl_Button {} {
              label P
              callback {master->lock();
presetsui->paste(master->insefx[ninseff],simpleinseffectui);
master->unlock();}
              xywh {560 65 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 12 labelcolor 7
            }
          }
        }
      }
      Fl_Group {} {
        xywh {5 300 590 30} box ENGRAVED_FRAME
      } {
        Fl_Box {} {
          label {VU-Meter}
          xywh {5 300 590 30} box FLAT_BOX color 41 selection_color 75
          code0 {o->init(master,-1);}
          class VUMeter
        }
      }
      Fl_Dial simplemastervolumedial {
        label {Master Volume}
        callback {master->setPvolume((int) o->value());}
        tooltip {Master Volume} xywh {10 35 40 40} box ROUND_UP_BOX labelfont 1 labelsize 12 align 130 maximum 127 step 1
        code0 {o->value(master->Pvolume);}
        class WidgetPDial
      }
      Fl_Counter simplemasterkeyshiftcounter {
        label {Master KeyShift}
        callback {master->setPkeyshift((int) o->value()+64);}
        xywh {25 110 90 20} labelsize 12 minimum -64 maximum 64 step 1
        code0 {o->lstep(12);}
        code1 {o->value(master->Pkeyshift-64);}
      }
      Fl_Button {} {
        label {Stop ALL sounds!}
        callback {virkeyboard->relaseallkeys();
master->lock();
master->shutup=1;
master->unlock();}
        xywh {5 149 115 31} box PLASTIC_UP_BOX color 231 labelfont 1 labelsize 12
      }
      Fl_Button {} {
        label Reset
        callback {simpleglobalfinedetuneslider->value(64.0);
simpleglobalfinedetuneslider->do_callback();}
        tooltip {Master fine detune reset} xywh {70 32 50 10} box THIN_UP_BOX labelfont 1 labelsize 12 align 128
      }
      Fl_Dial simpleglobalfinedetuneslider {
        label {Fine Detune}
        callback {master->microtonal.Pglobalfinedetune=(int) o->value();}
        tooltip {global fine detune} xywh {80 45 30 30} box ROUND_UP_BOX labelsize 12 align 130 maximum 127 step 1 value 64
        code0 {o->value(master->microtonal.Pglobalfinedetune);}
        class WidgetPDial
      }
      Fl_Counter simplenpartcounter {
        label Part
        callback {virkeys->relaseallkeys(0);
npartcounter->value(o->value());
npart=(int) o->value()-1;

simplerefresh();
virkeys->midich=master->part[npart]->Prcvchn;}
        tooltip {The part number} xywh {170 40 70 20} type Simple labelfont 1 align 4 minimum 0 maximum 127 step 1 value 1 textfont 1
        code0 {o->bounds(1,NUM_MIDI_PARTS);}
      }
      Fl_Counter {} {
        label {Keyb.Oct.}
        callback {virkeys->relaseallkeys(0);
virkeys->midioct=(int) o->value();
virkeys->take_focus();}
        tooltip {Midi Octave} xywh {5 195 55 20} type Simple labelsize 12 align 8 when 6 minimum 0 maximum 5 step 1 textfont 1 textsize 12
        code0 {o->value(virkeys->midioct);}
      }
    }
    Fl_Window selectuiwindow {
      label {User Interface mode}
      callback {*exitprogram=1;}
      xywh {342 246 430 250} type Double hide non_modal
    } {
      Fl_Box {} {
        label {Welcome to ZynAddSubFX}
        xywh {5 5 425 40} labeltype SHADOW_LABEL labelfont 1 labelsize 33
      }
      Fl_Box {} {
        label {Please choose the interface mode:}
        xywh {10 50 265 25} labelfont 1 labelsize 16
      }
      Fl_Button {} {
        label Advanced
        callback {config.cfg.UserInterfaceMode=1;
masterwindow->show();
selectuiwindow->hide();}
        xywh {10 165 100 35} box PLASTIC_UP_BOX color 229 labelfont 1 labelsize 20
      }
      Fl_Box {} {
        label {.. if you have used ZynAddSubFX before, or you like to have full controll to all parameters.}
        xywh {110 165 310 35} labelfont 1 labelsize 13 align 144
      }
      Fl_Button {} {
        label Beginner
        callback {simplemasterwindow->show();
selectuiwindow->hide();
config.cfg.UserInterfaceMode=2;}
        xywh {10 80 100 65} box PLASTIC_UP_BOX color 238 labelfont 1 labelsize 20
      }
      Fl_Box {} {
        label {..if you are a beginner, you prefer using presets or you prefer to use simpler user interfaces. Most functionality of ZynAddSubFX will be hidden in this mode to make simple the learning/using it.}
        xywh {110 75 320 75} labelfont 1 labelsize 13 align 144
      }
      Fl_Box {} {
        label {You can switch the interface modes anytime you want.}
        xywh {30 215 360 25} box BORDER_BOX color 51 labelfont 1 labelsize 13 align 144
      }
    }
  }
  Function {updatesendwindow()} {} {
    code {for (int neff1=0;neff1<NUM_SYS_EFX;neff1++) 
  for (int neff2=neff1+1;neff2<NUM_SYS_EFX;neff2++)
    syseffsend[neff1][neff2]->value(master->Psysefxsend[neff1][neff2]);} {}
  }
  Function {updatepanel()} {} {
    code {for (int npart=0;npart<NUM_MIDI_PARTS;npart++){
  panellistitem[npart]->refresh();
};} {}
  }
  Function {setfilelabel(const char *filename)} {} {
    code {if (filename!=NULL) snprintf(&masterwindowlabel[0],100,"%s - ZynAddSubFX",fl_filename_name(filename));
  else snprintf(&masterwindowlabel[0],100,"%s","ZynAddSubFX (c)2002-2005 Nasca O. Paul");
masterwindowlabel[99]='\\0';
masterwindow->label(&masterwindowlabel[0]);
simplemasterwindow->label(&masterwindowlabel[0]);} {}
  }
  Function {MasterUI(Master *master_,int *exitprogram_)} {} {
    code {master=master_;
exitprogram=exitprogram_;
ninseff=0;
nsyseff=0;
npart=0;

for (int i=0;i<NUM_SYS_EFX;i++)
   for (int j=0;j<NUM_SYS_EFX;j++)
     syseffsend[i][j]=NULL;

microtonalui=new MicrotonalUI(&master->microtonal);
virkeyboard=new VirKeyboard(master);
bankui=new BankUI(master,&npart);
configui=new ConfigUI();
sequi=new SeqUI(master);

make_window();
presetsui=new PresetsUI();
setfilelabel(NULL);
swapefftype=0;
simplerefresh();} {}
  }
  Function {~MasterUI()} {} {
    code {masterwindow->hide();
delete (masterwindow);
aboutwindow->hide();
delete (aboutwindow);
syseffsendwindow->hide();
delete(syseffsendwindow);

delete (virkeyboard);
delete (microtonalui);
delete (bankui);
delete (configui);
delete (sequi);

delete(presetsui);} {}
  }
  Function {showUI()} {} {
    code {switch (config.cfg.UserInterfaceMode){
	case 0:selectuiwindow->show();
	break;
	case 1:masterwindow->show();
	break;
	case 2:simplemasterwindow->show();
	break;
};} {}
  }
  Function {simplerefresh()} {} {
    code {partenabled->value(master->part[npart]->Penabled);
if (master->part[npart]->Penabled!=0) simplelistitemgroup->activate();
     else simplelistitemgroup->deactivate();

partvolume->value(master->part[npart]->Pvolume);
partpanning->value(master->part[npart]->Ppanning);
partrcv->value(master->part[npart]->Prcvchn);

if (master->part[npart]->Pname[0]!=0) partname->label((char *)master->part[npart]->Pname);
	else partname->label("Click here to load a instrument");

simplelistitemgroup->redraw();
simplepartportamento->value(master->part[npart]->ctl.portamento.portamento);
simpleminkcounter->value(master->part[npart]->Pminkey);
simplemaxkcounter->value(master->part[npart]->Pmaxkey);

simplepartkeyshiftcounter->value(master->part[npart]->Pkeyshift-64);
simplesyseffsend->value(master->Psysefxvol[nsyseff][npart]);} {}
  }
  Function {do_new_master()} {} {
    code {if (fl_ask("Clear *ALL* the parameters ?")){
       delete microtonalui;

       master->lock();
	master->defaults();
       master->unlock();
	
       npartcounter->value(1);
       refresh_master_ui();

};

updatepanel();} {}
  }
  Function {do_load_master()} {} {
    code {char *filename;
filename=fl_file_chooser("Open:","({*.xmz})",NULL,0);
if (filename==NULL) return;


master->lock();
  //clear all parameters
  master->defaults();

  //load the data
  int result=master->loadXML(filename);
master->unlock();
master->applyparameters();

npartcounter->value(1);
refresh_master_ui();
updatepanel();
if (result>=0) setfilelabel(filename);


if (result==-10) fl_alert("Error: Could not load the file\\nbecause it is not a zynaddsubfx parameters file.");
      else if (result<0) fl_alert("Error: Could not load the file.");} {}
  }
  Function {do_save_master()} {} {
    code {char *filename;
int result=0;

filename=fl_file_chooser("Save:","({*.xmz})",NULL,0);
if (filename==NULL) return;
filename=fl_filename_setext(filename,".xmz");

result=fileexists(filename);
if (result) {
    result=0;
   if (!fl_ask("The file exists. \\nOverwrite it?")) return;
       
};


master->lock();
result=master->saveXML(filename);
master->unlock();

if (result<0) fl_alert("Error: Could not save the file.");
	else setfilelabel(filename);

updatepanel();} {}
  }
  Function {refresh_master_ui()} {} {
    code {ninseff=0;
nsyseff=0;
npart=0;

//the Master UI
npartcounter->do_callback();
syseffnocounter->do_callback();
inseffnocounter->do_callback();
masterkeyshiftcounter->value(master->Pkeyshift-64);
mastervolumedial->value(master->Pvolume);    
globalfinedetuneslider->value(master->microtonal.Pglobalfinedetune);   
microtonalui=new MicrotonalUI(&master->microtonal);
nrpnbutton->value(master->ctl.NRPN.receive);
updatesendwindow();
updatepanel();

//the simle MasterUI
simplenpartcounter->value(1);
simplesyseffnocounter->value(1);
simpleinseffnocounter->value(1);
simplenpartcounter->do_callback();
simplesyseffnocounter->do_callback();
simpleinseffnocounter->do_callback();
simplemasterkeyshiftcounter->value(master->Pkeyshift-64);
simplemastervolumedial->value(master->Pvolume);    
simpleglobalfinedetuneslider->value(master->microtonal.Pglobalfinedetune);
virkeys->midich=master->part[npart]->Prcvchn;

simplerefresh();
bankui->hide();} {}
  }
  decl {Master *master;} {}
  decl {MicrotonalUI *microtonalui;} {}
  decl {SeqUI *sequi;} {}
  decl {BankUI *bankui;} {}
  decl {int ninseff,npart;} {}
  decl {int nsyseff;} {}
  decl {int *exitprogram;} {}
  decl {SysEffSend *syseffsend[NUM_SYS_EFX][NUM_SYS_EFX];} {}
  decl {VirKeyboard *virkeyboard;} {}
  decl {ConfigUI *configui;} {}
  decl {int swapefftype;} {}
  decl {char masterwindowlabel[100];} {}
  decl {Panellistitem *panellistitem[NUM_MIDI_PARTS];} {}
}