-
Notifications
You must be signed in to change notification settings - Fork 9
/
index3.html
1058 lines (985 loc) · 31.8 KB
/
index3.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>FP30 playground webmidi</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="mobile-web-app-capable" content="yes">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<style>
body{
font-family:verdana,sans-serif;
font-size:12pt;
background-color:#333;
margin:5px,5px,5px,5px;
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Old versions of Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently
supported by Chrome, Opera and Firefox */
}
h2{
color:#ccc;
margin-left:4px;
}
fieldset{
font-size:11pt;
margin:0px;
padding:0px;
border-color:#777;
border-radius: 8px;
width:100%;
}
select{
height:32px;
font-size:14pt;
font-weight:bold;
border-radius: 5px;
background:#ddd;
color:#333;
}
option{
font-size:13pt;
}
input[type=checkbox]{
-ms-transform: scale(1.5); /* IE */
-moz-transform: scale(1.5); /* FF */
-webkit-transform: scale(1.5); /* Safari and Chrome */
-o-transform: scale(1.5); /* Opera */
transform: scale(1.5);
padding:0px;
margin:0px;
}
input[type=radio]{
-ms-transform: scale(1.5); /* IE */
-moz-transform: scale(1.5); /* FF */
-webkit-transform: scale(1.5); /* Safari and Chrome */
-o-transform: scale(1.5); /* Opera */
transform: scale(1.5);
padding:10px;
margin:10px;
}
input[type=text]{
width:38px;
background:#555;
color:#eee;
border:1;
}
button{
width:30px;
height:30px;
font-size:11pt;
border-radius: 4px;
background-color:#555;
color:#ddd;
}
div{
margin-left:10px;
margin-right:10px;
margin-top:20px;
margin-bottom:20px;
}
label{
color:#ccc;
margin:3px;
}
.labslide{
font-size:10pt;
color:#ccc;
margin:3px;
}
.slider {
-webkit-appearance: none;
width: 60%;
height: 15px;
border-radius: 5px;
background: #888;
outline: none;
opacity: 0.7;
-webkit-transition: .2s;
transition: opacity .2s;
}
.slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 30px;
height: 32px;
border-color:#000;
border-width:1px;
border-radius: 30%;
background: #6ad;
cursor: pointer;
}
.slider::-moz-range-thumb {
width: 30px;
height: 30px;
border-color:#000;
border-width:1px;
border-radius: 30%;
background: #6ad;
cursor: pointer;
}
canvas{
background: #aaa;
border-radius: 6px;
margin:5px;
}
</style>
<script type="text/javascript">
var midi = null; // global MIDIAccess object
var midiinput = null;
var midioutput = null;
var midiIn = [];
var midiOut = [];
var sounds=null;
var part=0;
var efx_msb=0;
var efx_lsb=0;
var efx_p1_param=0;
var efx_p2_param=0;
var efx_p3_param=0;
var efx_p1_param_min=0;
var efx_p1_param_max=0;
var efx_p2_param_min=0;
var efx_p2_param_max=0;
var efx_p3_param_min=0;
var efx_p3_param_max=0;
var efx_level_param=0;
var efx_p1=0;
var efx_p2=0;
var efx_p3=0;
var efx_level=0;
var reverb = 40;
var chorus = 0;
var midiloopback = true;
var midilocal = false;
var midisustain = true;
var processID;
var process_dummy=0;
var sysex_init=[0xF0,0x41,0x10,0x42,0x12];
var sysex_end=[0xF7];
function checksum(data){ //Roland checksum for sysex
var check = 0;
for (i=0;i<data.length;i++)
check = check+data[i];
check = check % 128;
check = 128-check;
return check;
}
function sleep(milliseconds) {
const date = Date.now();
let currentDate = null;
do {
currentDate = Date.now();
} while (currentDate - date < milliseconds);
}
function reset(){
if (midioutput){
midioutput.send([0xb0,0x78,0x00]); // All sounds off
midioutput.send([0xb2,0x78,0x00]);
midioutput.send([0xb4,0x78,0x00]);
midioutput.send([0xb0,0x7B,0x00]); // All notes off
midioutput.send([0xb2,0x7B,0x00]);
midioutput.send([0xb4,0x7B,0x00]);
midioutput.send([0xb0,0x79,0x00]); //#Reset all
midioutput.send([0xb2,0x79,0x00]);
midioutput.send([0xb4,0x79,0x00]);
}
}
function setvolumen(value=127){
$("#vol").text(value);
if (midioutput)
midioutput.send([0xb0+part,0x07,value]);
}
function setmodulation(value=0){
$("#molabel").text(value);
if (midioutput)
midioutput.send([0xb0+part,1,value]);
}
function setpitchbend(value=64){
$("#pblabel").text(value);
if (midioutput)
midioutput.send([0xe0+part,0,value]);
}
function setexpression(value=127){
if (midioutput)
midioutput.send([0xb0+part,0x11,value]);
}
function sysex(data){
//if (1==1){
if(midioutput){
msg = sysex_init;
msg = msg.concat(data);
msg = msg.concat(parseInt(checksum(data)));
msg = msg.concat(sysex_end);
midioutput.send(msg);
sleep(50);
}
}
function setreverb(value=0){
reverb = parseInt(value);
$("#rev").text(reverb);
if (midioutput){
midioutput.send([0xb0+part,91,reverb]);
if ((efx_msb!=0)||(efx_lsb!=0)){
sysex([0x40,0x03,0x17,reverb]); // Send level to reverb
}
}
}
function setchorus(value=0){
chorus = parseInt(value);
$("#cho").text(chorus);
if (midioutput){
midioutput.send([0xb0+part,93,chorus]);
//if ((efx_msb!=0)||(efx_lsb!=0)){
sysex([0x40,0x03,0x18,chorus]); // Send level to chorus
//}
}
}
function setreverbtype(value){
var select = $("#selectReverb")[0];
var data = [0x40,0x01,0x30,parseInt(select.selectedIndex)];
sysex(data);
$(':focus').blur();
}
function setchorustype(value){
var select = $("#selectChorus")[0];
var data = [0x40,0x01,0x38,parseInt(select.selectedIndex)];
sysex(data);
$(':focus').blur();
}
function setefxlevel(value){
efx_level = parseInt(value);
$("#efx").text(efx_level);
//sysex([0x40,0x03,0x1A,parseInt(value)]);
//if ((efx_msb!=0)||(efx_lsb!=0)){
//sysex([0x40,0x41+part,0x23,efx_msb,efx_lsb,0,parseInt(efx_level),parseInt(efx_p1),parseInt(efx_p2)]);
//sysex([0x40,0x03,0x1A,efx_level]);
sysex([0x40,0x03,parseInt(efx_level_param)+2,efx_level]);
// }
}
function setefxp1(value=0){
efx_p1 = parseInt(value);
$("#efxp1").text(efx_p1);
//if ((efx_msb!=0)||(efx_lsb!=0)){
//sysex([0x40,0x41+part,0x23,efx_msb,efx_lsb,0,parseInt(efx_level),parseInt(efx_p1),parseInt(efx_p2)]);
//}
sysex([0x40,0x03,parseInt(efx_p1_param)+2,efx_p1]);
}
function setefxp2(value=0){
efx_p2 = parseInt(value);
$("#efxp2").text(efx_p2);
//if ((efx_msb!=0)||(efx_lsb!=0)){
// PART!!
//sysex([0x40,0x4+part1,0x23,efx_msb,efx_lsb,0,parseInt(efx_level),parseInt(efx_p1),parseInt(efx_p2)]);
//}
sysex([0x40,0x03,parseInt(efx_p2_param)+2,efx_p2]);
}
function setefxp3(value=0){
efx_p3 = parseInt(value);
$("#efxp3").text(efx_p3);
//if ((efx_msb!=0)||(efx_lsb!=0)){
// PART!!
//sysex([0x40,0x4+part1,0x23,efx_msb,efx_lsb,0,parseInt(efx_level),parseInt(efx_p1),parseInt(efx_p2)]);
//}
sysex([0x40,0x03,parseInt(efx_p3_param)+2,efx_p3]);
}
function setefxtype(value){
var select = $("#selectEFX")[0];
efxtype = parseInt(select.selectedIndex);
//if (midioutput == null)
// return;
switch (efxtype){
case 0:
//alert("None");
sysex([0x40,0x03,0x00,0x00,0x00]); //EFX OFF
efx_msb=0;
efx_lsb=0;
break;
case 1:
//alert("EQ1");
efx_msb=0x01;
efx_lsb=0x00;
sysex([0x40,0x03,0x00,efx_msb,efx_lsb]); // EFX
sysex([0x40,0x03,12,0]); // param 9
efx_p1_param = 2;
efx_p1_param_min = 0;
efx_p1_param_max = 30;
efx_p2_param = 4;
efx_p2_param_min = 0;
efx_p2_param_max = 30;
efx_p3_param = 7;
efx_p3_param_min = 0;
efx_p3_param_max = 30;
efx_level_param = 11;
efx_p1 = 15;
efx_p2 = 15;
efx_p3 = 15;
efx_level = 127;
break;
case 2:
//alert("EQ2");
efx_msb=0x01;
efx_lsb=0x01;
sysex([0x40,0x03,0x00,efx_msb,efx_lsb]); // EFX
sysex([0x40,0x03,8,3]); // param 9
efx_p1_param = 2;
efx_p1_param_min = 0;
efx_p1_param_max = 30;
efx_p2_param = 5;
efx_p2_param_min = 0;
efx_p2_param_max = 30;
efx_p3_param = 7;
efx_p3_param_min = 0;
efx_p3_param_max = 30;
efx_level_param = 10;
efx_p1 = 15;
efx_p2 = 15;
efx_p3 = 15;
efx_level = 127;
break;
case 3:
//alert("Delay");
efx_msb=0x01;
efx_lsb=0x5b;
sysex([0x40,0x03,0x00,efx_msb,efx_lsb]); // EFX
sysex([0x40,0x03,3,0]); // param 1 model ms
sysex([0x40,0x03,6,0]); // param 4 model ms
efx_p1_param = 2;
efx_p1_param_min = 0;
efx_p1_param_max = 127;
efx_p2_param = 5;
efx_p2_param_min = 0;
efx_p2_param_max = 127;
efx_p3_param = 10;
efx_p3_param_min = 49;
efx_p3_param_max = 89;
efx_level_param = 15;
efx_p1 = 64;
efx_p2 = 64;
efx_p3 = 64;
efx_level = 127;
break;
case 4:
//alert("Delay2");
efx_msb=0x01;
efx_lsb=0x57;
sysex([0x40,0x03,0x00,efx_msb,efx_lsb]); // EFX
sysex([0x40,0x03,3,0]); // param 1 model ms
sysex([0x40,0x03,6,0]); // param 4 model ms
efx_p1_param = 2;
efx_p1_param_min = 0;
efx_p1_param_max = 127;
efx_p2_param = 5;
efx_p2_param_min = 0;
efx_p2_param_max = 127;
efx_p3_param = 10;
efx_p3_param_min = 49;
efx_p3_param_max = 89;
efx_level_param = 19;
efx_p1 = 64;
efx_p2 = 64;
efx_p3 = 64;
efx_level = 127;
break;
case 5:
//alert("Tremolo");
efx_msb=0x01;
efx_lsb=0x25;
sysex([0x40,0x03,0x00,efx_msb,efx_lsb]); // EFX
sysex([0x40,0x03,4,0]); // param 2
efx_p1_param = 3;
efx_p1_param_min = 0;
efx_p1_param_max = 127;
efx_p2_param = 5;
efx_p2_param_min = 0;
efx_p2_param_max = 127;
efx_p3_param = 6;
efx_p3_param_min = 0;
efx_p3_param_max = 30;
efx_level_param = 8;
efx_p1 = 64;
efx_p2 = 64;
efx_p3 = 15;
efx_level = 127;
break;
case 6:
//alert("Rotary");
efx_msb=0x01;
efx_lsb=0x22;
sysex([0x40,0x03,0x00,efx_msb,efx_lsb]); // EFX
efx_p1_param = 1;
efx_p1_param_min = 0;
efx_p1_param_max = 1;
efx_p1 = 1;
efx_p2_param = 4;
efx_p2_param_min = 0;
efx_p2_param_max = 15;
efx_p2 = 7;
efx_p3_param = 5;
efx_p3_param_min = 0;
efx_p3_param_max = 127;
efx_p3 = 64;
efx_level_param = 11;
efx_level = 127;
break;
case 7:
//alert("Rotary2");
efx_msb=0x03;
efx_lsb=0x00;
sysex([0x40,0x03,0x00,efx_msb,efx_lsb]); // EFX
efx_p1_param = 9;
efx_p1_param_min = 0;
efx_p1_param_max = 1;
efx_p1 = 1;
efx_p2_param = 1;
efx_p2_param_min = 0;
efx_p2_param_max = 1;
efx_p2 = 1;
efx_p3_param = 7;
efx_p3_param_min = 0;
efx_p3_param_max = 127;
efx_p3 = 64;
efx_level_param = 19;
efx_level = 127;
break;
case 8:
//alert("Overdrive");
efx_msb=0x01;
efx_lsb=0x12;
sysex([0x40,0x03,0x00,efx_msb,efx_lsb]); // EFX
efx_p1_param = 1;
efx_p1_param_min = 0;
efx_p1_param_max = 127;
efx_p1 = 64;
efx_p2_param = 2;
efx_p2_param_min = 0;
efx_p2_param_max = 127;
efx_p2 = 64;
efx_p3_param = 5;
efx_p3_param_min = 0;
efx_p3_param_max = 30;
efx_p3 = 15;
efx_level_param = 8;
efx_level = 127;
break;
case 9:
//alert("Distortion");
efx_msb=0x01;
efx_lsb=0x13;
sysex([0x40,0x03,0x00,efx_msb,efx_lsb]); // EFX
efx_p1_param = 1;
efx_p1_param_min = 0;
efx_p1_param_max = 127;
efx_p1 = 64;
efx_p2_param = 2;
efx_p2_param_min = 0;
efx_p2_param_max = 127;
efx_p2 = 64;
efx_p3_param = 5;
efx_p3_param_min = 0;
efx_p3_param_max = 30;
efx_p3 = 15;
efx_level_param = 8;
efx_level = 127;
break;
default:
break;
}
if ((efx_msb!=0)||(efx_lsb!=0)){
efx_level = 127;
$("#efxlevel")[0].value = "127";
$("#efx").text("127");
sysex([0x40,0x03,0x17,parseInt(reverb)]); // Send level to reverb
sysex([0x40,0x03,0x18,parseInt(chorus)]); // Send level to chorus
sysex([0x40,0x03,0x1A,127]); // EFX Depth 100%
sysex([0x40,0x41,0x23,efx_msb,efx_lsb,0,127,64,64]); // Coonnect part to EFX
alert(efx_p3_param_max);
$("#efxparam1")[0].value = efx_p1;
$("#efxparam1")[0].min = efx_p1_param_min;
$("#efxparam1")[0].max = efx_p1_param_max;
$("#efxp1").text(efx_p1);
$("#efxparam2")[0].value = efx_p2;
$("#efxparam2")[0].min = efx_p2_param_min;
$("#efxparam2")[0].max = efx_p2_param_max;
$("#efxp2").text(efx_p2);
$("#efxparam3")[0].value = efx_p3;
$("#efxparam3")[0].min = efx_p3_param_min;
$("#efxparam3")[0].max = efx_p3_param_max;
$("#efxp3").text(efx_p3);
}
$(':focus').blur();
}
function setresonance(value=64,inc=0){
if (inc!=0)
value = parseInt($("#resonance")[0].value)+inc;
$("#res").text(value);
$("#resonance")[0].value=value;
if (midioutput)
midioutput.send([0xb0+part,71,value]);
}
function setrelease(value=64,inc=0){
if (inc!=0)
value = parseInt($("#release")[0].value)+inc;
$("#rel").text(value);
$("#release")[0].value=value;
if (midioutput)
midioutput.send([0xb0+part,72,value]);
}
function setattack(value=64,inc=0){
if (inc!=0)
value = parseInt($("#attack")[0].value)+inc;
$("#att").text(value);
$("#attack")[0].value=value;
if (midioutput)
midioutput.send([0xb0+part,73,value]);
}
function setcutoff(value=64,inc=0){
if (inc!=0)
value = parseInt($("#cutoff")[0].value)+inc;
$("#cut").text(value);
$("#cutoff")[0].value=value;
if (midioutput)
midioutput.send([0xb0+part,74,value]);
}
function setdecay(value=64,inc=0){
if (inc!=0)
value = parseInt($("#decay")[0].value)+inc;
$("#dec").text(value);
$("#decay")[0].value=value;
if (midioutput)
midioutput.send([0xb0+part,75,value]);
}
function setpcbank(){
var pc = $("#pc").val();
var msb = $("#msb").val();
var lsb = $("#lsb").val();
//alert (pc+" "+msb+" "+lsb);
if (midioutput){
midioutput.send([0xb0+part,0x00,msb]); // bank msb
midioutput.send([0xb0+part,0x20,lsb]); // bank lsb
midioutput.send([0xc0+part,pc-1]); // program change
}
}
function setslidecc(value=0){
$("#cclabel").text(value);
var cc = $("#cc").val();
//alert("CC "+cc+" val:"+value)
if (midioutput)
midioutput.send([0xb0+part,cc,value]);
}
function changepart(value){
//alert(value);
part = value;
setexpression(127);
}
function selectedSound1(){
var select = $("#selectSound1")[0];
//alert("SS1:"+select.selectedIndex);
$("#selectSound2 option").each(function(index, option) {
$(option).remove();
});
var select2 = $("#selectSound2")[0];
for(var i = 0; i < sounds["voice"].length; i++) {
var group = sounds["voice"][i]["Set"]+"-"+sounds["voice"][i]["Category"];
if (select.value == group){
var opt = sounds["voice"][i]["content"]
var el = document.createElement("option");
el.textContent = opt;
el.value = sounds["voice"][i]["PC"]+"_"+sounds["voice"][i]["MSB"]+"_"+sounds["voice"][i]["LSB"];
select2.appendChild(el);
}
}
$(':focus').blur();
selectedSound2();
}
function selectedSound2(){
var select = $("#selectSound2")[0];
var pc = select.value.split("_")[0];
var msb = select.value.split("_")[1];
var lsb = select.value.split("_")[2];
//alert (pc+" "+msb+" "+lsb);
if (midioutput){
midioutput.send([0xb0+part,0x00,msb]); // bank msb
midioutput.send([0xb0+part,0x20,lsb]); // bank lsb
midioutput.send([0xc0+part,pc-1]); // program change
}
$(':focus').blur();
setexpression(127);
setattack(64);
setrelease(64);
setresonance(64);
setcutoff(64);
setdecay(64);
$("#pc").val(pc);
$("#msb").val(msb);
$("#lsb").val(lsb);
}
function selectmidilocal(cb){
midilocal=cb.checked;
// Send midi looplocal command
var data=[];
if (midilocal)
data = [0xb0,0x7A,0x7F];
else
data = [0xb0,0x7A,0x00];
//alert("midilocal:"+midilocal);
if (midioutput)
midioutput.send(data);
}
function selectloopback(cb){
midiloopback=cb.checked;
midisustain=cb.checked;
$("#midisustain")[0].checked = cb.checked;
}
function selectmidisustain(cb){
midisustain=cb.checked;
}
function echoMIDIMessage( event ) {
//console.log(event.data)
if (midiloopback && midioutput) {
if ((midisustain)||(event.data[0]<176)){
console.log(event.data);
midioutput.send( event.data, event.timestamp );
}
}
}
function initDevices(midi) {
// MIDI devices that send you data.
const inputs = midi.inputs.values();
for (let input = inputs.next(); input && !input.done; input = inputs.next()) {
midiIn.push(input.value);
}
// MIDI devices that you send data to.
const outputs = midi.outputs.values();
for (let output = outputs.next(); output && !output.done; output = outputs.next()) {
midiOut.push(output.value);
}
var select = document.getElementById("selectInterface");
var options = midiIn;
for(var i = 0; i < options.length; i++) {
var opt = options[i].name;
var el = document.createElement("option");
el.textContent = opt;
el.value = opt;
select.appendChild(el);
}
}
function selectedInterface(){
var selectint = document.getElementById("selectInterface");
if (selectint.selectedIndex==0){
$("#con").text("Not connected!");
$("#con").css("color","#CCC");
midioutput = null;
return;
}
//alert(selectint.options[selectint.selectedIndex].index);
var interfacename = midiIn[selectint.options[selectint.selectedIndex].index-1].name
//alert(interfacename);
// Search this name on midi outputs
midioutput = null;
for (var i=0;i<midiOut.length;i++)
if (midiOut[i].name == interfacename){
// Connect midioutput
midioutput = midiOut[i]
//alert("Connected to: "+midioutput.name)
$("#con").text("Connected!");
$("#con").css("color","#008000");
break;
}
midiinput = midiIn[selectint.options[selectint.selectedIndex].index-1]
midiinput.onmidimessage = echoMIDIMessage;
//alert(midiinput.name);
// Reset
part=0;
selectmidilocal($("#cbox1")[0]); // set midilocal state
setvolumen(127);
setexpression(127);
setreverb(0x0e);
setchorus(0);
setattack(64);
setrelease(64);
setresonance(64);
setcutoff(64);
setdecay(64);
setpcbank()
reset();
$(':focus').blur();
}
function onMIDISuccess( midiAccess ) {
console.log( "MIDI sucess!" );
midi = midiAccess
initDevices(midi);
}
function onMIDIFailure(msg) {
console.log( "Failed to get MIDI access - " + msg );
alert("Failed to get MIDI access - " + msg)
}
function canvastend(canvas){
var ctx = canvas.getContext('2d');
//ctx.clear();
ctx.clearRect(0, 0, canvas.width, canvas.height);
canvasgrid(canvas);
canvas.pendown=false;
setpitchbend(64);
setmodulation(0);
}
function canvaststart(canvas){
e = window.event;
if (e.target == canvas) {
e.preventDefault();
}
var touch = e.touches[0];
var BB = canvas.getBoundingClientRect();
var offsetX=BB.left;
var offsetY=BB.top;
var x = parseInt(touch.clientX-offsetX);
var y = parseInt(touch.clientY-offsetY);
var ctx = canvas.getContext('2d');
ctx.fillRect(x,y, 8, 8);
canvas.pendown=true;
var centerx = canvas.width/2;
var centery = canvas.height/2;
var pitchbend = (x-(canvas.width/2))/(canvas.width/2);
pitchbend = Math.sign(pitchbend)*pitchbend*pitchbend; // exponential
pitchbend = Math.min(Math.max(parseInt(pitchbend*64 + 64.5), 0), 127);
//var pitchbend = Math.min(Math.max(parseInt((x*128)/canvas.width), 0), 127);
var modulation = 0;
if ((y-centery)<0)
modulation = Math.min(Math.max(parseInt((centery-y)*128/centery),0),127);
setpitchbend(pitchbend);
setmodulation(modulation);
//$("#pblabel").text(pitchbend+" "+x+" "+offsetX);
//$("#molabel").text(modulation+" "+y+" "+offsetY);
}
function canvastmove(canvas){
e = window.event;
if (e.target == canvas) {
e.preventDefault();
}
var touch = e.touches[0];
var BB = canvas.getBoundingClientRect();
var offsetX=BB.left;
var offsetY=BB.top;
var x = parseInt(touch.clientX-offsetX);
var y = parseInt(touch.clientY-offsetY);
if (canvas.pendown){
e = window.event;
var ctx = canvas.getContext('2d');
ctx.fillRect(x,y, 8, 8);
var centerx = canvas.width/2;
var centery = canvas.height/2;
var pitchbend = (x-(canvas.width/2))/(canvas.width/2);
pitchbend = Math.sign(pitchbend)*pitchbend*pitchbend; // exponential
pitchbend = Math.min(Math.max(parseInt(pitchbend*64 + 64.5), 0), 127);
//var pitchbend = Math.min(Math.max(parseInt((x*128)/canvas.width), 0), 127);
var modulation = 0;
if ((y-centery)<0)
modulation = Math.min(Math.max(parseInt((centery-y)*128/centery),0),127);
setpitchbend(pitchbend);
setmodulation(modulation);
//$("#pblabel").text(pitchbend+" "+x+" "+offsetX);
//$("#molabel").text(modulation+" "+y+" "+offsetY);
}
}
function canvasdown(canvas){
e = window.event;
var ctx = canvas.getContext('2d');
ctx.fillRect(e.offsetX, e.offsetY, 5, 5);
canvas.pendown=true;
var centerx = canvas.width/2;
var centery = canvas.height/2;
var pitchbend = (e.offsetX-(canvas.width/2))/(canvas.width/2);
pitchbend = Math.sign(pitchbend)*pitchbend*pitchbend; // exponential
pitchbend = Math.min(Math.max(parseInt(pitchbend*64 + 64.5), 0), 127);
//var pitchbend = Math.min(Math.max(parseInt((e.offsetX*128)/canvas.width), 0), 127);
var modulation = 0;
if ((e.offsetY-centery)<0)
modulation = Math.min(Math.max(parseInt((centery-e.offsetY)*128/centery),0),127);
setpitchbend(pitchbend);
setmodulation(modulation);
}
function canvasmove(canvas){
if (canvas.pendown){
e = window.event;
var ctx = canvas.getContext('2d');
ctx.fillRect(e.offsetX, e.offsetY, 5, 5);
var centerx = canvas.width/2;
var centery = canvas.height/2;
var pitchbend = (e.offsetX-(canvas.width/2))/(canvas.width/2);
pitchbend = Math.sign(pitchbend)*pitchbend*pitchbend; //exponential
pitchbend = Math.min(Math.max(parseInt(pitchbend*64 + 64.5), 0), 127);
//var pitchbend = Math.min(Math.max(parseInt((e.offsetX*128)/canvas.width), 0), 127);
var modulation = 0;
if ((e.offsetY-centery)<0)
modulation = Math.min(Math.max(parseInt((centery-e.offsetY)*128/centery),0),127);
setpitchbend(pitchbend);
setmodulation(modulation);
}
}
function canvasup(canvas){
var ctx = canvas.getContext('2d');
ctx.clearRect(0, 0, canvas.width, canvas.height);
canvasgrid(canvas);
canvas.pendown=false;
setpitchbend(64);
setmodulation(0);
}
function canvasgrid(canvas){
var ctx = canvas.getContext("2d");
ctx.beginPath();
ctx.strokeStyle = "gray";
ctx.moveTo(0,canvas.height/2);
ctx.lineTo(canvas.width, canvas.height/2);
ctx.moveTo(canvas.width/2,0);
ctx.lineTo(canvas.width/2, canvas.height);
ctx.stroke();
}
function stayawake(){
process_dummy++;
}
function setup(){
navigator.requestMIDIAccess({sysex:true}).then( onMIDISuccess, onMIDIFailure );
$.getJSON( "https://jjulio.github.io/FP30playground/sounds.json", function(data) {
console.log( "sounds load success" );
sounds = data["voices"]
var select1 = $("#selectSound1")[0];
var group = ""
for(var i = 0; i < sounds["voice"].length; i++) {
var newgroup = sounds["voice"][i]["Set"]+"-"+sounds["voice"][i]["Category"];
if (newgroup != group){
var el = document.createElement("option");
el.textContent = newgroup;
el.value = newgroup;
select1.appendChild(el);
group = newgroup;
}
}
selectedSound1();
});
processID = setInterval(stayawake(), 10000);
}
</script>
</head>
<body onload="setup();">
<div><h2>FP30 Playground v0.24</h2></div>
<div>
<select id="selectInterface">
<option>Choose Midi interface</option>
</select>
<label id="con" style="color:#777;font-size:11pt;"> Not connected</label>
</div>
<fieldset>
<div style="margin-top:10px;">
<input type="checkbox" id="cbox1" onchange="selectmidilocal(this);"> <label style="font-size:12pt;">Main keyboard (Midi local)</label>
</div>
<div style="margin-bottom:5px;">
<input type="checkbox" id="cbox2" checked="checked" onchange="selectloopback(this);"> <label style="font-size:12pt;">New sounds (Midi loopback) </label>
<input type="checkbox" id="midisustain" checked="checked" onchange="selectmidisustain(this);"> <label style="font-size:12pt;">Sustain(CC)</label>
</div>
</fieldset>
<fieldset>
<div id="radioset" style="padding:0px;margin:0px;font-size:10pt;">
<input type="radio" id="part1" name="radio" onchange="changepart(0);" checked="checked"><label style="font-size:12pt;">Part1(main)</label>
<input type="radio" id="part3" name="radio" onchange="changepart(2);"><label style="font-size:12pt;">Part3(split)</label>
<input type="radio" id="part5" name="radio" onchange="changepart(4);"><label style="font-size:12pt;">Part5(dual)</label>
</div>
</fieldset>
<div style="padding:6px;margin:0px;">
<label for="selectSound" style="font-weight:bold;">SOUND:</label>
<select id="selectSound1" name="selectSound1"></select>
<select id="selectSound2" name="selectSound2"></select>
</div>
<div><input type="range" min="0" max="127" value="127" class="slider" id="volumen" oninput="setvolumen(this.value);"><label class="labslide">Volume</label><label class="labslide" id="vol">127</label></div>
<div>
<label for="selectReverb" style="color:#777;font-size:11pt;">Reverb type:</label>
<select id="selectReverb" style="font-size:12pt;">
<option>Room1</option><option>Room2</option><option>Room3</option><option>Hall1</option><option selected="selected">Hall2(def)</option><option>Plate</option><option>Delay</option><option>Pan delay</option>
</select>
<label for="selectChorus" style="color:#777;font-size:11pt;">Chorus type:</label>
<select id="selectChorus" style="font-size:12pt;">
<option>Chorus1</option><option>Chorus2</option><option selected="selected">Chorus3(def)</option><option>Chorus4</option><option>Feedback Chorus</option><option>Flanger</option><option>Short delay</option><option>Short Delay FB</option>
</select>
</div>
<div><input type="range" min="0" max="127" value="15" class="slider" id="reverb" oninput="setreverb(this.value);"><label class="labslide">Reverb</label><label class="labslide" id="rev">15</label></div>
<div><input type="range" min="0" max="127" value="0" class="slider" id="chorus" oninput="setchorus(this.value);"><label class="labslide">Chorus</label><label class="labslide" id="cho">0</label></div>
<div>
<label for="selectEFX" style="color:#777;font-size:11pt;">EFX(*):</label>
<select id="selectEFX" style="font-size:12pt;">
<option selected="selected">None</option><option>EQ1</option><option>EQ2</option><option>Delay1</option><option>Delay2</option><option>Tremolo</option><option>Rotary</option><option>Rotary2</option><option>Overdrive</option><option>Distortion</option>
</select>
</div>
<div>
<input type="range" min="0" max="127" value="0" class="slider" style="width: 18%;" id="efxparam1" oninput="setefxp1(this.value);"><label class="labslide">P1</label><label class="labslide" id="efxp1">0</label>
<input type="range" min="0" max="127" value="0" class="slider" style="width: 18%;" id="efxparam2" oninput="setefxp2(this.value);"><label class="labslide">P2</label><label class="labslide" id="efxp2">0</label>
<input type="range" min="0" max="127" value="0" class="slider" style="width: 18%;" id="efxparam3" oninput="setefxp3(this.value);"><label class="labslide">P3</label><label class="labslide" id="efxp3">0</label>
</div>
<div><input type="range" min="0" max="127" value="0" class="slider" id="efxlevel" oninput="setefxlevel(this.value);"><label class="labslide">EFX level</label><label class="labslide" id="efx">0</label></div>
<fieldset style="height:1px;margin:0px;padding:0px;"></fieldset>
<div>
<input type="range" min="0" max="127" value="64" class="slider" style="width:50%;" id="attack" oninput="setattack(this.value);">
<button onclick="setattack(0,1);">+</button><button onclick="setattack(0,-1);">-</button><button onclick="setattack(64);">R</button>
<label class="labslide">Attack</label><label class="labslide" id="att">64</label>
</div>
<div>
<input type="range" min="0" max="127" value="64" class="slider" style="width:50%;" id="release" oninput="setrelease(this.value);">