diff --git a/data/bitmaps/xg/font.tsv b/data/bitmaps/xg/font.tsv index a4ce3ab8..7459c4ec 100644 --- a/data/bitmaps/xg/font.tsv +++ b/data/bitmaps/xg/font.tsv @@ -155,7 +155,7 @@ CdPt Bitmap 00b9 48f8080000 00ba 6090906000 00bb 4428542810 -00bc 1c223e2a22 +00bc 7c82fe9282 00bd 1c221c2a18 00be 20900e9020 00bf 0c12a20204 @@ -165,7 +165,7 @@ CdPt Bitmap 00c3 5ea8a8689e 00c4 1ea828a81e 00c5 1e28a8281e -00c6 1e283e2a22 +00c6 7e90fe9282 00c7 7a84848448 00c8 beaa2a2a22 00c9 3e2a2aaaa2 @@ -223,6 +223,187 @@ CdPt Bitmap 00fd 300a4a8a3c 00fe 3e14141408 00ff 308a0a8a3c +0100 1ea8a8a81e +0101 04aaaaaa1e +0104 78a0a0a47a +0105 085454543a +0106 1c2222a294 +0107 0c12529204 +0108 9ca222a294 +0109 0c52925204 +010c 1ca262a214 +010d 0c92529204 +010e 3ea262a21c +010f 0c1212fec0 +0110 10fe92827c +0111 0c12524afe +0112 3eaaaaaa22 +0113 1caaaaaa18 +0118 fca4a4a482 +0119 3854545432 +011a 3eaa6aaa22 +011b 1caa6aaa18 +011c 9ca222aa8c +011d 90aa2aaabc +0124 1e4888481e +0125 fe0850904e +012a 00a2bea200 +012b 00a2be8200 +0132 fe000482fc +0133 be000422bc +0134 0402529c50 +0135 0402529c40 +0139 fe02428202 +013a 0000be8200 +013d fe0202a2c2 +013e 82fe02a0c0 +0141 08fe122202 +0142 0092fe2200 +0143 3e1048843e +0144 3e1020a09e +0147 3e9048843e +0148 1e8850900e +014a f8422212fc +014b 381222221c +014c 1ca2a2a21c +014d 0c5252520c +0152 7c82fe9282 +0153 1c221c2a18 +0154 3e2868a816 +0155 1e08509008 +0158 3ea868a816 +0159 1e88509008 +015a 245252d2cc +015b 102a6aaa04 +015c a4d252d2cc +015d 90aa2aaa84 +0160 24d252d24c +0161 10aa6aaa04 +0164 10905e9010 +0165 20fc2282c4 +016a 3c8282823c +016b 3c8282843e +016c 9c4242429c +016d 9c4242449e +016e 1c42a2421c +016f 1c42a2441e +0178 20900e9020 +0179 464a52e2c2 +017a 22266ab222 +017b 464ad26242 +017c 2226aa3222 +017d 46ca52e242 +017e 22a66ab222 +01cd 1ea868a81e +01ce 04aa6aaa1e +01cf 00925e9200 +01d0 00925e8200 +01d1 1ca262a21c +01d2 0c9252920c +01d3 3c8242823c +01d4 3c8242843e +01d5 0ca282a20c +01d6 0ca282a40e +01d7 0c2202a28c +01d8 0c2202a48e +01d9 0ca242a20c +01da 0ca242a40e +01db 8ca202220c +01dc 8ca202240e +01dd 0c2a2a2a1c +01fe 3c465ae2bc +01ff 1c262ab29c +0250 3c2a2a2a10 +0251 1c22223c02 +0252 201e22221c +0253 7e92a2a21c +0254 142222221c +0255 1a242a2a04 +0256 18242414fe +0257 0c12127e80 +0258 182a2a2a1c +0259 0c2a2a2a1c +025a 0c2a2a1c20 +025b 142a2a2214 +025c 14222a2a14 +025d 14222a1420 +025e 1c222a2a14 +025f 00020a3c08 +0260 102a2a7c80 +0261 102a2a2a3c +0262 1c222a2a0c +0263 20100e1020 +0264 202c122c20 +0265 380404083e +0266 7e90a0a01e +0267 7c90a2a21c +0268 002abe0a00 +0269 00003c0200 +026a 00223e2200 +026b 0892fe0a10 +026c 10aafe0a00 +026d 0080fc0200 +026e fc4052526c +026f 3c020c023e +0270 380438043e +0271 38223a221c +0272 023c10201c +0273 3c10201c02 +0274 3e1008043e +0275 1c2a2a2a1c +0276 1c223e2a22 +0277 1c222c221c +0278 1028fe2810 +0279 040202043e +027a 04020204fe +027b 080408fc02 +027c 7e20404020 +027d 7c22404020 +027e 1e20202010 +027f 102020201e +0280 3e28282816 +0281 3e0a0a0a34 +0282 44aaa8a810 +0283 04027c8040 +0284 04127c9040 +0285 40807c0204 +0286 040a7c8240 +0287 40907e1000 +0288 0020fc2204 +0289 3c1212143e +028a 2c3202322c +028b 3c02022418 +028c 0618201806 +028d 1e2018201e +028e 0618609886 +028f 20100e1020 +0290 4c54546402 +0291 4c54566c4c +0292 8482a2a2dc +0293 848aa6a2dc +0294 40808e9060 +0295 60908e8040 +0296 0402e2120c +0297 7c82828244 +0298 7c8292827c +0299 3e2a2a2a14 +029a 142a2a221c +029b 1c222a2a4c +029c 3e0808083e +029d 00042abc08 +029e 00885020fe +029f 3e02020202 +02a0 1028287e80 +02a1 40848e9460 +02a2 60948e8440 +02ac 4824482448 +02ad 6c4848486c +02ae 203008083e +02af 2030083c02 +02c2 0010284400 +02c3 0044281000 +02c4 0810201008 +02c5 2010081020 02c6 0040804000 02c7 0080408000 02c8 00c0000000 @@ -233,36 +414,18 @@ CdPt Bitmap 02cd 0002020200 02ce 0004020000 02cf 0000020400 -0370 0000000000 -0371 0000000000 -0372 0000000000 -0373 0000000000 -0374 0000000000 -0375 0000000000 -0376 0000000000 -0377 0000000000 -0378 0000000000 -0379 0000000000 -037a 0000000000 -037b 0000000000 -037c 0000000000 -037d 0000000000 -037e 0000000000 -037f 1a2660a61a -0380 0000000000 -0381 0000000000 -0382 0000000000 -0383 0000000000 -0384 0000000000 -0385 0000000000 +02d0 0022362200 +02dc 4080402040 +02e5 008080fe00 +02e6 004040fe00 +02e7 001010fe00 +02e8 000404fe00 +02e9 000202fe00 0386 c0007e907e -0387 0000000000 0388 c000fe9292 0389 c000fe10fe 038a c00082fe82 -038b 0000000000 038c c0007c827c -038d 0000000000 038e c000f00ef0 038f c07a86867a 0390 4000dc0240 @@ -283,7 +446,6 @@ CdPt Bitmap 039f 7c8282827c 03a0 fe808080fe 03a1 fe90909060 -03a2 0000000000 03a3 c6aa928282 03a4 8080fe8080 03a5 c0300e30c0 @@ -328,10 +490,36 @@ CdPt Bitmap 03cc 0c1252920c 03cd 1c0242920c 03ce 0c1244920c +03e2 f20af20afc +03e3 320a320a3c +03e4 60901010fe +03e5 102808083e +03e6 f224242418 +03e7 0668242418 +03e8 4c92929264 +03e9 042a2a2a10 +03ea 866a126a86 +03eb 262a122a26 +03ec 7ca2a2a29c +03ed 7c92a2a29c +03ee 6042fe42fc +03ef 3022fc2020 +0400 beaa2a2a22 0401 3eaa2aaa22 +0402 80fe90a21c +0403 3e2060a020 0404 7c92928244 +0405 649292924c 0406 0082fe8200 0407 00a23ea200 +0408 040282fc80 +0409 3e40fe120c +040a fe10fe120c +040b 80fe90a01e +040c 3e48942200 +040d 3e8448103e +040e 308a4a8a3c +040f fc040604fc 0410 7e9090907e 0411 fe9292928c 0412 fe9292926c @@ -396,18 +584,131 @@ CdPt Bitmap 044d 14222a2a1c 044e 3e081c221c 044f 122a2c283e +0450 1caa6a2a18 0451 1caa2aaa18 +0452 40fe48520c +0453 003e60a020 0454 1c2a2a2214 +0455 102a2a2a04 0456 0022be0200 0457 00a23e8200 +0458 040222bc00 +0459 0e103e0a04 +045a 3e083e0a04 +045b 40fe48500e +045c 1e448c1200 +045d 1e824c101e +045e 104a2a4a1c +045f 3c0406043c 0462 40fe52520c 0463 20fe2a2a04 -0472 7c9292927c +0472 7ca2928a7c 0473 3c5252523c 0474 f00c027c80 0475 3804021c20 0490 7e404040c0 0491 3e202020e0 +0492 10fe909080 +0493 083e282020 +049a fc30488406 +049b 7c10284406 +04a2 fc1010fc06 +04a3 3c08083c06 +04ae c0300e30c0 +04af 20100e1020 +04b0 c4340e34c4 +04b1 24140e1424 +04b2 cc3030cc06 +04b3 2418182406 +04b6 e01010fc06 +04b7 3008083c06 +04ba fe2020201e +04bb fe1020201e +04d8 5c9292927c +04d9 0c2a2a2a1c +04e2 3e8488903e +04e3 1e424c501e +04e8 7c9292927c +04e9 1c2a2a2a1c +04ee 308a8a8a3c +04ef 104a4a4a1c +0531 fc020204fa +0532 7e88888868 +0533 7088887e08 +0534 7080807e08 +0535 fc2222220c +0536 6282868a72 +0537 fe22222222 +0538 7e82828272 +0539 7e808c927c +053a 0c1212fc10 +053b fe1020201c +053c fe02020202 +053d fe103c023c +053e 9c6242a29c +053f f80404083e +0540 04844a5222 +0541 648a848a72 +0542 6080807e02 +0543 4e3252928e +0544 fc0202fc80 +0545 549292926c +0546 80fc02020c +0547 9ca2c28284 +0548 7e8080807e +0549 44848a9262 +054a 7080f8807e +054b 62a29a867a +054c 7e80807e08 +054d fc020202fc +054e 300808fe02 +054f 649292924c +0550 7e80808070 +0551 689292926c +0552 fe20202020 +0553 3844fe4438 +0554 7e94949464 +0555 7c8282827c +0556 44a2fe221c +0561 3c020c023e +0562 3e14242410 +0563 1028283e08 +0564 3c1020201e +0565 fc2222240e +0566 1028283e02 +0567 fe22222220 +0568 3e1222221a +0569 3e10242a1c +056a 0c1212fc10 +056b fe1020201c +056c 00003e0200 +056d fe1038043e +056e c4aa92922c +056f f80404083e +0570 fe1020201e +0571 ce5262540e +0572 3e10201e02 +0573 261a32ca86 +0574 3c0204fe80 +0575 0402023c00 +0576 80fc02043e +0577 264a4a4a32 +0578 3e1020201e +0579 462a2a2a32 +057a 380418043e +057b 162a2a2a12 +057c 3e1020261a +057d 3c0202043e +057e 380408fe02 +057f 3c023c201e +0580 3e1020201c +0581 102a2a2a3c +0582 3e02020202 +0583 3804fe201c +0584 3e2a2a2a12 +0585 1c2222221c +0586 48a4fe2418 +0587 fc02043e02 05d0 2618080c32 05d1 2222221e02 05d2 2224180600 @@ -435,12 +736,183 @@ CdPt Bitmap 05e8 202020201e 05e9 3c0a32023c 05ea 223e20201e +16a0 fe2850a000 +16a1 fe149428d0 +16a2 fe8080403e +16a3 fe80661806 +16a4 fe8090403e +16a5 fe908e403e +16a6 fe28282810 +16a7 fe44544438 +16a8 fea0500000 +16a9 fea050a000 +16aa fea0508000 +16ab fea0502800 +16ac 5028fe140a +16ad 0000fe140a +16ae 0a14fe0000 +16af 0a14fe2850 +16b0 0a14fe2040 +16b1 fe88542200 +16b2 0010284400 +16b3 fe08040200 +16b4 fe20408000 +16b5 fe109020c0 +16b6 30fe304080 +16b7 c6281028c6 +16b8 d6281028d6 +16b9 fe88502000 +16ba fe100804fe +16bb fe502814fe +16bc 4428fe2844 +16bd 0030fe3000 +16be 4020fe1008 +16bf 0000fe1008 +16c0 4030fe3008 +16c1 0000fe0000 +16c2 0030fe3000 +16c3 2050001408 +16c4 1028fe2810 +16c5 0810fe2040 +16c6 0810fe0000 +16c7 0402fe8040 +16c8 fe82448200 +16c9 8040fe4080 +16ca 0028549200 +16cb f80810203e +16cc 0000e00000 +16cd 0030f03000 +16ce 2010f81020 +16cf 2040fe4020 +16d0 2040fe0000 +16d1 2058fe1800 +16d2 fe92aa4400 +16d3 0000fe2850 +16d4 fe92b6926c +16d5 fe10284482 +16d6 fe402040fe +16d7 fe502050fe +16d8 c020fe20c0 +16d9 00c0fec000 +16da 0000fe4020 +16db 0018fe5820 +16dc 1028442810 +16dd 10aa44aa10 +16de fe443844fe +16df 2254885422 +16e0 8080fe8080 +16e1 4428fe2844 +16e2 0204fe4080 +16e3 0204fe0402 +16e4 926cfe6c92 +16e5 fe542854fe +16e6 0608fe0806 +16e7 00000e0000 +16e8 2844fe4428 +16e9 00205088fe +16ea f84810243e +16eb 0018180000 +16ec 0000240000 +16ed 10107c1010 +16ee 0810fe8040 +16ef c628fe28c6 +16f0 3844fe4438 +16f1 fe10201806 +16f2 3e201008f8 +16f3 40a0fea040 +16f4 08f0101e20 +16f5 000054aa00 +16f6 8468102c42 +16f7 fe2020100e +16f8 0204f80402 +1950 201020201e +1951 20142a2a1e +1952 3e1020201e +1953 30103c221e +1954 30103c023e +1955 3e0408043e +1956 3c221e201e +1957 3c223e221e +1958 020402043e +1959 3c0202043e +195a 3c023e221e +195b 3c1212143e +195c 78047c443e +195d 3c1222241e +195e 78447e403c +195f 60207e403c +1960 402854543e +1961 602078443e +1962 3e0408103e +1963 0000fe0000 +1964 7e848a7e00 +1965 7e80807e00 +1966 7e80827c00 +1967 0000fc0202 +1968 0402fc0202 +1969 3c02023c00 +196a 7c92aa7800 +196b 7c82827800 +196c 00007e8080 +196d 60207e0478 +1970 223c203c02 +1971 1c2a2a2a18 +1972 1c2222241e +1973 3c02122a1c +1974 1c22222214 +1e9e 7e80a2d28c +2080 1c262a321c +2081 00123e0200 +2082 12262a2a12 +2083 14222a2a14 +2084 0c14243e04 +2085 3a2a2a2a24 +2086 1c2a2a2a04 +2087 2020262830 +2088 142a2a2a14 +2089 102a2a2a1c 2160 0082fe8200 2161 82fe82fe82 2162 82fe82fe82 2163 fe00fc02fc 2164 f00c020cf0 2165 fc02fc00fe +2191 10207c2010 +2192 1010543810 +2193 10087c0810 +2196 7860504804 +2197 0448506078 +2198 4024140c3c +2199 3c0c142440 +21b2 081c2a08f8 +2260 282c386828 +2264 0222528a02 +2265 028a522202 +23eb 2266ee6622 +23ec 88cceecc88 +23f8 fefe00fefe +2588 7c7c7c7c7c +25b6 00fe7c3810 +25b7 00fe442810 +25c0 10387cfe00 +25c1 102844fe00 +25cf 387c7c7c38 +2630 5454545454 +2631 5454145454 +2632 5454445454 +2633 5454045454 +2634 5454505454 +2635 5454105454 +2636 5454405454 +2637 5454005454 +2640 64949e9464 +2641 7c92fe927c +2642 0c12526c70 +2643 244c5424fe +2644 fe4850540a +2645 f024fa24f0 +2646 e014fe14e0 +2647 fe92929262 2648 60807e8060 2649 dc222222dc 264a 82fe82fe82 @@ -453,6 +925,123 @@ CdPt Bitmap 2651 f840fa1408 2652 2448244824 2653 927c107c92 +2665 30783c7830 +266a 0606fe4020 +266b 0cfc80467e +266d fe0a12120c +266e 00f8283e00 +266f 28fe28fe28 +2c80 8c92523c02 +2c81 042a2a1c02 +2c82 fe9292926c +2c83 3e2a2a2a14 +2c84 fe80808080 +2c85 003e202020 +2c86 0e32c2320e +2c87 061a221a06 +2c88 7c92928244 +2c89 1c2a2a2214 +2c8a 7088884a84 +2c8b 1824241422 +2c8c 868a92a2c2 +2c8d 22262a3222 +2c8e fe101010fe +2c8f 3e0808083e +2c90 7c9292927c +2c91 1c2a2a2a1c +2c92 0082fe8200 +2c93 00003c0200 +2c94 fe10284482 +2c95 3e08142200 +2c96 8698601806 +2c97 2214080402 +2c98 02fc02fc02 +2c99 023c023c02 +2c9a fe403804fe +2c9b 3e1008043e +2c9c 9296bad292 +2c9d 2a2e2a3a2a +2c9e 7c8282827c +2c9f 1c2222221c +2ca0 fe808080fe +2ca1 3e2020203e +2ca2 fe90909060 +2ca3 3e28282810 +2ca4 7c82828244 +2ca5 1c22222214 +2ca6 8080fe8080 +2ca7 20203e2020 +2ca8 c0300e30c0 +2ca9 202c122c20 +2caa 3844fe4438 +2cab 08143e1408 +2cac c6281028c6 +2cad 2214081422 +2cae 7008fe0870 +2caf 18043e0418 +2cb0 7c823c827c +2cb1 1c220c221c +2cb2 2020e02020 +2cb3 0808380808 +2cb4 1028449200 +2cb5 0814220800 +2cb6 9292929292 +2cb7 2a2a2a2a2a +2cb8 04844a5222 +2cb9 04042a2a12 +2cba 2020202020 +2cbb 1010101010 +2cbc fe00fe00fe +2cbd 3e003e003e +2cbe fe10fe10fe +2cbf 3e083e083e +2cc0 fe94949464 +2cc1 3e2a2a2a12 +2cc2 328a728a3c +2cc3 328a728a3c +2cc4 8482a2a2dc +2cc5 24222a2a34 +2cc6 000638c000 +2cc7 0204081020 +2cc8 0cb2929a60 +2cc9 042a3e2a10 +2cca 6092828478 +2ccb 102a22221c +2ccc 448292926c +2ccd 14222a2a14 +2cce 0e70809060 +2ccf 0618202810 +2cd0 fe02020202 +2cd1 3e02020202 +2cd2 3c4282920c +2cd3 1c22222a04 +2cd4 002060be00 +2cd5 0008182e00 +2cd6 06fe040404 +2cd7 063e040404 +2cd8 fe020202fe +2cd9 3e0202023e +2cda 0e32ca360e +2cdb 061a2a1a06 +2cdc 1c2262a29c +2cdd 0c1272928c +2cde fe82828080 +2cdf 3e22222020 +2ce0 e0107e9060 +2ce1 30081e2810 +2ce2 90aaaafc80 +2ce3 405a5a7c40 +2ce4 f820508a04 +2ce5 0c04fea44c +2ce6 0c08fea84c +2ce7 141af0b45a +2ce8 0808fea848 +2ce9 120cfeac52 +2cea 1c223c2214 +2ceb 728a728a72 +2cec 122a122a12 +2ced fe443844fe +2cee 3e1408143e 2e86 fe808082fe 2e87 02fc80fe02 2e8e 82fc80fe82 @@ -725,6 +1314,7 @@ CdPt Bitmap 304b 42fc423e70 304c 227ca23eb8 304d 5452fa5252 +304e 5452fa52d2 304f 1028448200 3050 0814942280 3051 fe0022fc20 @@ -746,7 +1336,7 @@ CdPt Bitmap 3061 40fa52524c 3062 207aaa2aa4 3063 101212120c -3064 202222221c +3064 2022424438 3065 2022a2229c 3066 809ca2c282 3067 202cb222a2 @@ -887,6 +1477,10 @@ CdPt Bitmap 30f4 1812b21498 30f5 121438121e 30f6 0832121c10 +30f7 3822a222bc +30f8 3828fe28a8 +30f9 2222ae32a2 +30fa 282aaa2abc 30fb 0000100000 30fc 1010101010 30fd 0020100800 @@ -1018,6 +1612,22 @@ CdPt Bitmap 31bd a2d48894a2 31be d0381638d0 31bf 0ef000f00e +31f0 083212121c +31f1 2a2a020438 +31f2 2224283422 +31f3 003e080400 +31f4 22322c2834 +31f5 0e3000300e +31f6 3c0a0a1212 +31f7 2222222438 +31f8 1020100c02 +31f9 14123e1014 +31fa 061a220402 +31fb 2a2a2a2a2c +31fc 003a02023c +31fd 023c003e04 +31fe 3e02020408 +31ff 3e2222223e 362f 247aecaaee 4e00 1010101010 4e01 8082fe8080 @@ -1047,6 +1657,7 @@ CdPt Bitmap 4e48 264a922442 4e49 6214c81462 4e4b 4244ca5262 +4e4c 7aca484a6e 4e59 848a92a2c6 4e5d 42fc407e02 4e5e 56da5a5256 @@ -1148,7 +1759,7 @@ CdPt Bitmap 535d 40e000e040 5364 3e36eab6be 5369 fe809088f0 -536f f2fc00fef0 +536f 729c00fef0 5382 06f8808080 539f feb4f2beb4 53a1 feb4f2beb4 @@ -1215,6 +1826,7 @@ CdPt Bitmap 5b83 605cca5260 5b89 d2ba94bad2 5b8f 6256fa5266 +5b97 645ade5864 5b98 605ed65660 5b9d 7a5ade5a7e 5b9e 6456fc5664 @@ -1240,6 +1852,10 @@ CdPt Bitmap 5c3e fea8beaaea 5c6e 7808fe0878 5c71 3e02fe023e +5c9b 7ace684a6e +5cf6 7ace684a6e +5d8b 7ace684a6e +5d8c 7ace684a6e 5ddd fe00fe00fe 5de5 8282fe8282 5df1 9c929292f6 @@ -1272,6 +1888,7 @@ CdPt Bitmap 5f25 baeed27e50 5f4c baeed27e50 5f50 92929292fe +5f53 aa2aea2abe 5f61 2a2a54a800 5f65 5e70d47a54 5f66 5e70d47a54 @@ -1302,6 +1919,7 @@ CdPt Bitmap 6534 021af45a42 6535 22f4487442 653f fe10fa447a +654f da5cf64876 6587 4274c87442 6589 527cd47e50 6597 a45404fe04 @@ -1312,6 +1930,7 @@ CdPt Bitmap 65e5 fe929292fe 65e9 f4d4feb4f4 65f6 fefe50f65e +660e 685afcaafe 6625 687eee7e68 662d fe00aecaee 663c 1aeeaebeea @@ -1358,6 +1977,7 @@ CdPt Bitmap 6cbb ae006eaa6e 6cbc ae00aecaee 6cbf ae00ee8aee +6cc9 747ade7874 6cd5 ae0056fa56 6d3d ae40aeae40 6d41 ae005eec5a @@ -1369,6 +1989,7 @@ CdPt Bitmap 6f22 ae00ee90ee 706b 7204f80472 70b9 1ef456541e +70cf 7aca484a6e 7121 929cf09e92 71df e656de56e6 722a 027c407c82 @@ -1392,9 +2013,11 @@ CdPt Bitmap 7531 7c54fc547c 7532 f8a8fea8f8 7533 7c54fe547c +7537 eadcf8baee 753b bebad6babe 7545 7cfeecaaee 756b bebad6babe +7576 aa2aea2abe 758b 8c82fe92d2 7592 2a7c40c040 7676 a0c000c0a0 @@ -1416,7 +2039,9 @@ CdPt Bitmap 77e5 d27c527c7c 77f3 9ee09e929e 793a 28a2bea028 +793b 48de680000 796d 54b23eb054 +798f de68b6b6b6 79b8 7e58e85a7e 79be 54587e9894 79c1 547e943ece @@ -1431,12 +2056,14 @@ CdPt Bitmap 7c73 5410fe1054 7cf8 2a78ae282a 7d00 5aaa189ef2 -7d30 5aa81afefe +7d14 5aaa58ce5a +7d30 5aaa7c547c 7dad 5aaa7efe4a 7db2 feb880bafe 7e23 3af8deb8fa 7eaa 5aaa189ef2 -7ec6 5aa81afefe +7eaf 5aaa58ce5a +7ec6 5aaa7c547c 7ef4 5aaa7efe4a 7f36 d6527e5256 7f51 feb880bafe @@ -1484,6 +2111,8 @@ CdPt Bitmap 8840 027efe7e02 884c 5ea000a2bc 8863 507eda444a +8864 4448de6854 +88d5 de6856a656 8907 da5a5c5a5a 897e befca4fcbe 897f befaa2fabe @@ -1534,6 +2163,8 @@ CdPt Bitmap 9054 be024af24a 9091 feaabaaafa 9093 645864fed8 +90ce 7ed274fed8 +90ed 74de74fed8 90f7 729c00fed8 9109 729c00fed8 9115 729c00fed8 @@ -1544,6 +2175,8 @@ CdPt Bitmap 91cc f2d6feb6f2 91cd 427a7eba82 91d1 2a6ebe6e2a +9234 5e8a50b65c +94c3 5e8a50b65c 9577 feb2e8a4aa 957f feb2e8a4aa 9580 fee000e2fe @@ -1624,9 +2257,58 @@ CdPt Bitmap 9f50 527cd07e50 9f8d 46f844de4a 9f99 46f844de4a +a4d0 fe9292926c +a4d1 fe90909060 +a4d2 0c121212fe +a4d3 fe8282827c +a4d4 8080fe8080 +a4d5 0202fe0202 +a4d6 7c8282925c +a4d7 fe10284482 +a4d8 82442810fe +a4d9 040282fc80 +a4da 7c82828244 +a4db 448282827c +a4dc 868a92a2c2 +a4dd fe90909080 +a4de 02121212fe +a4df fe403040fe +a4e0 fe403804fe +a4e1 fe02020202 +a4e2 649292924c +a4e3 fe90989462 +a4e4 8c523212fe +a4e5 1e6080601e +a4e6 f00c020cf0 +a4e7 fe101010fe +a4e8 749282827c +a4e9 7e80808070 +a4ea fc027c02fc +a4eb c6281028c6 +a4ec c0300e30c0 +a4ed 6c929292fe +a4ee 7e9090907e +a4ef fc121212fc +a4f0 fe92929282 +a4f1 82929292fe +a4f2 0082fe8200 +a4f3 7c8282827c +a4f4 fc020202fc +a4f5 7e8080807e +a4f6 80808080fe +a4f7 7c828282fe +a4f8 000c0c0000 +a4f9 000a0c0000 +a4fa 0c0c000c0c +a4fb 0c0c000a0c +a4fc 006a6c0000 +a4fd 006c6c0000 +a4fe 1010000c0c +a4ff 0028282800 f902 54f45e5454 f90a 2a6ebe6e2a f91f 2aea2aea2a +f92c 7ed274fed8 f92d 5a4cfe4c5a f92f ea4cd84aee f934 52f45e7652 @@ -1644,6 +2326,7 @@ f988 bea8bea8be f98a 424cf0427e f98e 5cd47e5454 f9a8 5094b49a50 +f9b1 5e8a50b65c f9ba 8082bec080 f9c4 46f844de4a f9ca ae005eec5a @@ -1657,8 +2340,10 @@ fa08 5ea000a2bc fa09 fed854ee54 fa0a facca89efa fa0c 82fc80fe82 +fa1b de68b6b6b6 fa1e a4aafcaafc fa3c 7808fe0878 +fa41 da5cf64876 fa44 fe48d85a5e fa45 ae00d85a5e fa47 ae00ee90ee @@ -1676,6 +2361,102 @@ faa8 425ef25e42 fab4 54fc5efc54 fab7 da5a5c5a5a fac7 6e506efe4a +ff01 0000fa0000 +ff02 00c000c000 +ff03 28fe28fe28 +ff04 2454fe5448 +ff05 644810244c +ff06 6c929a640a +ff07 0000c00000 +ff08 00007c8200 +ff09 00827c0000 +ff0a 28107c1028 +ff0b 10107c1010 +ff0c 000a0c0000 +ff0d 1010101010 +ff0e 0006060000 +ff0f 000638c000 +ff10 7c8a92a27c +ff11 0042fe0200 +ff12 42868a9262 +ff13 448292926c +ff14 182848fe08 +ff15 e4a2a2a29c +ff16 3c5292920c +ff17 80808eb0c0 +ff18 6c9292926c +ff19 6092929478 +ff1a 006c6c0000 +ff1b 006a6c0000 +ff1c 0010284400 +ff1d 0028282800 +ff1e 0044281000 +ff1f 40808a9060 +ff20 7c92aaaa78 +ff21 7e9090907e +ff22 fe9292926c +ff23 7c82828244 +ff24 fe8282827c +ff25 fe92929282 +ff26 fe90909080 +ff27 7c8282925c +ff28 fe101010fe +ff29 0082fe8200 +ff2a 040282fc80 +ff2b fe10284482 +ff2c fe02020202 +ff2d fe403040fe +ff2e fe403804fe +ff2f 7c8282827c +ff30 fe90909060 +ff31 7c828a847a +ff32 fe90989462 +ff33 649292924c +ff34 8080fe8080 +ff35 fc020202fc +ff36 f00c020cf0 +ff37 fc027c02fc +ff38 c6281028c6 +ff39 c0300e30c0 +ff3a 868a92a2c2 +ff3b 0000fe8200 +ff3c 00c0380600 +ff3d 0082fe0000 +ff3e 0040804000 +ff3f 0202020202 +ff40 0000804000 +ff41 042a2a2a1e +ff42 fe1222221c +ff43 1c22222214 +ff44 1c222212fe +ff45 1c2a2a2a18 +ff46 00107e9040 +ff47 102a2a2a3c +ff48 fe1020201e +ff49 0022be0200 +ff4a 040222bc00 +ff4b 00fe081422 +ff4c 0082fe0200 +ff4d 3e203e201e +ff4e 3e1020201e +ff4f 1c2222221c +ff50 3e28282810 +ff51 102828283e +ff52 3e10202010 +ff53 102a2a2a04 +ff54 20fc220204 +ff55 3c0202043e +ff56 300c020c30 +ff57 3c020c023c +ff58 2214081422 +ff59 300a0a0a3c +ff5a 22262a3222 +ff5b 00106c8200 +ff5c 0000fe0000 +ff5d 00826c1000 +ff5e 1020100810 +ff5f 7c82007c82 +ff60 827c00827c ff61 00040a0400 ff62 f880800000 ff63 000002023e @@ -1769,33 +2550,27 @@ ffbb 282828283e ffbc 3e2a2a2a2a ffbd 223e223e22 ffbe 141a3a1a14 -ffbf 0000000000 -ffc0 0000000000 -ffc1 0000000000 ffc2 0000fe1000 ffc3 00fe10fe00 ffc4 0000fe2800 ffc5 00fe28fe00 ffc6 0010fe0000 ffc7 0010fe00fe -ffc8 0000000000 -ffc9 0000000000 ffca 0028fe0000 ffcb 0028fe00fe ffcc 0808380808 ffcd 083808fe10 ffce 083808fefe ffcf 083808fe00 -ffd0 0000000000 -ffd1 0000000000 ffd2 0838083808 ffd3 10101c1010 ffd4 101e1004fe ffd5 101e14fefe ffd6 101e10fe00 ffd7 101c101c10 -ffd8 0000000000 -ffd9 0000000000 ffda 1010101010 ffdb 04040404fe -ffdc 0000fe0000 \ No newline at end of file +ffdc 0000fe0000 +ffe0 3844c64428 +ffe1 127e929242 +ffe5 a8683e68a8 \ No newline at end of file diff --git a/dist/basic.mjs b/dist/basic.mjs index a3fc66c7..fcbaec51 100644 --- a/dist/basic.mjs +++ b/dist/basic.mjs @@ -1,7 +1,7 @@ -var _=Object.create;var O=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var z=(t,n)=>()=>(n||t((n={exports:{}}).exports,n),n.exports);var q=(t,n,c,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of V(n))!K.call(t,s)&&s!==c&&O(t,s,{get:()=>n[s],enumerable:!(e=X(n,s))||e.enumerable});return t};var Q=(t,n,c)=>(c=t!=null?_(F(t)):{},q(n||!t||!t.__esModule?O(c,"default",{value:t,enumerable:!0}):c,t));var N=z((ze,T)=>{(function(){"use strict";let t={fatal:!0},n=[new TextDecoder("iso-8859-15",t),new TextDecoder("sjis",t),new TextDecoder("euc-jp",t),new TextDecoder("utf-8",t),new TextDecoder("utf-16",t),new TextDecoder("ascii")],c={debug:!1,parse:function(e,s){if(e instanceof Uint8Array)return c.Uint8(e);if(typeof e=="string")return c.Base64(e);if(e instanceof HTMLElement&&e.type==="file")return c.addListener(e,s);throw new Error("MidiParser.parse() : Invalid input provided")},addListener:function(e,s){if(!File||!FileReader)throw new Error("The File|FileReader APIs are not supported in this browser. Use instead MidiParser.Base64() or MidiParser.Uint8()");if(e===void 0||!(e instanceof HTMLElement)||e.tagName!=="INPUT"||e.type.toLowerCase()!=="file")return console.warn("MidiParser.addListener() : Provided element is not a valid FILE INPUT element"),!1;s=s||function(){},e.addEventListener("change",function(r){if(!r.target.files.length)return!1;console.log("MidiParser.addListener() : File detected in INPUT ELEMENT processing data..");let o=new FileReader;o.readAsArrayBuffer(r.target.files[0]),o.onload=function(h){s(c.Uint8(new Uint8Array(h.target.result)))}})},Base64:function(e){let s=function(h){var g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";if(h=h.replace(/^.*?base64,/,""),h=String(h).replace(/[\t\n\f\r ]+/g,""),!/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/.test(h))throw new TypeError("Failed to execute _atob() : The string to be decoded is not correctly encoded.");h+="==".slice(2-(3&h.length));let b,u="",a,i,l=0;for(;l>16&255):i===64?String.fromCharCode(b>>16&255,b>>8&255):String.fromCharCode(b>>16&255,b>>8&255,255&b);return u}(e=String(e));var r=s.length;let o=new Uint8Array(new ArrayBuffer(r));for(let h=0;h{i[d]=this.readInt(1)});for(let p=0;p191||y>127&&y<160)throw new RangeError(`Invalid code point: ${y}`)}l=!0,console.debug(`String byte sequence in ${n[p].encoding}`)}catch(d){console.debug(`SMF string ${d}`)}return f||"String byte sequence read failed."},backOne:function(){this.pointer--},readIntVLV:function(){let a=0;if(this.pointer>=this.data.byteLength)return-1;if(this.data.getUint8(this.pointer)<128)a=this.readInt(1);else{let l=[];for(;128<=this.data.getUint8(this.pointer);)l.push(this.readInt(1)-128);var i=this.readInt(1);for(let f=1;f<=l.length;f++)a+=l[l.length-f]*Math.pow(128,f);a+=i}return a}};if(s.data=new DataView(o.buffer,o.byteOffset,o.byteLength),s.readInt(4)!==1297377380)return console.warn("Header validation failed (not MIDI standard or file corrupt.)"),!1;s.readInt(4);let r={};r.formatType=s.readInt(2),r.tracks=s.readInt(2),r.track=[];var o=s.readInt(1),h=s.readInt(1);128<=o?(r.timeDivision=[],r.timeDivision[0]=o-128,r.timeDivision[1]=h):r.timeDivision=256*o+h;for(let a=1;a<=r.tracks;a++){r.track[a-1]={event:[]};var g,b=s.readInt(4);if(b===-1)break;if(b!==1297379947)return!1;s.readInt(4);let i=0,l=!1,f,p;for(;!l&&(i++,r.track[a-1].event[i-1]={},r.track[a-1].event[i-1].deltaTime=s.readIntVLV(),(f=s.readInt(1))!==-1);)if(128<=f?p=f:(f=p,s.movePointer(-1)),f===255){r.track[a-1].event[i-1].type=255,r.track[a-1].event[i-1].metaType=s.readInt(1);var u=s.readIntVLV();switch(r.track[a-1].event[i-1].metaType){case 47:case-1:l=!0;break;case 1:case 2:case 3:case 4:case 5:case 7:case 6:r.track[a-1].event[i-1].data=s.readStr(u);break;case 33:case 89:case 81:r.track[a-1].event[i-1].data=s.readInt(u);break;case 84:r.track[a-1].event[i-1].data=[],r.track[a-1].event[i-1].data[0]=s.readInt(1),r.track[a-1].event[i-1].data[1]=s.readInt(1),r.track[a-1].event[i-1].data[2]=s.readInt(1),r.track[a-1].event[i-1].data[3]=s.readInt(1),r.track[a-1].event[i-1].data[4]=s.readInt(1);break;case 88:r.track[a-1].event[i-1].data=[],r.track[a-1].event[i-1].data[0]=s.readInt(1),r.track[a-1].event[i-1].data[1]=s.readInt(1),r.track[a-1].event[i-1].data[2]=s.readInt(1),r.track[a-1].event[i-1].data[3]=s.readInt(1);break;default:this.customInterpreter!==null&&(r.track[a-1].event[i-1].data=this.customInterpreter(r.track[a-1].event[i-1].metaType,s,u)),this.customInterpreter!==null&&r.track[a-1].event[i-1].data!==!1||(s.readInt(u),r.track[a-1].event[i-1].data=s.readInt(u),this.debug&&console.info("Unimplemented 0xFF meta event! data block readed as Integer"))}}else switch((f=f.toString(16).split(""))[1]||f.unshift("0"),r.track[a-1].event[i-1].type=parseInt(f[0],16),r.track[a-1].event[i-1].channel=parseInt(f[1],16),r.track[a-1].event[i-1].type){case 15:this.customInterpreter!==null&&(r.track[a-1].event[i-1].data=this.customInterpreter(r.track[a-1].event[i-1].type,s,!1)),this.customInterpreter!==null&&r.track[a-1].event[i-1].data!==!1||(g=s.readIntVLV(),r.track[a-1].event[i-1].data=s.readInt(g),this.debug&&console.info("Unimplemented 0xF exclusive events! data block readed as Integer"));break;case 10:case 11:case 14:case 8:case 9:r.track[a-1].event[i-1].data=[],r.track[a-1].event[i-1].data[0]=s.readInt(1),r.track[a-1].event[i-1].data[1]=s.readInt(1);break;case 12:case 13:r.track[a-1].event[i-1].data=s.readInt(1);break;case-1:l=!0;break;default:if(this.customInterpreter!==null&&(r.track[a-1].event[i-1].data=this.customInterpreter(r.track[a-1].event[i-1].metaType,s,!1)),this.customInterpreter===null||r.track[a-1].event[i-1].data===!1)return console.log("Unknown EVENT detected... reading cancelled!"),!1}}return r},customInterpreter:null};if(typeof T<"u")T.exports=c;else{let e=typeof window=="object"&&window.self===window&&window||typeof self=="object"&&self.self===self&&self||typeof global=="object"&&global.global===global&&global;e.MidiParser=c}})()});var w=class{#e={};addEventListener(t,n){this.#e[t]||(this.#e[t]=[]),this.#e[t].unshift(n)}removeEventListener(t,n){if(this.#e[t]){let c=this.#e[t].indexOf(n);c>-1&&this.#e[t].splice(c,1),this.#e[t].length<1&&delete this.#e[t]}}dispatchEvent(t,n){let c=new Event(t),e=this;c.data=n,this.#e[t]?.length>0&&this.#e[t].forEach(function(s){try{s?.call(e,c)}catch(r){console.error(r)}}),this[`on${t}`]&&this[`on${t}`](c)}};var A=class{#e={};context;set(t,n){this.#e[t]=n}has(t){return!!this.#e[t]}async read(t,n){if(!this.has(t))throw new Error(`No decoder registered for "${t}"`);return await this.#e[t].call(this.context||this,n)}};var Y=function(t,n){let c=!0;return n.forEach((e,s)=>{c=c&&t[s]==e}),c},I=function(t){let n=0;return t.forEach(c=>{n*=256,n+=c}),n},v=new TextDecoder,U=new A;U.set("s7e",async function(t){let n=new Uint8Array(await t.slice(0,65536).arrayBuffer()),c="MSB LSB PRG NME",e=[0,0,0,0],s=32,r=0,o=0,h=!0,g=[],b=0;for(;h;){let u=n.subarray(r);([()=>{v.decode(u.subarray(0,4))=="YSFC"?(r+=80,o=1):r++},()=>{if(Y(u.subarray(0,4),e))g.forEach((a,i,l)=>{let f=I(n.subarray(a.start+4,a.start+8));a.length=f}),o=2;else{let a=v.decode(u.subarray(0,4)),i=I(u.subarray(4,8));g.push({type:a,start:i}),r+=8}},()=>{let a=g[b],i=n.subarray(a.start,a.start+a.length),l=32;switch(a.type){case"ENVC":{let f=s;for(;f=g.length&&(o=3,h=!1)}][o]||(()=>{h=!1}))()}return c});var j=["off","hall","room","stage","plate","delay LCR","delay LR","echo","cross delay","early reflections","gate reverb","reverse gate"].concat(new Array(4),["white room","tunnel","canyon","basement","karaoke"],new Array(43),["pass through","chorus","celeste","flanger","symphonic","rotary speaker","tremelo","auto pan","phaser","distortion","overdrive","amplifier","3-band EQ","2-band EQ","auto wah"],new Array(1),["pitch change","harmonic","touch wah","compressor","noise gate","voice channel","2-way rotary speaker","ensemble detune","ambience"],new Array(4),["talking mod","Lo-Fi","dist + delay","comp + dist + delay","wah + dist + delay","V dist","dual rotor speaker"]);var W=",a,i,u,e,o,ka,ki,ku,ke,ko,ky,kw,sa,si,su,se,so,sh,ta,ti,tu,te,to,t,ch,t,s,na,ni,nu,ne,no,ny,nn,ha,hi,hu,he,ho,hy,fa,fi,fu,fe,fo,ma,mi,mu,me,mo,my,mm,ya,yu,ye,yo,ra,ri,ru,re,ro,ry,wa,wi,we,wo,ga,gi,gu,ge,go,gy,gw,za,zi,zu,ze,zo,ja,ji,ju,je,jo,jy,da,di,du,de,do,dy,ba,bi,bu,be,bo,by,va,vi,vu,ve,vo,pa,pi,pu,pe,po,py,nga,ngi,ngu,nge,ngo,ngy,ng,hha,hhi,hhu,hhe,hho,hhy,hhw,*,_,,,~,.".split(","),Z={};`hi*, +var _=Object.create;var O=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var z=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports);var q=(t,i,c,e)=>{if(i&&typeof i=="object"||typeof i=="function")for(let s of V(i))!K.call(t,s)&&s!==c&&O(t,s,{get:()=>i[s],enumerable:!(e=X(i,s))||e.enumerable});return t};var Q=(t,i,c)=>(c=t!=null?_(F(t)):{},q(i||!t||!t.__esModule?O(c,"default",{value:t,enumerable:!0}):c,t));var N=z((Qe,T)=>{(function(){"use strict";let t={fatal:!0},i=[new TextDecoder("iso-8859-15",t),new TextDecoder("sjis",t),new TextDecoder("euc-jp",t),new TextDecoder("utf-8",t),new TextDecoder("utf-16",t),new TextDecoder("ascii")],c={debug:!1,parse:function(e,s){if(e instanceof Uint8Array)return c.Uint8(e);if(typeof e=="string")return c.Base64(e);if(e instanceof HTMLElement&&e.type==="file")return c.addListener(e,s);throw new Error("MidiParser.parse() : Invalid input provided")},addListener:function(e,s){if(!File||!FileReader)throw new Error("The File|FileReader APIs are not supported in this browser. Use instead MidiParser.Base64() or MidiParser.Uint8()");if(e===void 0||!(e instanceof HTMLElement)||e.tagName!=="INPUT"||e.type.toLowerCase()!=="file")return console.warn("MidiParser.addListener() : Provided element is not a valid FILE INPUT element"),!1;s=s||function(){},e.addEventListener("change",function(r){if(!r.target.files.length)return!1;console.log("MidiParser.addListener() : File detected in INPUT ELEMENT processing data..");let o=new FileReader;o.readAsArrayBuffer(r.target.files[0]),o.onload=function(h){s(c.Uint8(new Uint8Array(h.target.result)))}})},Base64:function(e){let s=function(h){var g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";if(h=h.replace(/^.*?base64,/,""),h=String(h).replace(/[\t\n\f\r ]+/g,""),!/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/.test(h))throw new TypeError("Failed to execute _atob() : The string to be decoded is not correctly encoded.");h+="==".slice(2-(3&h.length));let b,u="",a,n,l=0;for(;l>16&255):n===64?String.fromCharCode(b>>16&255,b>>8&255):String.fromCharCode(b>>16&255,b>>8&255,255&b);return u}(e=String(e));var r=s.length;let o=new Uint8Array(new ArrayBuffer(r));for(let h=0;h{n[d]=this.readInt(1)});for(let p=0;p191||y>127&&y<160)throw new RangeError(`Invalid code point: ${y}`)}l=!0,console.debug(`String byte sequence in ${i[p].encoding}`)}catch(d){console.debug(`SMF string ${d}`)}return f||"String byte sequence read failed."},backOne:function(){this.pointer--},readIntVLV:function(){let a=0;if(this.pointer>=this.data.byteLength)return-1;if(this.data.getUint8(this.pointer)<128)a=this.readInt(1);else{let l=[];for(;128<=this.data.getUint8(this.pointer);)l.push(this.readInt(1)-128);var n=this.readInt(1);for(let f=1;f<=l.length;f++)a+=l[l.length-f]*Math.pow(128,f);a+=n}return a}};if(s.data=new DataView(o.buffer,o.byteOffset,o.byteLength),s.readInt(4)!==1297377380)return console.warn("Header validation failed (not MIDI standard or file corrupt.)"),!1;s.readInt(4);let r={};r.formatType=s.readInt(2),r.tracks=s.readInt(2),r.track=[];var o=s.readInt(1),h=s.readInt(1);128<=o?(r.timeDivision=[],r.timeDivision[0]=o-128,r.timeDivision[1]=h):r.timeDivision=256*o+h;for(let a=1;a<=r.tracks;a++){r.track[a-1]={event:[]};var g,b=s.readInt(4);if(b===-1)break;if(b!==1297379947)return!1;s.readInt(4);let n=0,l=!1,f,p;for(;!l&&(n++,r.track[a-1].event[n-1]={},r.track[a-1].event[n-1].deltaTime=s.readIntVLV(),(f=s.readInt(1))!==-1);)if(128<=f?p=f:(f=p,s.movePointer(-1)),f===255){r.track[a-1].event[n-1].type=255,r.track[a-1].event[n-1].metaType=s.readInt(1);var u=s.readIntVLV();switch(r.track[a-1].event[n-1].metaType){case 47:case-1:l=!0;break;case 1:case 2:case 3:case 4:case 5:case 7:case 6:r.track[a-1].event[n-1].data=s.readStr(u);break;case 33:case 89:case 81:r.track[a-1].event[n-1].data=s.readInt(u);break;case 84:r.track[a-1].event[n-1].data=[],r.track[a-1].event[n-1].data[0]=s.readInt(1),r.track[a-1].event[n-1].data[1]=s.readInt(1),r.track[a-1].event[n-1].data[2]=s.readInt(1),r.track[a-1].event[n-1].data[3]=s.readInt(1),r.track[a-1].event[n-1].data[4]=s.readInt(1);break;case 88:r.track[a-1].event[n-1].data=[],r.track[a-1].event[n-1].data[0]=s.readInt(1),r.track[a-1].event[n-1].data[1]=s.readInt(1),r.track[a-1].event[n-1].data[2]=s.readInt(1),r.track[a-1].event[n-1].data[3]=s.readInt(1);break;default:this.customInterpreter!==null&&(r.track[a-1].event[n-1].data=this.customInterpreter(r.track[a-1].event[n-1].metaType,s,u)),this.customInterpreter!==null&&r.track[a-1].event[n-1].data!==!1||(s.readInt(u),r.track[a-1].event[n-1].data=s.readInt(u),this.debug&&console.info("Unimplemented 0xFF meta event! data block readed as Integer"))}}else switch((f=f.toString(16).split(""))[1]||f.unshift("0"),r.track[a-1].event[n-1].type=parseInt(f[0],16),r.track[a-1].event[n-1].channel=parseInt(f[1],16),r.track[a-1].event[n-1].type){case 15:this.customInterpreter!==null&&(r.track[a-1].event[n-1].data=this.customInterpreter(r.track[a-1].event[n-1].type,s,!1)),this.customInterpreter!==null&&r.track[a-1].event[n-1].data!==!1||(g=s.readIntVLV(),r.track[a-1].event[n-1].data=s.readInt(g),this.debug&&console.info("Unimplemented 0xF exclusive events! data block readed as Integer"));break;case 10:case 11:case 14:case 8:case 9:r.track[a-1].event[n-1].data=[],r.track[a-1].event[n-1].data[0]=s.readInt(1),r.track[a-1].event[n-1].data[1]=s.readInt(1);break;case 12:case 13:r.track[a-1].event[n-1].data=s.readInt(1);break;case-1:l=!0;break;default:if(this.customInterpreter!==null&&(r.track[a-1].event[n-1].data=this.customInterpreter(r.track[a-1].event[n-1].metaType,s,!1)),this.customInterpreter===null||r.track[a-1].event[n-1].data===!1)return console.log("Unknown EVENT detected... reading cancelled!"),!1}}return r},customInterpreter:null};if(typeof T<"u")T.exports=c;else{let e=typeof window=="object"&&window.self===window&&window||typeof self=="object"&&self.self===self&&self||typeof global=="object"&&global.global===global&&global;e.MidiParser=c}})()});var w=class{#e={};addEventListener(t,i){this.#e[t]||(this.#e[t]=[]),this.#e[t].unshift(i)}removeEventListener(t,i){if(this.#e[t]){let c=this.#e[t].indexOf(i);c>-1&&this.#e[t].splice(c,1),this.#e[t].length<1&&delete this.#e[t]}}dispatchEvent(t,i){let c=new Event(t),e=this;c.data=i,this.#e[t]?.length>0&&this.#e[t].forEach(function(s){try{s?.call(e,c)}catch(r){console.error(r)}}),this[`on${t}`]&&this[`on${t}`](c)}};var A=class{#e={};context;set(t,i){this.#e[t]=i}has(t){return!!this.#e[t]}async read(t,i){if(!this.has(t))throw new Error(`No decoder registered for "${t}"`);return await this.#e[t].call(this.context||this,i)}};var j=function(t,i){let c=!0;return i.forEach((e,s)=>{c=c&&t[s]==e}),c},I=function(t){let i=0;return t.forEach(c=>{i*=256,i+=c}),i},v=new TextDecoder,P=new A;P.set("s7e",async function(t){let i=new Uint8Array(await t.slice(0,65536).arrayBuffer()),c="MSB LSB PRG NME",e=[0,0,0,0],s=32,r=0,o=0,h=!0,g=[],b=0;for(;h;){let u=i.subarray(r);([()=>{v.decode(u.subarray(0,4))=="YSFC"?(r+=80,o=1):r++},()=>{if(j(u.subarray(0,4),e))g.forEach((a,n,l)=>{let f=I(i.subarray(a.start+4,a.start+8));a.length=f}),o=2;else{let a=v.decode(u.subarray(0,4)),n=I(u.subarray(4,8));g.push({type:a,start:n}),r+=8}},()=>{let a=g[b],n=i.subarray(a.start,a.start+a.length),l=32;switch(a.type){case"ENVC":{let f=s;for(;f=g.length&&(o=3,h=!1)}][o]||(()=>{h=!1}))()}return c});var Y=["off","hall","room","stage","plate","delay LCR","delay LR","echo","cross delay","early reflections","gate reverb","reverse gate"].concat(new Array(4),["white room","tunnel","canyon","basement","karaoke"],new Array(43),["pass through","chorus","celeste","flanger","symphonic","rotary speaker","tremelo","auto pan","phaser","distortion","overdrive","amplifier","3-band EQ","2-band EQ","auto wah"],new Array(1),["pitch change","harmonic","touch wah","compressor","noise gate","voice channel","2-way rotary speaker","ensemble detune","ambience"],new Array(4),["talking mod","Lo-Fi","dist + delay","comp + dist + delay","wah + dist + delay","V dist","dual rotor speaker"]);var W=",a,i,u,e,o,ka,ki,ku,ke,ko,ky,kw,sa,si,su,se,so,sh,ta,ti,tu,te,to,t,ch,t,s,na,ni,nu,ne,no,ny,nn,ha,hi,hu,he,ho,hy,fa,fi,fu,fe,fo,ma,mi,mu,me,mo,my,mm,ya,yu,ye,yo,ra,ri,ru,re,ro,ry,wa,wi,we,wo,ga,gi,gu,ge,go,gy,gw,za,zi,zu,ze,zo,ja,ji,ju,je,jo,jy,da,di,du,de,do,dy,ba,bi,bu,be,bo,by,va,vi,vu,ve,vo,pa,pi,pu,pe,po,py,nga,ngi,ngu,nge,ngo,ngy,ng,hha,hhi,hhu,hhe,hho,hhy,hhw,*,_,,,~,.".split(","),Z={};`hi*, ka,か ki,き ku,く @@ -138,6 +138,6 @@ o,お ~, ^, _,`.split(` -`).forEach(t=>{let n=t.split(",");Z[n[0]]=n[1]});var P=function(t,n,c){let e=[],s=c==!1?n.readIntVLV():c;t==0||t==127;for(let r=0;r127)return console.debug(`Early termination: ${e}`),e.pop(),n.backOne(),n.backOne(),new Uint8Array(e)}}}return new Uint8Array(e)};var J=["?","gm","gs","xg","g2","mt32","ns5r","x5d","05rw","sd","k11","sg","krs","s90es","motif"];var S=[20,21,22,23,24,25,26,28,29,30,31,36,37,48,49,52,53,64,65];var x=[0,1,2,4,5,6,7,8,10,11,32,38,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,84,91,92,93,94,95,98,99,100,101,128,12,13,16,17,18,19,14,15,20,21];var ee={};J.forEach((t,n)=>{ee[t]=n});var $={length:x.length};x.forEach((t,n)=>{$[t]=n});var L={length:S.length};S.forEach((t,n)=>{L[t]=n});var Fe={ch:128,cc:x.length,nn:128,pl:512,tr:256,cmt:14,rpn:6,rpnt:4,ace:8,drm:8,dpn:S.length,dnc:128,efx:7};var R=Q(N(),1);var B=class{#e=!1;constructor(t,n,c,e){this.#e=t,this.start=n,this.end=c,this.data=e}get duration(){return this.ranged?this.end-this.start:0}get ranged(){return this.#e}},C=class extends B{constructor(t,n,c){super(!0,t,n,c)}},H=class extends B{constructor(t,n){super(!1,t,t,n)}},M=class extends Array{#e=-1;constructor(){super(...arguments)}resetIndex(t){this.#e=-1}fresh(){this.sort(function(t,n){return t.start==n.start?0:(+(t.start>n.start)<<1)-1}),this.forEach(function(t,n){t.index=n})}step(t,n=!1){let c=[];if(n)for(let e=0;et);e++){if(this[e].ends.#e&&(c.push(r),s.#e=r.index)})}return c}getRange(t,n){t>n&&([t,n]=[n,t]);let c=[],e=-1,s=Math.ceil(Math.sqrt(this.length)),r=!0;for(let o=0;o=t&&(e=o):e=e<0?o:e;for(;r;)this[e]?.end=t&&c.push(this[e]):r=!1,e++;return c}};var te=0xffffffffffff,G=function(t){let n=new M,c=this,e=t.timeDivision,s=120,r=new M,o=0,h=0;r.push(new C(0,te,[120,0])),t.track.forEach(function(a){o=0,a.event.forEach(function(i){o+=i.deltaTime,i.type==255&&i?.metaType==81&&(s=6e7/i.data,r[r.length-1]&&r.push(new C(o,0xffffffffffff,[s,0])))})}),r.fresh(),r.forEach(function(a,i,l){i>0&&(l[i-1].end=a.start)});let g=120;r.forEach(function(a,i,l){i>0&&(a.end==a.start?l.splice(l.indexOf(a),1):g==a.data[0]&&(l[i-1].end=a.end,l.splice(l.indexOf(a),1)),g=a.data[0])});let b=0,u=120;return r.forEach(function(a){let i=a.start,l=i/u/e*60+b;u=a.data[0],b=l-i/u/e*60,a.data[1]=b}),console.debug("All tempo changes: ",r),s=120,o=0,h=0,t.track.forEach(function(a,i){o=0,h=0;let l=i+1;a.event.forEach(function(f,p){o+=f.deltaTime;let d=r.step(o,!0)[0];d&&(s=d.data[0],h=d.data[1]);let y={type:f.type,data:f.data,track:l,part:0};f.type>14?y.meta=f.metaType:y.part=f.channel,n.push(new H(o/s/e*60+h,y))})}),n.fresh(),self.midiEvents=n,console.debug(`Parsed a type ${t.formatType} MIDI sequence.`),n};R.default.customInterpreter=P;var m=function(t,n,c){t.addEventListener(c,e=>{n.dispatchEvent(c,e.data)})},st=class extends w{device;#e;#n={};#f=[];#a="";#c=[];#o=new Uint8ClampedArray(128);#h=new Uint8ClampedArray(128);#s=.5;#i=120;#t=4;#l=4;#r=0;#d=0;smoothingAtk=0;smoothingDcy=0;reset(){let t=this;t.dispatchEvent("reset"),t.#e?.resetIndex(),t.device.init(),t.#a="",t.#s=.5,t.#i=120,t.#t=4,t.#l=4,t.#r=0,t.#d=0,t.dispatchEvent("tempo",t.#i),t.dispatchEvent("title",t.#a)}init(){this.reset(),this.#e=void 0}async loadFile(t){this.#e=G(R.default.parse(new Uint8Array(await t.arrayBuffer())))}async loadMap(t,n){let c=this,e=0,s=0,r=0,o,h;t.split(` -`).forEach((g,b)=>{if(!g)return;let u=g.split(" ");if(b){if(!r)return;let a="",i="";u.forEach((l,f)=>{switch(f){case o:{a=l;break}case h:{i=l;break}}}),!c.#n[a]||n?(c.#n[a]=i,e++):self.debugMode&&console.debug(`Voice "${i}" (${a}) seems to be in conflict with (${c.#n[a]}).`),s++}else u.forEach((a,i)=>{switch(a){case"ID":{o=i,r++;break}case"Name":{h=i,r++;break}default:console.debug(`Unknown map field: ${a}`)}})}),console.debug(`Map: ${s} total, ${e} loaded.`),c?.device.forceVoiceRefresh()}async loadEfx(t,n){let c=this,e=0,s=0,r,o,h;t.split(` -`).forEach((g,b)=>{if(g)if(b){let u=0,a;g.split(" ").forEach((i,l)=>{switch(l){case r:{u|=parseInt(i,16)<<8;break}case o:{u|=parseInt(i,16);break}case h:{a=i;break}}}),!c.#f[u]||n?(c.#f[u]=a,e++):self.debugMode&&console.debug(`EFX ID 0x${u.toString(16).padStart(4,"0")} (${a}) seems to be in conflict.`),s++}else g.split(" ").forEach((u,a)=>{switch(u){case"MSB":{r=a;break}case"LSB":{o=a;break}case"Name":{h=a;break}default:console.debug(`Unknown EFX field: ${u}`)}})}),console.debug(`EFX: ${s} total, ${e} loaded.`),c.dispatchEvent("efxreverb",c.device.getEffectType(0)),c.dispatchEvent("efxchorus",c.device.getEffectType(1)),c.dispatchEvent("efxdelay",c.device.getEffectType(2)),c.dispatchEvent("efxinsert0",c.device.getEffectType(3)),c.dispatchEvent("efxinsert1",c.device.getEffectType(4)),c.dispatchEvent("efxinsert2",c.device.getEffectType(5)),c.dispatchEvent("efxinsert3",c.device.getEffectType(6))}switchMode(t,n=!1){this.device.switchMode(t,n)}getMode(){return this.device.getMode()}getVoice(){return this.device.getVoice(...arguments)}getChVoice(t){return this.device.getChVoice(t)}getMapped(t){return this.#n[t]||t}getEfx([t,n]){let c=t<<8|n;return this.#f[c]||`0x${c.toString(16).padStart(4,"0")}`}get noteProgress(){return this.#d/this.#s}get noteOverall(){return this.noteProgress-this.#r}get noteBar(){return Math.floor(this.noteOverall/this.#t)}get noteBeat(){let t=this.noteOverall%this.#t;return t<0&&(t+=this.#t),t}getTimeSig(){return[this.#t,this.#l]}getTempo(){return this.#i}sendCmd(t){this.device.runJson(t)}render(t){t>this.#d&&(this.#d=t);let n=this.#e?.step(t)||[],c=0,e=new Set,s=this,r=[];this.device.getStrength().forEach((p,d)=>{this.#h[d]=p}),s.device.newStrength(),n.forEach(function(p){let d=p.data;d.type==9&&(d.data[1]>0?e.add(d.part*128+d.data[0]):e.has(d.part*128+d.data[0])&&c++),p.data.type==8&&e.has(d.part*128+d.data[0])&&c++;let y=s.device.runJson(d);switch(y?.reply){case"meta":{r.push(y);break}}y?.reply&&delete y.reply}),r?.length>0&&this.dispatchEvent("meta",r);let o=this.device.getActive(),h=[],g=s.device.getPitch(),b=s.device.getCcAll(),u=s.device.getProgram(),a=s.device.getChType(),i=this.device.getStrength();i.forEach(function(p,d,y){y[d]=Math.max(s.#h[d],p);let E=y[d]-s.#o[d],D=$.length*d;if(E>=0){let k=4*.25**(b[D+$[73]]/64);s.#o[d]+=Math.ceil(E-E*s.smoothingAtk**k)}else{let k=4*.25**(b[D+$[72]]/64);s.#o[d]+=Math.floor(E-E*s.smoothingDcy**k)}});let l=0;return o.forEach(function(p,d){p&&(h[d]=s.device.getVel(d),l+=h[d].size)}),{extraPoly:c,curPoly:l,chInUse:o,chKeyPr:h,chPitch:g,chProgr:u,chContr:b,chType:a,eventCount:n.length,title:this.#a,bitmap:this.device.getBitmap(),letter:this.device.getLetter(),texts:this.device.getTexts(),master:this.device.getMaster(),mode:this.device.getMode(),strength:this.#o.slice(),velo:i,rpn:this.device.getRpn(),tSig:this.getTimeSig(),tempo:this.getTempo(),noteBar:this.noteBar,noteBeat:this.noteBeat,ace:this.device.getAce(),efxSink:this.device.getEffectSink()}}constructor(t,n=.5,c=.5){super();let e=this;e.smoothingAtk=n,e.smoothingDcy=c,e.device=t,e.addEventListener("meta",function(s){s?.data?.forEach(function(r){(e.#c[r.meta]||console.debug).call(e,r.meta,r.data)})}),m(e.device,e,"mode"),m(e.device,e,"mastervolume"),m(e.device,e,"channelactive"),m(e.device,e,"channelmin"),m(e.device,e,"channelmax"),m(e.device,e,"channelreset"),m(e.device,e,"channeltoggle"),m(e.device,e,"screen"),m(e.device,e,"metacommit"),m(e.device,e,"voice"),m(e.device,e,"pitch"),m(e.device,e,"note"),m(e.device,e,"reset"),m(e.device,e,"efxreverb"),m(e.device,e,"efxchorus"),m(e.device,e,"efxdelay"),m(e.device,e,"efxinsert0"),m(e.device,e,"efxinsert1"),m(e.device,e,"efxinsert2"),m(e.device,e,"efxinsert3"),m(e.device,e,"partefxtoggle"),e.#c[3]=function(s,r){e.#a?.length<1&&(e.#a=r,e.dispatchEvent("title",e.#a))},e.#c[81]=function(s,r){let o=e.noteProgress,h=e.#s||.5;e.#i=6e7/r,e.#s=r/1e6,e.#r+=o*(h/e.#s)-o,e.dispatchEvent("tempo",e.#i)},e.#c[88]=function(s,r){let o=e.noteProgress,h=e.noteOverall,g=e.noteBar,b=e.noteBeat,u=e.#t,a=e.#l;e.#t=r[0],e.#l=1<=u&&(u{let i=t.split(",");Z[i[0]]=i[1]});var U=function(t,i,c){let e=[],s=c==!1?i.readIntVLV():c;t==0||t==127;for(let r=0;r127)return console.debug(`Early termination: ${e}`),e.pop(),i.backOne(),i.backOne(),new Uint8Array(e)}}}return new Uint8Array(e)};var J=["?","gm","gs","xg","g2","mt32","ns5r","x5d","05rw","sd","k11","sg","krs","s90es","motif"],ee=["melodic","drum","menu"];var S=[20,21,22,23,24,25,26,28,29,30,31,36,37,48,49,52,53,64,65];var x=[0,1,2,4,5,6,7,8,10,11,32,38,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,84,91,92,93,94,95,98,99,100,101,128,12,13,16,17,18,19,14,15,20,21,26,28];var te={};J.forEach((t,i)=>{te[t]=i});var $={length:x.length};x.forEach((t,i)=>{$[t]=i});var L={length:S.length};S.forEach((t,i)=>{L[t]=i});var ae={};ee.forEach((t,i)=>{ae[t]=i});var ze={ch:128,cc:x.length,nn:128,pl:512,tr:256,cmt:14,rpn:6,rpnt:4,ace:8,drm:8,dpn:S.length,dnc:128,efx:7};var R=Q(N(),1);var B=class{#e=!1;constructor(t,i,c,e){this.#e=t,this.start=i,this.end=c,this.data=e}get duration(){return this.ranged?this.end-this.start:0}get ranged(){return this.#e}},C=class extends B{constructor(t,i,c){super(!0,t,i,c)}},H=class extends B{constructor(t,i){super(!1,t,t,i)}},M=class extends Array{#e=-1;constructor(){super(...arguments)}resetIndex(t){this.#e=-1}fresh(){this.sort(function(t,i){return t.start==i.start?0:(+(t.start>i.start)<<1)-1}),this.forEach(function(t,i){t.index=i})}step(t,i=!1){let c=[];if(i)for(let e=0;et);e++){if(this[e].ends.#e&&(c.push(r),s.#e=r.index)})}return c}getRange(t,i){t>i&&([t,i]=[i,t]);let c=[],e=-1,s=Math.ceil(Math.sqrt(this.length)),r=!0;for(let o=0;o=t&&(e=o):e=e<0?o:e;for(;r;)this[e]?.end=t&&c.push(this[e]):r=!1,e++;return c}};var re=0xffffffffffff,G=function(t){let i=new M,c=this,e=t.timeDivision,s=120,r=new M,o=0,h=0;r.push(new C(0,re,[120,0])),t.track.forEach(function(a){o=0,a.event.forEach(function(n){o+=n.deltaTime,n.type==255&&n?.metaType==81&&(s=6e7/n.data,r[r.length-1]&&r.push(new C(o,0xffffffffffff,[s,0])))})}),r.fresh(),r.forEach(function(a,n,l){n>0&&(l[n-1].end=a.start)});let g=120;r.forEach(function(a,n,l){n>0&&(a.end==a.start?l.splice(l.indexOf(a),1):g==a.data[0]&&(l[n-1].end=a.end,l.splice(l.indexOf(a),1)),g=a.data[0])});let b=0,u=120;return r.forEach(function(a){let n=a.start,l=n/u/e*60+b;u=a.data[0],b=l-n/u/e*60,a.data[1]=b}),console.debug("All tempo changes: ",r),s=120,o=0,h=0,t.track.forEach(function(a,n){o=0,h=0;let l=n+1;a.event.forEach(function(f,p){o+=f.deltaTime;let d=r.step(o,!0)[0];d&&(s=d.data[0],h=d.data[1]);let y={type:f.type,data:f.data,track:l,part:0};f.type>14?y.meta=f.metaType:y.part=f.channel,i.push(new H(o/s/e*60+h,y))})}),i.fresh(),self.midiEvents=i,console.debug(`Parsed a type ${t.formatType} MIDI sequence.`),i};R.default.customInterpreter=U;var m=function(t,i,c){t.addEventListener(c,e=>{i.dispatchEvent(c,e.data)})},nt=class extends w{device;#e;#n={};#f=[];#a="";#c=[];#o=new Uint8ClampedArray(128);#h=new Uint8ClampedArray(128);#s=.5;#i=120;#t=4;#l=4;#r=0;#d=0;smoothingAtk=0;smoothingDcy=0;reset(){let t=this;t.dispatchEvent("reset"),t.#e?.resetIndex(),t.device.init(),t.#a="",t.#s=.5,t.#i=120,t.#t=4,t.#l=4,t.#r=0,t.#d=0,t.dispatchEvent("tempo",t.#i),t.dispatchEvent("title",t.#a)}init(){this.reset(),this.#e=void 0}async loadFile(t){this.#e=G(R.default.parse(new Uint8Array(await t.arrayBuffer())))}async loadMap(t,i){let c=this,e=0,s=0,r=0,o,h;t.split(` +`).forEach((g,b)=>{if(!g)return;let u=g.split(" ");if(b){if(!r)return;let a="",n="";u.forEach((l,f)=>{switch(f){case o:{a=l;break}case h:{n=l;break}}}),!c.#n[a]||i?(c.#n[a]=n,e++):self.debugMode&&console.debug(`Voice "${n}" (${a}) seems to be in conflict with (${c.#n[a]}).`),s++}else u.forEach((a,n)=>{switch(a){case"ID":{o=n,r++;break}case"Name":{h=n,r++;break}default:console.debug(`Unknown map field: ${a}`)}})}),console.debug(`Voice names: ${s} total, ${e} loaded.`),c?.device.forceVoiceRefresh()}async loadEfx(t,i){let c=this,e=0,s=0,r,o,h;t.split(` +`).forEach((g,b)=>{if(g)if(b){let u=0,a;g.split(" ").forEach((n,l)=>{switch(l){case r:{u|=parseInt(n,16)<<8;break}case o:{u|=parseInt(n,16);break}case h:{a=n;break}}}),!c.#f[u]||i?(c.#f[u]=a,e++):self.debugMode&&console.debug(`EFX ID 0x${u.toString(16).padStart(4,"0")} (${a}) seems to be in conflict.`),s++}else g.split(" ").forEach((u,a)=>{switch(u){case"MSB":{r=a;break}case"LSB":{o=a;break}case"Name":{h=a;break}default:console.debug(`Unknown EFX field: ${u}`)}})}),console.debug(`EFX: ${s} total, ${e} loaded.`),c.dispatchEvent("efxreverb",c.device.getEffectType(0)),c.dispatchEvent("efxchorus",c.device.getEffectType(1)),c.dispatchEvent("efxdelay",c.device.getEffectType(2)),c.dispatchEvent("efxinsert0",c.device.getEffectType(3)),c.dispatchEvent("efxinsert1",c.device.getEffectType(4)),c.dispatchEvent("efxinsert2",c.device.getEffectType(5)),c.dispatchEvent("efxinsert3",c.device.getEffectType(6))}switchMode(t,i=!1){this.device.switchMode(t,i)}getMode(){return this.device.getMode()}getVoice(){return this.device.getVoice(...arguments)}getChVoice(t){return this.device.getChVoice(t)}getMapped(t){return this.#n[t]||t}getEfx([t,i]){let c=t<<8|i;return this.#f[c]||`0x${c.toString(16).padStart(4,"0")}`}get noteProgress(){return this.#d/this.#s}get noteOverall(){return this.noteProgress-this.#r}get noteBar(){return Math.floor(this.noteOverall/this.#t)}get noteBeat(){let t=this.noteOverall%this.#t;return t<0&&(t+=this.#t),t}getTimeSig(){return[this.#t,this.#l]}getTempo(){return this.#i}sendCmd(t){this.device.runJson(t)}render(t){t>this.#d&&(this.#d=t);let i=this.#e?.step(t)||[],c=0,e=new Set,s=this,r=[];this.device.getStrength().forEach((p,d)=>{this.#h[d]=p}),s.device.newStrength(),i.forEach(function(p){let d=p.data;d.type==9&&(d.data[1]>0?e.add(d.part*128+d.data[0]):e.has(d.part*128+d.data[0])&&c++),p.data.type==8&&e.has(d.part*128+d.data[0])&&c++;let y=s.device.runJson(d);switch(y?.reply){case"meta":{r.push(y);break}}y?.reply&&delete y.reply}),r?.length>0&&this.dispatchEvent("meta",r);let o=this.device.getActive(),h=[],g=s.device.getPitch(),b=s.device.getCcAll(),u=s.device.getProgram(),a=s.device.getChType(),n=this.device.getStrength();n.forEach(function(p,d,y){y[d]=Math.max(s.#h[d],p);let E=y[d]-s.#o[d],D=$.length*d;if(E>=0){let k=4*.25**(b[D+$[73]]/64);s.#o[d]+=Math.ceil(E-E*s.smoothingAtk**k)}else{let k=4*.25**(b[D+$[72]]/64);s.#o[d]+=Math.floor(E-E*s.smoothingDcy**k)}});let l=0;return o.forEach(function(p,d){p&&(h[d]=s.device.getVel(d),l+=h[d].size)}),{extraPoly:c,curPoly:l,chInUse:o,chKeyPr:h,chPitch:g,chProgr:u,chContr:b,chType:a,eventCount:i.length,title:this.#a,bitmap:this.device.getBitmap(),letter:this.device.getLetter(),texts:this.device.getTexts(),master:this.device.getMaster(),mode:this.device.getMode(),strength:this.#o.slice(),velo:n,rpn:this.device.getRpn(),tSig:this.getTimeSig(),tempo:this.getTempo(),noteBar:this.noteBar,noteBeat:this.noteBeat,ace:this.device.getAce(),efxSink:this.device.getEffectSink()}}constructor(t,i=.5,c=.5){super();let e=this;e.smoothingAtk=i,e.smoothingDcy=c,e.device=t,e.addEventListener("meta",function(s){s?.data?.forEach(function(r){(e.#c[r.meta]||console.debug).call(e,r.meta,r.data)})}),m(e.device,e,"mode"),m(e.device,e,"mastervolume"),m(e.device,e,"channelactive"),m(e.device,e,"channelmin"),m(e.device,e,"channelmax"),m(e.device,e,"channelreset"),m(e.device,e,"channeltoggle"),m(e.device,e,"screen"),m(e.device,e,"metacommit"),m(e.device,e,"voice"),m(e.device,e,"pitch"),m(e.device,e,"note"),m(e.device,e,"reset"),m(e.device,e,"efxreverb"),m(e.device,e,"efxchorus"),m(e.device,e,"efxdelay"),m(e.device,e,"efxinsert0"),m(e.device,e,"efxinsert1"),m(e.device,e,"efxinsert2"),m(e.device,e,"efxinsert3"),m(e.device,e,"partefxtoggle"),e.#c[3]=function(s,r){e.#a?.length<1&&(e.#a=r,e.dispatchEvent("title",e.#a))},e.#c[81]=function(s,r){let o=e.noteProgress,h=e.#s||.5;e.#i=6e7/r,e.#s=r/1e6,e.#r+=o*(h/e.#s)-o,e.dispatchEvent("tempo",e.#i)},e.#c[88]=function(s,r){let o=e.noteProgress,h=e.noteOverall,g=e.noteBar,b=e.noteBeat,u=e.#t,a=e.#l;e.#t=r[0],e.#l=1<=u&&(u()=>(t||e((t={exports:{}}).exports,t),t.exports);var je=(e,t,n,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of qe(t))!Qe.call(e,u)&&u!==n&&fe(e,u,{get:()=>t[u],enumerable:!(l=ze(t,u))||l.enumerable});return e};var Ze=(e,t,n)=>(n=e!=null?Ve(We(e)):{},je(t||!e||!e.__esModule?fe(n,"default",{value:e,enumerable:!0}):n,e));var Le=Ye((_t,re)=>{(function(){"use strict";let e={fatal:!0},t=[new TextDecoder("iso-8859-15",e),new TextDecoder("sjis",e),new TextDecoder("euc-jp",e),new TextDecoder("utf-8",e),new TextDecoder("utf-16",e),new TextDecoder("ascii")],n={debug:!1,parse:function(l,u){if(l instanceof Uint8Array)return n.Uint8(l);if(typeof l=="string")return n.Base64(l);if(l instanceof HTMLElement&&l.type==="file")return n.addListener(l,u);throw new Error("MidiParser.parse() : Invalid input provided")},addListener:function(l,u){if(!File||!FileReader)throw new Error("The File|FileReader APIs are not supported in this browser. Use instead MidiParser.Base64() or MidiParser.Uint8()");if(l===void 0||!(l instanceof HTMLElement)||l.tagName!=="INPUT"||l.type.toLowerCase()!=="file")return console.warn("MidiParser.addListener() : Provided element is not a valid FILE INPUT element"),!1;u=u||function(){},l.addEventListener("change",function(p){if(!p.target.files.length)return!1;console.log("MidiParser.addListener() : File detected in INPUT ELEMENT processing data..");let h=new FileReader;h.readAsArrayBuffer(p.target.files[0]),h.onload=function(a){u(n.Uint8(new Uint8Array(a.target.result)))}})},Base64:function(l){let u=function(a){var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";if(a=a.replace(/^.*?base64,/,""),a=String(a).replace(/[\t\n\f\r ]+/g,""),!/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/.test(a))throw new TypeError("Failed to execute _atob() : The string to be decoded is not correctly encoded.");a+="==".slice(2-(3&a.length));let d,s="",r,c,f=0;for(;f>16&255):c===64?String.fromCharCode(d>>16&255,d>>8&255):String.fromCharCode(d>>16&255,d>>8&255,255&d);return s}(l=String(l));var p=u.length;let h=new Uint8Array(new ArrayBuffer(p));for(let a=0;a{c[y]=this.readInt(1)});for(let b=0;b191||E>127&&E<160)throw new RangeError(`Invalid code point: ${E}`)}f=!0,console.debug(`String byte sequence in ${t[b].encoding}`)}catch(y){console.debug(`SMF string ${y}`)}return o||"String byte sequence read failed."},backOne:function(){this.pointer--},readIntVLV:function(){let r=0;if(this.pointer>=this.data.byteLength)return-1;if(this.data.getUint8(this.pointer)<128)r=this.readInt(1);else{let f=[];for(;128<=this.data.getUint8(this.pointer);)f.push(this.readInt(1)-128);var c=this.readInt(1);for(let o=1;o<=f.length;o++)r+=f[f.length-o]*Math.pow(128,o);r+=c}return r}};if(u.data=new DataView(h.buffer,h.byteOffset,h.byteLength),u.readInt(4)!==1297377380)return console.warn("Header validation failed (not MIDI standard or file corrupt.)"),!1;u.readInt(4);let p={};p.formatType=u.readInt(2),p.tracks=u.readInt(2),p.track=[];var h=u.readInt(1),a=u.readInt(1);128<=h?(p.timeDivision=[],p.timeDivision[0]=h-128,p.timeDivision[1]=a):p.timeDivision=256*h+a;for(let r=1;r<=p.tracks;r++){p.track[r-1]={event:[]};var i,d=u.readInt(4);if(d===-1)break;if(d!==1297379947)return!1;u.readInt(4);let c=0,f=!1,o,b;for(;!f&&(c++,p.track[r-1].event[c-1]={},p.track[r-1].event[c-1].deltaTime=u.readIntVLV(),(o=u.readInt(1))!==-1);)if(128<=o?b=o:(o=b,u.movePointer(-1)),o===255){p.track[r-1].event[c-1].type=255,p.track[r-1].event[c-1].metaType=u.readInt(1);var s=u.readIntVLV();switch(p.track[r-1].event[c-1].metaType){case 47:case-1:f=!0;break;case 1:case 2:case 3:case 4:case 5:case 7:case 6:p.track[r-1].event[c-1].data=u.readStr(s);break;case 33:case 89:case 81:p.track[r-1].event[c-1].data=u.readInt(s);break;case 84:p.track[r-1].event[c-1].data=[],p.track[r-1].event[c-1].data[0]=u.readInt(1),p.track[r-1].event[c-1].data[1]=u.readInt(1),p.track[r-1].event[c-1].data[2]=u.readInt(1),p.track[r-1].event[c-1].data[3]=u.readInt(1),p.track[r-1].event[c-1].data[4]=u.readInt(1);break;case 88:p.track[r-1].event[c-1].data=[],p.track[r-1].event[c-1].data[0]=u.readInt(1),p.track[r-1].event[c-1].data[1]=u.readInt(1),p.track[r-1].event[c-1].data[2]=u.readInt(1),p.track[r-1].event[c-1].data[3]=u.readInt(1);break;default:this.customInterpreter!==null&&(p.track[r-1].event[c-1].data=this.customInterpreter(p.track[r-1].event[c-1].metaType,u,s)),this.customInterpreter!==null&&p.track[r-1].event[c-1].data!==!1||(u.readInt(s),p.track[r-1].event[c-1].data=u.readInt(s),this.debug&&console.info("Unimplemented 0xFF meta event! data block readed as Integer"))}}else switch((o=o.toString(16).split(""))[1]||o.unshift("0"),p.track[r-1].event[c-1].type=parseInt(o[0],16),p.track[r-1].event[c-1].channel=parseInt(o[1],16),p.track[r-1].event[c-1].type){case 15:this.customInterpreter!==null&&(p.track[r-1].event[c-1].data=this.customInterpreter(p.track[r-1].event[c-1].type,u,!1)),this.customInterpreter!==null&&p.track[r-1].event[c-1].data!==!1||(i=u.readIntVLV(),p.track[r-1].event[c-1].data=u.readInt(i),this.debug&&console.info("Unimplemented 0xF exclusive events! data block readed as Integer"));break;case 10:case 11:case 14:case 8:case 9:p.track[r-1].event[c-1].data=[],p.track[r-1].event[c-1].data[0]=u.readInt(1),p.track[r-1].event[c-1].data[1]=u.readInt(1);break;case 12:case 13:p.track[r-1].event[c-1].data=u.readInt(1);break;case-1:f=!0;break;default:if(this.customInterpreter!==null&&(p.track[r-1].event[c-1].data=this.customInterpreter(p.track[r-1].event[c-1].metaType,u,!1)),this.customInterpreter===null||p.track[r-1].event[c-1].data===!1)return console.log("Unknown EVENT detected... reading cancelled!"),!1}}return p},customInterpreter:null};if(typeof re<"u")re.exports=n;else{let l=typeof window=="object"&&window.self===window&&window||typeof self=="object"&&self.self===self&&self||typeof global=="object"&&global.global===global&&global;l.MidiParser=n}})()});var he=function(e,t){let n=Math.min(e.length,t.length),l=e.slice(0,n),u=t.slice(0,n),p=0,h=0;for(;h0){let l=this.pool.length,u=1<=1&&h>=0;){if(h<=0)throw new Error("TTL reached.");if(p==l)p-=u;else{let i=he(t,this.pool[p]);switch(i){case 0:{h=0;break}case 1:{p+u<=l&&(p+=u);break}case-1:{p!=0&&(p-=u);break}default:console.warn(`Unexpected result ${i}.`)}}u=u>>1,h--}let a=!0;if(p>=this.pool.length)a=!1;else{let i=this;this.pool[p].forEach(function(d,s,r){a&&d!=t[s]&&(a=!1)}),!a&&he(t,this.pool[p])>0&&p++}return a||n?p:-1}else return n?0:-1},this.add=function(t,n){return t.data=n,this.pool.splice(this.point(t,!0),0,t),this},this.default=function(t){console.warn(`No match in "${this.name||"(unknown)"}" for "${t}". Default action not defined.`)},this.get=function(t){let n=this.point(t);if(n>-1)return this.pool[n].data;this.default(t)},this.run=function(t,...n){let l=this.point(t);l>-1?t.subarray?this.pool[l].data(t.subarray(this.pool[l].length),...n):this.pool[l].data(t.slice(this.pool[l].length),...n):this.default(t,...n)}};var V=class{#t={};addEventListener(e,t){this.#t[e]||(this.#t[e]=[]),this.#t[e].unshift(t)}removeEventListener(e,t){if(this.#t[e]){let n=this.#t[e].indexOf(t);n>-1&&this.#t[e].splice(n,1),this.#t[e].length<1&&delete this.#t[e]}}dispatchEvent(e,t){let n=new Event(e),l=this;n.data=t,this.#t[e]?.length>0&&this.#t[e].forEach(function(u){try{u?.call(l,n)}catch(p){console.error(p)}}),this[`on${e}`]&&this[`on${e}`](n)}};var Je=["MSB","PRG","LSB"],Y=function(e){let t=Math.floor(e/10),n=e%10;return`${t.toString(16)}${n}`},j=class{#t;strictMode=!1;get(e=0,t=0,n=0,l){let u=[e,t,n],p,h=Array.from(arguments);switch(l){case"xg":{switch(e){case 0:{n==126?h[2]=125:n==127&&(h[2]=0);break}case 16:{n==126&&(h[2]=0);break}case 32:{n>125&&(h[2]=0),h[2]+=4;break}case 33:case 35:case 36:{n>125&&(h[2]=0),h[2]+=5;break}case 79:case 80:case 81:case 82:case 83:case 84:h[0]+=16;case 95:case 96:case 97:case 98:case 99:case 100:{n==126&&(h[2]=0);break}case 48:case 64:case 126:case 127:{n==126&&(h[2]=0);break}}break}case"gs":{e==0&&n<5?h[2]=0:e>125&&n<5&&n!=2&&(h[2]=e,h[0]=0);break}case"g2":case"sd":{(e>>1==40||e>95&&e<100)&&(h[2]|=16);break}case"sg":{e==8&&n==0&&(h[2]=5);break}case"s90es":{n<8?h[2]+=17:n<32?h[2]+=13:h[2]=(h[2]>>3)+19;break}case"motif":{n<8?h[2]+=28:n<32?h[2]+=13:h[2]=(h[2]>>3)+19;break}}let a=" ",i="M",d=0,s=0;switch(h[0]){case 0:{h[2]==127?i="MT-a":h[2]==126?i="MT-b":h[2]==7?i="GM-k":h[2]==5?i="SG-a":h[2]==4?i="SP-l":h[2]==0||l=="gs"&&h[2]<5?i="GM-a":(i="y",d=3);break}case 8:{l=="sg"?i="GM-s":i="r:";break}case 48:{i=`yM${(h[2]>>3).toString().padStart(2,"0")}`,d=1;break}case 56:{i="GM-b";break}case 61:case 120:{i="rDrm";break}case 62:{i="kDrm";break}case 63:{if(h[2]<17){let o=h[2];i=o<10?"kP:":"kC:",i+=o%10}else h[2]<34?i=["Pre1","Pre2","Pre3","Pre4","Usr1","Usr2","DrmP","DrmU","Plg1","Plg2","Plg3","Pre1","Pre2","Pre3","Pre4","Pre5","Pre6"][h[2]-17]:i="Ds";break}case 64:{i="ySFX";break}case 67:{i="DX:S";break}case 80:case 81:case 82:case 83:{i=`Prg${"UABC"[h[0]-80]}`;break}case 88:case 89:case 90:case 91:{i=`Cmb${"UABC"[h[0]-88]}`;break}case 95:{i=`${["DR","PC"][h[2]]}-d`;break}case 96:{i=h[2]==106?"AP-a":h[2]>>4==1?"SDg":"PF",h[2]>63?s=63:h[2]>>4==1&&(s=16),d=3;break}case 97:{i=h[2]>>4==1?"SDa":"VL:",d=3,h[2]>>4==1?s=16:s=112;break}case 98:{i=h[2]>>4==1?"SDb":"SG-a",d=3,s=16;break}case 99:{i=h[2]>>4==1?"SDc":"DX",h[2]>63?s=63:h[2]>>4==1&&(s=16),d=3;break}case 100:{i="AN",h[2]>63?s=63:h[2]>>4==1&&(s=16),d=3;break}case 104:case 105:case 106:case 107:{i="SDd",s=104;break}case 121:{i=`GM-${h[2]?"":"a"}`,d=3;break}case 122:{i="lDrm";break}case 126:{i="yDrS";break}case 127:{h[2]==127?i="rDrm":i="yDrm";break}default:h[0]<48?i="r:":i="M"}i.length<4&&(i+=`${[e,n,h[0],h[2]][d]-s}`.padStart(4-i.length,"0")),l=="xg"&&(e==0?h[2]<100?i=i.replace("y0","y:"):h[2]==125&&(i="y126"):e==16&&(p=`Voice${(h[2]*128+h[1]+1).toString().padStart(3,"0")}`,a=" "));let r=[h[0],h[1],h[2]];for(;!(p?.length>=0);)p=this.#t[h[1]||0][(h[0]<<7)+h[2]],p||(this.strictMode?(p="",a="?"):this.#t[h[1]||0][h[0]<<7]?h[0]==0?(h[2]=0,a="^"):h[2]<1?(h[0]=0,a="*"):(h[2]--,a="^"):e==48?(h[0]=0,h[2]=0,a="!"):e==62?(h[1]--,a=" ",h[1]<1&&!p?.length&&(h[0]=0,a="!")):e<63?h[0]==0?(h[2]=0,a="^"):h[2]<1?(h[0]=0,a="*"):h[2]--:e==80?(p=`PrgU:${t.toString().padStart(3,"0")}`,a="!"):e==88?(p=`CmbU:${t.toString().padStart(3,"0")}`,a="!"):e==121?(p=`GM2Vox0${n}`,a="#"):e==122?(h[1]==32?h[1]==0:h[1]%=7,p=this.#t[h[1]||0][(h[0]<<7)+h[2]],p?a=" ":(p="",a="*")):h[1]==0?(p=`${e.toString().padStart(3,"0")} ${t.toString().padStart(3,"0")} ${n.toString().padStart(3,"0")}`,a="!"):h[0]==0?(h[2]=0,a="^"):h[2]>0?h[2]--:h[1]>0?(h[1]=0,a="!"):(h[0]=0,a="?"));let c=[h[0],h[1],h[2]];(l=="gs"||l=="ns5r")&&a=="^"&&(a=" "),e==127&&a=="^"&&(a=" "),a!=" "&&self.debugMode&&(p="");let f="??";switch(h[0]){case 0:{h[2]==0?f="GM":h[2]==5||h[2]==7?f="KG":h[2]<126?f="XG":h[2]==127&&(f="MT");break}case 32:case 33:case 35:case 36:{h[2]>4?f=["AP","VL","PF","DX","AN"][h[0]-32]:f="GS";break}case 48:{f="MU";break}case 56:{f="AG";break}case 61:case 80:case 83:case 88:case 89:case 91:{f="AI";break}case 62:case 82:case 90:{f="XD";break}case 63:{h[2]<17?f="KR":h[2]<34?f="ES":f="DS";break}case 64:case 126:{f="XG";break}case 67:case 99:{f=h[2]>>4==1?"SD":"DX";break}case 81:{f="RW";break}case 95:{f=["DR","PC"][h[2]];break}case 96:{f=h[2]==106?"AP":h[2]>>4==1?"SD":"PF";break}case 97:{f=h[2]>>4==1?"SD":"VL";break}case 98:{f=h[2]>>4==1?"SD":"SG";break}case 100:{f="AN";break}case 104:case 105:case 106:case 107:{f="SD";break}case 120:{f="GS";break}case 121:{f=h[2]?"G2":"GM";break}case 122:{f="KG";break}case 127:{f=h[2]==127?"MT":t==0?"GM":"XG";break}default:h[0]<48&&(h[0]==16&&l=="xg"?f="XG":f="GS")}return{name:p||`${Y(e||0)} ${Y(t||0)} ${Y(n||0)}`,iid:r,eid:c,sid:u,ending:a,sect:i,standard:f}}async load(e,t,n){let l=this,u=[],p=0,h=0;e.split(` -`).forEach(function(a,i){let d=a.split(" "),s=[];i==0?d.forEach(function(r,c){u[Je.indexOf(r)]=c}):d.forEach(async function(r,c){c>2?(l.#t[s[u[1]]]=l.#t[s[u[1]]]||[],(!l.#t[s[u[1]]][(s[u[0]]<<7)+s[u[2]]]?.length||t)&&(l.#t[s[u[1]]][(s[u[0]]<<7)+s[u[2]]]=d[3],p++),h++):s.push(parseInt(d[c]))})}),t||console.debug(`Map "${n||"(internal)"}": ${h} total, ${p} loaded.`)}clearRange(e){let t=e.prg!=null?e.prg.constructor==Array?e.prg:[e.prg,e.prg]:[0,127],n=e.msb!=null?e.msb.constructor==Array?e.msb:[e.msb,e.msb]:[0,127],l=e.lsb!=null?e.lsb.constructor==Array?e.lsb:[e.lsb,e.lsb]:[0,127];for(let u=n[0];u<=n[1];u++){let p=u<<7;for(let h=l[0];h<=l[1];h++){let a=p+h;for(let i=t[0];i<=t[1];i++)delete this.#t[i][a]}}}init(){this.#t=[];for(let e=0;e<128;e++)this.#t.push([""])}async loadFiles(...e){this.init();let t=this;e.forEach(async function(n,l){try{await fetch(`./data/bank/${n}.tsv`).then(function(u){return u.text()}).then(u=>{t.load(u,!1,n)})}catch{console.error(`Failed loading "${n}.tsv".`)}})}constructor(...e){this.loadFiles(...e)}};var ue=class{#t={};context;set(e,t){this.#t[e]=t}has(e){return!!this.#t[e]}async read(e,t){if(!this.has(e))throw new Error(`No decoder registered for "${e}"`);return await this.#t[e].call(this.context||this,t)}};var et=function(e,t){let n=!0;return t.forEach((l,u)=>{n=n&&e[u]==l}),n},pe=function(e){let t=0;return e.forEach(n=>{t*=256,t+=n}),t},H=new TextDecoder,z=new ue;z.set("s7e",async function(e){let t=new Uint8Array(await e.slice(0,65536).arrayBuffer()),n="MSB LSB PRG NME",l=[0,0,0,0],u=32,p=0,h=0,a=!0,i=[],d=0;for(;a;){let s=t.subarray(p);([()=>{H.decode(s.subarray(0,4))=="YSFC"?(p+=80,h=1):p++},()=>{if(et(s.subarray(0,4),l))i.forEach((r,c,f)=>{let o=pe(t.subarray(r.start+4,r.start+8));r.length=o}),h=2;else{let r=H.decode(s.subarray(0,4)),c=pe(s.subarray(4,8));i.push({type:r,start:c}),p+=8}},()=>{let r=i[d],c=t.subarray(r.start,r.start+r.length),f=32;switch(r.type){case"ENVC":{let o=u;for(;o=i.length&&(h=3,a=!1)}][h]||(()=>{a=!1}))()}return n});var G=["off","hall","room","stage","plate","delay LCR","delay LR","echo","cross delay","early reflections","gate reverb","reverse gate"].concat(new Array(4),["white room","tunnel","canyon","basement","karaoke"],new Array(43),["pass through","chorus","celeste","flanger","symphonic","rotary speaker","tremelo","auto pan","phaser","distortion","overdrive","amplifier","3-band EQ","2-band EQ","auto wah"],new Array(1),["pitch change","harmonic","touch wah","compressor","noise gate","voice channel","2-way rotary speaker","ensemble detune","ambience"],new Array(4),["talking mod","Lo-Fi","dist + delay","comp + dist + delay","wah + dist + delay","V dist","dual rotor speaker"]),X=["melodic","drums","drum set 1","drum set 2","drum set 3","drum set 4","drum set 5","drum set 6","drum set 7","drum set 8"],tt=[17.1,18.6,20.2,21.8,23.3,24.9,26.5,28,29.6,31.2,32.8,34.3,35.9,37.5,39,40.6,42.2,43.7,45.3,46.9,48.4,50],N=[20,22,25,28,32,36,40,45,50,56,63,70,80,90,100,110,125,140,160,180,200,225,250,280,315,355,400,450,500,560,630,700,800,900,1e3,1100,1200,1400,1600,1800,2e3,2200,2500,2800,3200,3600,4e3,4500,5e3,5600,6300,7e3,8e3,9e3,1e4,11e3,12e3,14e3,16e3,18e3,2e4],be=[0,.04,.08,.13,.17,.21,.25,.29,.34,.38,.42,.46,.51,.55,.59,.63,.67,.72,.76,.8,.84,.88,.93,.97,1.01,1.05,1.09,1.14,1.18,1.22,1.26,1.3,1.35,1.39,1.43,1.47,1.51,1.56,1.6,1.64,1.68,1.72,1.77,1.81,1.85,1.89,1.94,1.98,2.02,2.06,2.1,2.15,2.19,2.23,2.27,2.31,2.36,2.4,2.44,2.48,2.52,2.57,2.61,2.65,2.69,2.78,2.86,2.94,3.03,3.11,3.2,3.28,3.37,3.45,3.53,3.62,3.7,3.87,4.04,4.21,4,37,4.54,4.71,4.88,5.05,5.22,5.38,5.55,5.72,6.06,6.39,6.73,7.07,7.4,7.74,8.08,8.41,8.75,9.08,9.42,9.76,10.1,10.8,11.4,12.1,12.8,13.5,14.1,14.8,15.5,16.2,16.8,17.5,18.2,19.5,20.9,22.2,23.6,24.9,26.2,27.6,28.9,30.3,31.6,33,34.3,37,39.7],ge=function(e){let t=.1,n=-.3;return e>66?(t=5,n=315):e>56?(t=1,n=47):e>46&&(t=.5,n=18.5),t*e-n},me=function(e){return e>105?tt[e-106]:e>100?e*1.1-100:e/10},ye=",a,i,u,e,o,ka,ki,ku,ke,ko,ky,kw,sa,si,su,se,so,sh,ta,ti,tu,te,to,t,ch,t,s,na,ni,nu,ne,no,ny,nn,ha,hi,hu,he,ho,hy,fa,fi,fu,fe,fo,ma,mi,mu,me,mo,my,mm,ya,yu,ye,yo,ra,ri,ru,re,ro,ry,wa,wi,we,wo,ga,gi,gu,ge,go,gy,gw,za,zi,zu,ze,zo,ja,ji,ju,je,jo,jy,da,di,du,de,do,dy,ba,bi,bu,be,bo,by,va,vi,vu,ve,vo,pa,pi,pu,pe,po,py,nga,ngi,ngu,nge,ngo,ngy,ng,hha,hhi,hhu,hhe,hho,hhy,hhw,*,_,,,~,.".split(","),Z={};`hi*, +var Ke=Object.create;var fe=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var qe=Object.getOwnPropertyNames;var We=Object.getPrototypeOf,Qe=Object.prototype.hasOwnProperty;var Ye=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var je=(e,t,c,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let h of qe(t))!Qe.call(e,h)&&h!==c&&fe(e,h,{get:()=>t[h],enumerable:!(o=ze(t,h))||o.enumerable});return e};var Ze=(e,t,c)=>(c=e!=null?Ke(We(e)):{},je(t||!e||!e.__esModule?fe(c,"default",{value:e,enumerable:!0}):c,e));var Le=Ye((Vt,re)=>{(function(){"use strict";let e={fatal:!0},t=[new TextDecoder("iso-8859-15",e),new TextDecoder("sjis",e),new TextDecoder("euc-jp",e),new TextDecoder("utf-8",e),new TextDecoder("utf-16",e),new TextDecoder("ascii")],c={debug:!1,parse:function(o,h){if(o instanceof Uint8Array)return c.Uint8(o);if(typeof o=="string")return c.Base64(o);if(o instanceof HTMLElement&&o.type==="file")return c.addListener(o,h);throw new Error("MidiParser.parse() : Invalid input provided")},addListener:function(o,h){if(!File||!FileReader)throw new Error("The File|FileReader APIs are not supported in this browser. Use instead MidiParser.Base64() or MidiParser.Uint8()");if(o===void 0||!(o instanceof HTMLElement)||o.tagName!=="INPUT"||o.type.toLowerCase()!=="file")return console.warn("MidiParser.addListener() : Provided element is not a valid FILE INPUT element"),!1;h=h||function(){},o.addEventListener("change",function(u){if(!u.target.files.length)return!1;console.log("MidiParser.addListener() : File detected in INPUT ELEMENT processing data..");let m=new FileReader;m.readAsArrayBuffer(u.target.files[0]),m.onload=function(r){h(c.Uint8(new Uint8Array(r.target.result)))}})},Base64:function(o){let h=function(r){var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";if(r=r.replace(/^.*?base64,/,""),r=String(r).replace(/[\t\n\f\r ]+/g,""),!/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/.test(r))throw new TypeError("Failed to execute _atob() : The string to be decoded is not correctly encoded.");r+="==".slice(2-(3&r.length));let n,s="",a,l,f=0;for(;f>16&255):l===64?String.fromCharCode(n>>16&255,n>>8&255):String.fromCharCode(n>>16&255,n>>8&255,255&n);return s}(o=String(o));var u=h.length;let m=new Uint8Array(new ArrayBuffer(u));for(let r=0;r{l[g]=this.readInt(1)});for(let p=0;p191||v>127&&v<160)throw new RangeError(`Invalid code point: ${v}`)}f=!0,console.debug(`String byte sequence in ${t[p].encoding}`)}catch(g){console.debug(`SMF string ${g}`)}return d||"String byte sequence read failed."},backOne:function(){this.pointer--},readIntVLV:function(){let a=0;if(this.pointer>=this.data.byteLength)return-1;if(this.data.getUint8(this.pointer)<128)a=this.readInt(1);else{let f=[];for(;128<=this.data.getUint8(this.pointer);)f.push(this.readInt(1)-128);var l=this.readInt(1);for(let d=1;d<=f.length;d++)a+=f[f.length-d]*Math.pow(128,d);a+=l}return a}};if(h.data=new DataView(m.buffer,m.byteOffset,m.byteLength),h.readInt(4)!==1297377380)return console.warn("Header validation failed (not MIDI standard or file corrupt.)"),!1;h.readInt(4);let u={};u.formatType=h.readInt(2),u.tracks=h.readInt(2),u.track=[];var m=h.readInt(1),r=h.readInt(1);128<=m?(u.timeDivision=[],u.timeDivision[0]=m-128,u.timeDivision[1]=r):u.timeDivision=256*m+r;for(let a=1;a<=u.tracks;a++){u.track[a-1]={event:[]};var i,n=h.readInt(4);if(n===-1)break;if(n!==1297379947)return!1;h.readInt(4);let l=0,f=!1,d,p;for(;!f&&(l++,u.track[a-1].event[l-1]={},u.track[a-1].event[l-1].deltaTime=h.readIntVLV(),(d=h.readInt(1))!==-1);)if(128<=d?p=d:(d=p,h.movePointer(-1)),d===255){u.track[a-1].event[l-1].type=255,u.track[a-1].event[l-1].metaType=h.readInt(1);var s=h.readIntVLV();switch(u.track[a-1].event[l-1].metaType){case 47:case-1:f=!0;break;case 1:case 2:case 3:case 4:case 5:case 7:case 6:u.track[a-1].event[l-1].data=h.readStr(s);break;case 33:case 89:case 81:u.track[a-1].event[l-1].data=h.readInt(s);break;case 84:u.track[a-1].event[l-1].data=[],u.track[a-1].event[l-1].data[0]=h.readInt(1),u.track[a-1].event[l-1].data[1]=h.readInt(1),u.track[a-1].event[l-1].data[2]=h.readInt(1),u.track[a-1].event[l-1].data[3]=h.readInt(1),u.track[a-1].event[l-1].data[4]=h.readInt(1);break;case 88:u.track[a-1].event[l-1].data=[],u.track[a-1].event[l-1].data[0]=h.readInt(1),u.track[a-1].event[l-1].data[1]=h.readInt(1),u.track[a-1].event[l-1].data[2]=h.readInt(1),u.track[a-1].event[l-1].data[3]=h.readInt(1);break;default:this.customInterpreter!==null&&(u.track[a-1].event[l-1].data=this.customInterpreter(u.track[a-1].event[l-1].metaType,h,s)),this.customInterpreter!==null&&u.track[a-1].event[l-1].data!==!1||(h.readInt(s),u.track[a-1].event[l-1].data=h.readInt(s),this.debug&&console.info("Unimplemented 0xFF meta event! data block readed as Integer"))}}else switch((d=d.toString(16).split(""))[1]||d.unshift("0"),u.track[a-1].event[l-1].type=parseInt(d[0],16),u.track[a-1].event[l-1].channel=parseInt(d[1],16),u.track[a-1].event[l-1].type){case 15:this.customInterpreter!==null&&(u.track[a-1].event[l-1].data=this.customInterpreter(u.track[a-1].event[l-1].type,h,!1)),this.customInterpreter!==null&&u.track[a-1].event[l-1].data!==!1||(i=h.readIntVLV(),u.track[a-1].event[l-1].data=h.readInt(i),this.debug&&console.info("Unimplemented 0xF exclusive events! data block readed as Integer"));break;case 10:case 11:case 14:case 8:case 9:u.track[a-1].event[l-1].data=[],u.track[a-1].event[l-1].data[0]=h.readInt(1),u.track[a-1].event[l-1].data[1]=h.readInt(1);break;case 12:case 13:u.track[a-1].event[l-1].data=h.readInt(1);break;case-1:f=!0;break;default:if(this.customInterpreter!==null&&(u.track[a-1].event[l-1].data=this.customInterpreter(u.track[a-1].event[l-1].metaType,h,!1)),this.customInterpreter===null||u.track[a-1].event[l-1].data===!1)return console.log("Unknown EVENT detected... reading cancelled!"),!1}}return u},customInterpreter:null};if(typeof re<"u")re.exports=c;else{let o=typeof window=="object"&&window.self===window&&window||typeof self=="object"&&self.self===self&&self||typeof global=="object"&&global.global===global&&global;o.MidiParser=c}})()});var he=function(e,t){let c=Math.min(e.length,t.length),o=e.slice(0,c),h=t.slice(0,c),u=0,m=0;for(;m0){let o=this.pool.length,h=1<=1&&m>=0;){if(m<=0)throw new Error("TTL reached.");if(u==o)u-=h;else{let i=he(t,this.pool[u]);switch(i){case 0:{m=0;break}case 1:{u+h<=o&&(u+=h);break}case-1:{u!=0&&(u-=h);break}default:console.warn(`Unexpected result ${i}.`)}}h=h>>1,m--}let r=!0;if(u>=this.pool.length)r=!1;else{let i=this;this.pool[u].forEach(function(n,s,a){r&&n!=t[s]&&(r=!1)}),!r&&he(t,this.pool[u])>0&&u++}return r||c?u:-1}else return c?0:-1},this.add=function(t,c){return t.data=c,this.pool.splice(this.point(t,!0),0,t),this},this.default=function(t){console.warn(`No match in "${this.name||"(unknown)"}" for "${t}". Default action not defined.`)},this.get=function(t){let c=this.point(t);if(c>-1)return this.pool[c].data;this.default(t)},this.run=function(t,...c){let o=this.point(t);o>-1?t.subarray?this.pool[o].data(t.subarray(this.pool[o].length),...c):this.pool[o].data(t.slice(this.pool[o].length),...c):this.default(t,...c)}};var K=class{#t={};addEventListener(e,t){this.#t[e]||(this.#t[e]=[]),this.#t[e].unshift(t)}removeEventListener(e,t){if(this.#t[e]){let c=this.#t[e].indexOf(t);c>-1&&this.#t[e].splice(c,1),this.#t[e].length<1&&delete this.#t[e]}}dispatchEvent(e,t){let c=new Event(e),o=this;c.data=t,this.#t[e]?.length>0&&this.#t[e].forEach(function(h){try{h?.call(o,c)}catch(u){console.error(u)}}),this[`on${e}`]&&this[`on${e}`](c)}};var Je=["MSB","PRG","LSB","NME","ELC","DRM"],Y=function(e){let t=Math.floor(e/10),c=e%10;return`${t.toString(16)}${c}`},j=class{#t;strictMode=!1;get(e=0,t=0,c=0,o){let h=[e,t,c],u,m=1,r=0,i,n=Array.from(arguments);switch(o){case"xg":{switch(e){case 0:{c==126?n[2]=125:c==127&&(n[2]=0);break}case 16:{c==126&&(n[2]=0);break}case 32:{c>125&&(n[2]=0),n[2]+=4;break}case 33:case 34:case 35:case 36:{c>125&&(n[2]=0),n[2]+=5;break}case 79:case 80:case 81:case 82:case 83:case 84:n[0]+=16;case 95:case 96:case 97:case 98:case 99:case 100:{c==126&&(n[2]=0);break}case 48:case 64:case 126:case 127:{c==126&&(n[2]=0);break}}break}case"gs":{e==0&&c<5?n[2]=0:e>125&&c<5&&c!=2&&(n[2]=e,n[0]=0);break}case"g2":case"sd":{(e>>1==40||e>95&&e<100)&&(n[2]|=16);break}case"sg":{e==8&&c==0&&(n[2]=5);break}case"s90es":{c<8?n[2]+=17:c<32?n[2]+=13:n[2]=(n[2]>>3)+19;break}case"motif":{c<8?n[2]+=28:c<32?n[2]+=13:n[2]=(n[2]>>3)+19;break}}let s=" ",a="M",l=0,f=0;switch(n[0]){case 0:{n[2]==127?a="MT-a":n[2]==126?a="MT-b":n[2]==7?a="GM-k":n[2]==5?a="SG-a":n[2]==4?a="SP-l":n[2]==0||o=="gs"&&n[2]<5?a="GM-a":(a="y",l=3);break}case 8:{o=="sg"?a="GM-s":a="r:";break}case 32:case 33:case 34:case 35:case 36:{o=="xg"&&(a=`${["AP","VL","PF","DX","AN"][e&7]}-${"abcdefgh"[c]}`);break}case 48:{a=`yM${(n[2]>>3).toString().padStart(2,"0")}`,l=1;break}case 56:{a="GM-b";break}case 61:case 120:{a="rDrm";break}case 62:{a="kDrm";break}case 63:{if(n[2]<17){let v=n[2];a=v<10?"kP:":"kC:",a+=v%10}else n[2]<34?a=["Pre1","Pre2","Pre3","Pre4","Usr1","Usr2","DrmP","DrmU","Plg1","Plg2","Plg3","Pre1","Pre2","Pre3","Pre4","Pre5","Pre6"][n[2]-17]:a="Ds";break}case 64:{a="ySFX";break}case 67:{a="DX:S";break}case 80:case 81:case 82:case 83:{a=`Prg${"UABC"[n[0]-80]}`;break}case 88:case 89:case 90:case 91:{a=`Cmb${"UABC"[n[0]-88]}`;break}case 95:{a=`${["DR","PC"][n[2]]}-d`;break}case 96:{a=n[2]==106?"AP-a":n[2]>>4==1?"SDg":"PF",n[2]>63?f=63:n[2]>>4==1&&(f=16),l=3;break}case 97:{a=n[2]>>4==1?"SDa":"VL:",l=3,n[2]>>4==1?f=16:f=112;break}case 98:{a=n[2]>>4==1?"SDb":"SG-a",l=3,f=16;break}case 99:{a=n[2]>>4==1?"SDc":"DX",n[2]>63?f=63:n[2]>>4==1&&(f=16),l=3;break}case 100:{a="AN",n[2]>63?f=63:n[2]>>4==1&&(f=16),l=3;break}case 104:case 105:case 106:case 107:{a="SDd",f=104;break}case 121:{a=`GM-${n[2]?"":"a"}`,l=3;break}case 122:{a="lDrm";break}case 126:{a="yDrS";break}case 127:{n[2]==127?a="rDrm":a="yDrm";break}default:n[0]<48?a="r:":a="M"}a.length<4&&(a+=`${[e,c,n[0],n[2]][l]-f}`.padStart(4-a.length,"0")),o=="xg"&&(e==0?n[2]<100?a=a.replace("y0","y:"):n[2]==125&&(a="y126"):e==16&&(u=`Voice${(n[2]*128+n[1]+1).toString().padStart(3,"0")}`,s=" "));let d=[n[0],n[1],n[2]];for(;!(u?.length>=0);)if(u=this.#t[n[1]||0][(n[0]<<7)+n[2]]?.name,u){let v=this.#t[n[1]||0][(n[0]<<7)+n[2]];m=v?.poly||m,r=v?.type||r,i=v?.drum}else if(this.strictMode)u="",s="?";else if(n[0]==0&&n[1]==0&&n[2]==0)u="Unloaded";else if(this.#t[n[1]||0][n[0]<<7])n[0]==0?(n[2]=0,s="^"):n[2]<1?(n[0]=0,s="*"):(n[2]--,s="^");else if(e==48)n[0]=0,n[2]=0,s="!";else if(e==62)n[1]--,s=" ",n[1]<1&&!u?.length&&(n[0]=0,s="!");else if(e<63)n[0]==0?(n[2]=0,s="^"):n[2]<1?(n[0]=0,s="*"):n[2]--;else if(e==80)u=`PrgU:${t.toString().padStart(3,"0")}`,s="!";else if(e==88)u=`CmbU:${t.toString().padStart(3,"0")}`,s="!";else if(e==121)u=`GM2Vox0${c}`,s="#";else if(e==122)if(n[1]==32?n[1]==0:n[1]%=7,u=this.#t[n[1]||0][(n[0]<<7)+n[2]]?.name,u){s=" ";let v=this.#t[n[1]||0][(n[0]<<7)+n[2]];m=v?.poly||m,r=v?.type||r,i=v?.drum}else u="",s="*";else n[1]==0?(u=`${e.toString().padStart(3,"0")} ${t.toString().padStart(3,"0")} ${c.toString().padStart(3,"0")}`,s="!"):n[0]==0?(n[2]=0,s="^"):n[2]>0?n[2]--:n[1]>0?(n[1]=0,s="!"):(n[0]=0,s="?");let p=[n[0],n[1],n[2]];(o=="gs"||o=="ns5r")&&s=="^"&&(s=" "),e==127&&s=="^"&&(s=" "),s!=" "&&self.debugMode&&(u="");let g="??";switch(n[0]){case 0:{n[2]==0?g="GM":n[2]==5||n[2]==7?g="KG":n[2]<126?g="XG":n[2]==127&&(g="MT");break}case 32:case 33:case 35:case 36:{n[2]>4?g=["AP","VL","PF","DX","AN"][n[0]-32]:g="GS";break}case 48:{g="MU";break}case 56:{g="AG";break}case 61:case 80:case 83:case 88:case 89:case 91:{g="AI";break}case 62:case 82:case 90:{g="XD";break}case 63:{n[2]<17?g="KR":n[2]<34?g="ES":g="DS";break}case 64:case 126:{g="XG";break}case 67:case 99:{g=n[2]>>4==1?"SD":"DX";break}case 81:{g="RW";break}case 95:{g=["DR","PC"][n[2]];break}case 96:{g=n[2]==106?"AP":n[2]>>4==1?"SD":"PF";break}case 97:{g=n[2]>>4==1?"SD":"VL";break}case 98:{g=n[2]>>4==1?"SD":"SG";break}case 100:{g="AN";break}case 104:case 105:case 106:case 107:{g="SD";break}case 120:{g="GS";break}case 121:{g=n[2]?"G2":"GM";break}case 122:{g="KG";break}case 127:{g=n[2]==127?"MT":t==0?"GM":"XG";break}default:n[0]<48&&(n[0]==16&&o=="xg"?g="XG":g="GS")}return{name:u||`${Y(e||0)} ${Y(t||0)} ${Y(c||0)}`,poly:m,type:r,drum:i,iid:d,eid:p,sid:h,ending:s,sect:a,standard:g}}async load(e,t,c="(internal)"){let o=this,h=[],u=0,m=0;e.split(` +`).forEach(function(r,i){let n=r.split(" "),s=[];if(i==0){if(n.forEach(function(a,l){h[Je.indexOf(a)]=l}),h.length<4){console.debug("Debugger launched.");debugger}}else{let a=0,l=0,f=0,d,p=1,g=0,v;n.forEach(async function($,I){switch(I){case h[0]:{a=parseInt($);break}case h[1]:{l=parseInt($);break}case h[2]:{f=parseInt($);break}case h[3]:{d=$;break}case h[4]:{$=parseInt($),$<16?p=$+1:g=($&15)+1;break}case h[5]:{v=$;break}}}),o.#t[l]=o.#t[l]||[];let k=o.#t[l];if(!k[a<<7|f]||t){let $={msb:a,prg:l,lsb:f,name:d,poly:p,type:g,drum:v};k[a<<7|f]=$,u++}m++}}),t||console.debug(`Map "${c}": ${m} total, ${u} loaded.`)}clearRange(e){let t=e.prg!=null?e.prg.constructor==Array?e.prg:[e.prg,e.prg]:[0,127],c=e.msb!=null?e.msb.constructor==Array?e.msb:[e.msb,e.msb]:[0,127],o=e.lsb!=null?e.lsb.constructor==Array?e.lsb:[e.lsb,e.lsb]:[0,127];for(let h=c[0];h<=c[1];h++){let u=h<<7;for(let m=o[0];m<=o[1];m++){let r=u+m;for(let i=t[0];i<=t[1];i++)delete this.#t[i][r]}}}init(){this.#t=[];for(let e=0;e<128;e++)this.#t.push([""])}async loadFiles(...e){this.init();let t=this;e.forEach(async function(c){try{await fetch(`./data/bank/${c}.tsv`).then(function(o){return o.text()}).then(o=>{t.load(o,!1,c)})}catch{console.error(`Failed loading "${c}.tsv".`)}})}constructor(...e){this.loadFiles(...e)}};var ue=class{#t={};context;set(e,t){this.#t[e]=t}has(e){return!!this.#t[e]}async read(e,t){if(!this.has(e))throw new Error(`No decoder registered for "${e}"`);return await this.#t[e].call(this.context||this,t)}};var et=function(e,t){let c=!0;return t.forEach((o,h)=>{c=c&&e[h]==o}),c},pe=function(e){let t=0;return e.forEach(c=>{t*=256,t+=c}),t},H=new TextDecoder,z=new ue;z.set("s7e",async function(e){let t=new Uint8Array(await e.slice(0,65536).arrayBuffer()),c="MSB LSB PRG NME",o=[0,0,0,0],h=32,u=0,m=0,r=!0,i=[],n=0;for(;r;){let s=t.subarray(u);([()=>{H.decode(s.subarray(0,4))=="YSFC"?(u+=80,m=1):u++},()=>{if(et(s.subarray(0,4),o))i.forEach((a,l,f)=>{let d=pe(t.subarray(a.start+4,a.start+8));a.length=d}),m=2;else{let a=H.decode(s.subarray(0,4)),l=pe(s.subarray(4,8));i.push({type:a,start:l}),u+=8}},()=>{let a=i[n],l=t.subarray(a.start,a.start+a.length),f=32;switch(a.type){case"ENVC":{let d=h;for(;d=i.length&&(m=3,r=!1)}][m]||(()=>{r=!1}))()}return c});var G=["off","hall","room","stage","plate","delay LCR","delay LR","echo","cross delay","early reflections","gate reverb","reverse gate"].concat(new Array(4),["white room","tunnel","canyon","basement","karaoke"],new Array(43),["pass through","chorus","celeste","flanger","symphonic","rotary speaker","tremelo","auto pan","phaser","distortion","overdrive","amplifier","3-band EQ","2-band EQ","auto wah"],new Array(1),["pitch change","harmonic","touch wah","compressor","noise gate","voice channel","2-way rotary speaker","ensemble detune","ambience"],new Array(4),["talking mod","Lo-Fi","dist + delay","comp + dist + delay","wah + dist + delay","V dist","dual rotor speaker"]),X=["melodic","drums","drum set 1","drum set 2","drum set 3","drum set 4","drum set 5","drum set 6","drum set 7","drum set 8"],tt=[17.1,18.6,20.2,21.8,23.3,24.9,26.5,28,29.6,31.2,32.8,34.3,35.9,37.5,39,40.6,42.2,43.7,45.3,46.9,48.4,50],B=[20,22,25,28,32,36,40,45,50,56,63,70,80,90,100,110,125,140,160,180,200,225,250,280,315,355,400,450,500,560,630,700,800,900,1e3,1100,1200,1400,1600,1800,2e3,2200,2500,2800,3200,3600,4e3,4500,5e3,5600,6300,7e3,8e3,9e3,1e4,11e3,12e3,14e3,16e3,18e3,2e4],be=[0,.04,.08,.13,.17,.21,.25,.29,.34,.38,.42,.46,.51,.55,.59,.63,.67,.72,.76,.8,.84,.88,.93,.97,1.01,1.05,1.09,1.14,1.18,1.22,1.26,1.3,1.35,1.39,1.43,1.47,1.51,1.56,1.6,1.64,1.68,1.72,1.77,1.81,1.85,1.89,1.94,1.98,2.02,2.06,2.1,2.15,2.19,2.23,2.27,2.31,2.36,2.4,2.44,2.48,2.52,2.57,2.61,2.65,2.69,2.78,2.86,2.94,3.03,3.11,3.2,3.28,3.37,3.45,3.53,3.62,3.7,3.87,4.04,4.21,4,37,4.54,4.71,4.88,5.05,5.22,5.38,5.55,5.72,6.06,6.39,6.73,7.07,7.4,7.74,8.08,8.41,8.75,9.08,9.42,9.76,10.1,10.8,11.4,12.1,12.8,13.5,14.1,14.8,15.5,16.2,16.8,17.5,18.2,19.5,20.9,22.2,23.6,24.9,26.2,27.6,28.9,30.3,31.6,33,34.3,37,39.7],ge=function(e){let t=.1,c=-.3;return e>66?(t=5,c=315):e>56?(t=1,c=47):e>46&&(t=.5,c=18.5),t*e-c},me=function(e){return e>105?tt[e-106]:e>100?e*1.1-100:e/10},ye=",a,i,u,e,o,ka,ki,ku,ke,ko,ky,kw,sa,si,su,se,so,sh,ta,ti,tu,te,to,t,ch,t,s,na,ni,nu,ne,no,ny,nn,ha,hi,hu,he,ho,hy,fa,fi,fu,fe,fo,ma,mi,mu,me,mo,my,mm,ya,yu,ye,yo,ra,ri,ru,re,ro,ry,wa,wi,we,wo,ga,gi,gu,ge,go,gy,gw,za,zi,zu,ze,zo,ja,ji,ju,je,jo,jy,da,di,du,de,do,dy,ba,bi,bu,be,bo,by,va,vi,vu,ve,vo,pa,pi,pu,pe,po,py,nga,ngi,ngu,nge,ngo,ngy,ng,hha,hhi,hhu,hhe,hho,hhy,hhw,*,_,,,~,.".split(","),Z={};`hi*, ka,か ki,き ku,く @@ -139,8 +139,8 @@ o,お ~, ^, _,`.split(` -`).forEach(e=>{let t=e.split(",");Z[t[0]]=t[1]});var ve=function(e){let t=e;e[0]=="*"&&(t=t.slice(1)),["aa","ii","uu","ee","oo"].forEach(l=>{for(;t.indexOf(l)>-1;)t=t.replace(l,l[0])});for(let l in Z)t=t.replaceAll(l,Z[l]);t.indexOf("ん")==0&&t.length>1&&(t=t.slice(1));let n=t.indexOf("!");return n>-1&&t.length>1&&(t=t.slice(n+1)),t},Ee=function(e){return e?e<96?`cc${e}`:["aftertouch","velocity","pitch bend"][e-96]:"off"};var J=["room 1","room 2","room 3","hall 1","hall 2","plate","delay","panning delay"],we=["chorus 1","chorus 2","chorus 3","chorus 4","feedback","flanger","short delay","short delay feedback"],$e=["delay 1","delay 2","delay 3","delay 4","pan delay 1","pan delay 2","pan delay 3","pan delay 4","delay to reverb","pan repeat"];var at={0:"thru",256:"stereo EQ",257:"spectrum",258:"enhancer",259:"humanizer",272:"overdrive",273:"distortion",288:"phaser",289:"auto wah",290:"rotary",291:"stereo flanger",292:"step flanger",293:"tremelo",294:"auto pan",304:"compressor",305:"limiter",320:"hexa chorus",321:"tremelo chorus",322:"stereo chorus",323:"space D",324:"3D chorus",336:"stereo delay",337:"modulated delay",338:"3-tap delay",339:"4-tap delay",340:"tremelo control delay",341:"reverb",342:"gate reverb",343:"3D delay",352:"2-pitch shifter",353:"feedback pitch shifter",368:"3D auto",369:"3D manual",370:"Lo-Fi 1",371:"Lo-Fi 2",512:"overdrive - chorus",513:"overdrive - flanger",514:"overdrive - delay",515:"distortion - chorus",516:"distortion - flanger",517:"distortion - delay",518:"enhancer - chorus",519:"enhancer - flanger",520:"enhancer - delay",521:"chorus - delay",522:"flanger - delay",523:"chorus - flanger",524:"rotary multi",1024:"guitar multi 1",1025:"guitar multi 2",1026:"guitar multi 3",1027:"clean guitar multi 1",1028:"clean guitar multi 2",1029:"bass multi",1030:"rhodes multi",1280:"keyboard multi",4352:"chorus / delay",4353:"flanger / delay",4354:"chorus / flanger",4355:"overdrive / distortion",4356:"overdrive / rotary",4357:"overdrive / phaser",4358:"overdrive / auto wah",4359:"phaser / rotary",4360:"phaser / auto wah"},rt={66307:["drive"],66309:["vowel",e=>"aiueo"[e]],94723:["pre-filter"],94724:["Lo-Fi type"],94725:["post-filter"],94979:["Lo-Fi type"],94980:["fill type",e=>["off","LPF","HPF"][e]],94984:["noise type",e=>["white","pink"][e]],94987:["disc type",e=>["LP","SP","EP","RND"]],94990:["hum type",e=>`${e+5}0Hz`],94993:["M/S",e=>["mono","stereo"][e]]},ee=function(e){return at[(e[0]-32<<8)+e[1]]||`0x${e[0].toString(16).padStart(2,"0")}${e[1].toString(16).padStart(2,"0")}`},ke=function(e,t,n){let l=(e[0]-32<<16)+(e[1]<<8)+t,u=rt[l]||{},p=u[0];if(p?.length)return p+=`: ${(u[1]||function(){})(n)||n}`,p},te=[68,48,95,78,41,3,110,122,0];var C=function(e=64){return Math.round(2e3*Math.log10(e/64))/100},xe=function(e,t,n){let l=[],u=n==!1?t.readIntVLV():n;e==0||e==127;for(let p=0;p127)return console.debug(`Early termination: ${l}`),l.pop(),t.backOne(),t.backOne(),new Uint8Array(l)}}}return new Uint8Array(l)},ae=function(e){let t=0;return e.forEach(n=>{t+=n,t=t&127}),~t+1&127},O=function(e,t){let n=0,l=0;for(let u=0;u>p&1)<<7,a=e[u];a+=h,u%8!=0?(t(a,n,e),n++):l=e[u]}},_=function(e){let t=Math.floor(e*14.2);return t<128?t:0};var A=["?","gm","gs","xg","g2","mt32","ns5r","x5d","05rw","sd","k11","sg","krs","s90es","motif"],Se=[[0,0,0,0,121,0,0,82,81,97,0,0,63,63,63],[0,0,4,0,0,127,0,0,0,0,0,0,0,0,0]],I=[120,127,120,127,120,127,61,62,62,105,122,122,120,127,127],it=[0,3,81,84,88],Te={8:"Off",9:"On",10:"Note aftertouch",11:"cc",12:"pc",13:"Channel aftertouch",14:"Pitch"},Ce={0:0,1:1,2:3,5:4},Me={0:0,1:1,2:2,5:3},Re=[[0,24],[0,127],[0,127],[40,88],[0,127],[0,127]],De=[36,37,48,49,52,53],q=[20,21,22,23,24,25,26,28,29,30,31,36,37,48,49,52,53,64,65],Oe={26:127,29:0,30:0,31:0,52:12,53:54},F=[0,1,2,4,5,6,7,8,10,11,32,38,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,84,91,92,93,94,95,98,99,100,101,128,12,13,16,17,18,19,14,15,20,21],st=[12,13,14,15,16,17,18,19,20,21],nt=[33,99,100,32,102,8,9,10],Pe=[0,16,25,40,32,64,26,48],w={};A.forEach((e,t)=>{w[e]=t});var g={length:F.length};F.forEach((e,t)=>{g[e]=t});var R={length:q.length};q.forEach((e,t)=>{R[e]=t});var k=function(){return!!self.Bun||self.debugMode||!1},ct=function(e){let t=[],n=0;return e?.forEach(function(l,u){l==247?t.push(e.subarray(n,u)):l==240&&(n=u+1)}),t.length||t.push(e.subarray(0)),k()&&console.debug(t),t};var m={ch:128,cc:F.length,nn:128,pl:512,tr:256,cmt:14,rpn:6,rpnt:4,ace:8,drm:8,dpn:q.length,dnc:128,efx:7},Ae=class extends V{NOTE_IDLE=0;NOTE_ATTACK=1;NOTE_DECAY=2;NOTE_SUSTAIN=3;NOTE_HELD=4;NOTE_RELEASE=5;NOTE_SOSTENUTO_ATTACK=8;NOTE_SOSTENUTO_DECAY=9;NOTE_SOSTENUTO_SUSTAIN=10;NOTE_SOSTENUTO_HELD=11;CH_MELODIC=0;CH_DRUMS=1;CH_DRUM1=2;CH_DRUM2=3;CH_DRUM3=4;CH_DRUM4=5;CH_DRUM5=6;CH_DRUM6=7;CH_DRUM7=8;CH_DRUM8=9;#t=0;#h=0;#E=0;#o=new Array(11);get#m(){return this.#o[this.#h]}set#m(e){this.#o[this.#h]=e}#w=new Uint8Array(m.ch);#u=new Uint8Array(m.ch);#s=new Uint8Array(m.ch);#e=new Uint8Array(m.ch*m.cc);#d=new Uint8Array(m.ace);#n=new Uint8Array(m.ch);#l=new Uint8Array(m.ch*m.nn);#p=new Uint8Array(m.ch);#b=new Uint16Array(m.pl);#v=new Uint8Array(m.pl);#D=new Int16Array(m.ch);#C=new Uint8Array(m.ch);#H=0;#r=new Uint8Array(m.ch*m.rpn);#i=new Uint8Array(m.ch*m.rpnt);#I=new Int8Array(m.ch*De.length);#x=new Uint8Array(m.drm*m.dpn*m.dnc);#a=new Uint8Array(m.ch);#$=new Uint8Array(128);#c=new Uint8Array(m.cmt*8);#y=new Uint8Array(1024);#S=new Uint8Array(m.cmt*64);#T=new Uint8Array(m.efx*3);#G=new Uint8Array(m.ch);#O=0;#M=0;#f=100;#X=0;#z=500;#U=0;#_="";#N=0;#q=0;#F=0;#B=!0;#g=!1;#te;#ie=new Uint8Array(2);#P=[];#K=new Uint8Array(m.ch);#W=new Uint8Array(m.tr);baseBank=new j("gm","gm2","xg","gs","ns5r","sd","gmega","plg-150vl","plg-150pf","plg-150dx","plg-150an","plg-150dr","plg-100sg","kross","s90es");userBank=new j("gm");initOnReset=!1;aiEfxName="";chRedir(e,t,n){if(this.#W[t])return(this.#W[t]-1)*16+e;if([2,3].indexOf(this.#M)>-1){if(n==1)return e;let l=0,u=!0;for(;u;)this.#K[e+l]==0?(this.#K[e+l]=t,console.debug(`Assign track ${t} to channel ${e+l+1}.`),u=!1):this.#K[e+l]==t?u=!1:(l+=16,l>=128&&(l=0,u=!1));return e+l}else return e}forceVoiceRefresh(){for(let e=0;e{let n=e*128+t,l=this.#b.lastIndexOf(n);l>-1&&(this.#e[m.cc*e+g[64]]>63?(this.#v[l]=this.NOTE_HELD,this.dispatchEvent("note",{part:e,note:t,velo:this.#l[n],state:this.NOTE_HELD})):this.#e[m.cc*e+g[66]]>63&&this.#v[l]==this.NOTE_SOSTENUTO_SUSTAIN?(this.#v[l]=this.NOTE_SOSTENUTO_HELD,this.dispatchEvent("note",{part:e,note:t,velo:this.#l[n],state:this.NOTE_SOSTENUTO_HELD})):(this.#b[l]=0,this.#l[n]=0,this.#v[l]=this.NOTE_IDLE,this.dispatchEvent("note",{part:e,note:t,velo:0,state:this.NOTE_IDLE})))},nOn:(e,t,n)=>{let l=e*128+t,u=0;for(this.#p[e]&&this.#k.ano(e);this.#v[u]>0&&this.#b[u]!=l;)u++;u{},cAt:(e,t)=>{},hoOf:e=>{this.#v.forEach((t,n)=>{if(t==this.NOTE_HELD){let l=this.#b[n],u=l>>7;e==u&&(this.#v[n]=this.NOTE_IDLE,this.#b[n]=0,this.#l[l]=0,this.dispatchEvent("note",{part:e,note:l&127,velo:0,state:this.NOTE_IDLE}))}})},soOn:e=>{this.#v.forEach((t,n)=>{let l;switch(t){case this.NOTE_ATTACK:{l=this.NOTE_SOSTENUTO_ATTACK;break}case this.NOTE_DECAY:{l=this.NOTE_SOSTENUTO_DECAY;break}case this.NOTE_SUSTAIN:{l=this.NOTE_SOSTENUTO_SUSTAIN;break}}if(l){this.#v[n]=l;let u=this.#b[n];this.dispatchEvent("note",{part:e,note:u&127,velo:this.#l[u],state:l})}})},soOf:e=>{this.#v.forEach((t,n)=>{if(t==this.NOTE_SOSTENUTO_HELD){let l=this.#b[n],u=l>>7;e==u&&(this.#v[n]=this.NOTE_IDLE,this.#b[n]=0,this.#l[l]=0,this.dispatchEvent("note",{part:e,note:l&127,velo:0,state:this.NOTE_IDLE}))}})},ano:e=>{this.#b.forEach((t,n,l)=>{let u=t>>7,p=t&127;t==0&&this.#l[0]==0||u==e&&this.#k.nOff(u,p)})}};#ae={8:function(e){let t=e.channel,n=e.data[0];this.#k.nOff(t,n)},9:function(e){let t=e.channel;this.setChActive(t,1);let n=e.data[0],l=e.data[1];l>0?this.#k.nOn(t,n,l):this.#k.nOff(t,n)},10:function(e){let t=e.channel,n=t*128+e.data[0];this.#b.indexOf(n)>-1&&(this.#l[n]=data[1],this.dispatchEvent("note",{part:t,note:e.data[0],velo:e.data[1],state:this.NOTE_SUSTAIN}))},11:function(e){let t=e.channel;[0,32].indexOf(e.data[0])>-1&&(()=>{switch(this.#t){case w.s90es:case w.motif:{if(e.data[0]==0){[0,63].indexOf(e.data[1])>-1&&this.setChActive(t,1);break}e.data[1]&&this.setChActive(t,1);break}default:{this.setChActive(t,1);break}}})();let n=t*m.cc;switch(e.data[0]){case 96:return;case 97:return;case 120:return;case 121:{this.#k.ano(t),this.#D[t]=0;let l=t*m.cc;this.#e[l+g[1]]=0,this.#e[l+g[5]]=0,this.#e[l+g[64]]=0,this.#e[l+g[65]]=0,this.#e[l+g[66]]=0,this.#e[l+g[67]]=0,this.#e[l+g[11]]=127,this.#e[l+g[101]]=127,this.#e[l+g[100]]=127,this.#e[l+g[99]]=127,this.#e[l+g[98]]=127;return}case 123:{this.#k.ano(t);return}case 124:{this.#k.ano(t);return}case 125:{this.#k.ano(t);return}case 126:{this.#p[t]=1,this.#k.ano(t);return}case 127:{this.#p[t]=0,this.#k.ano(t);return}}if(g[e.data[0]]==null)console.warn(`cc${e.data[0]} is not accepted.`);else{switch(st.indexOf(e.data[0])>-1&&this.allocateAce(e.data[0]),e.data[0]){case 0:{switch(k()&&console.debug(`${A[this.#t]}, CH${t+1}: ${e.data[1]}`),this.#t==0?e.data[1]<48?(this.#s[t]>0&&(e.data[1]=this.#e[n],e.data[1]=120,console.debug(`Forced channel ${t+1} to stay drums.`)),e.data[1]>0&&(console.debug(`Roland GS detected with MSB: ${e.data[1]}`),this.switchMode("gs"))):e.data[1]==62?this.switchMode("x5d"):e.data[1]==63?this.switchMode("krs"):(e.data[1]==64||e.data[1]==127)&&this.switchMode("xg"):this.#t==w.gs?e.data[1]<56&&this.#s[t]>0&&(e.data[1]=this.#e[n],e.data[1]=120,console.debug(`Forced channel ${t+1} to stay drums.`)):this.#t==w.gm?e.data[1]<48?this.#s[t]>0&&(e.data[1]=120,this.switchMode("gs",!0),console.debug(`Forced channel ${t+1} to stay drums.`)):(e.data[1]==64||e.data[1]==127)&&this.switchMode("xg",!0):this.#t==w.x5d&&e.data[1]>0&&e.data[1]<8&&this.switchMode("05rw",!0),this.#t){case w.xg:{[126,127].indexOf(e.data[1])>-1?this.#s[t]==0&&(this.setChType(t,this.CH_DRUM2),console.debug(`CH${t+1} set to drums by MSB.`)):this.#s[t]>0&&(this.setChType(t,this.CH_MELODIC),console.debug(`CH${t+1} set to melodic by MSB.`));break}case w["05rw"]:case w.x5d:case w.ns5r:{[61,62,126,127].indexOf(e.data[1])>-1?this.#s[t]==0&&(this.setChType(t,this.CH_DRUM2),console.debug(`CH${t+1} set to drums by MSB.`)):this.#s[t]>0&&(this.setChType(t,this.CH_MELODIC),console.debug(`CH${t+1} set to melodic by MSB.`));break}case w.sd:{[104,105,106,107].indexOf(e.data[1])>-1?this.#s[t]==0&&(this.setChType(t,this.CH_DRUM2),console.debug(`CH${t+1} set to drums by MSB.`)):this.#s[t]>0&&(this.setChType(t,this.CH_MELODIC),console.debug(`CH${t+1} set to melodic by MSB.`));break}case w.g2:{e.data[1]==120?this.#s[t]==0&&(this.setChType(t,this.CH_DRUMS),console.debug(`CH${t+1} set to drums by MSB.`)):this.#s[t]>0&&(this.setChType(t,this.CH_MELODIC),console.debug(`CH${t+1} set to melodic by MSB.`));break}}this.dispatchEvent("voice",{part:t});break}case 6:{if(this.#H){[w.xg,w.gs,w.ns5r].indexOf(this.#t)<0&&console.warn(`NRPN commits are not available under "${A[this.#t]}" mode, even when they are supported in Octavia.`);let l=this.#e[n+g[99]],u=this.#e[n+g[98]];if(l==1){let p=nt.indexOf(u);if(p>-1)this.#e[n+g[71+p]]=e.data[1],k()&&console.debug(`Redirected NRPN 1 ${u} to cc${71+p}.`),this.dispatchEvent("cc",{part:t,cc:71+p,data:e.data[1]});else{let h=De.indexOf(u);h>-1?this.#I[t*10+h]=e.data[1]-64:console.warn(`NRPN 0x01${u.toString(16).padStart(2,"0")} is not supported.`),k()&&console.debug(`CH${t+1} voice NRPN ${u} commit`)}}else{if(q.indexOf(l)<0){let h=`NRPN 0x${l.toString(16).padStart(2,"0")}${u.toString(16).padStart(2,"0")} `;l==127?console.warn(`${h}is not necessary. Consider removing it.`):console.warn(`${h}is not supported.`)}else{let h=this.#s[t]-2;h<0?console.warn(`CH${t+1} cannot accept drum NRPN as type ${X[this.#s[t]]}.`):this.#x[(h*m.dpn+R[l])*m.dnc+u]=e.data[1]}k()&&console.debug(`CH${t+1} (${X[this.#s[t]]}) drum NRPN ${l} commit`)}}else{let l=Ce[this.#e[n+g[100]]],u=Me[this.#e[n+g[100]]];this.#e[n+g[101]]==0&&l!=null&&(k()&&console.debug(`CH${t+1} RPN 0 ${this.#e[n+g[100]]} commit: ${e.data[1]}`),e.data[1]=Math.min(Math.max(e.data[1],Re[l][0]),Re[l][1]),this.#r[t*m.rpn+l]=e.data[1],this.#i[t*m.rpnt+u]=1)}break}case 32:{switch(k()&&console.debug(`${A[this.#t]}, CH${t+1} LSB: ${e.data[1]}`),this.#t){case w.s90es:case w.motif:{this.setChType(t,[32,40].indexOf(e.data[1])>-1?this.CH_DRUMS:this.CH_MELODIC,this.#t,!0);break}}this.dispatchEvent("voice",{part:t});break}case 38:{if(!this.#H){let l=Ce[this.#e[n+100]],u=Me[this.#e[n+100]];this.#e[n+101]==0&&l!=null&&(this.#r[t*m.rpn+l+1]=e.data[1],this.#i[t*m.rpnt+u]=1)}break}case 64:{e.data[1]<64&&this.#k.hoOf(t);break}case 66:{e.data[1]>>6?this.#k.soOn(t):this.#k.soOf(t);break}case 98:case 99:{this.#H=1;break}case 100:case 101:{this.#H=0;break}}this.#e[n+g[e.data[0]]]=e.data[1],this.dispatchEvent("cc",{part:t,cc:e.data[0],data:e.data[1]})}},12:function(e){let t=e.channel;switch(this.#t){case w.s90es:case w.motif:{e.data&&this.setChActive(t,1);break}default:this.setChActive(t,1)}this.#n[t]=e.data,this.#a[t]=0,k()&&console.debug(`T:${e.track} C:${t} P:${e.data}`),this.dispatchEvent("voice",{part:t})},13:function(e){let t=this,n=e.channel;this.#b.forEach(function(l){let u=l>>7;n==u&&(t.#l[l]=e.data,t.dispatchEvent("note",{part:n,note:l&127,velo:e.data,state:t.NOTE_SUSTAIN}))})},14:function(e){let t=e.channel;this.#D[t]=e.data[1]*128+e.data[0]-8192,this.dispatchEvent("pitch",{part:t,pitch:this.getPitchShift(t)})},15:function(e){ct(e.data).forEach(t=>{let n=t[0],l=t[1];(this.#re[n]||function(){console.debug(`Unknown manufacturer ${n}.`)})(l,t.subarray(2),e.track)})},248:function(e){},250:function(e){},251:function(e){},252:function(e){},254:function(e){},255:function(e){(this.#R[e.meta]||function(n,l,u){}).call(this,e.data,e.track,e.meta),e.meta!=32&&(this.#X=0);let t=it.indexOf(e.meta)>-1;if(k()&&console.debug(e),t)return e.reply="meta",e}};#re={64:(e,t,n)=>{this.#Z.run(t,n,e)},65:(e,t,n)=>{if(t[0]<16)if(t[1]==72){let l=t[t.length-1],u=ae(t.subarray(3,t.length-1));l==u?this.#L.run(t.subarray(0,t.length-1),n,e):console.warn(`Bad SD checksum ${l}. Should be ${u}.`)}else this.#L.run(t,n,e);else{let l=t[t.length-1],u=ae(t.subarray(2,t.length-1));l==u?this.#L.run(t.subarray(0,t.length-1),n,e):console.warn(`Bad GS checksum ${l}. Should be ${u}.`)}},66:(e,t,n)=>{this.#V.run(t,n,e)},67:(e,t,n)=>{this.#A.run(t,n,e)},68:(e,t,n)=>{this.#ee.run(t,n,e)},71:(e,t,n)=>{this.#J.run(t,n,e)},126:(e,t,n)=>{this.#Y.run(t,n,e)},127:(e,t,n)=>{this.switchMode("gm"),this.#j.run(t,n,e)}};#Y;#j;#A;#L;#V;#Z;#J;#ee;buildRchTree(){let e=[];this.#u.forEach((t,n)=>{t0&&!l&&(this.#e[e*m.cc+g[0]]=I[n])}setChActive(e,t=0){this.#w[e]!=t&&this.dispatchEvent("channeltoggle",{part:e,active:t}),this.#w[e]=t}getPitch(){return this.#D}getProgram(){return this.#n}getTexts(){return this.#P.slice()}getVel(e){let t=new Map,n=this;return n.#b.forEach(function(l,u){let p=Math.floor(l/128),h=l%128;e==p&&n.#l[l]>0&&t.set(h,{v:n.#l[l],s:n.#v[u]})}),t}getBitmap(){return{bitmap:this.#m,expire:this.#E}}getLetter(){return{text:this.#_,set:this.#q,expire:this.#N}}getMode(){return A[this.#t]}getMaster(){return{volume:this.#f}}getRawStrength(){let e=this;return this.#b.forEach(function(t){let n=Math.floor(t/128);e.#l[t]>e.#C[n]&&(e.#C[n]=e.#l[t])}),this.#C}getStrength(){let e=[],t=this;return this.getRawStrength().forEach(function(n,l){e[l]=Math.floor(n*t.#e[l*m.cc+g[7]]*t.#e[l*m.cc+g[11]]*t.#f/803288)}),e}getRpn(){return this.#r}getNrpn(){return this.#I}getVoice(e,t,n,l){let u=e||this.#O,p=t,h=n||this.#M;A[this.#t]=="ns5r"&&u>0&&u<56&&(h=3);let a=this.userBank.get(u,p,h,l);if(A[this.#t]=="mt32"&&a.name.indexOf("MT-m:")==0){let i=parseInt(a.name.slice(5)),d=i*m.cmt,s="";this.#S.subarray(d,d+10).forEach(r=>{r>31&&(s+=String.fromCharCode(r))}),this.userBank.load(`MSB LSB PRG -0 127 ${p} ${s}`,!0),a.name=s,a.ending=" "}return(a.ending!=" "||!a.name.length)&&(a=this.baseBank.get(u,p,h,l)),a}getChVoice(e){let t=this.getVoice(this.#e[e*m.cc+g[0]],this.#n[e],this.#e[e*m.cc+g[32]],A[this.#t]);if(this.#a[e])switch(this.#t){case w.mt32:t.ending="~",t.name="",this.#c.subarray(14*(e-1),14*(e-1)+10).forEach(n=>{n>31&&(t.name+=String.fromCharCode(n))})}return t}getPitchShift(e){let t=this,n=e*m.rpn,l=t.#r[n];return t.#i[e*m.rpnt]||t.#t==w.mt32&&(l=12),t.#D[e]/8192*l+(t.#r[n+3]-64)+((t.#r[n+1]<<7)+t.#r[n+2]-8192)/8192}getEffectType(e=0){let t=3*e+1;return this.#T.subarray(t,t+2)}setEffectTypeRaw(e=0,t,n){let l=3*e;this.#T[l]=1,this.#T[l+1+ +t]=n}setEffectType(e=0,t,n){this.setEffectTypeRaw(e,!1,t),this.setEffectTypeRaw(e,!0,n)}getEffectSink(){return this.#G}setLetterDisplay(e,t,n=0,l=3200){let u=this,p;u.#_=" ".repeat(n),e.forEach(h=>{u.#_+=String.fromCharCode(h>31?h:32),h<32&&(p=p||new Set,p.add(h))}),u.#q=Date.now(),u.#N=Date.now()+l,p&&(p=Array.from(p),p.forEach((h,a,i)=>{i[a]=h.toString(16).padStart(2,"0")}),console.warn(`${t}${t?" ":""}invalid code point${p.length>1?"s":""}: 0x${p.join(", 0x")}`))}allocateAce(e){if(!e||e>95){console.warn(`cc${e} cannot be allocated as an active custom effect.`);return}let t=!0,n=0;for(;t&&n=m.ace&&console.warn("ACE slots are full.")}getAce(){return this.#d}getChAce(e,t){if(t<0||t>=m.ace)throw new RangeError("No such ACE slot");let n=this.#d[t];if(n){if(F.indexOf(n)>=0)return this.#e[e*m.cc+g[n]];throw new Error(`Invalid ACE source: ${n}`)}else return 0}initDrums(){let e=this;e.#x.fill(64);for(let t=0;t-1){if(n.#t==0||t){let u=n.#t;n.initOnReset&&t&&(this.init(1),u=w["?"]),n.#t=l,n.#h=0,n.#O=Se[0][l],n.#M=Se[1][l];for(let h=0;h0&&n.#e[h*m.cc+g[0]]==I[u]&&(n.#e[h*m.cc]=I[l]);switch(l){case w.mt32:{te.forEach((h,a)=>{let i=a+1;n.#w[i]||(n.#n[i]=h,n.#e[i*m.cc+g[91]]=127)});for(let h=1;h<10;h++)n.dispatchEvent("voice",{part:h});break}}let p;switch(l){case w["?"]:case w.xg:{p=[1,0,65,0,5,0,0,0];break}case w.gm:case w.gs:case w.g2:case w.sd:{p=[40,4,40,18,40,32,32,0];break}case w["05rw"]:case w.x5d:case w.ns5r:{p=[44,1,44,19,44,0,44,0];break}case w.k11:case w.sg:{p=[24,0,0,0,0,0,0,0];break}case w.mt32:{p=[40,4,0,0,0,0,0,0];break}default:p=[0,0,0,0,0,0,0,0]}for(let h=0;h<4;h++)n.#T[3*h]||(n.#T[3*h+1]=p[2*h],n.#T[3*h+2]=p[2*h+1],n.dispatchEvent(`efx${["reverb","chorus","delay","insert"][h]}`,n.getEffectType(h)));n.dispatchEvent("mode",e),n.forceVoiceRefresh()}}else throw new Error(`Unknown mode ${e}`)}newStrength(){this.#C.fill(0)}runJson(e){if(e.type>14)return e.type==15&&e.data.constructor!=Uint8Array&&(e.data=Uint8Array.from(e.data)),this.#ae[e.type].call(this,e);{let t=this.chRedir(e.part,e.track),n=!1;this.#te[t]?.forEach(l=>{e.channel=l,n=!0,this.#ae[e.type].call(this,e)}),n||console.warn(`${Te[e.type]?Te[e.type]:e.type}${[11,12].includes(e.type)?(e.data[0]!=null?e.data[0]:e.data).toString():""} event sent to CH${t+1} without any recipient.`)}this.#P.length>100&&this.#P.splice(100,this.#P.length-99)}runRaw(e){}async loadBank(e,t){let n=this;switch(e=e.toLowerCase(),e){case"s7e":{n.userBank.clearRange({msb:63,lsb:[21,22]}),n.userBank.clearRange({msb:63,lsb:[24,27]});break}default:throw new Error(`Unknown bank format ${e}`)}switch(e){case"s7e":{z.context=this,n.userBank.load(await z.read(e,t));break}}n.forceVoiceRefresh()}constructor(){super();let e=this;this.#m=new Uint8Array(256),this.#o[10]=new Uint8Array(512),this.#Q=new D,this.userBank.strictMode=!0,this.userBank.load(`MSB PRG LSB NME +`).forEach(e=>{let t=e.split(",");Z[t[0]]=t[1]});var ve=function(e){let t=e;e[0]=="*"&&(t=t.slice(1)),["aa","ii","uu","ee","oo"].forEach(o=>{for(;t.indexOf(o)>-1;)t=t.replace(o,o[0])});for(let o in Z)t=t.replaceAll(o,Z[o]);t.indexOf("ん")==0&&t.length>1&&(t=t.slice(1));let c=t.indexOf("!");return c>-1&&t.length>1&&(t=t.slice(c+1)),t},Ee=function(e){return e?e<96?`cc${e}`:["aftertouch","velocity","pitch bend"][e-96]:"off"};var J=["room 1","room 2","room 3","hall 1","hall 2","plate","delay","panning delay"],we=["chorus 1","chorus 2","chorus 3","chorus 4","feedback","flanger","short delay","short delay feedback"],$e=["delay 1","delay 2","delay 3","delay 4","pan delay 1","pan delay 2","pan delay 3","pan delay 4","delay to reverb","pan repeat"];var at={0:"thru",256:"stereo EQ",257:"spectrum",258:"enhancer",259:"humanizer",272:"overdrive",273:"distortion",288:"phaser",289:"auto wah",290:"rotary",291:"stereo flanger",292:"step flanger",293:"tremelo",294:"auto pan",304:"compressor",305:"limiter",320:"hexa chorus",321:"tremelo chorus",322:"stereo chorus",323:"space D",324:"3D chorus",336:"stereo delay",337:"modulated delay",338:"3-tap delay",339:"4-tap delay",340:"tremelo control delay",341:"reverb",342:"gate reverb",343:"3D delay",352:"2-pitch shifter",353:"feedback pitch shifter",368:"3D auto",369:"3D manual",370:"Lo-Fi 1",371:"Lo-Fi 2",512:"overdrive - chorus",513:"overdrive - flanger",514:"overdrive - delay",515:"distortion - chorus",516:"distortion - flanger",517:"distortion - delay",518:"enhancer - chorus",519:"enhancer - flanger",520:"enhancer - delay",521:"chorus - delay",522:"flanger - delay",523:"chorus - flanger",524:"rotary multi",1024:"guitar multi 1",1025:"guitar multi 2",1026:"guitar multi 3",1027:"clean guitar multi 1",1028:"clean guitar multi 2",1029:"bass multi",1030:"rhodes multi",1280:"keyboard multi",4352:"chorus / delay",4353:"flanger / delay",4354:"chorus / flanger",4355:"overdrive / distortion",4356:"overdrive / rotary",4357:"overdrive / phaser",4358:"overdrive / auto wah",4359:"phaser / rotary",4360:"phaser / auto wah"},rt={66307:["drive"],66309:["vowel",e=>"aiueo"[e]],94723:["pre-filter"],94724:["Lo-Fi type"],94725:["post-filter"],94979:["Lo-Fi type"],94980:["fill type",e=>["off","LPF","HPF"][e]],94984:["noise type",e=>["white","pink"][e]],94987:["disc type",e=>["LP","SP","EP","RND"]],94990:["hum type",e=>`${e+5}0Hz`],94993:["M/S",e=>["mono","stereo"][e]]},ee=function(e){return at[(e[0]-32<<8)+e[1]]||`0x${e[0].toString(16).padStart(2,"0")}${e[1].toString(16).padStart(2,"0")}`},ke=function(e,t,c){let o=(e[0]-32<<16)+(e[1]<<8)+t,h=rt[o]||{},u=h[0];if(u?.length)return u+=`: ${(h[1]||function(){})(c)||c}`,u},te=[68,48,95,78,41,3,110,122,0];var C=function(e=64){return Math.round(2e3*Math.log10(e/64))/100},xe=function(e,t,c){let o=[],h=c==!1?t.readIntVLV():c;e==0||e==127;for(let u=0;u127)return console.debug(`Early termination: ${o}`),o.pop(),t.backOne(),t.backOne(),new Uint8Array(o)}}}return new Uint8Array(o)},ae=function(e){let t=0;return e.forEach(c=>{t+=c,t=t&127}),~t+1&127},O=function(e,t){let c=0,o=0;for(let h=0;h>u&1)<<7,r=e[h];r+=m,h%8!=0?(t(r,c,e),c++):o=e[h]}},_=function(e){let t=Math.floor(e*14.2);return t<128?t:0};var A=["?","gm","gs","xg","g2","mt32","ns5r","x5d","05rw","sd","k11","sg","krs","s90es","motif"],it=["melodic","drum","menu"],Se=[[0,0,0,0,121,0,0,82,81,97,0,0,63,63,63],[0,0,4,0,0,127,0,0,0,0,0,0,0,0,0]],U=[120,127,120,127,120,127,61,62,62,105,122,122,120,127,127],st=[0,3,81,84,88],Te={8:"Off",9:"On",10:"Note aftertouch",11:"cc",12:"pc",13:"Channel aftertouch",14:"Pitch"},Ce={0:0,1:1,2:3,5:4},Me={0:0,1:1,2:2,5:3},Re=[[0,24],[0,127],[0,127],[40,88],[0,127],[0,127]],De=[36,37,48,49,52,53],q=[20,21,22,23,24,25,26,28,29,30,31,36,37,48,49,52,53,64,65],Oe={26:127,29:0,30:0,31:0,52:12,53:54},F=[0,1,2,4,5,6,7,8,10,11,32,38,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,84,91,92,93,94,95,98,99,100,101,128,12,13,16,17,18,19,14,15,20,21,26,28],nt=[12,13,14,15,16,17,18,19,20,21],ct=[33,99,100,32,102,8,9,10],Pe=[0,16,25,40,32,64,26,48],w={};A.forEach((e,t)=>{w[e]=t});var b={length:F.length};F.forEach((e,t)=>{b[e]=t});var R={length:q.length};q.forEach((e,t)=>{R[e]=t});var lt={};it.forEach((e,t)=>{lt[e]=t});var x=function(){return!!self.Bun||self.debugMode||!1},ot=function(e){let t=[],c=0;return e?.forEach(function(o,h){o==247?t.push(e.subarray(c,h)):o==240&&(c=h+1)}),t.length||t.push(e.subarray(0)),x()&&console.debug(t),t};var y={ch:128,cc:F.length,nn:128,pl:512,tr:256,cmt:14,rpn:6,rpnt:4,ace:8,drm:8,dpn:q.length,dnc:128,efx:7},Ae=class extends K{NOTE_IDLE=0;NOTE_ATTACK=1;NOTE_DECAY=2;NOTE_SUSTAIN=3;NOTE_HELD=4;NOTE_RELEASE=5;NOTE_SOSTENUTO_ATTACK=8;NOTE_SOSTENUTO_DECAY=9;NOTE_SOSTENUTO_SUSTAIN=10;NOTE_SOSTENUTO_HELD=11;CH_MELODIC=0;CH_DRUMS=1;CH_DRUM1=2;CH_DRUM2=3;CH_DRUM3=4;CH_DRUM4=5;CH_DRUM5=6;CH_DRUM6=7;CH_DRUM7=8;CH_DRUM8=9;#t=0;#h=0;#E=0;#o=new Array(11);get#m(){return this.#o[this.#h]}set#m(e){this.#o[this.#h]=e}#w=new Uint8Array(y.ch);#u=new Uint8Array(y.ch);#s=new Uint8Array(y.ch);#e=new Uint8Array(y.ch*y.cc);#d=new Uint8Array(y.ace);#n=new Uint8Array(y.ch);#l=new Uint8Array(y.ch*y.nn);#p=new Uint8Array(y.ch);#b=new Uint16Array(y.pl);#v=new Uint8Array(y.pl);#D=new Int16Array(y.ch);#C=new Uint8Array(y.ch);#H=0;#r=new Uint8Array(y.ch*y.rpn);#i=new Uint8Array(y.ch*y.rpnt);#I=new Int8Array(y.ch*De.length);#x=new Uint8Array(y.drm*y.dpn*y.dnc);#a=new Uint8Array(y.ch);#$=new Uint8Array(128);#c=new Uint8Array(y.cmt*8);#y=new Uint8Array(1024);#S=new Uint8Array(y.cmt*64);#T=new Uint8Array(y.efx*3);#G=new Uint8Array(y.ch);#O=0;#M=0;#f=100;#X=0;#z=500;#U=0;#_="";#N=0;#q=0;#F=0;#B=!0;#g=!1;#te;#ie=new Uint8Array(2);#P=[];#V=new Uint8Array(y.ch);#W=new Uint8Array(y.tr);baseBank=new j("gm","gm2","xg","gs","ns5r","sd","gmega","plg-150vl","plg-150pf","plg-150dx","plg-150an","plg-150dr","plg-100sg","kross","s90es");userBank=new j("gm");initOnReset=!1;aiEfxName="";chRedir(e,t,c){if(this.#W[t])return(this.#W[t]-1)*16+e;if([2,3].indexOf(this.#M)>-1){if(c==1)return e;let o=0,h=!0;for(;h;)this.#V[e+o]==0?(this.#V[e+o]=t,console.debug(`Assign track ${t} to channel ${e+o+1}.`),h=!1):this.#V[e+o]==t?h=!1:(o+=16,o>=128&&(o=0,h=!1));return e+o}else return e}forceVoiceRefresh(){for(let e=0;e{let c=e*128+t,o=this.#b.lastIndexOf(c);o>-1&&(this.#e[y.cc*e+b[64]]>63?(this.#v[o]=this.NOTE_HELD,this.dispatchEvent("note",{part:e,note:t,velo:this.#l[c],state:this.NOTE_HELD})):this.#e[y.cc*e+b[66]]>63&&this.#v[o]==this.NOTE_SOSTENUTO_SUSTAIN?(this.#v[o]=this.NOTE_SOSTENUTO_HELD,this.dispatchEvent("note",{part:e,note:t,velo:this.#l[c],state:this.NOTE_SOSTENUTO_HELD})):(this.#b[o]=0,this.#l[c]=0,this.#v[o]=this.NOTE_IDLE,this.dispatchEvent("note",{part:e,note:t,velo:0,state:this.NOTE_IDLE})))},nOn:(e,t,c)=>{let o=e*128+t,h=0;for(this.#p[e]&&this.#k.ano(e);this.#v[h]>0&&this.#b[h]!=o;)h++;h{},cAt:(e,t)=>{},hoOf:e=>{this.#v.forEach((t,c)=>{if(t==this.NOTE_HELD){let o=this.#b[c],h=o>>7;e==h&&(this.#v[c]=this.NOTE_IDLE,this.#b[c]=0,this.#l[o]=0,this.dispatchEvent("note",{part:e,note:o&127,velo:0,state:this.NOTE_IDLE}))}})},soOn:e=>{this.#v.forEach((t,c)=>{let o;switch(t){case this.NOTE_ATTACK:{o=this.NOTE_SOSTENUTO_ATTACK;break}case this.NOTE_DECAY:{o=this.NOTE_SOSTENUTO_DECAY;break}case this.NOTE_SUSTAIN:{o=this.NOTE_SOSTENUTO_SUSTAIN;break}}if(o){this.#v[c]=o;let h=this.#b[c];this.dispatchEvent("note",{part:e,note:h&127,velo:this.#l[h],state:o})}})},soOf:e=>{this.#v.forEach((t,c)=>{if(t==this.NOTE_SOSTENUTO_HELD){let o=this.#b[c],h=o>>7;e==h&&(this.#v[c]=this.NOTE_IDLE,this.#b[c]=0,this.#l[o]=0,this.dispatchEvent("note",{part:e,note:o&127,velo:0,state:this.NOTE_IDLE}))}})},ano:e=>{this.#b.forEach((t,c,o)=>{let h=t>>7,u=t&127;t==0&&this.#l[0]==0||h==e&&this.#k.nOff(h,u)})}};#ae={8:function(e){let t=e.channel,c=e.data[0];this.#k.nOff(t,c)},9:function(e){let t=e.channel;this.setChActive(t,1);let c=e.data[0],o=e.data[1];o>0?this.#k.nOn(t,c,o):this.#k.nOff(t,c)},10:function(e){let t=e.channel,c=t*128+e.data[0];this.#b.indexOf(c)>-1&&(this.#l[c]=data[1],this.dispatchEvent("note",{part:t,note:e.data[0],velo:e.data[1],state:this.NOTE_SUSTAIN}))},11:function(e){let t=e.channel;[0,32].indexOf(e.data[0])>-1&&(()=>{switch(this.#t){case w.s90es:case w.motif:{if(e.data[0]==0){[0,63].indexOf(e.data[1])>-1&&this.setChActive(t,1);break}e.data[1]&&this.setChActive(t,1);break}default:{this.setChActive(t,1);break}}})();let c=t*y.cc;switch(e.data[0]){case 96:return;case 97:return;case 120:return;case 121:{this.#k.ano(t),this.#D[t]=0;let o=t*y.cc;this.#e[o+b[1]]=0,this.#e[o+b[5]]=0,this.#e[o+b[64]]=0,this.#e[o+b[65]]=0,this.#e[o+b[66]]=0,this.#e[o+b[67]]=0,this.#e[o+b[11]]=127,this.#e[o+b[101]]=127,this.#e[o+b[100]]=127,this.#e[o+b[99]]=127,this.#e[o+b[98]]=127;return}case 123:{this.#k.ano(t);return}case 124:{this.#k.ano(t);return}case 125:{this.#k.ano(t);return}case 126:{this.#p[t]=1,this.#k.ano(t);return}case 127:{this.#p[t]=0,this.#k.ano(t);return}}if(b[e.data[0]]==null)console.warn(`cc${e.data[0]} is not accepted.`);else{switch(nt.indexOf(e.data[0])>-1&&this.allocateAce(e.data[0]),e.data[0]){case 0:{switch(x()&&console.debug(`${A[this.#t]}, CH${t+1}: ${e.data[1]}`),this.#t==0?e.data[1]<48?(this.#s[t]>0&&(e.data[1]=this.#e[c],e.data[1]=120,console.debug(`Forced channel ${t+1} to stay drums.`)),e.data[1]>0&&(console.debug(`Roland GS detected with MSB: ${e.data[1]}`),this.switchMode("gs"))):e.data[1]==62?this.switchMode("x5d"):e.data[1]==63?this.switchMode("krs"):(e.data[1]==64||e.data[1]==127)&&this.switchMode("xg"):this.#t==w.gs?e.data[1]<56&&this.#s[t]>0&&(e.data[1]=this.#e[c],e.data[1]=120,console.debug(`Forced channel ${t+1} to stay drums.`)):this.#t==w.gm?e.data[1]<48?this.#s[t]>0&&(e.data[1]=120,this.switchMode("gs",!0),console.debug(`Forced channel ${t+1} to stay drums.`)):(e.data[1]==64||e.data[1]==127)&&this.switchMode("xg",!0):this.#t==w.x5d&&e.data[1]>0&&e.data[1]<8&&this.switchMode("05rw",!0),this.#t){case w.xg:{[79,95,126,127].indexOf(e.data[1])>-1?this.#s[t]==0&&(this.setChType(t,this.CH_DRUM2),console.debug(`CH${t+1} set to drums by MSB.`)):this.#s[t]>0&&(this.setChType(t,this.CH_MELODIC),console.debug(`CH${t+1} set to melodic by MSB.`));break}case w["05rw"]:case w.x5d:case w.ns5r:{[61,62,126,127].indexOf(e.data[1])>-1?this.#s[t]==this.CH_MELODIC&&(this.setChType(t,this.CH_DRUM2),console.debug(`CH${t+1} set to drums by MSB.`)):[80,81,82,83].indexOf(e.data[1])>-1||this.#s[t]!=this.CH_MELODIC&&(this.setChType(t,this.CH_MELODIC),console.debug(`CH${t+1} set to melodic by MSB.`));break}case w.sd:{[104,105,106,107].indexOf(e.data[1])>-1?this.#s[t]==0&&(this.setChType(t,this.CH_DRUM2),console.debug(`CH${t+1} set to drums by MSB.`)):this.#s[t]>0&&(this.setChType(t,this.CH_MELODIC),console.debug(`CH${t+1} set to melodic by MSB.`));break}case w.g2:{e.data[1]==120?this.#s[t]==0&&(this.setChType(t,this.CH_DRUMS),console.debug(`CH${t+1} set to drums by MSB.`)):this.#s[t]>0&&(this.setChType(t,this.CH_MELODIC),console.debug(`CH${t+1} set to melodic by MSB.`));break}}this.dispatchEvent("voice",{part:t});break}case 6:{if(this.#H){[w.xg,w.gs,w.ns5r].indexOf(this.#t)<0&&console.warn(`NRPN commits are not available under "${A[this.#t]}" mode, even when they are supported in Octavia.`);let o=this.#e[c+b[99]],h=this.#e[c+b[98]];if(o==1){let u=ct.indexOf(h);if(u>-1)this.#e[c+b[71+u]]=e.data[1],x()&&console.debug(`Redirected NRPN 1 ${h} to cc${71+u}.`),this.dispatchEvent("cc",{part:t,cc:71+u,data:e.data[1]});else{let m=De.indexOf(h);m>-1?this.#I[t*10+m]=e.data[1]-64:console.warn(`NRPN 0x01${h.toString(16).padStart(2,"0")} is not supported.`),x()&&console.debug(`CH${t+1} voice NRPN ${h} commit`)}}else{if(q.indexOf(o)<0){let m=`NRPN 0x${o.toString(16).padStart(2,"0")}${h.toString(16).padStart(2,"0")} `;o==127?console.warn(`${m}is not necessary. Consider removing it.`):console.warn(`${m}is not supported.`)}else{let m=this.#s[t]-2;m<0?console.warn(`CH${t+1} cannot accept drum NRPN as type ${X[this.#s[t]]}.`):this.#x[(m*y.dpn+R[o])*y.dnc+h]=e.data[1]}x()&&console.debug(`CH${t+1} (${X[this.#s[t]]}) drum NRPN ${o} commit`)}}else{let o=Ce[this.#e[c+b[100]]],h=Me[this.#e[c+b[100]]];this.#e[c+b[101]]==0&&o!=null&&(x()&&console.debug(`CH${t+1} RPN 0 ${this.#e[c+b[100]]} commit: ${e.data[1]}`),e.data[1]=Math.min(Math.max(e.data[1],Re[o][0]),Re[o][1]),this.#r[t*y.rpn+o]=e.data[1],this.#i[t*y.rpnt+h]=1)}break}case 32:{switch(x()&&console.debug(`${A[this.#t]}, CH${t+1} LSB: ${e.data[1]}`),this.#t){case w.s90es:case w.motif:{this.setChType(t,[32,40].indexOf(e.data[1])>-1?this.CH_DRUMS:this.CH_MELODIC,this.#t,!0);break}}this.dispatchEvent("voice",{part:t});break}case 38:{if(!this.#H){let o=Ce[this.#e[c+100]],h=Me[this.#e[c+100]];this.#e[c+101]==0&&o!=null&&(this.#r[t*y.rpn+o+1]=e.data[1],this.#i[t*y.rpnt+h]=1)}break}case 64:{e.data[1]<64&&this.#k.hoOf(t);break}case 66:{e.data[1]>>6?this.#k.soOn(t):this.#k.soOf(t);break}case 98:case 99:{this.#H=1;break}case 100:case 101:{this.#H=0;break}}this.#e[c+b[e.data[0]]]=e.data[1],this.dispatchEvent("cc",{part:t,cc:e.data[0],data:e.data[1]})}},12:function(e){let t=e.channel;switch(this.#t){case w.s90es:case w.motif:{e.data&&this.setChActive(t,1);break}default:this.setChActive(t,1)}this.#n[t]=e.data,this.#a[t]=0,x()&&console.debug(`T:${e.track} C:${t} P:${e.data}`),this.dispatchEvent("voice",{part:t})},13:function(e){let t=this,c=e.channel;this.#b.forEach(function(o){let h=o>>7;c==h&&(t.#l[o]=e.data,t.dispatchEvent("note",{part:c,note:o&127,velo:e.data,state:t.NOTE_SUSTAIN}))})},14:function(e){let t=e.channel;this.#D[t]=e.data[1]*128+e.data[0]-8192,this.dispatchEvent("pitch",{part:t,pitch:this.getPitchShift(t)})},15:function(e){ot(e.data).forEach(t=>{let c=t[0],o=t[1];(this.#re[c]||function(){console.debug(`Unknown manufacturer ${c}.`)})(o,t.subarray(2),e.track)})},248:function(e){},250:function(e){},251:function(e){},252:function(e){},254:function(e){},255:function(e){(this.#R[e.meta]||function(c,o,h){}).call(this,e.data,e.track,e.meta),e.meta!=32&&(this.#X=0);let t=st.indexOf(e.meta)>-1;if(x()&&console.debug(e),t)return e.reply="meta",e}};#re={64:(e,t,c)=>{this.#Z.run(t,c,e)},65:(e,t,c)=>{if(t[0]<16)if(t[1]==72){let o=t[t.length-1],h=ae(t.subarray(3,t.length-1));o==h?this.#L.run(t.subarray(0,t.length-1),c,e):console.warn(`Bad SD checksum ${o}. Should be ${h}.`)}else this.#L.run(t,c,e);else{let o=t[t.length-1],h=ae(t.subarray(2,t.length-1));o==h?this.#L.run(t.subarray(0,t.length-1),c,e):console.warn(`Bad GS checksum ${o}. Should be ${h}.`)}},66:(e,t,c)=>{this.#K.run(t,c,e)},67:(e,t,c)=>{this.#A.run(t,c,e)},68:(e,t,c)=>{this.#ee.run(t,c,e)},71:(e,t,c)=>{this.#J.run(t,c,e)},126:(e,t,c)=>{this.#Y.run(t,c,e)},127:(e,t,c)=>{this.switchMode("gm"),this.#j.run(t,c,e)}};#Y;#j;#A;#L;#K;#Z;#J;#ee;buildRchTree(){let e=[];this.#u.forEach((t,c)=>{t0&&!o&&(this.#e[e*y.cc+b[0]]=U[c])}setChActive(e,t=0){this.#w[e]!=t&&this.dispatchEvent("channeltoggle",{part:e,active:t}),this.#w[e]=t}getPitch(){return this.#D}getProgram(){return this.#n}getTexts(){return this.#P.slice()}getVel(e){let t=new Map,c=this;return c.#b.forEach(function(o,h){let u=Math.floor(o/128),m=o%128;e==u&&c.#l[o]>0&&t.set(m,{v:c.#l[o],s:c.#v[h]})}),t}getBitmap(){return{bitmap:this.#m,expire:this.#E}}getLetter(){return{text:this.#_,set:this.#q,expire:this.#N}}getMode(){return A[this.#t]}getMaster(){return{volume:this.#f}}getRawStrength(){let e=this;return this.#b.forEach(function(t){let c=Math.floor(t/128);e.#l[t]>e.#C[c]&&(e.#C[c]=e.#l[t])}),this.#C}getStrength(){let e=[],t=this;return this.getRawStrength().forEach(function(c,o){e[o]=Math.floor(c*t.#e[o*y.cc+b[7]]*t.#e[o*y.cc+b[11]]*t.#f/803288)}),e}getRpn(){return this.#r}getNrpn(){return this.#I}getVoice(e,t,c,o){let h=e||this.#O,u=t,m=c||this.#M;A[this.#t]=="ns5r"&&h>0&&h<56&&(m=3);let r=this.userBank.get(h,u,m,o);if(A[this.#t]=="mt32"&&r.name.indexOf("MT-m:")==0){let i=parseInt(r.name.slice(5)),n=i*y.cmt,s="";this.#S.subarray(n,n+10).forEach(l=>{l>31&&(s+=String.fromCharCode(l))});let a=`MSB LSB PRG NME +0 127 ${u} ${s}`;this.userBank.load(a,!0),r.name=s,r.ending=" "}return(r.ending!=" "||!r.name.length)&&(r=this.baseBank.get(h,u,m,o)),r}getChVoice(e){let t=this.getVoice(this.#e[e*y.cc+b[0]],this.#n[e],this.#e[e*y.cc+b[32]],A[this.#t]);if(this.#a[e])switch(this.#t){case w.mt32:t.ending="~",t.name="",this.#c.subarray(14*(e-1),14*(e-1)+10).forEach(c=>{c>31&&(t.name+=String.fromCharCode(c))})}return t}getPitchShift(e){let t=this,c=e*y.rpn,o=t.#r[c];return t.#i[e*y.rpnt]||t.#t==w.mt32&&(o=12),t.#D[e]/8192*o+(t.#r[c+3]-64)+((t.#r[c+1]<<7)+t.#r[c+2]-8192)/8192}getEffectType(e=0){let t=3*e+1;return this.#T.subarray(t,t+2)}setEffectTypeRaw(e=0,t,c){let o=3*e;this.#T[o]=1,this.#T[o+1+ +t]=c}setEffectType(e=0,t,c){this.setEffectTypeRaw(e,!1,t),this.setEffectTypeRaw(e,!0,c)}getEffectSink(){return this.#G}setLetterDisplay(e,t,c=0,o=3200){let h=this,u;h.#_=" ".repeat(c),e.forEach(m=>{h.#_+=String.fromCharCode(m>31?m:32),m<32&&(u=u||new Set,u.add(m))}),h.#q=Date.now(),h.#N=Date.now()+o,u&&(u=Array.from(u),u.forEach((m,r,i)=>{i[r]=m.toString(16).padStart(2,"0")}),console.warn(`${t}${t?" ":""}invalid code point${u.length>1?"s":""}: 0x${u.join(", 0x")}`))}allocateAce(e){if(!e||e>95){console.warn(`cc${e} cannot be allocated as an active custom effect.`);return}let t=!0,c=0;for(;t&&c=y.ace&&console.warn("ACE slots are full.")}getAce(){return this.#d}getChAce(e,t){if(t<0||t>=y.ace)throw new RangeError("No such ACE slot");let c=this.#d[t];if(c){if(F.indexOf(c)>=0)return this.#e[e*y.cc+b[c]];throw new Error(`Invalid ACE source: ${c}`)}else return 0}initDrums(){let e=this;e.#x.fill(64);for(let t=0;t-1){if(c.#t==0||t){let h=c.#t;c.initOnReset&&t&&(this.init(1),h=w["?"]),c.#t=o,c.#h=0,c.#O=Se[0][o],c.#M=Se[1][o];for(let m=0;m0&&c.#e[m*y.cc+b[0]]==U[h]&&(c.#e[m*y.cc]=U[o]);switch(o){case w.mt32:{te.forEach((m,r)=>{let i=r+1;c.#w[i]||(c.#n[i]=m,c.#e[i*y.cc+b[91]]=127)});for(let m=1;m<10;m++)c.dispatchEvent("voice",{part:m});break}}let u;switch(o){case w["?"]:case w.xg:{u=[1,0,65,0,5,0,0,0];break}case w.gm:case w.gs:case w.g2:case w.sd:{u=[40,4,40,18,40,32,32,0];break}case w["05rw"]:case w.x5d:case w.ns5r:{u=[44,1,44,19,44,0,44,0];break}case w.k11:case w.sg:{u=[24,0,0,0,0,0,0,0];break}case w.mt32:{u=[40,4,0,0,0,0,0,0];break}default:u=[0,0,0,0,0,0,0,0]}for(let m=0;m<4;m++)c.#T[3*m]||(c.#T[3*m+1]=u[2*m],c.#T[3*m+2]=u[2*m+1],c.dispatchEvent(`efx${["reverb","chorus","delay","insert"][m]}`,c.getEffectType(m)));c.dispatchEvent("mode",e),c.forceVoiceRefresh()}}else throw new Error(`Unknown mode ${e}`)}newStrength(){this.#C.fill(0)}runJson(e){if(e.type>14)return e.type==15&&e.data.constructor!=Uint8Array&&(e.data=Uint8Array.from(e.data)),this.#ae[e.type].call(this,e);{let t=this.chRedir(e.part,e.track),c=!1;this.#te[t]?.forEach(o=>{e.channel=o,c=!0,this.#ae[e.type].call(this,e)}),c||console.warn(`${Te[e.type]?Te[e.type]:e.type}${[11,12].includes(e.type)?(e.data[0]!=null?e.data[0]:e.data).toString():""} event sent to CH${t+1} without any recipient.`)}this.#P.length>100&&this.#P.splice(100,this.#P.length-99)}runRaw(e){}async loadBank(e,t){let c=this;switch(e=e.toLowerCase(),e){case"s7e":{c.userBank.clearRange({msb:63,lsb:[21,22]}),c.userBank.clearRange({msb:63,lsb:[24,27]});break}default:throw new Error(`Unknown bank format ${e}`)}switch(e){case"s7e":{z.context=this,c.userBank.load(await z.read(e,t));break}}c.forceVoiceRefresh()}constructor(){super();let e=this;this.#m=new Uint8Array(256),this.#o[10]=new Uint8Array(512),this.#Q=new D,this.userBank.strictMode=!0,this.userBank.load(`MSB PRG LSB NME 062 000 000 122 000 000 122 001 000 @@ -148,21 +148,21 @@ _,`.split(` 122 003 000 122 004 000 122 005 000 -122 006 000 `),this.addEventListener("metacommit",function(a){let{data:i}=a;e.#P[0]?.type==i.type&&e.#P[0]?.amend?(e.#P[0].amend=i.amend,e.#P[0].data+=i.data):e.#P.unshift(i)}),this.#R[1]=function(a){switch(a=a.replaceAll(`\r +122 006 000 `),this.addEventListener("metacommit",function(r){let{data:i}=r;e.#P[0]?.type==i.type&&e.#P[0]?.amend?(e.#P[0].amend=i.amend,e.#P[0].data+=i.data):e.#P.unshift(i)}),this.#R[1]=function(r){switch(r=r.replaceAll(`\r `,` `).replaceAll("\r",` -`),a.slice(0,2)){case"@I":{this.#g=!0,this.dispatchEvent("metacommit",{type:"Kar.Info",data:a.slice(2)?.trimLeft()});break}case"@K":{this.#g=!0,this.dispatchEvent("metacommit",{type:"Kar.Mode",data:a.slice(2)?.trimLeft()}),console.debug(`Karaoke mode active: ${a.slice(2)}`);break}case"@L":{this.#g=!0,this.dispatchEvent("metacommit",{type:"Kar.Lang",data:a.slice(2)?.trimLeft()});break}case"@T":{this.#g=!0,this.dispatchEvent("metacommit",{type:"KarTitle",data:a.slice(2)?.trimLeft()});break}case"@V":{this.#g=!0,this.dispatchEvent("metacommit",{type:"Kar.Ver.",data:a.slice(2)?.trimLeft()});break}case"XF":{let i=a.slice(2).split(":");switch(i[0]){case"hd":{i.slice(1).forEach((d,s)=>{d.length&&this.dispatchEvent("metacommit",{type:["XfSngDte","XfSngRgn","XfSngCat","XfSongBt","XfSngIns","XfSngVoc","XfSngCmp","XfSngLrc","XfSngArr","XfSngPer","XfSngPrg","XfSngTag"][s],data:d})});break}case"ln":{i.slice(1).forEach((d,s)=>{d.length&&this.dispatchEvent("metacommit",{type:["XfKarLng","XfKarNme","XfKarCmp","XfKarLrc","XfKarArr","XfKarPer","XfKarPrg"][s],data:d})});break}default:this.dispatchEvent("metacommit",{type:"XfUnData",data:a})}break}default:this.#g?a[0]=="\\"?(this.dispatchEvent("metacommit",{type:"KarLyric",data:"",amend:!1}),this.dispatchEvent("metacommit",{type:"KarLyric",data:a.slice(1),amend:!0})):a[0]=="/"?(this.dispatchEvent("metacommit",{type:"KarLyric",data:"",mask:!0,amend:!1}),this.dispatchEvent("metacommit",{type:"KarLyric",data:a.slice(1),mask:!0,amend:!0})):this.dispatchEvent("metacommit",{type:"KarLyric",data:a,amend:!0}):a.split(` -`).forEach((i,d)=>{this.dispatchEvent("metacommit",{type:"Cmn.Text",data:i,mask:d!=0})})}},this.#R[2]=function(a){this.dispatchEvent("metacommit",{type:"Copyrite",data:a})},this.#R[3]=function(a,i){i<1&&this.#X<1&&this.dispatchEvent("metacommit",{type:"TrkTitle",data:a})},this.#R[4]=function(a,i){this.dispatchEvent("metacommit",{type:"Instrmnt",data:a})},this.#R[5]=function(a){a.trim()==""?this.dispatchEvent("metacommit",{type:"C.Lyrics",data:"",amend:!1}):this.dispatchEvent("metacommit",{type:"C.Lyrics",data:a,amend:!0})},this.#R[6]=function(a){this.dispatchEvent("metacommit",{type:"C.Marker",data:a})},this.#R[7]=function(a){this.dispatchEvent("metacommit",{type:"CuePoint",data:a})},this.#R[32]=function(a){this.#X=a[0]+1},this.#R[33]=function(a,i){e.#W[i]=a+1},this.#R[81]=function(a,i){e.#z=a/1e3},this.#R[127]=function(a,i){e.#Q.run(a,i)},this.#Q.default=function(a){console.warn(`Unrecognized sequencer-specific byte sequence: ${a}`)},this.#Q.add([67,0,1],function(a,i){e.#W[i]=a[0]+1}),this.#Y=new D("universal non-realtime"),this.#j=new D("universal realtime"),this.#A=new D("Yamaha"),this.#L=new D("Roland"),this.#V=new D("Korg"),this.#Z=new D("Kawai"),this.#J=new D("Akai"),this.#ee=new D("Casio");let t=function(a){console.info(`Unrecognized SysEx in "${this.name}" set. -%o`,a)};this.#Y.default=t,this.#j.default=t,this.#A.default=t,this.#L.default=t,this.#V.default=t,this.#Z.default=t,this.#J.default=t,this.#ee.default=t,this.#Y.add([9],a=>{e.switchMode(["gm","?","g2"][a[0]-1],!0),e.#g=e.#g||!1,console.info(`MIDI reset: ${["GM","Init","GM2"][a[0]-1]}`),a[0]==2&&e.init()}),this.#j.add([4,1],a=>{e.#f=((a[1]<<7)+a[0])/16383*100,e.dispatchEvent("mastervolume",e.#f)}).add([4,3],a=>((a[1]<<7)+a[0]-8192)/8192).add([4,4],a=>a[1]-64),this.#A.add([76,0,0],a=>{switch(a[0]){case 125:{e.initDrums(),console.info(`XG drum setup reset: ${a}`);break}case 126:{e.switchMode("xg",!0),e.#g=!1,console.info("MIDI reset: XG");break}default:{let i=[0,0,0,0],d=(s,r)=>{i[r]=s};if(a.subarray(1).forEach((s,r)=>{let c=r+a[0];([d,d,d,d,f=>{this.#f=f*129/16383*100,e.dispatchEvent("mastervolume",e.#f)},f=>{},f=>{}][c]||(()=>{}))(s,r)}),a[0]<4){let s=0;i.forEach(r=>{s=s<<4,s+=r}),s-=1024}}}}).add([76,2,1],a=>{let i="XG ";a[0]<32?(i+="reverb ",a.subarray(1).forEach((d,s)=>{([r=>{e.setEffectTypeRaw(0,!1,r),console.info(`${i}main type: ${G[r]}`),e.dispatchEvent("efxreverb",e.getEffectType(0))},r=>{e.setEffectTypeRaw(0,!0,r),console.debug(`${i}sub type: ${r+1}`),e.dispatchEvent("efxreverb",e.getEffectType(0))},r=>{console.debug(`${i}time: ${ge(r)}s`)},r=>{console.debug(`${i}diffusion: ${r}`)},r=>{console.debug(`${i}initial delay: ${r}`)},r=>{console.debug(`${i}HPF cutoff: ${N[r]}Hz`)},r=>{console.debug(`${i}LPF cutoff: ${N[r]}Hz`)},r=>{console.debug(`${i}width: ${r}`)},r=>{console.debug(`${i}height: ${r}`)},r=>{console.debug(`${i}depth: ${r}`)},r=>{console.debug(`${i}wall type: ${r}`)},r=>{console.debug(`${i}dry/wet: ${r}`)},r=>{console.debug(`${i}send: ${C(r)}dB`)},r=>{console.debug(`${i}pan: ${r-64}`)},!1,!1,r=>{console.debug(`${i}delay: ${r}`)},r=>{console.debug(`${i}density: ${r}`)},r=>{console.debug(`${i}balance: ${r}`)},r=>{},r=>{console.debug(`${i}feedback: ${r}`)},r=>{}][a[0]+s]||function(){console.warn(`Unknown XG reverb address: ${a[0]}.`)})(d)})):a[0]<64?(i+="chorus ",a.subarray(1).forEach((d,s)=>{([r=>{e.setEffectTypeRaw(1,!1,r),console.info(`${i}main type: ${G[r]}`),e.dispatchEvent("efxchorus",e.getEffectType(1))},r=>{e.setEffectTypeRaw(1,!0,r),console.debug(`${i}sub type: ${r+1}`),e.dispatchEvent("efxchorus",e.getEffectType(1))},r=>{console.debug(`${i}LFO: ${be[r]}Hz`)},r=>{},r=>{console.debug(`${i}feedback: ${r}`)},r=>{console.debug(`${i}delay offset: ${me(r)}ms`)},r=>{},r=>{console.debug(`${i}low: ${N[r]}Hz`)},r=>{console.debug(`${i}low: ${r-64}dB`)},r=>{console.debug(`${i}high: ${N[r]}Hz`)},r=>{console.debug(`${i}high: ${r-64}dB`)},r=>{console.debug(`${i}dry/wet: ${r}`)},r=>{console.debug(`${i}send: ${C(r)}dB`)},r=>{console.debug(`${i}pan: ${r-64}`)},r=>{console.debug(`${i}to reverb: ${C(r)}dB`)},!1,r=>{},r=>{},r=>{},r=>{console.debug(`${i}LFO phase diff: ${(r-64)*3}deg`)},r=>{console.debug(`${i}input mode: ${r?"stereo":"mono"}`)},r=>{}][a[0]-32+s]||function(){console.warn(`Unknown XG chorus address: ${a[0]}.`)})(d)})):a[0]<86?(i+="variation ",a.subarray(1).forEach((d,s)=>{([r=>{e.setEffectTypeRaw(2,!1,r),console.info(`${i}main type: ${G[r]}`),e.dispatchEvent("efxdelay",e.getEffectType(2))},r=>{e.setEffectTypeRaw(2,!0,r),console.debug(`${i}sub type: ${r+1}`),e.dispatchEvent("efxdelay",e.getEffectType(2))}][a[0]-64+s]||function(){})(d)})):a[0]<97?(i+="variation ",a.subarray(1).forEach((d,s)=>{[r=>{console.debug(`${i}send: ${C(r)}dB`)},r=>{console.debug(`${i}pan: ${r-64}`)},r=>{console.debug(`${i}to reverb: ${C(r)}dB`)},r=>{console.debug(`${i}to chorus: ${C(r)}dB`)},r=>{console.debug(`${i}connection: ${r?"system":"insertion"}`)},r=>{console.debug(`${i}channel: CH${r+1}`)},r=>{console.debug(`${i}mod wheel: ${r-64}`)},r=>{console.debug(`${i}bend wheel: ${r-64}`)},r=>{console.debug(`${i}channel after touch: ${r-64}`)},r=>{console.debug(`${i}AC1: ${r-64}`)},r=>{console.debug(`${i}AC2: ${r-64}`)}][a[0]-86+s](d)})):a[0]>111&&a[0]<118?i+="variation ":console.warn(`Unknown XG variation address: ${a[0]}`)}).add([76,2,64],a=>{a.subarray(1).forEach((i,d)=>{let s=d+a[0];if(s==0)console.debug(`XG EQ preset: ${["flat","jazz","pop","rock","classic"][i]}`);else{let r=s-1>>2,c=s-1&3,f=`XG EQ ${r} ${["gain","freq","Q","shape"][c]}: `;[()=>{console.debug(`${f}${i-64}dB`)},()=>{console.debug(`${f}${i} (raw)`)},()=>{console.debug(`${f}${i/10}`)},()=>{console.debug(`${f}${["shelf","peak"][+!!i]}`)}][c]()}})}).add([76,3],a=>{let i=a[0],d=a[1],s=`XG Insertion ${a[0]+1} `;a.subarray(2).forEach((r,c)=>{([f=>{e.setEffectTypeRaw(3+i,!1,f),console.info(`${s}main type: ${G[f]}`),e.dispatchEvent(`efxinsert${i}`,e.getEffectType(3+i))},f=>{e.setEffectTypeRaw(3+i,!0,f),console.debug(`${s}sub type: ${f+1}`),e.dispatchEvent(`efxinsert${i}`,e.getEffectType(3+i))}][d+c]||function(){})(r)})}).add([76,6,0],a=>{let i=a[0];i<64?e.setLetterDisplay(a.subarray(1),"XG letter display",i):e.#N=Date.now()}).add([76,7,0],a=>{let i=a[0];e.#h=0,e.#E=Date.now()+3200,e.#m.fill(0);let d=a.subarray(1);for(let s=0;s>6-y&1,y++})}).add([76,8],(a,i)=>{let d=e.chRedir(a[0],i,!0),s=a[1],r=m.cc*d,c=`XG CH${d+1} `,f=`Unknown XG part address ${s}.`;a.subarray(2).forEach((o,b)=>{s<1?console.debug(f):s<41?([()=>{e.#e[r+g[0]]=o,e.dispatchEvent("voice",{part:d})},()=>{e.#e[r+g[32]]=o,e.dispatchEvent("voice",{part:d})},()=>{e.#n[d]=o,e.dispatchEvent("voice",{part:d})},()=>{let y=e.chRedir(o,i,!0);e.#u[d]=y,d!=y&&(e.buildRchTree(),console.info(`${c}receives from CH${y+1}`))},()=>{e.#p[d]=+!o},()=>{},()=>{e.setChType(d,o,w.xg),console.debug(`${c}type: ${X[o]||o}`)},()=>{e.#r[m.rpn*d+3]=o,e.#i[m.rpnt*d+2]=1},!1,!1,()=>{e.#e[r+g[7]]=o},!1,!1,()=>{e.#e[r+g[10]]=o||128},!1,!1,()=>{e.#e[r+g[128]]=o},()=>{e.#e[r+g[93]]=o},()=>{e.#e[r+g[91]]=o},()=>{e.#e[r+g[94]]=o},()=>{e.#e[r+g[76]]=o},()=>{e.#e[r+g[77]]=o},()=>{e.#e[r+g[78]]=o},()=>{e.#e[r+g[74]]=o},()=>{e.#e[r+g[71]]=o},()=>{e.#e[r+g[73]]=o},()=>{e.#e[r+g[75]]=o},()=>{e.#e[r+g[72]]=o}][s+b-1]||(()=>{}))():s<48?console.debug(f):s<111?s>102&&s<105&&(e.#e[r+g[[5,65][s&1]]]=o):s<114?console.debug(f):s<116?console.debug(`${c}EQ ${["bass","treble"][s&1]} gain: ${o-64}dB`):s<118?console.debug(f):s<120?console.debug(`${c}EQ ${["bass","treble"][s&1]} freq: ${o}`):console.debug(f)})}).add([76,9],(a,i)=>{let d=e.chRedir(a[0],i,!0),s=a[1],r=`PLG-150VL CH${d+1} `;a.subarray(2).forEach((c,f)=>{let o=f+s;switch(o){case 1:{console.info(`${r}breath mode: ${["system","breath","velocity","touch EG"][c]}`);break}case 0:case 27:case 28:break;default:if(o<27){let b=["pressure","embouchure","tonguing","scream","breath noise","growl","throat formant","harmonic enhancer","damping","absorption","amplification","brightness"][o-3>>1];o&1?o<23?(console.debug(`${r}${b} control source: ${Ee(c)}`),c&&c<96&&e.allocateAce(c)):console.debug(`${r}${b} scale break point: ${c}`):console.debug(`${r}${b} depth: ${c-64}`)}}})}).add([76,10],a=>{}).add([76,16],a=>{}).add([76,17,0,0],a=>{}).add([76,112],a=>{console.debug(`XG enable PLG-1${["50VL","00SG","50DX"][a[0]]} for CH${a[2]+1}.`)}).add([73,0,0],(a,i)=>{let d=a[0],s="MU1000 System: ";a.subarray(1).forEach((r,c)=>{let f=d+c;f==8?console.debug(`${s}LCD contrast set to ${r}.`):f==18?(e.#M=r?126:0,console.debug(`${s}bank defaults to ${r?"MU100 Native":"MU Basic"}.`)):f>=64&&f<69&&[()=>{e.dispatchEvent("channelactive",r)},()=>{r<8?(e.dispatchEvent("channelmin",r<<4),console.debug(`Octavia System: Minimum CH${(r<<4)+1}`)):(e.dispatchEvent("channelreset"),console.info("Octavia System: Clear channel ranges"))},()=>{r<8?(e.dispatchEvent("channelmax",(r<<4)+15),console.debug(`Octavia System: Maximum CH${(r<<4)+16}`)):(e.dispatchEvent("channelreset"),console.info("Octavia System: Clear channel ranges"))},()=>{e.dispatchEvent("channelreset"),console.info("Octavia System: Clear channel ranges")},()=>{e.#B=!!r,console.info(`Octavia System: RS receiving ${["dis","en"][r]}abled.`)}][f-64]()})}).add([73,10,0],(a,i)=>{let d=a[0],s=`MU1000 RS${e.#B?"":" (ignored)"}: `;if(d<16)switch(d){case 2:{let r=e.chRedir(0,i,!0);e.#B&&(e.dispatchEvent("channelmin",r),e.dispatchEvent("channelmax",r+63)),console.info(`${s}Show CH1~64`);break}case 3:{let r=e.chRedir(a[1]<<5,i,!0);e.#B&&e.dispatchEvent("channelmin",r),e.#B&&e.dispatchEvent("channelmax",r+31),console.info(`${s}Show CH${r+1}~CH${r+32}`);break}default:console.debug(`${s}unknown switch ${d} invoked.`)}else if(d<32){if(e.#B){let r=e.chRedir(d-16+(e.#F<<4),i,!0);e.dispatchEvent("channelactive",r)}}else if(d<36){let r=e.chRedir(d-32<<4,i,!0);e.#B&&(e.dispatchEvent("channelmin",r),e.dispatchEvent("channelmax",r+15),e.#F=d-32),console.info(`${s}Show CH${r+1}~CH${r+16}`)}}).add([93,3],(a,i)=>{let d=e.chRedir(a[0],i,!0),s=`PLG-100SG CH${d+1} `,r=Date.now();if(a[1]==0){let c="",f=0;a.subarray(2).forEach((o,b)=>{b%2==0?c+=ye[o]||o.toString().padStart("0"):f+=o*13}),r>=e.#U&&this.dispatchEvent("metacommit",{type:"SGLyrics",data:"",amend:!1}),this.dispatchEvent("metacommit",{type:"SGLyrics",data:`${ve(c)}`,amend:!0}),e.#U=r+Math.ceil(f/2)+e.#z,k()&&console.debug(`${s}vocals: ${c}`)}else console.warn(`Unknown PLG-100SG data: ${a}`)});let n=function(a,i,d,s){},l=function(a,i){let d=a*m.dpn,s=i[0],r=i[1];i.subarray(2).forEach((c,f)=>{let o=f+r,b=-1;o<16?([()=>{b=24},()=>{b=25},()=>{b=26},()=>{},()=>{b=28},()=>{b=29},()=>{b=30},()=>{b=31},()=>{},()=>{},()=>{},()=>{b=20},()=>{b=21},()=>{b=22},()=>{b=23},()=>{}][o]||(()=>{console.debug(`Unknown XG-style drum param ${o} on set ${a+1}.`)}))():o<32||(o<40?([()=>{b=48},()=>{b=49},!1,!1,()=>{b=52},()=>{b=53}][o-32]||(()=>{console.debug(`Unknown XG-style drum param ${o} on set ${a+1}.`)}))():o<80||([()=>{b=36}][o-80]||(()=>{console.debug(`Unknown XG-style drum param ${o} on set ${a+1}.`)}))()),b>=0?(k()&&console.debug(d,b,s,c),e.#x[(d+R[b])*m.dnc+s]=c):k()&&console.debug(`XG-style drum param ${o} has no writes.`)})},u=function(a,i,d){let s=a*m.dpn,r=(i<<7)+d[0];d.subarray(1).forEach((c,f)=>{let o=f+r,b=o&127,y=o>>7,E=-1;y>1&&([()=>{E=26},()=>{},()=>{E=28},()=>{E=29},()=>{E=30},()=>{},()=>{},()=>{E=31}][y-2]||(()=>{console.debug(`Unknown GS-style drum param ${y} on set ${a+1}.`)}))(),E>-1?(k()&&console.debug(s,E,b,c),e.#x[(s+R[E])*m.dnc+b]=c):k()&&console.debug(`GS-style drum param ${y} has no writes.`)})};this.#A.add([76,48],(a,i,d)=>{l(0,a)}).add([76,49],(a,i,d)=>{l(1,a)}).add([76,50],(a,i,d)=>{l(2,a)}).add([76,51],(a,i,d)=>{l(3,a)}).add([76,52],(a,i,d)=>{l(4,a)}).add([76,53],(a,i,d)=>{l(5,a)}).add([76,54],(a,i,d)=>{l(6,a)}).add([76,55],(a,i,d)=>{l(7,a)}),this.#A.add([89,0],(a,i,d)=>{if(e.eprom){let s=a[0],r=(a[1]<<14)+(a[2]<<7)+a[3]+(e.eprom.offset||0);k()&&console.debug(`MU1000 EPROM trail to 0x${r.toString(16).padStart(6,"0")}, ${s} bytes.`);let c=e.eprom.data;a.subarray(4).forEach((f,o)=>{let b=o>>3,y=o&7;if(y==7)for(let E=0;E<7;E++)c[r+7*b+E]+=(f>>6-E&1)<<7;else c[r+7*b+y]=f})}}).add([89,1],(a,i,d)=>{let s=(a[0]<<21)+(a[1]<<14)+(a[2]<<7)+a[3];k()&&console.debug(`MU1000 EPROM jump to 0x${s.toString(16).padStart(6,"0")}.`),e.eprom&&(e.eprom.offset=s)}).add([89,2],(a,i,d)=>{if(e.eprom){let s=(a[0]<<21)+(a[1]<<14)+(a[2]<<7)+a[3]+(e.eprom.offset||0);k()&&console.debug(`MU1000 EPROM write to 0x${s.toString(16).padStart(6,"0")}.`);let r=e.eprom.data;a.subarray(4).forEach((c,f)=>{let o=f>>3,b=f&7;if(b==7)for(let y=0;y<7;y++)r[s+7*o+y]+=(c>>6-y&1)<<7;else r[s+7*o+b]=c})}}).add([89,3],(a,i,d)=>{}),this.#A.add([39,48],(a,i,d)=>{}).add([43,0,0],(a,i,d)=>{let s=[0,0,0,0],r=(c,f)=>{s[f]=c};if(a.subarray(1).forEach((c,f)=>{let o=f+a[0];[r,r,r,r,()=>{this.#f=c*129/16383*100,e.dispatchEvent("mastervolume",e.#f)},()=>c-64,()=>c||128,()=>c,()=>c,()=>{console.debug(`TG300 variation on cc${c}.`)}][o](c,o)}),a[0]<4){let c=0;s.forEach(f=>{c=c<<4,c+=f}),c-=1024}}).add([43,1,0],(a,i,d)=>{}).add([43,2],(a,i,d)=>{let s=e.chRedir(a[0],i,!0),r=a[1],c=m.cc*s,f=`TG300 CH${s+1} `;a.subarray(2).forEach((o,b)=>{b<5?([()=>{},()=>{e.#e[c+g[0]]=o,e.dispatchEvent("voice",{part:s})},()=>{e.#e[c+g[32]]=o,e.dispatchEvent("voice",{part:s})},()=>{e.#n[s]=o,e.dispatchEvent("voice",{part:s})},()=>{let y=e.chRedir(o,i,!0);e.#u[s]=y,s!=y&&(e.buildRchTree(),console.info(`${f}receives from CH${y+1}`))}][b+r]||(()=>{}))(o,b+r):b<21||(b<47?([()=>{e.#p[s]=+!o},()=>{},()=>{},()=>{e.#r[m.rpn*s+3]=o,e.#i[m.rpnt*s+2]=1},()=>{},()=>{e.#e[c+g[7]]=o},!1,!1,()=>{e.#e[c+g[10]]=o||128},!1,!1,()=>{console.debug(`${f} AC1 at cc${o}`)},()=>{console.debug(`${f} AC2 at cc${o}`)},()=>{e.#e[c+g[128]]=o},()=>{e.#e[c+g[93]]=o},()=>{e.#e[c+g[91]]=o},()=>{e.#e[c+g[94]]=o},()=>{e.#e[c+g[76]]=o},()=>{e.#e[c+g[77]]=o},()=>{e.#e[c+g[74]]=o},()=>{e.#e[c+g[71]]=o},()=>{e.#e[c+g[73]]=o},()=>{e.#e[c+g[75]]=o},()=>{e.#e[c+g[72]]=o},()=>{e.#e[c+g[78]]=o}][b+r-21]||(()=>{}))(o,b+r):b<95||([()=>{e.#e[c+g[65]]=o},()=>{e.#e[c+g[5]]=o}][b+r-95]||(()=>{}))(o,b+r))})}).add([43,7,0],(a,i,d)=>{let s=a[0];e.setLetterDisplay(a.subarray(1),"TG300 letter display",s)}).add([43,7,1],(a,i,d)=>{e.#h=0,e.#E=Date.now()+3200,e.#m.fill(0),a.forEach(function(s,r){let c=Math.floor(r/16),f=r%16,o=(f*3+c)*7,b=7,y=0;for(o-=f*5,c==2&&(b=2);y>6-y&1,y++})}),this.#L.add([66,18,0,0,127],(a,i,d)=>{e.switchMode("gs",!0),e.#e[m.cc*9]=120,e.#e[m.cc*25]=120,e.#e[m.cc*41]=120,e.#e[m.cc*57]=120,e.#M=3,e.#g=!1,e.#K.fill(0),console.info(`GS system to ${["single","dual"][a[0]]} mode.`)}).add([66,18,64,0],(a,i,d)=>{switch(a[0]){case 127:{e.switchMode("gs",!0),e.#e[m.cc*9]=120,e.#e[m.cc*25]=120,e.#e[m.cc*41]=120,e.#e[m.cc*57]=120,e.#g=!1,e.#K.fill(0),console.info("MIDI reset: GS");break}default:{let s=[0,0,0,0],r=(c,f)=>{s[f]=c};if(a.subarray(1).forEach((c,f)=>{let o=f+a[0];[r,r,r,r,b=>{this.#f=b*129/16383*100,e.dispatchEvent("mastervolume",e.#f)},b=>{},b=>{}][o](c,f)}),a[0]<4){let c=0;s.forEach(f=>{c=c<<4,c+=f}),c-=1024}}}}).add([66,18,64,1],a=>{let i=a[0];if(i<16){let d="".padStart(i," ");a.subarray(1).forEach((s,r)=>{d+=String.fromCharCode(Math.max(32,s))}),d=d.padEnd(16," "),console.debug(`GS patch name: ${d}`)}else i<48||(i<65?a.subarray(1).forEach((d,s)=>{let r=`GS ${i+s>55?"chorus":"reverb"} `;([()=>{console.info(`${r}type: ${J[d]}`),e.setEffectType(0,40,d),e.dispatchEvent("efxreverb",e.getEffectType(0))},()=>{},()=>{},()=>{},()=>{},()=>{},!1,()=>{console.debug(`${r}predelay: ${d}ms`)},()=>{console.info(`${r}type: ${we[d]}`),e.setEffectType(1,40,16+d),e.dispatchEvent("efxchorus",e.getEffectType(1))},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{console.debug(`${r}to reverb: ${C(d)}`)},()=>{console.debug(`${r}to delay: ${C(d)}`)}][i+s-48]||(()=>{}))()}):i<80?console.debug(`Unknown GS patch address: ${i}`):i<91?a.subarray(1).forEach((d,s)=>{let r="GS delay ";([()=>{console.info(`${r}type: ${$e[d]}`),e.setEffectType(2,40,32+d),e.dispatchEvent("efxdelay",e.getEffectType(2))},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{console.debug(`${r}to reverb: ${C(d)}`)}][i+s-80]||(()=>{}))()}):console.debug(`Unknown GS patch address: ${i}`))}).add([66,18,64,2],a=>{let i="GS EQ ";a.subarray(1).forEach((d,s)=>{([()=>{console.debug(`${i}low freq: ${[200,400][d]}Hz`)},()=>{console.debug(`${i}low gain: ${d-64}dB`)},()=>{console.debug(`${i}high freq: ${[3e3,6e3][d]}Hz`)},()=>{console.debug(`${i}high gain: ${d-64}dB`)}][a[0]+s]||function(){console.warn(`Unknown GS EQ address: ${a[0]+s}`)})()})}).add([66,18,64,3],a=>{let i="GS EFX ",d=function(s,r){let c=ke(e.#T.subarray(10,12),r,s);c&&console.debug(`${i}${ee(e.#T.subarray(10,12))} ${c}`)};a.subarray(1).forEach((s,r)=>{([()=>{e.setEffectTypeRaw(3,!1,32+s),e.dispatchEvent("efxinsert0",e.getEffectType(3))},()=>{e.setEffectTypeRaw(3,!0,s),console.info(`${i}type: ${ee(e.#T.subarray(10,12))}`),e.dispatchEvent("efxinsert0",e.getEffectType(3))},!1,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,()=>{console.debug(`${i}to reverb: ${C(s)}dB`)},()=>{console.debug(`${i}to chorus: ${C(s)}dB`)},()=>{console.debug(`${i}to delay: ${C(s)}dB`)},!1,()=>{console.debug(`${i}1 source: ${s}`),s&&s<96&&e.allocateAce(s)},()=>{console.debug(`${i}1 depth: ${s-64}`)},()=>{console.debug(`${i}2 source: ${s}`),s&&s<96&&e.allocateAce(s)},()=>{console.debug(`${i}2 depth: ${s-64}`)},()=>{console.debug(`${i}to EQ: ${s?"ON":"OFF"}`)}][a[0]+r]||function(c,f){console.warn(`Unknown GS EFX address: ${f}`)})(s,a[0]+r)})}).add([66,18,65],a=>{u((a[0]>>4)+1<<1,a[0]&15,a.subarray(1))}).add([69,18,16],a=>{switch(a[0]){case 0:{let i=a[1];e.setLetterDisplay(a.subarray(2),"GS display text",i);break}case 32:{e.#E=Date.now()+3200,a[1]==0&&(e.#h=Math.max(Math.min(a[2]-1,9),0),k()&&console.debug(`GS switch display page ${a[2]-1}.`));break}default:if(a[0]<6){e.#h>9&&(e.#h=0);let i=a[0]-1<<1|a[1]>>6;e.#h==i&&(e.#E=Date.now()+3200),e.#o[i]?.length||(e.#o[i]=new Uint8Array(256));let d=e.#o[i];k()&&console.debug(`GS frame draw page ${i}.`);let s=a[1]&63;d.fill(0),a.subarray(2).forEach(function(c,f){let o=f+s,b=Math.floor(o/16),y=o%16,E=(y*4+b)*5,$=5,x=0;for(E-=y*4,b==3&&($=1);x<$;)d[E+x]=c>>4-x&1,x++})}else console.warn(`Unknown GS display section: ${a[0]}`)}});let p=function(a,i,d){let s=a[0],r=m.cc*i,c=m.rpn*i,f=`GS CH${i+1} `;s<3?(a.subarray(1).forEach((o,b)=>{[()=>{e.#e[r+g[0]]=o},()=>{e.#n[i]=o},()=>{let y=0;o<16?y=e.chRedir(o,d,!0):y=m.ch,e.#u[i]=y,i!=y&&(e.buildRchTree(),console.info(`${f}receives from CH${y+1}`))}][s+b]()}),e.dispatchEvent("voice",{part:i})):s<19||(s<44?a.subarray(1).forEach((o,b)=>{([()=>{e.#p[i]=+!o},!1,()=>{e.setChType(i,o<<1,w.gs),console.debug(`${f}type: ${o?"drum ":"melodic"}${o||""}`)},()=>{e.#r[c+3]=o,e.#i[m.rpnt*i+2]=1},!1,()=>{e.#e[r+g[7]]=o},!1,!1,()=>{e.#e[r+g[10]]=o||128},!1,!1,()=>{console.debug(`${f}CC 1: cc${o}`)},()=>{console.debug(`${f}CC 2: cc${o}`)},()=>{e.#e[r+g[93]]=o},()=>{e.#e[r+g[91]]=o},!1,!1,()=>{e.#r[c+1]=o,e.#i[m.rpnt*i+1]=1},()=>{e.#r[c+2]=o,e.#i[m.rpnt*i+1]=1},()=>{e.#e[r+g[94]]=o}][s+b-19]||(()=>{}))()}):s<76||console.debug(`Unknown GS part address: ${s}`))},h=function(a,i){let d=a[0],s=`GS CH${i+1} `;d<2?a.subarray(1).forEach((r,c)=>{[()=>{e.#e[m.cc*i+g[32]]=r},()=>{}][d+c]()}):d<32?console.warn(`Unknown GS misc address: ${d}`):d<35?a.subarray(1).forEach((r,c)=>{[()=>{console.debug(`${s}EQ: o${["ff","n"][r]}`)},()=>{},()=>{console.debug(`${s}EFX: o${["ff","n"][r]}`),e.#G[i]=r,e.dispatchEvent("partefxtoggle",{part:i,active:r})}][d+c-32]()}):console.warn(`Unknown GS misc address: ${d}`)};this.#L.add([66,18,64,16],(a,i)=>{p(a,e.chRedir(9,i,!0),i)}).add([66,18,64,17],(a,i)=>{p(a,e.chRedir(0,i,!0),i)}).add([66,18,64,18],(a,i)=>{p(a,e.chRedir(1,i,!0),i)}).add([66,18,64,19],(a,i)=>{p(a,e.chRedir(2,i,!0),i)}).add([66,18,64,20],(a,i)=>{p(a,e.chRedir(3,i,!0),i)}).add([66,18,64,21],(a,i)=>{p(a,e.chRedir(4,i,!0),i)}).add([66,18,64,22],(a,i)=>{p(a,e.chRedir(5,i,!0),i)}).add([66,18,64,23],(a,i)=>{p(a,e.chRedir(6,i,!0),i)}).add([66,18,64,24],(a,i)=>{p(a,e.chRedir(7,i,!0),i)}).add([66,18,64,25],(a,i)=>{p(a,e.chRedir(8,i,!0),i)}).add([66,18,64,26],(a,i)=>{p(a,e.chRedir(10,i,!0),i)}).add([66,18,64,27],(a,i)=>{p(a,e.chRedir(11,i,!0),i)}).add([66,18,64,28],(a,i)=>{p(a,e.chRedir(12,i,!0),i)}).add([66,18,64,29],(a,i)=>{p(a,e.chRedir(13,i,!0),i)}).add([66,18,64,30],(a,i)=>{p(a,e.chRedir(14,i,!0),i)}).add([66,18,64,31],(a,i)=>{p(a,e.chRedir(15,i,!0),i)}).add([66,18,64,64],(a,i)=>{h(a,e.chRedir(9,i,!0))}).add([66,18,64,65],(a,i)=>{h(a,e.chRedir(0,i,!0))}).add([66,18,64,66],(a,i)=>{h(a,e.chRedir(1,i,!0))}).add([66,18,64,67],(a,i)=>{h(a,e.chRedir(2,i,!0))}).add([66,18,64,68],(a,i)=>{h(a,e.chRedir(3,i,!0))}).add([66,18,64,69],(a,i)=>{h(a,e.chRedir(4,i,!0))}).add([66,18,64,70],(a,i)=>{h(a,e.chRedir(5,i,!0))}).add([66,18,64,71],(a,i)=>{h(a,e.chRedir(6,i,!0))}).add([66,18,64,72],(a,i)=>{h(a,e.chRedir(7,i,!0))}).add([66,18,64,73],(a,i)=>{h(a,e.chRedir(8,i,!0))}).add([66,18,64,74],(a,i)=>{h(a,e.chRedir(10,i,!0))}).add([66,18,64,75],(a,i)=>{h(a,e.chRedir(11,i,!0))}).add([66,18,64,76],(a,i)=>{h(a,e.chRedir(12,i,!0))}).add([66,18,64,77],(a,i)=>{h(a,e.chRedir(13,i,!0))}).add([66,18,64,78],(a,i)=>{h(a,e.chRedir(14,i,!0))}).add([66,18,64,79],(a,i)=>{h(a,e.chRedir(15,i,!0))}),this.#V.add([54,65],(a,i)=>{e.switchMode("x5d");let d=(a[1]<<7)+a[0],s=(a[3]<<7)+a[2],r=e.chRedir(d&15,i,!0),c=m.cc*r;[()=>{s<1||(s<101?(e.setChType(r,e.CH_MELODIC,w.x5d),e.#n[r]=s-1,e.#e[c+g[0]]=82):s<229?(e.setChType(r,e.CH_MELODIC,w.x5d),e.#n[r]=s-101,e.#e[c+g[0]]=56):(e.setChType(r,e.CH_DRUMS,w.x5d),e.#n[r]=Pe[s-229]||0,e.#e[c+g[0]]=62)),e.dispatchEvent("voice",{part:r})},()=>{e.#e[c+g[7]]=s},()=>{s<31&&(e.#e[c+g[10]]=Math.round((s-15)*4.2+64))},()=>{e.#e[c+g[93]]=_(s)},()=>{e.#e[c+g[91]]=_(s)},()=>{e.#r[r*m.rpn+3]=s>8191?s-16320:64+s,e.#i[m.rpnt*r+2]=1},()=>{e.#r[r*m.rpn+1]=s>8191?s-16320:64+s,e.#i[m.rpnt*r+1]=1},()=>{s>0&&(e.#r[r*m.rpn]=s,e.#i[m.rpnt*r]=1)},()=>{}][d>>4]()}).add([54,76,0],(a,i)=>{e.switchMode("x5d",!0);let d="",s=82,r=0,c=0,f="MSB PRG LSB NME";O(a,function(o,b){if(b<16400){let y=b%164;switch(!0){case y<10:{o>31&&(d+=String.fromCharCode(o));break}case y==11:{f+=` -${s} ${r} ${c} ${d.trim().replace("Init Voice","")}`,r++,d="";break}}r>99&&(s=90,r=0)}}),e.userBank.clearRange({msb:82,prg:[0,99],lsb:0}),e.userBank.load(f),k()&&console.debug(f),e.forceVoiceRefresh()}).add([54,77,0],(a,i)=>{e.switchMode("x5d",!0);let d="",s=90,r=0,c=0,f="MSB PRG LSB NME";O(a,function(o,b){if(b<13600){let y=b%136;switch(!0){case y<10:{o>31&&(d+=String.fromCharCode(o));break}case y==11:{f+=` -${s} ${r} ${c} ${d.trim().replace("Init Combi","")}`,r++,d="";break}}}}),e.userBank.clearRange({msb:90,prg:[0,99],lsb:0}),e.userBank.load(f),k()&&console.debug(f),e.forceVoiceRefresh()}).add([54,78],(a,i)=>{e.switchMode("x5d",!0),console.debug(`X5D mode switch requested: ${["combi","combi edit","prog","prog edit","multi","global"][a[0]]} mode.`)}).add([54,85],(a,i)=>{e.switchMode("x5d",!0),O(a,(d,s)=>{s>0&&s<3&&(e.setEffectType(s-1,44,d),e.dispatchEvent(`efx${["reverb","chorus"][s-1]}`,e.getEffectType(s-1)))})}).add([54,104],(a,i)=>{e.switchMode("x5d",!0),O(a,function(d,s,r,c){if(s<192){let f=e.chRedir(Math.floor(s/12),i,!0),o=f*m.cc;switch(s%12){case 0:{d<128?(e.setChType(f,e.CH_MELODIC,w.x5d),e.#e[o+g[0]]=82,e.#n[f]=d):(e.setChType(f,e.CH_DRUMS,w.x5d),e.#e[o+g[0]]=62,e.#n[f]=Pe[d-128]),d>0&&e.setChActive(f,1),e.dispatchEvent("voice",{part:f});break}case 1:{e.#e[o+g[7]]=d;break}case 2:{e.#r[f*m.rpn+3]=d>127?d-192:64+d,e.#i[m.rpnt*f+2]=1;break}case 3:{e.#r[f*m.rpn+1]=d>127?d-192:64+d,e.#i[m.rpnt*f+1]=1;break}case 4:{d<31&&(e.#e[o+g[10]]=Math.round((d-15)*4.2+64));break}case 5:{let b=d>>4,y=d&15;e.#e[o+g[91]]=_(y),e.#e[o+g[93]]=_(b);break}case 10:break;case 11:{let b=e.chRedir(d&15,i,!0),y=d>>4;e.#u[f]=d,(b!=f||y)&&(console.info(`X5D Part CH${f+1} receives from CH${b+1}.`),e.buildRchTree())}}}else{let f=e.chRedir(s-192,i,!0)}})}),this.#L.add([22,18,127],a=>{e.switchMode("mt32",!0),e.#g=!1,e.userBank.clearRange({msb:0,lsb:127,prg:[0,127]}),console.info("MIDI reset: MT-32")}).add([22,18,0],(a,i,d)=>{e.switchMode("mt32");let s=e.chRedir(d,i,!0),r=a[1];a.subarray(2).forEach((c,f)=>{let o=f+r;e.#$[o+(s-1)*16]=c,([!1,()=>{let b=e.#$[s-1<<4];if(b<3){if(e.#a[s]=1,b==2)for(let y=0;y{e.#r[s*m.rpn+3]=c+40,e.#i[m.rpnt*s+2]=1},()=>{e.#r[s*m.rpn+1]=c+14,e.#i[m.rpnt*s+1]=1},()=>{e.#r[s*m.rpn]=c,e.#i[m.rpnt*s]=1},!1,()=>{e.#e[m.cc*s+g[91]]=c?127:0},!1,()=>{e.#e[m.cc*s+g[7]]=c},()=>{e.#e[m.cc*s+g[10]]=Math.ceil(c*9.05)}][o]||(()=>{}))()})}).add([22,18,1],(a,i,d)=>{e.switchMode("mt32");let s=d&7;console.debug(`MT-32 slot #${d+1} Drum: ${a}`);let r=a[0]<<7|a[1];a.subarray(2).forEach((c,f)=>{let o=f+r,b=(o>>2)+24,y=o&3,E=s*m.dpn;if(k()&&console.debug(`MT-32 temp drum note ${b} param ${y}: ${c}`),b<24){console.warn(`MT-32 dev drum write attempted on an OOB note: ${b}`);return}[()=>{},()=>{e.#x[(E+R[26])*m.dnc+b]=Math.round(c*1.27)},()=>{e.#x[(E+R[26])*m.dnc+b]=c*9+1&127},()=>{e.#x[(E+R[26])*m.dnc+b]=c?127:0}][y]()})}).add([22,18,2],(a,i,d)=>{e.switchMode("mt32");let s=e.chRedir(d,i,!0),r=a[1]+(a[0]<<7);r<10&&(e.#a[s]=1),a.subarray(2).forEach((c,f)=>{let o=f+r;o<14&&(e.#c[(s-1)*m.cmt+o]=c)}),e.dispatchEvent("voice",{part:s})}).add([22,18,3],(a,i,d)=>{e.switchMode("mt32");let s=d&7;if(a[0]){let r=(a[0]-1<<7)+a[1]-16;a.subarray(2).forEach((c,f)=>{let o=f+r,b=(o>>2)+24,y=o&3,E=s*m.dpn;if(k()&&console.debug(`MT-32 dev drum note ${b} param ${y}: ${c}`),b<24){console.warn(`MT-32 dev drum write attempted on an OOB note: ${b}`);return}[()=>{},()=>{e.#x[(E+R[26])*m.dnc+b]=Math.round(c*1.27)},()=>{e.#x[(E+R[26])*m.dnc+b]=c*9+1&127},()=>{e.#x[(E+R[26])*m.dnc+b]=c?127:0}][y]()})}else{let r=a[1];a.subarray(2).forEach((c,f)=>{let o=f+r;e.#$[o]=c;let b=e.chRedir(1+(o>>4),i,!0),y=o&15;([!1,()=>{let E=e.#$[b-1<<4];if(E<3)if(e.#a[b]=1,E==2)for(let $=0;${e.#r[b*m.rpn+3]=c+40,e.#i[m.rpnt*b+2]=1},()=>{e.#r[b*m.rpn+1]=c+14,e.#i[m.rpnt*b+1]=1},()=>{e.#r[b*m.rpn]=c,e.#i[m.rpnt*b]=1},!1,()=>{e.#e[m.cc*b+g[91]]=c?127:0},!1,()=>{e.#e[m.cc*b+g[7]]=c},()=>{e.#e[m.cc*b+g[10]]=Math.ceil(c*9.05)}][y]||(()=>{}))()})}}).add([22,18,4],(a,i,d)=>{e.switchMode("mt32");let s=a[1]+(a[0]<<7),r=[];a.subarray(2).forEach((c,f)=>{let o=f+s,b=e.chRedir(Math.floor(o/246+1),i,!0),y=o%246;y<14&&(e.#c[(b-1)*m.cmt+y]=c),y<10&&(e.#a[b]=1),r.indexOf(b)<0&&r.push(b)}),r.forEach(c=>{e.dispatchEvent("voice",{part:c})})}).add([22,18,5],(a,i,d)=>{e.switchMode("mt32");let s=(a[0]<<7)+a[1];a.subarray(2).forEach((r,c)=>{let f=s+c,o=Math.floor(f/8),b=f&7,y=o*8;e.#y[f]=r,([!1,()=>{let E=e.#y[y];if(E<3){let $="";if(E==2){let x=m.cmt*o;$=`MT-m:${r.toString().padStart(3,"0")}`}else $=e.baseBank.get(0,r+(E<<6),127,"mt32").name;e.userBank.clearRange({msb:0,lsb:127,prg:o}),e.userBank.load(`MSB LSB PRG NME -000 127 ${o} ${$}`,!0)}}][b]||(()=>{}))()}),e.forceVoiceRefresh()}).add([22,18,8],(a,i,d)=>{e.switchMode("mt32");let s=((a[0]&1)<<7)+a[1];a.subarray(2).forEach((r,c)=>{let f=s+c;f>1)*m.cmt+f]=r)}),e.forceVoiceRefresh()}).add([22,18,16],(a,i,d)=>{e.switchMode("mt32");let s=a[1],r=!1,c=function(f,o){e.#u[o-12]=f,r=!0};a.subarray(2).forEach((f,o)=>{let b=o+s;([!1,!1,!1,!1,!1,!1,!1,!1,!1,!1,!1,!1,!1,c,c,c,c,c,c,c,c,c,()=>{e.#f=f,e.dispatchEvent("mastervolume",e.#f)}][b]||(()=>{}))(f,o)}),r&&e.buildRchTree()}).add([22,18,32],a=>{e.switchMode("mt32");let i=a[1],d=" ".repeat(i);a.subarray(2).forEach(s=>{s>31?d+=String.fromCharCode(s):d+=" "}),e.#_=d.padStart(20," "),e.#N=Date.now()+3200}).add([22,18,82],(a,i)=>{let d=e.chRedir(0,i,!0);for(let s=0;s<16;s++)e.#k.ano(d+s),s&&s<10&&(e.#n[d+s]=te[s-1]);console.info("MT-32 alt reset complete.")}),this.#V.add([66,0],(a,i)=>{e.switchMode("ns5r",!0),e.#g=!1,console.debug(`NS5R mode switch requested: ${["global","multi","prog edit","comb edit","drum edit","effect edit"][a[0]]} mode.`)}).add([66,1],(a,i)=>{e.switchMode(["ns5r","05rw"][a[0]],!0),e.#g=!1}).add([66,18,0,0],(a,i)=>{let d=a[0];switch(d){case 124:case 126:case 127:{e.switchMode("ns5r",!0),e.#g=!1;break}case 125:{e.initDrums(),console.info(`NS5R drum setup reset: ${a}`);break}default:if(d<10){let s=[0,0,0,0],r=(c,f)=>{s[f]=c};if(a.subarray(1).forEach((c,f)=>{[r,r,r,r,()=>{e.#f=c*129/16383*100,e.dispatchEvent("mastervolume",e.#f)},()=>c-64,()=>c-64,()=>{},()=>{},()=>{}][d+f]()}),a[0]<4){let c=0;s.forEach(f=>{c=c<<4,c+=f}),c-=1024}}}}).add([66,18,0,1],(a,i)=>{}).add([66,18,0,2],(a,i)=>{}).add([66,18,1],(a,i)=>{let d=e.chRedir(a[0],i,!0),s=d*m.cc,r=a[1],c=`NS5R CH${d+1} `;a.subarray(2).forEach((f,o)=>{let b=r+o;b<3?([()=>{e.#e[s+g[0]]=f||121},()=>{e.#e[s+g[32]]=f},()=>{e.#n[d]=f}][b](),e.dispatchEvent("voice",{part:d})):b<8||(b<14?[()=>{let y=e.chRedir(f,i,!0);e.#u[d]=y,d!=y&&(e.buildRchTree(),console.info(`${c}receives from CH${y+1}`))},()=>{e.#p[d]=+!f},()=>{e.setChType(d,f,w.ns5r),console.debug(`${c}type: ${X[f]}`)},()=>{e.#r[m.rpn*d+3]=f,e.#i[m.rpnt*d+2]=1},()=>{},()=>{}][b-8]():b<16||(b<33?[()=>{e.#e[s+g[7]]=f},()=>{e.#e[s+g[11]]=f},()=>{},()=>{},()=>{e.#e[s+g[10]]=f||128},()=>{},()=>{},()=>{e.#e[s+g[93]]=f},()=>{e.#e[s+g[91]]=f},()=>{e.#e[s+g[76]]=f},()=>{e.#e[s+g[77]]=f},()=>{e.#e[s+g[78]]=f},()=>{e.#e[s+g[74]]=f},()=>{e.#e[s+g[71]]=f},()=>{e.#e[s+g[73]]=f},()=>{e.#e[s+g[75]]=f},()=>{e.#e[s+g[72]]=f}][b-16]():b<112||b<114&&[()=>{e.#e[s+g[5]]=f},()=>{e.#e[s+g[65]]=f}][b-112]()))})}).add([66,18,8,0],(a,i)=>{let d=a[0];if(d<32)e.setLetterDisplay(a.subarray(1,33),"NS5R letter display");else{let s=d-32;e.#E=Date.now()+3200,e.#h=10,e.#m.fill(0);let r=a.subarray(1),c=4;r.forEach(function(f,o){let b=o+s,y=b>>4,E=b&15;if(b<80){let $=y>3,x=0,B=y0;)e.#m[E*32+y*7+(B-x)]=$&1,$=$>>1,x++}})}}).add([66,18,48],(a,i,d)=>{l(0,a)}).add([66,18,49],(a,i,d)=>{l(1,a)}).add([66,18,50],(a,i,d)=>{l(2,a)}).add([66,18,51],(a,i,d)=>{l(3,a)}).add([66,18,52],(a,i,d)=>{l(4,a)}).add([66,18,53],(a,i,d)=>{l(5,a)}).add([66,18,54],(a,i,d)=>{l(6,a)}).add([66,18,55],(a,i,d)=>{l(7,a)}).add([66,52],(a,i)=>{e.switchMode("ns5r",!0),e.#g=!1;let d="";O(a,(s,r)=>{r<8?(s>31&&(d+=String.fromCharCode(s)),r==7&&(e.aiEfxName=d)):r<10&&(e.setEffectType(r-8,44,s),e.dispatchEvent(`efx${["reverb","chorus"][r-8]}`,e.getEffectType(r-8)))})}).add([66,53],(a,i)=>{e.switchMode("ns5r",!0),e.#g=!1,O(a,function(d,s){switch(!0){case s<2944:{let r=e.chRedir(Math.floor(s/92),i,!0),c=r*m.cc;switch(s%92){case 0:{e.#e[c+g[0]]=d||121,e.dispatchEvent("voice",{part:r});break}case 1:{e.#e[c+g[32]]=d,e.dispatchEvent("voice",{part:r});break}case 2:{e.#n[r]=d,d>0&&e.setChActive(r,1),e.dispatchEvent("voice",{part:r});break}case 3:{let f=e.chRedir(d,i,!0);e.#u[r]=f,r!=f&&(console.info(`NS5R CH${r+1} receives from CH${f+1}.`),e.buildRchTree())}case 7:break;case 8:{e.#r[r*m.rpn+3]=d<40||d>88?d+(d>63?-192:64):d,e.#i[m.rpnt*r+2]=1;break}case 9:case 10:{e.#e[c+g[7]]=d;break}case 11:{e.#e[c+g[11]]=d;break}case 14:{e.#e[c+g[10]]=d||128;break}case 19:{e.#e[c+g[93]]=d;break}case 20:{e.#e[c+g[91]]=d;break}case 84:{e.#e[c+g[65]]=d;break}case 85:{e.#e[c+g[5]]=d;break}}break}case s<3096:break;case s<3134:break;case s<8566:break}})}).add([66,54],(a,i)=>{e.switchMode("ns5r",!0);let d="",s=80,r=0,c=0,f="MSB PRG LSB NME";O(a,function(o,b){let y=b%158;switch(!0){case y<10:{o>31&&(d+=String.fromCharCode(o));break}case y==11:{s=o&127;break}case y==12:{c=o&127;break}case y==13:{f+=` -${s} ${r} ${c} ${d.trim().replace("Init Voice","")}`,r++,d="";break}}}),e.userBank.clearRange({msb:80,lsb:0}),e.userBank.load(f),k()&&console.debug(f),e.forceVoiceRefresh()}).add([66,55],(a,i)=>{e.switchMode("ns5r",!0);let d="",s=88,r=0,c=0,f="MSB PRG LSB NME";O(a,function(o,b){let y=b%126;switch(!0){case y<10:{o>31&&(d+=String.fromCharCode(o));break}case y==11:break;case y==12:break;case y==13:{f+=` -${s} ${r} ${c} ${d.trim().replace("Init Combi","")}`,r++,d="";break}}}),e.userBank.clearRange({msb:88,lsb:0}),e.userBank.load(f),k()&&console.debug(f),e.forceVoiceRefresh()}).add([66,125],a=>{e.dispatchEvent("backlight",["green","orange","red",!1,"yellow","blue","purple"][a[0]]||"white")}).add([66,127],a=>{let i=new Uint8Array(5760);O(a,(d,s,r)=>{if(s<720)for(let c=0;c<8;c++)i[s*8+c]=d>>7-c&1}),e.dispatchEvent("screen",{type:"ns5r",data:i})}).add([76],(a,i,d)=>{e.#V.run([66,...a],i,d)}),this.#Z.add([16,0,8,0],(a,i,d)=>{let s=(a[2]<<4)+a[3],r="K11 ";([()=>{e.switchMode("k11",!0),e.#g=!1,e.#M=s?4:0,console.info("MIDI reset: GMega/K11")},()=>{e.setEffectType(0,24,s),console.debug(`${r}reverb type: ${s}`),e.dispatchEvent("efxreverb",e.getEffectType(0))},()=>{console.debug(`${r}reverb time: ${s}`)},()=>{console.debug(`${r}reverb time: ${s}`)},()=>{console.debug(`${r}reverb predelay: ${s}`)},()=>{console.debug(`${r}reverb predelay: ${s}`)},()=>{console.debug(`${r}depth high: ${s}`)},()=>{console.debug(`${r}depth high: ${s}`)},()=>{console.debug(`${r}depth low: ${s}`)},()=>{console.debug(`${r}depth low: ${s}`)}][a[0]]||(()=>{}))()}).add([16,0,8,1],(a,i,d)=>{let s=e.chRedir(a[1],i,!0),r=m.cc*s,c=m.rpn*s,f=(a[3]<<4)+a[4],o=`K11 CH${s+1} `;([()=>{f<128?(e.setChType(s,e.CH_MELODIC,w.k11),e.#e[r+g[0]]=0,e.#n[s]=f):(e.setChType(s,e.CH_DRUMS,w.k11),e.#n[s]=f-128),e.dispatchEvent("voice",{part:s})},()=>{let b=e.chRedir(f,i,!0);e.#u[s]=b,s!=b&&(e.buildRchTree(),console.info(`${o}receives from CH${b+1}`))},()=>{e.#e[r+g[7]]=f},()=>{uupThis.setChActive(s,f)},()=>{e.#e[r+g[10]]=f},()=>{e.#r[c+3]=f+40,e.#i[m.rpnt*s+2]=1},()=>{e.#r[c+1]=f>>1,e.#r[c+2]=f&1,e.#i[m.rpnt*s+1]=1},()=>{e.#e[r+g[91]]=f?127:0},()=>{},()=>{e.#e[r+g[74]]=f},()=>{e.#e[r+g[73]]=f},()=>{e.#e[r+g[72]]=f}][a[0]]||(()=>{}))()}).add([16,0,9,0],(a,i,d)=>{let s=(a[2]<<4)+a[3],r="GMLX ";([()=>{console.debug(`${r}reverb type: ${s}`)},()=>{console.debug(`${r}reverb time: ${s}`)},()=>{console.debug(`${r}reverb predelay: ${s}`)},()=>{console.debug(`${r}depth high: ${s}`)},()=>{console.debug(`${r}depth low: ${s}`)}][a[0]]||(()=>{}))()}).add([16,0,9,3],(a,i,d)=>{let s=(a[2]<<4)+a[3],r=e.chRedir(a[1],i,!0),c=r*m.cc;[()=>{s<128?(e.setChType(r,e.CH_MELODIC,w.k11),e.#e[c+g[0]]=0,e.#e[c+g[32]]=0,e.#n[r]=s):s<160?(e.setChType(r,e.CH_MELODIC,w.k11),e.#e[c+g[0]]=0,e.#e[c+g[32]]=7,e.#n[r]=s-100):(e.setChType(r,e.CH_DRUMS,w.k11),e.#e[c+g[0]]=122,e.#e[c+g[32]]=0,e.#n[r]=s-160),e.dispatchEvent("voice",{part:r})},()=>{let f=e.chRedir(s,i,!0);e.#u[r]=f,r!=f&&(e.buildRchTree(),console.info(`GMLX CH${r+1} receives from CH${f+1}`))}][a[0]]()}).add([16,0,9,4],(a,i,d)=>{let s=(a[2]<<4)+a[3],r=e.chRedir(a[1],i,!0),c=r*m.cc,f=r*m.rpn,o=`GMLX CH${r+1} `;[()=>{e.setChActive(r,s)},()=>{e.#e[c+g[7]]=s},()=>{e.#e[c+g[10]]=s},()=>{e.#e[c+g[91]]=s?127:0},()=>{e.#r[f+3]=s+40,e.#i[m.rpnt*r+2]=1},()=>{e.#r[f+1]=s,e.#i[m.rpnt*r+1]=1},()=>{e.#r[f]=s,e.#i[m.rpnt*r]=1},()=>{}][a[0]]()}),this.#J.add([66,93,64],(a,i,d)=>{let s=a[2];switch(a[0]){case 0:{switch(a[1]){case 4:{e.#f=s*129/16383*100,e.dispatchEvent("mastervolume",e.#f);break}case 5:{s-64;break}case 6:{console.debug(`SG global reverb: ${s?"on":"off"}`);break}case 127:{e.switchMode("sg",!0);break}}break}case 1:{switch(a[1]){case 48:{console.debug(`SG reverb type: ${J[s]}`);break}}break}default:if(a[0]>>4==1){let r=e.chRedir(a[0]&15,i,!0);if(a[1]==2){let c=e.chRedir(s,i,!0);e.#u[r]=c,r!=c&&(e.buildRchTree(),console.info(`SG CH${r+1} receives from CH${c+1}`))}else a[1]==19&&(e.#e[m.cc*r+g[7]]=s)}else console.warn(`Unknown AKAI SG SysEx: ${a}`)}}),this.#ee.add([9],(a,i,d)=>{console.debug(`GZ set effect: ${["stage reverb","hall reverb","room reverb","chorus","tremelo","phaser","rotary speaker","enhancer","flanger","EQ"][a[0]]||"off"}`)}),this.#A.add([127,0],(a,i,d)=>{e.switchMode("motif");let s=new Uint8Array([127,1,...a]);e.#A.run(s,i,d)}).add([127,1,0,0],(a,i,d)=>{e.switchMode("s90es");let s="S90/Motif ES system ",r=a[0];a.subarray(1).forEach((c,f)=>{([()=>{e.#f=c*12900/16383,e.dispatchEvent("mastervolume",e.#f)}][r+f]||(()=>{console.info(`Unrecognized ${s}ID: ${r+f}`)}))()})}).add([127,1,0,0,14],(a,i,d)=>{e.switchMode("s90es");let s="S90/Motif ES bulk header ",r=[];r[95]=(c,f,o)=>{console.debug(`${s}multi edit buffer: ${c[1]}`)},(r[a[0]]||(()=>{console.info(`Unrecognized ${s}ID: ${a[0]}.`)}))(a.subarray(1))}).add([127,1,0,0,15],(a,i,d)=>{e.switchMode("s90es");let s="S90/Motif ES bulk footer ",r=[];r[95]=(c,f,o)=>{console.debug(`${s}multi edit buffer: ${c[1]}`)},(r[a[0]]||(()=>{console.info(`Unrecognized ${s}ID: ${a[0]}.`)}))(a.subarray(1))}).add([127,1,0,58,55],(a,i,d)=>{e.switchMode("s90es");let s=e.chRedir(a[0],i,!0),r=m.cc*s,c=a[1],f=`S90/Motif ES bulk CH${s<16?s+1:"U"+(s-95)} `;console.debug(f,a),!(a[0]>15)&&a.subarray(2).forEach((o,b)=>{([()=>{e.#e[r+g[0]]=o,e.dispatchEvent("voice",{part:s})},()=>{o&&e.setChActive(s,1),e.#e[r+g[32]]=o,e.setChType(s,[32,40].indexOf(o)>-1?e.CH_DRUMS:e.CH_MELODIC,e.#t,!0),e.dispatchEvent("voice",{part:s})},()=>{o&&e.setChActive(s,1),e.#n[s]=o,e.dispatchEvent("voice",{part:s})},()=>{let y=e.chRedir(o,i,!0);e.#u[s]=y,s!=y&&(e.buildRchTree(),console.info(`${f}receives from CH${y+1}`))},()=>{e.#p[s]=o?0:1},!1,!1,!1,!1,!1,!1,!1,!1,()=>{e.#e[r+g[7]]=o},()=>{e.#e[r+g[10]]=o},!1,!1,!1,()=>{e.#e[r+g[91]]=o},()=>{e.#e[r+g[93]]=o},()=>{e.#e[r+g[94]]=o},()=>{e.#e[r+g[128]]=o},()=>{},()=>{e.#e[r+g[74]]=o},()=>{e.#e[r+g[71]]=o},!1,()=>{e.#e[r+g[65]]=o},()=>{e.#e[r+g[5]]=o},()=>{}][c+b]||(()=>{}))()})}).add([127,1,54,16],(a,i,d)=>{e.switchMode("s90es");let s=a[0];a.subarray(1).forEach((r,c)=>{let o=`S90/Motif ES EQ${(c>>2)+1} `;([()=>{let b=r-64},()=>{let b=N[r]},()=>{let b=r/10},()=>{let b=r}][s+c&3]||(()=>{}))()})}),this.#L.add([0,72,18,0,0,0,0],(a,i,d)=>{e.switchMode("sd",!0),console.info("MIDI reset: SD")}).add([0,72,18,16,0],(a,i,d)=>{let s=a[0]>>5,r=a[0]&31;switch(s){case 0:{console.debug(`Unknown SD-90 global effects message: -%o`,a);break}case 1:{let c=e.chRedir(r,i,!0),f=a[1],o=c*m.cc;a.subarray(2).forEach((b,y)=>{let E=f+y;E<37?([()=>{},()=>{},0,()=>{},()=>{switch(e.#e[o+g[0]]=b,b){case 104:case 105:case 106:case 107:case 120:{e.#s[c]||e.setChType(c,e.CH_DRUMS);break}default:e.#s[c]&&e.setChType(c,e.CH_MELODIC)}e.dispatchEvent("voice",{part:c})},()=>{e.#e[o+g[32]]=b,e.dispatchEvent("voice",{part:c})},()=>{e.#n[c]=b,e.dispatchEvent("voice",{part:c})},()=>{e.#e[o+g[7]]=b},()=>{e.#e[o+g[10]]=b},()=>{},()=>{},()=>{b<2&&(e.#p[c]=b)},()=>{b<2&&(e.#e[o+g[68]]=b?127:0)},()=>{},()=>{b<2&&(e.#e[o+g[65]]=b?127:0)},()=>{e.#e[o+g[5]]=b&15<<4|e.#e[o+g[5]]&15},()=>{e.#e[o+g[5]]=b&15|(e.#e[o+g[5]]&240)>>4},()=>{e.#e[o+g[74]]=b},()=>{e.#e[o+g[71]]=b},()=>{e.#e[o+g[73]]=b},()=>{e.#e[o+g[72]]=b},0,0,0,0,0,0,0,()=>{e.#e[o+g[128]]=b},()=>{e.#e[o+g[93]]=b},()=>{e.#e[o+g[91]]=b},0,0,()=>{e.#e[o+g[75]]=b},()=>{e.#e[o+g[76]]=b},()=>{e.#e[o+g[77]]=b},()=>{e.#e[o+g[78]]=b}][E]||(()=>{}))():E<63||(E<64?e.#s[c]?e.#e[o+g[0]]=104|b:e.#e[o+g[0]]=96|b:console.debug(`Unknown SD-90 global CH${c+1} param setup message: -%o`,a))});break}case 2:{let c=e.chRedir(r,i,!0),f=a[1];console.debug(`Unknown SD-90 global CH${c+1} MIDI setup message: -%o`,a.subarray(2));break}default:console.warn(`Unknown SD-90 global part setup message: -%o`,a)}})}};var ne=Ze(Le(),1);var Ie=class{#t=!1;constructor(e,t,n,l){this.#t=e,this.start=t,this.end=n,this.data=l}get duration(){return this.ranged?this.end-this.start:0}get ranged(){return this.#t}},ie=class extends Ie{constructor(e,t,n){super(!0,e,t,n)}},Ue=class extends Ie{constructor(e,t){super(!1,e,e,t)}},se=class extends Array{#t=-1;constructor(){super(...arguments)}resetIndex(e){this.#t=-1}fresh(){this.sort(function(e,t){return e.start==t.start?0:(+(e.start>t.start)<<1)-1}),this.forEach(function(e,t){e.index=t})}step(e,t=!1){let n=[];if(t)for(let l=0;le);l++){if(this[l].endu.#t&&(n.push(p),u.#t=p.index)})}return n}getRange(e,t){e>t&&([e,t]=[t,e]);let n=[],l=-1,u=Math.ceil(Math.sqrt(this.length)),p=!0;for(let h=0;h=e&&(l=h):l=l<0?h:l;for(;p;)this[l]?.end=e&&n.push(this[l]):p=!1,l++;return n}};var lt=0xffffffffffff,Ne=function(e){let t=new se,n=this,l=e.timeDivision,u=120,p=new se,h=0,a=0;p.push(new ie(0,lt,[120,0])),e.track.forEach(function(r){h=0,r.event.forEach(function(c){h+=c.deltaTime,c.type==255&&c?.metaType==81&&(u=6e7/c.data,p[p.length-1]&&p.push(new ie(h,0xffffffffffff,[u,0])))})}),p.fresh(),p.forEach(function(r,c,f){c>0&&(f[c-1].end=r.start)});let i=120;p.forEach(function(r,c,f){c>0&&(r.end==r.start?f.splice(f.indexOf(r),1):i==r.data[0]&&(f[c-1].end=r.end,f.splice(f.indexOf(r),1)),i=r.data[0])});let d=0,s=120;return p.forEach(function(r){let c=r.start,f=c/s/l*60+d;s=r.data[0],d=f-c/s/l*60,r.data[1]=d}),console.debug("All tempo changes: ",p),u=120,h=0,a=0,e.track.forEach(function(r,c){h=0,a=0;let f=c+1;r.event.forEach(function(o,b){h+=o.deltaTime;let y=p.step(h,!0)[0];y&&(u=y.data[0],a=y.data[1]);let E={type:o.type,data:o.data,track:f,part:0};o.type>14?E.meta=o.metaType:E.part=o.channel,t.push(new Ue(h/u/l*60+a,E))})}),t.fresh(),self.midiEvents=t,console.debug(`Parsed a type ${e.formatType} MIDI sequence.`),t};ne.default.customInterpreter=xe;var S=function(e,t,n){e.addEventListener(n,l=>{t.dispatchEvent(n,l.data)})},Be=class extends V{device;#t;#h={};#E=[];#o="";#m=[];#w=new Uint8ClampedArray(128);#u=new Uint8ClampedArray(128);#s=.5;#e=120;#d=4;#n=4;#l=0;#p=0;smoothingAtk=0;smoothingDcy=0;reset(){let e=this;e.dispatchEvent("reset"),e.#t?.resetIndex(),e.device.init(),e.#o="",e.#s=.5,e.#e=120,e.#d=4,e.#n=4,e.#l=0,e.#p=0,e.dispatchEvent("tempo",e.#e),e.dispatchEvent("title",e.#o)}init(){this.reset(),this.#t=void 0}async loadFile(e){this.#t=Ne(ne.default.parse(new Uint8Array(await e.arrayBuffer())))}async loadMap(e,t){let n=this,l=0,u=0,p=0,h,a;e.split(` -`).forEach((i,d)=>{if(!i)return;let s=i.split(" ");if(d){if(!p)return;let r="",c="";s.forEach((f,o)=>{switch(o){case h:{r=f;break}case a:{c=f;break}}}),!n.#h[r]||t?(n.#h[r]=c,l++):self.debugMode&&console.debug(`Voice "${c}" (${r}) seems to be in conflict with (${n.#h[r]}).`),u++}else s.forEach((r,c)=>{switch(r){case"ID":{h=c,p++;break}case"Name":{a=c,p++;break}default:console.debug(`Unknown map field: ${r}`)}})}),console.debug(`Map: ${u} total, ${l} loaded.`),n?.device.forceVoiceRefresh()}async loadEfx(e,t){let n=this,l=0,u=0,p,h,a;e.split(` -`).forEach((i,d)=>{if(i)if(d){let s=0,r;i.split(" ").forEach((c,f)=>{switch(f){case p:{s|=parseInt(c,16)<<8;break}case h:{s|=parseInt(c,16);break}case a:{r=c;break}}}),!n.#E[s]||t?(n.#E[s]=r,l++):self.debugMode&&console.debug(`EFX ID 0x${s.toString(16).padStart(4,"0")} (${r}) seems to be in conflict.`),u++}else i.split(" ").forEach((s,r)=>{switch(s){case"MSB":{p=r;break}case"LSB":{h=r;break}case"Name":{a=r;break}default:console.debug(`Unknown EFX field: ${s}`)}})}),console.debug(`EFX: ${u} total, ${l} loaded.`),n.dispatchEvent("efxreverb",n.device.getEffectType(0)),n.dispatchEvent("efxchorus",n.device.getEffectType(1)),n.dispatchEvent("efxdelay",n.device.getEffectType(2)),n.dispatchEvent("efxinsert0",n.device.getEffectType(3)),n.dispatchEvent("efxinsert1",n.device.getEffectType(4)),n.dispatchEvent("efxinsert2",n.device.getEffectType(5)),n.dispatchEvent("efxinsert3",n.device.getEffectType(6))}switchMode(e,t=!1){this.device.switchMode(e,t)}getMode(){return this.device.getMode()}getVoice(){return this.device.getVoice(...arguments)}getChVoice(e){return this.device.getChVoice(e)}getMapped(e){return this.#h[e]||e}getEfx([e,t]){let n=e<<8|t;return this.#E[n]||`0x${n.toString(16).padStart(4,"0")}`}get noteProgress(){return this.#p/this.#s}get noteOverall(){return this.noteProgress-this.#l}get noteBar(){return Math.floor(this.noteOverall/this.#d)}get noteBeat(){let e=this.noteOverall%this.#d;return e<0&&(e+=this.#d),e}getTimeSig(){return[this.#d,this.#n]}getTempo(){return this.#e}sendCmd(e){this.device.runJson(e)}render(e){e>this.#p&&(this.#p=e);let t=this.#t?.step(e)||[],n=0,l=new Set,u=this,p=[];this.device.getStrength().forEach((b,y)=>{this.#u[y]=b}),u.device.newStrength(),t.forEach(function(b){let y=b.data;y.type==9&&(y.data[1]>0?l.add(y.part*128+y.data[0]):l.has(y.part*128+y.data[0])&&n++),b.data.type==8&&l.has(y.part*128+y.data[0])&&n++;let E=u.device.runJson(y);switch(E?.reply){case"meta":{p.push(E);break}}E?.reply&&delete E.reply}),p?.length>0&&this.dispatchEvent("meta",p);let h=this.device.getActive(),a=[],i=u.device.getPitch(),d=u.device.getCcAll(),s=u.device.getProgram(),r=u.device.getChType(),c=this.device.getStrength();c.forEach(function(b,y,E){E[y]=Math.max(u.#u[y],b);let $=E[y]-u.#w[y],x=g.length*y;if($>=0){let B=4*.25**(d[x+g[73]]/64);u.#w[y]+=Math.ceil($-$*u.smoothingAtk**B)}else{let B=4*.25**(d[x+g[72]]/64);u.#w[y]+=Math.floor($-$*u.smoothingDcy**B)}});let f=0;return h.forEach(function(b,y){b&&(a[y]=u.device.getVel(y),f+=a[y].size)}),{extraPoly:n,curPoly:f,chInUse:h,chKeyPr:a,chPitch:i,chProgr:s,chContr:d,chType:r,eventCount:t.length,title:this.#o,bitmap:this.device.getBitmap(),letter:this.device.getLetter(),texts:this.device.getTexts(),master:this.device.getMaster(),mode:this.device.getMode(),strength:this.#w.slice(),velo:c,rpn:this.device.getRpn(),tSig:this.getTimeSig(),tempo:this.getTempo(),noteBar:this.noteBar,noteBeat:this.noteBeat,ace:this.device.getAce(),efxSink:this.device.getEffectSink()}}constructor(e,t=.5,n=.5){super();let l=this;l.smoothingAtk=t,l.smoothingDcy=n,l.device=e,l.addEventListener("meta",function(u){u?.data?.forEach(function(p){(l.#m[p.meta]||console.debug).call(l,p.meta,p.data)})}),S(l.device,l,"mode"),S(l.device,l,"mastervolume"),S(l.device,l,"channelactive"),S(l.device,l,"channelmin"),S(l.device,l,"channelmax"),S(l.device,l,"channelreset"),S(l.device,l,"channeltoggle"),S(l.device,l,"screen"),S(l.device,l,"metacommit"),S(l.device,l,"voice"),S(l.device,l,"pitch"),S(l.device,l,"note"),S(l.device,l,"reset"),S(l.device,l,"efxreverb"),S(l.device,l,"efxchorus"),S(l.device,l,"efxdelay"),S(l.device,l,"efxinsert0"),S(l.device,l,"efxinsert1"),S(l.device,l,"efxinsert2"),S(l.device,l,"efxinsert3"),S(l.device,l,"partefxtoggle"),l.#m[3]=function(u,p){l.#o?.length<1&&(l.#o=p,l.dispatchEvent("title",l.#o))},l.#m[81]=function(u,p){let h=l.noteProgress,a=l.#s||.5;l.#e=6e7/p,l.#s=p/1e6,l.#l+=h*(a/l.#s)-h,l.dispatchEvent("tempo",l.#e)},l.#m[88]=function(u,p){let h=l.noteProgress,a=l.noteOverall,i=l.noteBar,d=l.noteBeat,s=l.#d,r=l.#n;l.#d=p[0],l.#n=1<=s&&(s{le&&(ce[K]=!ce[K],K++,K>34&&(K=0))},1e3/50);Uint8Array.prototype.render=function(e){let t=0,n=0,l=this.width||5,u=this.height||8;for(let p=0;p=l&&(t=0,n++)};var He=class{#t=[];async load(e,t=!1,n="(internal)"){let l=this,u=0,p=0;console.debug(`Font "${n||"(internal)"}": loading started.`),e.split(` -`).forEach(function(h,a){if(a>0&&h?.length>0){let i=h.split(" "),d=parseInt(i[0],16);if(p++,l.#t[d]&&!t)return;let s=new Uint8Array(40);Array.from(i[1]).forEach(async function(r,c){let f=c%2?4:0,o=Math.floor(c/2),b=parseInt(r,16),y=3;for(;b>0||y>=0;){let E=(f+y)*5+o;s[E]=b&1,b=b>>1,y--}}),l.#t[d]=s,u++}}),console.debug(`Font "${n||"(internal)"}": ${p} total, ${u} loaded.`)}async loadFile(e,t=!1){let n=this;console.debug(`Requested font file from "${e}".`),await n.load(await(await fetch(e)).text(),t,e),le=!1}constructor(...e){le=!0,(async()=>{for(let t=0;t{l.classList.add(s)});let{t:u,l:p,w:h,h:a,i,a:d}=n;return u?.constructor&&(l.style.top=u?.length?u:`${u}px`),p?.constructor&&(l.style.left=p?.length?p:`${p}px`),h?.constructor&&(l.style.width=h?.length?h:`${h}px`),a?.constructor&&(l.style.height=a?.length?a:`${a}px`),i?.constructor&&l.appendChild(document.createTextNode(i)),d?.constructor&&(l.style.textAlign=d),l},M=function(e,t){let n=document.createElementNS("http://www.w3.org/2000/svg",e);for(let l in t)n.setAttribute(l,t[l]);return n},T=function(e,t){t?.forEach(n=>{e.appendChild(n)})},L=function(e,t){t.forEach(n=>{e.classList.contains(n)&&e.classList.remove(n)})},U=function(e,t){t.forEach(n=>{e.classList.contains(n)||e.classList.add(n)})},Fe=new Array(128).fill(0);Fe.forEach((e,t,n)=>{n[t]=Math.floor(24*t/12.7)/10});var de=new Array(128).fill(0);de.forEach((e,t,n)=>{n[t]=Math.abs(Math.round(48*(t-64)/12.7)/10)});var Ke=new Array(11).fill(null);Ke.forEach((e,t,n)=>{n[t]=`${Math.round(t*12/.0128)/100}%`});var bt=new Array(128).fill(null);bt.forEach((e,t,n)=>{n[t]=`${Math.round(t/1.27)/100}`});var P=function(e,t){let n=Fe[t];e.setAttribute("height",n),e.setAttribute("y",24-n)},_e=function(e,t){e.innerText=t,e.rNew=!0;let n=e.measureText(t);e.rWidth=n.width},la=class extends Be{#t=128;#h=!1;#E="";#o;#m=0;#w=0;#u=0;#s=0;#e=1;#d=0;#n=new Uint8Array(1280);#l=new Uint8Array(1280);#p=new Uint8Array(1280);#b=new Uint8Array(512);#v=new Uint8Array(512);#D=new Uint8Array(512);#C;#H;#r;#i;#I;#x="fcdaff";#a={};#$={};#c=[];#y={};#S={};#T=[];#G=[];#O="block";glyphs=new He;#M(e,t,n,l=0,u=0){let p=this,{width:h,height:a}=e.canvas,i,d,s,r,c=p.#e,f=l>3,o=dt.indexOf(t%12)>-1;switch(p.#O){case"block":case"comb":{i=Math.round(t*h/128),d=Math.round((t+1)*h/128),s=d-i,r=c==1?2:1;break}case"piano":{i=Math.round((Math.floor(t/12)*7+Ge[t%12])*h/75*1.0044642857142856),d=Math.round((Math.floor(t/12)*7+Ge[t%12]+1)*h/75*1.0044642857142856)-1,s=d-i,r=c==1?3:1;break}case"line":{let b=t-u;Math.abs(u)>2&&(b=t-Math.sign(u)*2),d=Math.round((t+.5)*h/128),i=Math.round((b+.5)*h/128)}default:}switch(e.fillStyle=`#${o?p.#x:"ffffff"}${(n<<1|n>>6).toString(16).padStart(2,"0")}`,e.strokeStyle=e.fillStyle,e.lineWidth=c==1?4:2,e.lineDashOffset=0,p.#O){case"block":{let b=e.canvas.height-1;e.fillRect(i,1,s,b),f&&e.clearRect(i+r,r+1,s-(r<<1),b-(r<<1));break}case"comb":{let b=(o?Math.round((e.canvas.height<<1)/3):e.canvas.height)-1;e.fillRect(i,1,s,b),f&&e.clearRect(i+r,r+1,s-(r<<1),b-(r<<1));break}case"piano":{let b=(o?0:e.canvas.height>>1)+1,y=(e.canvas.height>>1)-1;e.fillRect(i,b,s,y),f&&e.clearRect(i+r,b+r,s-(r<<1),y-(r<<1));break}case"line":{if(f)switch(c){case 4:{e.setLineDash(oe[2]);break}default:e.setLineDash(oe[1])}else e.setLineDash(oe[0]),c!=4&&self?.document?.mozFullScreen&&(i+=.5,d+=.5);e.beginPath(),e.moveTo(i,(c==4||!f)&&self?.document?.mozFullScreen?2:1),e.lineTo(d,(a>>1)+2),e.lineTo(i,a+2),e.stroke();break}default:}}#f(e,t){let n=this;(e?.chInUse||t).forEach((l,u)=>{if(l){let p=n.#c[u>>4][u&15].cxt;p.clearRect(0,0,p.canvas.width,p.canvas.height),e.chKeyPr[u].forEach(({v:h,s:a},i)=>{n.#M(p,i,h,a,n.device.getPitchShift(u))})}})}#X(e){let t=this;Date.now()-t.#m>4e3&&(t.#w=0,t.#u=142-t.#y.view.clientHeight,(t.#o?.clientWidth||0)>840&&(t.#w=840-t.#o.clientWidth),t.#y.view.style.transform=`translateX(${t.#w}px) translateY(${t.#u}px)`,e&&(t.#m=0))}#z(){let e=self.innerWidth/self.innerHeight,t=1,n=self.innerWidth,l=self.innerHeight;e>=W?(t=Math.round(self.innerHeight/1080*1e4)/1e4,n=Math.ceil(self.innerHeight*W)):e>4,f=r*m.cc,o=e.#c[c][r&15];if(n.chInUse[r]&&c>=e.#d&&co.metre.canvas.width){o.metre.rNew&&(o.metre.rNew=!1,o.metre.rOffset=t);let y=t-(o.metre.rOffset||0),E=32,$=o.metre.rWidth-o.metre.canvas.width+E,x=y*-25%(o.metre.rWidth+E+48)+48;x>0&&(x=0),o.metre.fillText(o.metre.innerText,x,3+e.#I.font4[0]),Math.abs(x)>$&&o.metre.fillText(o.metre.innerText,x+o.metre.rWidth+E,3+e.#I.font4[0])}else o.metre.fillText(o.metre.innerText,0,3+e.#I.font4[0]);o.metre.globalCompositeOperation="xor",o.metre.fillRect(0,0,n.strength[r]*121/255,25);let b=n.chContr[f+g[10]];o.pan.setAttribute("width",`${de[b]||0}`),b<64?o.pan.setAttribute("x",`${84-de[b]}`):b>127?(o.pan.setAttribute("x","60"),o.pan.setAttribute("width","48")):o.pan.setAttribute("x","84")}}let h=new Set,a=new Set,i=new Array(m.ch),d={};if(e.#c.forEach((r,c)=>{r.forEach((f,o)=>{f.refresh&&(f.refresh=!1,i[c<<7|o]=!0)})}),["line"].indexOf(e.#O)>-1)for(;e.#G.length>0;){let r=e.#G.shift();i[r.part]=!0}for(;e.#T.length>0;){let r=e.#T.shift(),{part:c,note:f,velo:o,state:b}=r,y=c<<7|f;i[c]=!0,b==0?h.has(y)&&(a.add(y),e.#c[c>>4][c&15].refresh=!0):(h.add(y),d[y]=r)}e.#f(n,i),a.forEach(r=>{let{part:c,note:f,velo:o,state:b}=d[r],y=e.#c[c>>4][c&15].cxt;e.#M(y,f,o,b,e.device.getPitchShift(c))});let s=e.#S.cxt;l>n.bitmap.expire?e.#D.fill(0):n.bitmap.bitmap.length>256?n.bitmap.bitmap.forEach((r,c)=>{e.#D[c]=r?255:0}):n.bitmap.bitmap.forEach((r,c)=>{e.#D[c<<1]=r?255:0,e.#D[c<<1|1]=r?255:0}),e.#p.fill(0),l<=n.letter.expire&&e.glyphs.getStr(n.letter.text).forEach((r,c)=>{let f=(c&15)*5,o=c>>4<<3;r.forEach((b,y)=>{let E=f+y%5,$=o+Math.floor(y/5);e.#p[$*80+E]=b?255:0})}),e.#b.forEach((r,c,f)=>{let o=e.#D[c];o>r?f[c]+=Math.min(o-r,Q):o{let o=e.#p[c];o>r?f[c]+=Math.min(o-r,Q):o{let f=c>>5,o=c&31;e.#v[c]!=r?(s.clearRect(252+(o<<2),f<<2,3,3),r&&(s.fillStyle=`#ffffff${r.toString(16).padStart(2,"0")}`,s.fillRect(252+(o<<2),f<<2,3,3))):self.debugMode&&(s.clearRect(252+(o<<2),f<<2,3,3),r&&(s.fillStyle=`#ff0000${r.toString(16).padStart(2,"0")}`,s.fillRect(252+(o<<2),f<<2,3,3)))}),e.#n.forEach((r,c)=>{let f=Math.floor(c/80),o=c%80;o+=Math.floor(o/5),e.#l[c]!=r?(s.clearRect(o<<2,(f|16)<<2,3,3),r&&(s.fillStyle=`#ffffff${r.toString(16).padStart(2,"0")}`,s.fillRect(o<<2,(f|16)<<2,3,3))):self.debugMode&&(s.clearRect(o<<2,(f|16)<<2,3,3),r&&(s.fillStyle=`#ff0000${r.toString(16).padStart(2,"0")}`,s.fillRect(o<<2,(f|16)<<2,3,3)))}),e.#v.forEach((r,c,f)=>{f[c]=e.#b[c]}),e.#l.forEach((r,c,f)=>{f[c]=e.#n[c]})}#N;#q;get style(){return this.#O}set style(e){let t=this;t.#O=e,t.#f(t.render(t.#C?.currentTime||0)),L(t.#i,["cambiare-style-block","cambiare-style-comb","cambiare-style-piano","cambiare-style-line"]),U(t.#i,[`cambiare-style-${e}`])}setClockSource(e){this.#C=e}setPixelProfile(e){let t=this;if(Xe[e]){let n=Xe[e];t.#I=n,t.#i&&(t.#i.style.setProperty("--pcp-font4",`translate(${n.font4[1]}px, ${n.font4[0]}px)`),t.#i.style.setProperty("--pcp-font7",`translate(${n.font7[1]}px, ${n.font7[0]}px)`))}else throw new Error(`"${e}" is not a valid pixel correction profile`)}setMode(e){let t=this;L(t.#i,["cambiare-mode-gm","cambiare-mode-xg","cambiare-mode-gs","cambiare-mode-ns5r","cambiare-mode-05rw","cambiare-mode-x5d","cambiare-mode-k11","cambiare-mode-sg","cambiare-mode-g2","cambiare-mode-mt32","cambiare-mode-sd","cambiare-mode-krs","cambiare-mode-s90es","cambiare-mode-motif"]),e!="?"&&U(t.#i,[`cambiare-mode-${e}`]),t.#x={xg:"9efaa0",ns5r:"9efaa0",x5d:"9efaa0","05rw":"9efaa0",k11:"9efaa0",s90es:"9efaa0",motif:"9efaa0",gm:"a1f3ff",g2:"a1f3ff",krs:"a1f3ff",gs:"ffe1a5",mt32:"ffe1a5",sd:"ffe1a5",sg:"ffdddd"}[e]||"fcdaff"}#F(e){let t=this,n=t.#e,l=t.#d;t.#c.forEach((u,p)=>{if(p>=l&&p{d.root.style.top=`${s*(n>2?26:52)}px`})}else L(u.root,["port-active"]),u.root.style.top="",u.root.style.left="",u.forEach((h,a)=>{h.root.style.top=""});e&&u.forEach((h,a)=>{h.cxt.canvas.width=t.#e==1?1193:495,h.cxt.canvas.height=t.#e==4?26:52})})}setPort(e){let t=this;L(t.#i,["cambiare-start0","cambiare-start1","cambiare-start2","cambiare-start3","cambiare-start4","cambiare-start5","cambiare-start6","cambiare-start7"]),U(t.#i,[`cambiare-start${e}`]),t.#d=e,t.#F(!1)}setRange(e){let t=this;L(t.#i,["cambiare-port1","cambiare-port2","cambiare-port4","cambiare-compact"]),U(t.#i,[`cambiare-${e}`]),t.#e=parseInt(e.slice(4))||1,t.#F(!0)}attach(e){let t=this;t.#H=e;let n=v("div",["cambiare-container"]);e.appendChild(n),t.#r=n;let l=v("div",["cambiare-canvas","cambiare-port1","cambiare-start0","cambiare-style-block"]);n.appendChild(l),t.#i=l,self.addEventListener("resize",t.#U),t.#U(),t.#q=setInterval(t.#N,20),t.#a.root=v("div",["sect-info"]),t.#a.events=v("span",["field","pcp-font4"],{t:1,l:0,w:35,h:33}),t.#a.curPoly=v("span",["field","pcp-font4"],{t:1,l:52,w:35,h:33}),t.#a.maxPoly=v("span",["field","pcp-font4"],{t:1,l:98,w:35,h:33}),t.#a.sigN=v("span",["field","pcp-font4"],{t:1,l:194,w:23,h:33,a:"right"}),t.#a.sigD=v("span",["field","pcp-font4"],{t:1,l:232,w:23,h:33}),t.#a.barCount=v("span",["field","pcp-font4"],{t:1,l:304,w:35,h:33,a:"right"}),t.#a.barNote=v("span",["field","pcp-font4"],{t:1,l:354,w:23,h:33}),t.#a.tempo=v("span",["field","pcp-font4"],{t:1,l:454,w:64,h:33,a:"right"}),t.#a.volume=v("span",["field","pcp-font4"],{t:1,l:562,w:63,h:33,a:"right"}),t.#a.mode=v("span",["field","pcp-font4"],{t:1,l:708,w:152,h:33}),t.#a.reverb=v("span",["field","pcp-font4"],{t:1,l:1e3,w:190,h:33}),t.#a.chorus=v("span",["field","pcp-font4"],{t:1,l:1240,w:190,h:33}),t.#a.delay=v("span",["field","pcp-font4"],{t:1,l:1475,w:190,h:33}),t.#a.insert=v("span",["field","pcp-font4"],{t:1,l:1706,w:190,h:33}),t.#a.title=v("span",["field","pcp-font4"],{t:35,l:50,w:810,h:33}),l.appendChild(t.#a.root),T(t.#a.root,[t.#a.events,t.#a.curPoly,v("span",["field","field-label","pcp-font4"],{t:1,l:89,w:5,h:33,i:":"}),t.#a.maxPoly,v("span",["field","field-key","pcp-font7"],{t:1,l:148,w:41,h:33,i:"TSig"}),t.#a.sigN,v("span",["field","field-label","pcp-font4"],{t:0,l:221,w:8,h:33,i:"/"}),t.#a.sigD,v("span",["field","field-key","pcp-font7"],{t:1,l:268,w:30,h:33,i:"Bar"}),t.#a.barCount,v("span",["field","field-label","pcp-font4"],{t:0,l:343,w:8,h:33,i:"/"}),t.#a.barNote,v("span",["field","field-key","pcp-font7"],{t:1,l:390,w:61,h:33,i:"Tempo",a:"right"}),t.#a.tempo,v("span",["field","field-key","pcp-font7"],{t:1,l:528,w:29,h:33,i:"Vol"}),t.#a.volume,v("span",["field","field-label","pcp-font4"],{t:1,l:626,w:17,h:33,i:"%"}),v("span",["field","field-key","pcp-font7"],{t:1,l:652,w:52,h:33,i:"Mode"}),t.#a.mode,v("span",["field","field-key","pcp-font7"],{t:1,l:960,w:34,h:33,i:"Rev"}),t.#a.reverb,v("span",["field","field-key","pcp-font7"],{t:1,l:1198,w:36,h:33,i:"Cho"}),t.#a.chorus,v("span",["field","field-key","pcp-font7"],{t:1,l:1438,w:31,h:33,i:"Var"}),t.#a.delay,v("span",["field","field-key","pcp-font7"],{t:1,l:1673,w:27,h:33,i:"Ins"}),t.#a.insert,v("span",["field","field-key","pcp-font7"],{t:35,l:0,w:44,h:33,i:"Title"}),t.#a.title]),t.#$.root=v("div",["sect-mark"]),t.#$.left=v("div",["sect-mark-left","boundary"],{t:0,l:0}),t.#$.right=v("div",["sect-mark-right","boundary"],{t:0,l:960}),l.appendChild(t.#$.root),T(t.#$.root,[t.#$.left,t.#$.right]),T(t.#$.left,[v("span",["field","field-key"],{t:0,l:0,w:26,h:33,i:"CH"}),v("span",["field","field-key"],{t:0,l:30,w:49,h:33,i:"Voice"}),v("span",["field","field-key","mark-send-title"],{t:2,l:164,w:25,h:18,i:"Send"}),v("span",["field","field-label","mark-send-param"],{t:16,l:146,w:58,h:16,i:"VEMRCDBP12",a:"center"}),v("span",["field","field-key"],{t:0,l:212,w:35,h:33,i:"Pan"}),v("span",["field","field-key"],{t:0,l:256,w:45,h:33,i:"Note"})]),T(t.#$.right,[v("span",["field","field-key"],{t:0,l:0,w:26,h:33,i:"CH"}),v("span",["field","field-key"],{t:0,l:30,w:49,h:33,i:"Voice"}),v("span",["field","field-key","mark-send-title"],{t:2,l:164,w:25,h:18,i:"Send"}),v("span",["field","field-label","mark-send-param"],{t:16,l:146,w:58,h:16,i:"VEMRCDBP12",a:"center"}),v("span",["field","field-key"],{t:0,l:212,w:35,h:33,i:"Pan"}),v("span",["field","field-key"],{t:0,l:256,w:45,h:33,i:"Note"})]),t.#c.root=v("div",["sect-part"]);for(let u=0;u>4;u++){let p=u<<4;t.#c[u]=[],t.#c[u].root=v("div",["boundary",`part-port-${u}`]);for(let h=0;h<16;h++){let a=(p|h)+1;a>=100?a=`${Math.floor(a/10).toString(16)}${a%10}`:a=`${a}`.padStart(2,"0"),t.#c[u][h]={root:v("div",["boundary","part-channel"]),major:v("div",["boundary","part-info-major"]),minor:v("div",["boundary","part-info-minor"],{t:26}),keys:v("div",["boundary","part-keys"]),notes:v("div",["boundary","part-keyboard"]),cxt:v("canvas",["field"]).getContext("2d"),number:v("span",["field","field-label","pcp-font4"],{t:1,w:18,h:25,i:a}),voice:v("span",["field"],{l:22,t:1,w:121,h:25}),metre:v("canvas",["field"]).getContext("2d"),type:v("span",["field","field-label","pcp-font4"],{t:1,w:18,h:25}),std:v("span",["field","pcp-font4"],{l:22,t:1,w:20,h:25,a:"center"}),msb:v("span",["field","pcp-font4"],{l:48,t:1,w:27,h:25}),prg:v("span",["field","pcp-font4"],{l:81,t:1,w:27,h:25}),lsb:v("span",["field","pcp-font4"],{l:114,t:1,w:27,h:25}),cc:M("svg",{viewBox:"0 0 108 24",width:108,style:"left: 146px; top: 1px; position: absolute;"}),vol:M("rect",{fill:"var(--accent-color)",width:4,height:24,x:0}),exp:M("rect",{fill:"var(--accent-color)",width:4,height:24,x:6}),mod:M("rect",{fill:"var(--accent-color)",width:4,height:24,x:12}),rev:M("rect",{fill:"var(--accent-color)",width:4,height:24,x:18}),cho:M("rect",{fill:"var(--accent-color)",width:4,height:24,x:24}),var:M("rect",{fill:"var(--accent-color)",width:4,height:24,x:30}),brt:M("rect",{fill:"var(--accent-color)",width:4,height:24,x:36}),por:M("rect",{fill:"var(--accent-color)",width:4,height:24,x:42}),cea:M("rect",{fill:"var(--accent-color)",width:4,height:24,x:48}),ceb:M("rect",{fill:"var(--accent-color)",width:4,height:24,x:54}),pan:M("rect",{fill:"var(--accent-color)",width:0,height:24,x:84})};let i=t.#c[u][h];Ke.forEach(d=>{i.notes.appendChild(v("span",["field","part-csplit"],{l:d}))}),i.notes.appendChild(v("span",["field","part-csplit","part-cdive"],{l:0,w:"100%",h:1})),i.metre.canvas.width=121,i.metre.canvas.height=25,i.metre.fillStyle="#fff",i.metre.textBaseline="top",i.metre.font="20px 'PT Sans Narrow'",T(i.notes,[i.cxt.canvas]),T(i.keys,[i.notes]),T(i.voice,[i.metre.canvas]),T(i.cc,[i.vol,i.exp,i.mod,i.rev,i.cho,i.var,i.brt,i.por,i.cea,i.ceb,i.pan,M("rect",{x:83,y:0,width:1,height:24,fill:"var(--foreground-color)"})]),T(i.major,[i.number,i.voice,i.cc]),T(i.minor,[i.type,i.std,i.msb,i.prg,i.lsb]),T(i.root,[i.major,i.minor,i.keys]),T(t.#c[u].root,[i.root])}t.#c.root.appendChild(t.#c[u].root)}l.appendChild(t.#c.root),t.#y.root=v("div",["sect-meta"]),t.#y.view=v("div",["boundary"]),l.appendChild(t.#y.root),T(t.#y.root,[t.#y.view]),t.#S.root=v("div",["sect-pix","boundary"],{l:1529,t:950,w:379,h:127}),t.#S.cxt=v("canvas",["field"]).getContext("2d"),t.#S.cxt.canvas.width=379,t.#S.cxt.canvas.height=127,T(t.#S.root,[t.#S.cxt.canvas]),l.appendChild(t.#S.root),t.addEventListener("mode",u=>{t.#a.mode.innerText=`${ft[u.data]}`,t.setMode(u.data)}),t.addEventListener("mastervolume",u=>{let p=Math.round(u.data*100)/100;t.#a.volume.innerText=`${Math.floor(p)}.${`${Math.floor(p%1*100)}`.padStart(2,"0")}`}),t.addEventListener("tempo",u=>{let p=Math.round(u.data*100);t.#a.tempo.innerText=`${Math.floor(p/100)}.${`${Math.floor(p%100)}`.padStart(2,"0")}`}),t.addEventListener("tsig",u=>{[t.#a.sigN.innerText,t.#a.sigD.innerText]=u.data}),t.addEventListener("title",u=>{t.#a.title.innerText=u.data||"No Title"}),t.addEventListener("voice",({data:u})=>{let p=t.getChVoice(u.part),h=t.#c[u.part>>4][u.part&15];_e(h.metre,t.getMapped(p.name)),h.type.innerText=ot[t.device.getChType()[u.part]],h.std.innerText=p.standard,h.msb.innerText=`${p.sid[0]}`.padStart(3,"0"),h.prg.innerText=`${p.sid[1]}`.padStart(3,"0"),h.lsb.innerText=`${p.sid[2]}`.padStart(3,"0")}),t.addEventListener("pitch",u=>{let{part:p,pitch:h}=u.data;t.#c[p>>4][p&15].notes.style.transform=`translateX(${h/1.28}%)`}),t.addEventListener("efxreverb",u=>{t.#a.reverb.innerText=t.getEfx(u.data)}),t.addEventListener("efxchorus",u=>{t.#a.chorus.innerText=t.getEfx(u.data)}),t.addEventListener("efxdelay",u=>{t.#a.delay.innerText=t.getEfx(u.data)}),t.addEventListener("efxinsert0",u=>{t.#a.insert.innerText=t.getEfx(u.data)}),t.addEventListener("partefxtoggle",u=>{let{part:p,active:h}=u.data;[L,U][h](t.#c[p>>4][p&15].number,["part-efx"])}),t.addEventListener("channeltoggle",u=>{let{part:p,active:h}=u.data;[L,U][h](t.#c[p>>4][p&15].root,["part-active"])}),t.addEventListener("metacommit",u=>{let p=u.data;if(t.#h&&p.type==t.#E&&t.#o)switch(p.type){case"C.Lyrics":case"KarLyric":case"SGLyrics":{T(t.#o,[v("span",["meta-slice"],{i:p.data})]);break}default:t.#o.childNodes[0].data+=p.data}else if(p.data?.length&&ut.indexOf(p.type)==-1){let h=v("div",["meta-line"]),a=v("span",["field","field-key","meta-type"],{i:ht[p.type]||p.type});switch(p.mask&&(a.style.display="none"),p.type){case"C.Lyrics":case"KarLyric":case"SGLyrics":{t.#o=v("span",["field","meta-data"]),T(t.#o,[v("span",["meta-slice"],{i:p.data})]);break}default:t.#o=v("span",["field","meta-data"],{i:p.data})}for(t.#y.view.appendChild(h),T(h,[a,t.#o]);t.#y.view.children.length>t.#t;)t.#y.view.children[0].remove()}t.#h=p.amend||!1,t.#E=p.type||"",t.#X()}),t.#y.view.style.transform="translateX(0px) translateY(140px)",t.dispatchEvent("mode","?"),t.dispatchEvent("mastervolume",100),t.dispatchEvent("tempo",120),t.dispatchEvent("tsig",[4,4]),t.dispatchEvent("title",""),t.dispatchEvent("efxreverb",t.device.getEffectType(0)),t.dispatchEvent("efxchorus",t.device.getEffectType(1)),t.dispatchEvent("efxdelay",t.device.getEffectType(2)),t.dispatchEvent("efxinsert0",t.device.getEffectType(3)),t.#F(!0)}detach(e){let t=this;self.removeEventListener("resize",t.#U),t.#i.remove(),t.#i=void 0,t.#r.remove(),t.#r=void 0,t.#H=void 0,clearInterval(t.#q)}constructor(e,t){super(new Ae,.1,.75);let n=this;n.#U=n.#z.bind(this),n.#N=n.#_.bind(this),e&&n.attach(e),t&&n.setClockSource(t),n.setPixelProfile("none"),n.addEventListener("reset",()=>{n.#s=0,n.#h=!1,n.#E="",n.#o=null;try{let l=n.#y.view.children;for(let u=l.length-1;u>=0;u--)l[u].remove();n.#y.view.style.transform="translateX(0px) translateY(140px)";for(let u=0;u>4][u&15];L(p.root,["part-active"]),L(p.number,["part-efx"]),_e(p.metre,""),p.type.innerText="",p.std.innerText="",p.msb.innerText="",p.prg.innerText="",p.lsb.innerText="",p.notes.style.transform=""}}catch{}}),n.addEventListener("note",({data:l})=>{n.#T.push(l)}),n.addEventListener("pitch",({data:l})=>{n.#G.push(l)})}};export{la as Cambiare}; +`),r.slice(0,2)){case"@I":{this.#g=!0,this.dispatchEvent("metacommit",{type:"Kar.Info",data:r.slice(2)?.trimLeft()});break}case"@K":{this.#g=!0,this.dispatchEvent("metacommit",{type:"Kar.Mode",data:r.slice(2)?.trimLeft()}),console.debug(`Karaoke mode active: ${r.slice(2)}`);break}case"@L":{this.#g=!0,this.dispatchEvent("metacommit",{type:"Kar.Lang",data:r.slice(2)?.trimLeft()});break}case"@T":{this.#g=!0,this.dispatchEvent("metacommit",{type:"KarTitle",data:r.slice(2)?.trimLeft()});break}case"@V":{this.#g=!0,this.dispatchEvent("metacommit",{type:"Kar.Ver.",data:r.slice(2)?.trimLeft()});break}case"XF":{let i=r.slice(2).split(":");switch(i[0]){case"hd":{i.slice(1).forEach((n,s)=>{n.length&&this.dispatchEvent("metacommit",{type:["XfSngDte","XfSngRgn","XfSngCat","XfSongBt","XfSngIns","XfSngVoc","XfSngCmp","XfSngLrc","XfSngArr","XfSngPer","XfSngPrg","XfSngTag"][s],data:n})});break}case"ln":{i.slice(1).forEach((n,s)=>{n.length&&this.dispatchEvent("metacommit",{type:["XfKarLng","XfKarNme","XfKarCmp","XfKarLrc","XfKarArr","XfKarPer","XfKarPrg"][s],data:n})});break}default:this.dispatchEvent("metacommit",{type:"XfUnData",data:r})}break}default:this.#g?r[0]=="\\"?(this.dispatchEvent("metacommit",{type:"KarLyric",data:"",amend:!1}),this.dispatchEvent("metacommit",{type:"KarLyric",data:r.slice(1),amend:!0})):r[0]=="/"?(this.dispatchEvent("metacommit",{type:"KarLyric",data:"",mask:!0,amend:!1}),this.dispatchEvent("metacommit",{type:"KarLyric",data:r.slice(1),mask:!0,amend:!0})):this.dispatchEvent("metacommit",{type:"KarLyric",data:r,amend:!0}):r.split(` +`).forEach((i,n)=>{this.dispatchEvent("metacommit",{type:"Cmn.Text",data:i,mask:n!=0})})}},this.#R[2]=function(r){this.dispatchEvent("metacommit",{type:"Copyrite",data:r})},this.#R[3]=function(r,i){i<1&&this.#X<1&&this.dispatchEvent("metacommit",{type:"TrkTitle",data:r})},this.#R[4]=function(r,i){this.dispatchEvent("metacommit",{type:"Instrmnt",data:r})},this.#R[5]=function(r){r.trim()==""?this.dispatchEvent("metacommit",{type:"C.Lyrics",data:"",amend:!1}):this.dispatchEvent("metacommit",{type:"C.Lyrics",data:r,amend:!0})},this.#R[6]=function(r){this.dispatchEvent("metacommit",{type:"C.Marker",data:r})},this.#R[7]=function(r){this.dispatchEvent("metacommit",{type:"CuePoint",data:r})},this.#R[32]=function(r){this.#X=r[0]+1},this.#R[33]=function(r,i){e.#W[i]=r+1},this.#R[81]=function(r,i){e.#z=r/1e3},this.#R[127]=function(r,i){e.#Q.run(r,i)},this.#Q.default=function(r){console.warn(`Unrecognized sequencer-specific byte sequence: ${r}`)},this.#Q.add([67,0,1],function(r,i){e.#W[i]=r[0]+1}),this.#Y=new D("universal non-realtime"),this.#j=new D("universal realtime"),this.#A=new D("Yamaha"),this.#L=new D("Roland"),this.#K=new D("Korg"),this.#Z=new D("Kawai"),this.#J=new D("Akai"),this.#ee=new D("Casio");let t=function(r){console.info(`Unrecognized SysEx in "${this.name}" set. +%o`,r)};this.#Y.default=t,this.#j.default=t,this.#A.default=t,this.#L.default=t,this.#K.default=t,this.#Z.default=t,this.#J.default=t,this.#ee.default=t,this.#Y.add([9],r=>{e.switchMode(["gm","?","g2"][r[0]-1],!0),e.#g=e.#g||!1,console.info(`MIDI reset: ${["GM","Init","GM2"][r[0]-1]}`),r[0]==2&&e.init()}),this.#j.add([4,1],r=>{e.#f=((r[1]<<7)+r[0])/16383*100,e.dispatchEvent("mastervolume",e.#f)}).add([4,3],r=>((r[1]<<7)+r[0]-8192)/8192).add([4,4],r=>r[1]-64),this.#A.add([76,0,0],r=>{switch(r[0]){case 125:{e.initDrums(),console.info(`XG drum setup reset: ${r}`);break}case 126:{e.switchMode("xg",!0),e.#g=!1,console.info("MIDI reset: XG");break}default:{let i=[0,0,0,0],n=(s,a)=>{i[a]=s};if(r.subarray(1).forEach((s,a)=>{let l=a+r[0];([n,n,n,n,f=>{this.#f=f*129/16383*100,e.dispatchEvent("mastervolume",e.#f)},f=>{},f=>{}][l]||(()=>{}))(s,a)}),r[0]<4){let s=0;i.forEach(a=>{s=s<<4,s+=a}),s-=1024}}}}).add([76,2,1],r=>{let i="XG ";r[0]<32?(i+="reverb ",r.subarray(1).forEach((n,s)=>{([a=>{e.setEffectTypeRaw(0,!1,a),console.info(`${i}main type: ${G[a]}`),e.dispatchEvent("efxreverb",e.getEffectType(0))},a=>{e.setEffectTypeRaw(0,!0,a),console.debug(`${i}sub type: ${a+1}`),e.dispatchEvent("efxreverb",e.getEffectType(0))},a=>{console.debug(`${i}time: ${ge(a)}s`)},a=>{console.debug(`${i}diffusion: ${a}`)},a=>{console.debug(`${i}initial delay: ${a}`)},a=>{console.debug(`${i}HPF cutoff: ${B[a]}Hz`)},a=>{console.debug(`${i}LPF cutoff: ${B[a]}Hz`)},a=>{console.debug(`${i}width: ${a}`)},a=>{console.debug(`${i}height: ${a}`)},a=>{console.debug(`${i}depth: ${a}`)},a=>{console.debug(`${i}wall type: ${a}`)},a=>{console.debug(`${i}dry/wet: ${a}`)},a=>{console.debug(`${i}send: ${C(a)}dB`)},a=>{console.debug(`${i}pan: ${a-64}`)},!1,!1,a=>{console.debug(`${i}delay: ${a}`)},a=>{console.debug(`${i}density: ${a}`)},a=>{console.debug(`${i}balance: ${a}`)},a=>{},a=>{console.debug(`${i}feedback: ${a}`)},a=>{}][r[0]+s]||function(){console.warn(`Unknown XG reverb address: ${r[0]}.`)})(n)})):r[0]<64?(i+="chorus ",r.subarray(1).forEach((n,s)=>{([a=>{e.setEffectTypeRaw(1,!1,a),console.info(`${i}main type: ${G[a]}`),e.dispatchEvent("efxchorus",e.getEffectType(1))},a=>{e.setEffectTypeRaw(1,!0,a),console.debug(`${i}sub type: ${a+1}`),e.dispatchEvent("efxchorus",e.getEffectType(1))},a=>{console.debug(`${i}LFO: ${be[a]}Hz`)},a=>{},a=>{console.debug(`${i}feedback: ${a}`)},a=>{console.debug(`${i}delay offset: ${me(a)}ms`)},a=>{},a=>{console.debug(`${i}low: ${B[a]}Hz`)},a=>{console.debug(`${i}low: ${a-64}dB`)},a=>{console.debug(`${i}high: ${B[a]}Hz`)},a=>{console.debug(`${i}high: ${a-64}dB`)},a=>{console.debug(`${i}dry/wet: ${a}`)},a=>{console.debug(`${i}send: ${C(a)}dB`)},a=>{console.debug(`${i}pan: ${a-64}`)},a=>{console.debug(`${i}to reverb: ${C(a)}dB`)},!1,a=>{},a=>{},a=>{},a=>{console.debug(`${i}LFO phase diff: ${(a-64)*3}deg`)},a=>{console.debug(`${i}input mode: ${a?"stereo":"mono"}`)},a=>{}][r[0]-32+s]||function(){console.warn(`Unknown XG chorus address: ${r[0]}.`)})(n)})):r[0]<86?(i+="variation ",r.subarray(1).forEach((n,s)=>{([a=>{e.setEffectTypeRaw(2,!1,a),console.info(`${i}main type: ${G[a]}`),e.dispatchEvent("efxdelay",e.getEffectType(2))},a=>{e.setEffectTypeRaw(2,!0,a),console.debug(`${i}sub type: ${a+1}`),e.dispatchEvent("efxdelay",e.getEffectType(2))}][r[0]-64+s]||function(){})(n)})):r[0]<97?(i+="variation ",r.subarray(1).forEach((n,s)=>{[a=>{console.debug(`${i}send: ${C(a)}dB`)},a=>{console.debug(`${i}pan: ${a-64}`)},a=>{console.debug(`${i}to reverb: ${C(a)}dB`)},a=>{console.debug(`${i}to chorus: ${C(a)}dB`)},a=>{console.debug(`${i}connection: ${a?"system":"insertion"}`)},a=>{console.debug(`${i}channel: CH${a+1}`)},a=>{console.debug(`${i}mod wheel: ${a-64}`)},a=>{console.debug(`${i}bend wheel: ${a-64}`)},a=>{console.debug(`${i}channel after touch: ${a-64}`)},a=>{console.debug(`${i}AC1: ${a-64}`)},a=>{console.debug(`${i}AC2: ${a-64}`)}][r[0]-86+s](n)})):r[0]>111&&r[0]<118?i+="variation ":console.warn(`Unknown XG variation address: ${r[0]}`)}).add([76,2,64],r=>{r.subarray(1).forEach((i,n)=>{let s=n+r[0];if(s==0)console.debug(`XG EQ preset: ${["flat","jazz","pop","rock","classic"][i]}`);else{let a=s-1>>2,l=s-1&3,f=`XG EQ ${a} ${["gain","freq","Q","shape"][l]}: `;[()=>{console.debug(`${f}${i-64}dB`)},()=>{console.debug(`${f}${i} (raw)`)},()=>{console.debug(`${f}${i/10}`)},()=>{console.debug(`${f}${["shelf","peak"][+!!i]}`)}][l]()}})}).add([76,3],r=>{let i=r[0],n=r[1],s=`XG Insertion ${r[0]+1} `;r.subarray(2).forEach((a,l)=>{([f=>{e.setEffectTypeRaw(3+i,!1,f),console.info(`${s}main type: ${G[f]}`),e.dispatchEvent(`efxinsert${i}`,e.getEffectType(3+i))},f=>{e.setEffectTypeRaw(3+i,!0,f),console.debug(`${s}sub type: ${f+1}`),e.dispatchEvent(`efxinsert${i}`,e.getEffectType(3+i))}][n+l]||function(){})(a)})}).add([76,6,0],r=>{let i=r[0];i<64?e.setLetterDisplay(r.subarray(1),"XG letter display",i):e.#N=Date.now()}).add([76,7,0],r=>{let i=r[0];e.#h=0,e.#E=Date.now()+3200,e.#m.fill(0);let n=r.subarray(1);for(let s=0;s>6-g&1,g++})}).add([76,8],(r,i)=>{let n=e.chRedir(r[0],i,!0),s=r[1],a=y.cc*n,l=`XG CH${n+1} `,f=`Unknown XG part address ${s}.`;r.subarray(2).forEach((d,p)=>{s<1?console.debug(f):s<41?([()=>{e.#e[a+b[0]]=d,e.dispatchEvent("voice",{part:n})},()=>{e.#e[a+b[32]]=d,e.dispatchEvent("voice",{part:n})},()=>{e.#n[n]=d,e.dispatchEvent("voice",{part:n})},()=>{let g=e.chRedir(d,i,!0);e.#u[n]=g,n!=g&&(e.buildRchTree(),console.info(`${l}receives from CH${g+1}`))},()=>{e.#p[n]=+!d},()=>{},()=>{e.setChType(n,d,w.xg),console.debug(`${l}type: ${X[d]||d}`)},()=>{e.#r[y.rpn*n+3]=d,e.#i[y.rpnt*n+2]=1},!1,!1,()=>{e.#e[a+b[7]]=d},!1,!1,()=>{e.#e[a+b[10]]=d||128},!1,!1,()=>{e.#e[a+b[128]]=d},()=>{e.#e[a+b[93]]=d},()=>{e.#e[a+b[91]]=d},()=>{e.#e[a+b[94]]=d},()=>{e.#e[a+b[76]]=d},()=>{e.#e[a+b[77]]=d},()=>{e.#e[a+b[78]]=d},()=>{e.#e[a+b[74]]=d},()=>{e.#e[a+b[71]]=d},()=>{e.#e[a+b[73]]=d},()=>{e.#e[a+b[75]]=d},()=>{e.#e[a+b[72]]=d}][s+p-1]||(()=>{}))():s<48?console.debug(f):s<111?s>102&&s<105&&(e.#e[a+b[[5,65][s&1]]]=d):s<114?console.debug(f):s<116?console.debug(`${l}EQ ${["bass","treble"][s&1]} gain: ${d-64}dB`):s<118?console.debug(f):s<120?console.debug(`${l}EQ ${["bass","treble"][s&1]} freq: ${d}`):console.debug(f)})}).add([76,9],(r,i)=>{let n=e.chRedir(r[0],i,!0),s=r[1],a=`PLG-150VL CH${n+1} `;r.subarray(2).forEach((l,f)=>{let d=f+s;switch(d){case 1:{console.info(`${a}breath mode: ${["system","breath","velocity","touch EG"][l]}`);break}case 0:case 27:case 28:break;default:if(d<27){let p=["pressure","embouchure","tonguing","scream","breath noise","growl","throat formant","harmonic enhancer","damping","absorption","amplification","brightness"][d-3>>1];d&1?d<23?(console.debug(`${a}${p} control source: ${Ee(l)}`),l&&l<96&&e.allocateAce(l)):console.debug(`${a}${p} scale break point: ${l}`):console.debug(`${a}${p} depth: ${l-64}`)}}})}).add([76,10],r=>{}).add([76,16],r=>{}).add([76,17,0,0],r=>{}).add([76,112],r=>{console.debug(`XG enable PLG1${["50-VL","00-SG","50-DX","50-AN","50-PF","50-DR","50-PC","50-AP"][r[0]]} for CH${r[2]+1}.`)}).add([73,0,0],(r,i)=>{let n=r[0],s="MU1000 System: ";r.subarray(1).forEach((a,l)=>{let f=n+l;f==8?console.debug(`${s}LCD contrast set to ${a}.`):f==18?(e.#M=a?126:0,console.debug(`${s}bank defaults to ${a?"MU100 Native":"MU Basic"}.`)):f>=64&&f<69&&[()=>{e.dispatchEvent("channelactive",a)},()=>{a<8?(e.dispatchEvent("channelmin",a<<4),console.debug(`Octavia System: Minimum CH${(a<<4)+1}`)):(e.dispatchEvent("channelreset"),console.info("Octavia System: Clear channel ranges"))},()=>{a<8?(e.dispatchEvent("channelmax",(a<<4)+15),console.debug(`Octavia System: Maximum CH${(a<<4)+16}`)):(e.dispatchEvent("channelreset"),console.info("Octavia System: Clear channel ranges"))},()=>{e.dispatchEvent("channelreset"),console.info("Octavia System: Clear channel ranges")},()=>{e.#B=!!a,console.info(`Octavia System: RS receiving ${["dis","en"][a]}abled.`)}][f-64]()})}).add([73,10,0],(r,i)=>{let n=r[0],s=`MU1000 RS${e.#B?"":" (ignored)"}: `;if(n<16)switch(n){case 2:{let a=e.chRedir(0,i,!0);e.#B&&(e.dispatchEvent("channelmin",a),e.dispatchEvent("channelmax",a+63)),console.info(`${s}Show CH1~64`);break}case 3:{let a=e.chRedir(r[1]<<5,i,!0);e.#B&&e.dispatchEvent("channelmin",a),e.#B&&e.dispatchEvent("channelmax",a+31),console.info(`${s}Show CH${a+1}~CH${a+32}`);break}default:console.debug(`${s}unknown switch ${n} invoked.`)}else if(n<32){if(e.#B){let a=e.chRedir(n-16+(e.#F<<4),i,!0);e.dispatchEvent("channelactive",a)}}else if(n<36){let a=e.chRedir(n-32<<4,i,!0);e.#B&&(e.dispatchEvent("channelmin",a),e.dispatchEvent("channelmax",a+15),e.#F=n-32),console.info(`${s}Show CH${a+1}~CH${a+16}`)}}).add([93,3],(r,i)=>{let n=e.chRedir(r[0],i,!0),s=`PLG-100SG CH${n+1} `,a=Date.now();if(r[1]==0){let l="",f=0;r.subarray(2).forEach((d,p)=>{p%2==0?l+=ye[d]||d.toString().padStart("0"):f+=d*13}),a>=e.#U&&this.dispatchEvent("metacommit",{type:"SGLyrics",data:"",amend:!1}),this.dispatchEvent("metacommit",{type:"SGLyrics",data:`${ve(l)}`,amend:!0}),e.#U=a+Math.ceil(f/2)+e.#z,x()&&console.debug(`${s}vocals: ${l}`)}else console.warn(`Unknown PLG-100SG data: ${r}`)});let c=function(r,i,n,s){},o=function(r,i){let n=r*y.dpn,s=i[0],a=i[1];i.subarray(2).forEach((l,f)=>{let d=f+a,p=-1;d<16?([()=>{p=24},()=>{p=25},()=>{p=26},()=>{},()=>{p=28},()=>{p=29},()=>{p=30},()=>{p=31},()=>{},()=>{},()=>{},()=>{p=20},()=>{p=21},()=>{p=22},()=>{p=23},()=>{}][d]||(()=>{console.debug(`Unknown XG-style drum param ${d} on set ${r+1}.`)}))():d<32||(d<40?([()=>{p=48},()=>{p=49},!1,!1,()=>{p=52},()=>{p=53}][d-32]||(()=>{console.debug(`Unknown XG-style drum param ${d} on set ${r+1}.`)}))():d<80||([()=>{p=36}][d-80]||(()=>{console.debug(`Unknown XG-style drum param ${d} on set ${r+1}.`)}))()),p>=0?(x()&&console.debug(n,p,s,l),e.#x[(n+R[p])*y.dnc+s]=l):x()&&console.debug(`XG-style drum param ${d} has no writes.`)})},h=function(r,i,n){let s=r*y.dpn,a=(i<<7)+n[0];n.subarray(1).forEach((l,f)=>{let d=f+a,p=d&127,g=d>>7,v=-1;g>1&&([()=>{v=26},()=>{},()=>{v=28},()=>{v=29},()=>{v=30},()=>{},()=>{},()=>{v=31}][g-2]||(()=>{console.debug(`Unknown GS-style drum param ${g} on set ${r+1}.`)}))(),v>-1?(x()&&console.debug(s,v,p,l),e.#x[(s+R[v])*y.dnc+p]=l):x()&&console.debug(`GS-style drum param ${g} has no writes.`)})};this.#A.add([76,48],(r,i,n)=>{o(0,r)}).add([76,49],(r,i,n)=>{o(1,r)}).add([76,50],(r,i,n)=>{o(2,r)}).add([76,51],(r,i,n)=>{o(3,r)}).add([76,52],(r,i,n)=>{o(4,r)}).add([76,53],(r,i,n)=>{o(5,r)}).add([76,54],(r,i,n)=>{o(6,r)}).add([76,55],(r,i,n)=>{o(7,r)}),this.#A.add([89,0],(r,i,n)=>{if(e.eprom){let s=r[0],a=(r[1]<<14)+(r[2]<<7)+r[3]+(e.eprom.offset||0);x()&&console.debug(`MU1000 EPROM trail to 0x${a.toString(16).padStart(6,"0")}, ${s} bytes.`);let l=e.eprom.data;r.subarray(4).forEach((f,d)=>{let p=d>>3,g=d&7;if(g==7)for(let v=0;v<7;v++)l[a+7*p+v]+=(f>>6-v&1)<<7;else l[a+7*p+g]=f})}}).add([89,1],(r,i,n)=>{let s=(r[0]<<21)+(r[1]<<14)+(r[2]<<7)+r[3];x()&&console.debug(`MU1000 EPROM jump to 0x${s.toString(16).padStart(6,"0")}.`),e.eprom&&(e.eprom.offset=s)}).add([89,2],(r,i,n)=>{if(e.eprom){let s=(r[0]<<21)+(r[1]<<14)+(r[2]<<7)+r[3]+(e.eprom.offset||0);x()&&console.debug(`MU1000 EPROM write to 0x${s.toString(16).padStart(6,"0")}.`);let a=e.eprom.data;r.subarray(4).forEach((l,f)=>{let d=f>>3,p=f&7;if(p==7)for(let g=0;g<7;g++)a[s+7*d+g]+=(l>>6-g&1)<<7;else a[s+7*d+p]=l})}}).add([89,3],(r,i,n)=>{}),this.#A.add([39,48],(r,i,n)=>{}).add([43,0,0],(r,i,n)=>{let s=[0,0,0,0],a=(l,f)=>{s[f]=l};if(r.subarray(1).forEach((l,f)=>{let d=f+r[0];[a,a,a,a,()=>{this.#f=l*129/16383*100,e.dispatchEvent("mastervolume",e.#f)},()=>l-64,()=>l||128,()=>l,()=>l,()=>{console.debug(`TG300 variation on cc${l}.`)}][d](l,d)}),r[0]<4){let l=0;s.forEach(f=>{l=l<<4,l+=f}),l-=1024}}).add([43,1,0],(r,i,n)=>{}).add([43,2],(r,i,n)=>{let s=e.chRedir(r[0],i,!0),a=r[1],l=y.cc*s,f=`TG300 CH${s+1} `;r.subarray(2).forEach((d,p)=>{p<5?([()=>{},()=>{e.#e[l+b[0]]=d,e.dispatchEvent("voice",{part:s})},()=>{e.#e[l+b[32]]=d,e.dispatchEvent("voice",{part:s})},()=>{e.#n[s]=d,e.dispatchEvent("voice",{part:s})},()=>{let g=e.chRedir(d,i,!0);e.#u[s]=g,s!=g&&(e.buildRchTree(),console.info(`${f}receives from CH${g+1}`))}][p+a]||(()=>{}))(d,p+a):p<21||(p<47?([()=>{e.#p[s]=+!d},()=>{},()=>{},()=>{e.#r[y.rpn*s+3]=d,e.#i[y.rpnt*s+2]=1},()=>{},()=>{e.#e[l+b[7]]=d},!1,!1,()=>{e.#e[l+b[10]]=d||128},!1,!1,()=>{console.debug(`${f} AC1 at cc${d}`)},()=>{console.debug(`${f} AC2 at cc${d}`)},()=>{e.#e[l+b[128]]=d},()=>{e.#e[l+b[93]]=d},()=>{e.#e[l+b[91]]=d},()=>{e.#e[l+b[94]]=d},()=>{e.#e[l+b[76]]=d},()=>{e.#e[l+b[77]]=d},()=>{e.#e[l+b[74]]=d},()=>{e.#e[l+b[71]]=d},()=>{e.#e[l+b[73]]=d},()=>{e.#e[l+b[75]]=d},()=>{e.#e[l+b[72]]=d},()=>{e.#e[l+b[78]]=d}][p+a-21]||(()=>{}))(d,p+a):p<95||([()=>{e.#e[l+b[65]]=d},()=>{e.#e[l+b[5]]=d}][p+a-95]||(()=>{}))(d,p+a))})}).add([43,7,0],(r,i,n)=>{let s=r[0];e.setLetterDisplay(r.subarray(1),"TG300 letter display",s)}).add([43,7,1],(r,i,n)=>{e.#h=0,e.#E=Date.now()+3200,e.#m.fill(0),r.forEach(function(s,a){let l=Math.floor(a/16),f=a%16,d=(f*3+l)*7,p=7,g=0;for(d-=f*5,l==2&&(p=2);g>6-g&1,g++})}),this.#L.add([66,18,0,0,127],(r,i,n)=>{e.switchMode("gs",!0),e.#e[y.cc*9]=120,e.#e[y.cc*25]=120,e.#e[y.cc*41]=120,e.#e[y.cc*57]=120,e.#M=3,e.#g=!1,e.#V.fill(0),console.info(`GS system to ${["single","dual"][r[0]]} mode.`)}).add([66,18,64,0],(r,i,n)=>{switch(r[0]){case 127:{e.switchMode("gs",!0),e.#e[y.cc*9]=120,e.#e[y.cc*25]=120,e.#e[y.cc*41]=120,e.#e[y.cc*57]=120,e.#g=!1,e.#V.fill(0),console.info("MIDI reset: GS");break}default:{let s=[0,0,0,0],a=(l,f)=>{s[f]=l};if(r.subarray(1).forEach((l,f)=>{let d=f+r[0];[a,a,a,a,p=>{this.#f=p*129/16383*100,e.dispatchEvent("mastervolume",e.#f)},p=>{},p=>{}][d](l,f)}),r[0]<4){let l=0;s.forEach(f=>{l=l<<4,l+=f}),l-=1024}}}}).add([66,18,64,1],r=>{let i=r[0];if(i<16){let n="".padStart(i," ");r.subarray(1).forEach((s,a)=>{n+=String.fromCharCode(Math.max(32,s))}),n=n.padEnd(16," "),console.debug(`GS patch name: ${n}`)}else i<48||(i<65?r.subarray(1).forEach((n,s)=>{let a=`GS ${i+s>55?"chorus":"reverb"} `;([()=>{console.info(`${a}type: ${J[n]}`),e.setEffectType(0,40,n),e.dispatchEvent("efxreverb",e.getEffectType(0))},()=>{},()=>{},()=>{},()=>{},()=>{},!1,()=>{console.debug(`${a}predelay: ${n}ms`)},()=>{console.info(`${a}type: ${we[n]}`),e.setEffectType(1,40,16+n),e.dispatchEvent("efxchorus",e.getEffectType(1))},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{console.debug(`${a}to reverb: ${C(n)}`)},()=>{console.debug(`${a}to delay: ${C(n)}`)}][i+s-48]||(()=>{}))()}):i<80?console.debug(`Unknown GS patch address: ${i}`):i<91?r.subarray(1).forEach((n,s)=>{let a="GS delay ";([()=>{console.info(`${a}type: ${$e[n]}`),e.setEffectType(2,40,32+n),e.dispatchEvent("efxdelay",e.getEffectType(2))},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{console.debug(`${a}to reverb: ${C(n)}`)}][i+s-80]||(()=>{}))()}):console.debug(`Unknown GS patch address: ${i}`))}).add([66,18,64,2],r=>{let i="GS EQ ";r.subarray(1).forEach((n,s)=>{([()=>{console.debug(`${i}low freq: ${[200,400][n]}Hz`)},()=>{console.debug(`${i}low gain: ${n-64}dB`)},()=>{console.debug(`${i}high freq: ${[3e3,6e3][n]}Hz`)},()=>{console.debug(`${i}high gain: ${n-64}dB`)}][r[0]+s]||function(){console.warn(`Unknown GS EQ address: ${r[0]+s}`)})()})}).add([66,18,64,3],r=>{let i="GS EFX ",n=function(s,a){let l=ke(e.#T.subarray(10,12),a,s);l&&console.debug(`${i}${ee(e.#T.subarray(10,12))} ${l}`)};r.subarray(1).forEach((s,a)=>{([()=>{e.setEffectTypeRaw(3,!1,32+s),e.dispatchEvent("efxinsert0",e.getEffectType(3))},()=>{e.setEffectTypeRaw(3,!0,s),console.info(`${i}type: ${ee(e.#T.subarray(10,12))}`),e.dispatchEvent("efxinsert0",e.getEffectType(3))},!1,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,()=>{console.debug(`${i}to reverb: ${C(s)}dB`)},()=>{console.debug(`${i}to chorus: ${C(s)}dB`)},()=>{console.debug(`${i}to delay: ${C(s)}dB`)},!1,()=>{console.debug(`${i}1 source: ${s}`),s&&s<96&&e.allocateAce(s)},()=>{console.debug(`${i}1 depth: ${s-64}`)},()=>{console.debug(`${i}2 source: ${s}`),s&&s<96&&e.allocateAce(s)},()=>{console.debug(`${i}2 depth: ${s-64}`)},()=>{console.debug(`${i}to EQ: ${s?"ON":"OFF"}`)}][r[0]+a]||function(l,f){console.warn(`Unknown GS EFX address: ${f}`)})(s,r[0]+a)})}).add([66,18,65],r=>{h((r[0]>>4)+1<<1,r[0]&15,r.subarray(1))}).add([69,18,16],r=>{switch(r[0]){case 0:{let i=r[1];e.setLetterDisplay(r.subarray(2),"GS display text",i);break}case 32:{e.#E=Date.now()+3200,r[1]==0&&(e.#h=Math.max(Math.min(r[2]-1,9),0),x()&&console.debug(`GS switch display page ${r[2]-1}.`));break}default:if(r[0]<6){e.#h>9&&(e.#h=0);let i=r[0]-1<<1|r[1]>>6;e.#h==i&&(e.#E=Date.now()+3200),e.#o[i]?.length||(e.#o[i]=new Uint8Array(256));let n=e.#o[i];x()&&console.debug(`GS frame draw page ${i}.`);let s=r[1]&63;n.fill(0),r.subarray(2).forEach(function(l,f){let d=f+s,p=Math.floor(d/16),g=d%16,v=(g*4+p)*5,k=5,$=0;for(v-=g*4,p==3&&(k=1);$>4-$&1,$++})}else console.warn(`Unknown GS display section: ${r[0]}`)}});let u=function(r,i,n){let s=r[0],a=y.cc*i,l=y.rpn*i,f=`GS CH${i+1} `;s<3?(r.subarray(1).forEach((d,p)=>{[()=>{e.#e[a+b[0]]=d},()=>{e.#n[i]=d},()=>{let g=0;d<16?g=e.chRedir(d,n,!0):g=y.ch,e.#u[i]=g,i!=g&&(e.buildRchTree(),console.info(`${f}receives from CH${g+1}`))}][s+p]()}),e.dispatchEvent("voice",{part:i})):s<19||(s<44?r.subarray(1).forEach((d,p)=>{([()=>{e.#p[i]=+!d},!1,()=>{e.setChType(i,d<<1,w.gs),console.debug(`${f}type: ${d?"drum ":"melodic"}${d||""}`)},()=>{e.#r[l+3]=d,e.#i[y.rpnt*i+2]=1},!1,()=>{e.#e[a+b[7]]=d},!1,!1,()=>{e.#e[a+b[10]]=d||128},!1,!1,()=>{console.debug(`${f}CC 1: cc${d}`)},()=>{console.debug(`${f}CC 2: cc${d}`)},()=>{e.#e[a+b[93]]=d},()=>{e.#e[a+b[91]]=d},!1,!1,()=>{e.#r[l+1]=d,e.#i[y.rpnt*i+1]=1},()=>{e.#r[l+2]=d,e.#i[y.rpnt*i+1]=1},()=>{e.#e[a+b[94]]=d}][s+p-19]||(()=>{}))()}):s<76||console.debug(`Unknown GS part address: ${s}`))},m=function(r,i){let n=r[0],s=`GS CH${i+1} `;n<2?r.subarray(1).forEach((a,l)=>{[()=>{e.#e[y.cc*i+b[32]]=a},()=>{}][n+l]()}):n<32?console.warn(`Unknown GS misc address: ${n}`):n<35?r.subarray(1).forEach((a,l)=>{[()=>{console.debug(`${s}EQ: o${["ff","n"][a]}`)},()=>{},()=>{console.debug(`${s}EFX: o${["ff","n"][a]}`),e.#G[i]=a,e.dispatchEvent("partefxtoggle",{part:i,active:a})}][n+l-32]()}):console.warn(`Unknown GS misc address: ${n}`)};this.#L.add([66,18,64,16],(r,i)=>{u(r,e.chRedir(9,i,!0),i)}).add([66,18,64,17],(r,i)=>{u(r,e.chRedir(0,i,!0),i)}).add([66,18,64,18],(r,i)=>{u(r,e.chRedir(1,i,!0),i)}).add([66,18,64,19],(r,i)=>{u(r,e.chRedir(2,i,!0),i)}).add([66,18,64,20],(r,i)=>{u(r,e.chRedir(3,i,!0),i)}).add([66,18,64,21],(r,i)=>{u(r,e.chRedir(4,i,!0),i)}).add([66,18,64,22],(r,i)=>{u(r,e.chRedir(5,i,!0),i)}).add([66,18,64,23],(r,i)=>{u(r,e.chRedir(6,i,!0),i)}).add([66,18,64,24],(r,i)=>{u(r,e.chRedir(7,i,!0),i)}).add([66,18,64,25],(r,i)=>{u(r,e.chRedir(8,i,!0),i)}).add([66,18,64,26],(r,i)=>{u(r,e.chRedir(10,i,!0),i)}).add([66,18,64,27],(r,i)=>{u(r,e.chRedir(11,i,!0),i)}).add([66,18,64,28],(r,i)=>{u(r,e.chRedir(12,i,!0),i)}).add([66,18,64,29],(r,i)=>{u(r,e.chRedir(13,i,!0),i)}).add([66,18,64,30],(r,i)=>{u(r,e.chRedir(14,i,!0),i)}).add([66,18,64,31],(r,i)=>{u(r,e.chRedir(15,i,!0),i)}).add([66,18,64,64],(r,i)=>{m(r,e.chRedir(9,i,!0))}).add([66,18,64,65],(r,i)=>{m(r,e.chRedir(0,i,!0))}).add([66,18,64,66],(r,i)=>{m(r,e.chRedir(1,i,!0))}).add([66,18,64,67],(r,i)=>{m(r,e.chRedir(2,i,!0))}).add([66,18,64,68],(r,i)=>{m(r,e.chRedir(3,i,!0))}).add([66,18,64,69],(r,i)=>{m(r,e.chRedir(4,i,!0))}).add([66,18,64,70],(r,i)=>{m(r,e.chRedir(5,i,!0))}).add([66,18,64,71],(r,i)=>{m(r,e.chRedir(6,i,!0))}).add([66,18,64,72],(r,i)=>{m(r,e.chRedir(7,i,!0))}).add([66,18,64,73],(r,i)=>{m(r,e.chRedir(8,i,!0))}).add([66,18,64,74],(r,i)=>{m(r,e.chRedir(10,i,!0))}).add([66,18,64,75],(r,i)=>{m(r,e.chRedir(11,i,!0))}).add([66,18,64,76],(r,i)=>{m(r,e.chRedir(12,i,!0))}).add([66,18,64,77],(r,i)=>{m(r,e.chRedir(13,i,!0))}).add([66,18,64,78],(r,i)=>{m(r,e.chRedir(14,i,!0))}).add([66,18,64,79],(r,i)=>{m(r,e.chRedir(15,i,!0))}),this.#K.add([54,65],(r,i)=>{e.switchMode("x5d");let n=(r[1]<<7)+r[0],s=(r[3]<<7)+r[2],a=e.chRedir(n&15,i,!0),l=y.cc*a;[()=>{s<1||(s<101?(e.setChType(a,e.CH_MELODIC,w.x5d),e.#n[a]=s-1,e.#e[l+b[0]]=82):s<229?(e.setChType(a,e.CH_MELODIC,w.x5d),e.#n[a]=s-101,e.#e[l+b[0]]=56):(e.setChType(a,e.CH_DRUMS,w.x5d),e.#n[a]=Pe[s-229]||0,e.#e[l+b[0]]=62)),e.dispatchEvent("voice",{part:a})},()=>{e.#e[l+b[7]]=s},()=>{s<31&&(e.#e[l+b[10]]=Math.round((s-15)*4.2+64))},()=>{e.#e[l+b[93]]=_(s)},()=>{e.#e[l+b[91]]=_(s)},()=>{e.#r[a*y.rpn+3]=s>8191?s-16320:64+s,e.#i[y.rpnt*a+2]=1},()=>{e.#r[a*y.rpn+1]=s>8191?s-16320:64+s,e.#i[y.rpnt*a+1]=1},()=>{s>0&&(e.#r[a*y.rpn]=s,e.#i[y.rpnt*a]=1)},()=>{}][n>>4]()}).add([54,76,0],(r,i)=>{e.switchMode("x5d",!0);let n="",s=82,a=0,l=0,f="MSB PRG LSB NME";O(r,function(d,p){if(p<16400){let g=p%164;switch(!0){case g<10:{d>31&&(n+=String.fromCharCode(d));break}case g==10:break;case g==11:{f+=` +${s} ${a} ${l} ${n.trim().replace("Init Voice","")}`,a++,n="";break}}a>99&&(s=90,a=0)}}),e.userBank.clearRange({msb:82,prg:[0,99],lsb:0}),e.userBank.load(f),x()&&console.debug(f),e.forceVoiceRefresh()}).add([54,77,0],(r,i)=>{e.switchMode("x5d",!0);let n="",s=90,a=0,l=0,f="MSB PRG LSB NME";O(r,function(d,p){if(p<13600){let g=p%136;switch(!0){case g<10:{d>31&&(n+=String.fromCharCode(d));break}case g==11:{f+=` +${s} ${a} ${l} ${n.trim().replace("Init Combi","")}`,a++,n="";break}}}}),e.userBank.clearRange({msb:90,prg:[0,99],lsb:0}),e.userBank.load(f),x()&&console.debug(f),e.forceVoiceRefresh()}).add([54,78],(r,i)=>{e.switchMode("x5d",!0),console.debug(`X5D mode switch requested: ${["combi","combi edit","prog","prog edit","multi","global"][r[0]]} mode.`)}).add([54,85],(r,i)=>{e.switchMode("x5d",!0),O(r,(n,s)=>{s>0&&s<3&&(e.setEffectType(s-1,44,n),e.dispatchEvent(`efx${["reverb","chorus"][s-1]}`,e.getEffectType(s-1)))})}).add([54,104],(r,i)=>{e.switchMode("x5d",!0),O(r,function(n,s,a,l){if(s<192){let f=e.chRedir(Math.floor(s/12),i,!0),d=f*y.cc;switch(s%12){case 0:{n<128?(e.setChType(f,e.CH_MELODIC,w.x5d),e.#e[d+b[0]]=82,e.#n[f]=n):(e.setChType(f,e.CH_DRUMS,w.x5d),e.#e[d+b[0]]=62,e.#n[f]=Pe[n-128]),n>0&&e.setChActive(f,1),e.dispatchEvent("voice",{part:f});break}case 1:{e.#e[d+b[7]]=n;break}case 2:{e.#r[f*y.rpn+3]=n>127?n-192:64+n,e.#i[y.rpnt*f+2]=1;break}case 3:{e.#r[f*y.rpn+1]=n>127?n-192:64+n,e.#i[y.rpnt*f+1]=1;break}case 4:{n<31&&(e.#e[d+b[10]]=Math.round((n-15)*4.2+64));break}case 5:{let p=n>>4,g=n&15;e.#e[d+b[91]]=_(g),e.#e[d+b[93]]=_(p);break}case 10:break;case 11:{let p=e.chRedir(n&15,i,!0),g=n>>4;e.#u[f]=n,(p!=f||g)&&(console.info(`X5D Part CH${f+1} receives from CH${p+1}.`),e.buildRchTree())}}}else{let f=e.chRedir(s-192,i,!0)}})}),this.#L.add([22,18,127],r=>{e.switchMode("mt32",!0),e.#g=!1,e.userBank.clearRange({msb:0,lsb:127,prg:[0,127]}),console.info("MIDI reset: MT-32")}).add([22,18,0],(r,i,n)=>{e.switchMode("mt32");let s=e.chRedir(n,i,!0),a=r[1];r.subarray(2).forEach((l,f)=>{let d=f+a;e.#$[d+(s-1)*16]=l,([!1,()=>{let p=e.#$[s-1<<4];if(p<3){if(e.#a[s]=1,p==2)for(let g=0;g{e.#r[s*y.rpn+3]=l+40,e.#i[y.rpnt*s+2]=1},()=>{e.#r[s*y.rpn+1]=l+14,e.#i[y.rpnt*s+1]=1},()=>{e.#r[s*y.rpn]=l,e.#i[y.rpnt*s]=1},!1,()=>{e.#e[y.cc*s+b[91]]=l?127:0},!1,()=>{e.#e[y.cc*s+b[7]]=l},()=>{e.#e[y.cc*s+b[10]]=Math.ceil(l*9.05)}][d]||(()=>{}))()})}).add([22,18,1],(r,i,n)=>{e.switchMode("mt32");let s=n&7;console.debug(`MT-32 slot #${n+1} Drum: ${r}`);let a=r[0]<<7|r[1];r.subarray(2).forEach((l,f)=>{let d=f+a,p=(d>>2)+24,g=d&3,v=s*y.dpn;if(x()&&console.debug(`MT-32 temp drum note ${p} param ${g}: ${l}`),p<24){console.warn(`MT-32 dev drum write attempted on an OOB note: ${p}`);return}[()=>{},()=>{e.#x[(v+R[26])*y.dnc+p]=Math.round(l*1.27)},()=>{e.#x[(v+R[26])*y.dnc+p]=l*9+1&127},()=>{e.#x[(v+R[26])*y.dnc+p]=l?127:0}][g]()})}).add([22,18,2],(r,i,n)=>{e.switchMode("mt32");let s=e.chRedir(n,i,!0),a=r[1]+(r[0]<<7);a<10&&(e.#a[s]=1),r.subarray(2).forEach((l,f)=>{let d=f+a;d<14&&(e.#c[(s-1)*y.cmt+d]=l)}),e.dispatchEvent("voice",{part:s})}).add([22,18,3],(r,i,n)=>{e.switchMode("mt32");let s=n&7;if(r[0]){let a=(r[0]-1<<7)+r[1]-16;r.subarray(2).forEach((l,f)=>{let d=f+a,p=(d>>2)+24,g=d&3,v=s*y.dpn;if(x()&&console.debug(`MT-32 dev drum note ${p} param ${g}: ${l}`),p<24){console.warn(`MT-32 dev drum write attempted on an OOB note: ${p}`);return}[()=>{},()=>{e.#x[(v+R[26])*y.dnc+p]=Math.round(l*1.27)},()=>{e.#x[(v+R[26])*y.dnc+p]=l*9+1&127},()=>{e.#x[(v+R[26])*y.dnc+p]=l?127:0}][g]()})}else{let a=r[1];r.subarray(2).forEach((l,f)=>{let d=f+a;e.#$[d]=l;let p=e.chRedir(1+(d>>4),i,!0),g=d&15;([!1,()=>{let v=e.#$[p-1<<4];if(v<3)if(e.#a[p]=1,v==2)for(let k=0;k{e.#r[p*y.rpn+3]=l+40,e.#i[y.rpnt*p+2]=1},()=>{e.#r[p*y.rpn+1]=l+14,e.#i[y.rpnt*p+1]=1},()=>{e.#r[p*y.rpn]=l,e.#i[y.rpnt*p]=1},!1,()=>{e.#e[y.cc*p+b[91]]=l?127:0},!1,()=>{e.#e[y.cc*p+b[7]]=l},()=>{e.#e[y.cc*p+b[10]]=Math.ceil(l*9.05)}][g]||(()=>{}))()})}}).add([22,18,4],(r,i,n)=>{e.switchMode("mt32");let s=r[1]+(r[0]<<7),a=[];r.subarray(2).forEach((l,f)=>{let d=f+s,p=e.chRedir(Math.floor(d/246+1),i,!0),g=d%246;g<14&&(e.#c[(p-1)*y.cmt+g]=l),g<10&&(e.#a[p]=1),a.indexOf(p)<0&&a.push(p)}),a.forEach(l=>{e.dispatchEvent("voice",{part:l})})}).add([22,18,5],(r,i,n)=>{e.switchMode("mt32");let s=(r[0]<<7)+r[1];r.subarray(2).forEach((a,l)=>{let f=s+l,d=Math.floor(f/8),p=f&7,g=d*8;e.#y[f]=a,([!1,()=>{let v=e.#y[g];if(v<3){let k="";if(v==2){let I=y.cmt*d;k=`MT-m:${a.toString().padStart(3,"0")}`}else k=e.baseBank.get(0,a+(v<<6),127,"mt32").name;e.userBank.clearRange({msb:0,lsb:127,prg:d});let $=`MSB LSB PRG NME +000 127 ${d} ${k}`;e.userBank.load($,!0)}}][p]||(()=>{}))()}),e.forceVoiceRefresh()}).add([22,18,8],(r,i,n)=>{e.switchMode("mt32");let s=((r[0]&1)<<7)+r[1];r.subarray(2).forEach((a,l)=>{let f=s+l;f>1)*y.cmt+f]=a)}),e.forceVoiceRefresh()}).add([22,18,16],(r,i,n)=>{e.switchMode("mt32");let s=r[1],a=!1,l=function(f,d){e.#u[d-12]=f,a=!0};r.subarray(2).forEach((f,d)=>{let p=d+s;([!1,!1,!1,!1,!1,!1,!1,!1,!1,!1,!1,!1,!1,l,l,l,l,l,l,l,l,l,()=>{e.#f=f,e.dispatchEvent("mastervolume",e.#f)}][p]||(()=>{}))(f,d)}),a&&e.buildRchTree()}).add([22,18,32],r=>{e.switchMode("mt32");let i=r[1],n=" ".repeat(i);r.subarray(2).forEach(s=>{s>31?n+=String.fromCharCode(s):n+=" "}),e.#_=n.padStart(20," "),e.#N=Date.now()+3200}).add([22,18,82],(r,i)=>{let n=e.chRedir(0,i,!0);for(let s=0;s<16;s++)e.#k.ano(n+s),s&&s<10&&(e.#n[n+s]=te[s-1]);console.info("MT-32 alt reset complete.")}),this.#K.add([66,0],(r,i)=>{e.switchMode("ns5r",!0),e.#g=!1,console.debug(`NS5R mode switch requested: ${["global","multi","prog edit","comb edit","drum edit","effect edit"][r[0]]} mode.`)}).add([66,1],(r,i)=>{e.switchMode(["ns5r","05rw"][r[0]],!0),e.#g=!1}).add([66,18,0,0],(r,i)=>{let n=r[0];switch(n){case 124:case 126:case 127:{e.switchMode("ns5r",!0),e.#g=!1;break}case 125:{e.initDrums(),console.info(`NS5R drum setup reset: ${r}`);break}default:if(n<10){let s=[0,0,0,0],a=(l,f)=>{s[f]=l};if(r.subarray(1).forEach((l,f)=>{[a,a,a,a,()=>{e.#f=l*129/16383*100,e.dispatchEvent("mastervolume",e.#f)},()=>l-64,()=>l-64,()=>{},()=>{},()=>{}][n+f]()}),r[0]<4){let l=0;s.forEach(f=>{l=l<<4,l+=f}),l-=1024}}}}).add([66,18,0,1],(r,i)=>{}).add([66,18,0,2],(r,i)=>{}).add([66,18,1],(r,i)=>{let n=e.chRedir(r[0],i,!0),s=n*y.cc,a=r[1],l=`NS5R CH${n+1} `;r.subarray(2).forEach((f,d)=>{let p=a+d;p<3?([()=>{e.#e[s+b[0]]=f||121},()=>{e.#e[s+b[32]]=f},()=>{e.#n[n]=f}][p](),e.dispatchEvent("voice",{part:n})):p<8||(p<14?[()=>{let g=e.chRedir(f,i,!0);e.#u[n]=g,n!=g&&(e.buildRchTree(),console.info(`${l}receives from CH${g+1}`))},()=>{e.#p[n]=+!f},()=>{e.setChType(n,f,w.ns5r),console.debug(`${l}type: ${X[f]}`)},()=>{e.#r[y.rpn*n+3]=f,e.#i[y.rpnt*n+2]=1},()=>{},()=>{}][p-8]():p<16||(p<33?[()=>{e.#e[s+b[7]]=f},()=>{e.#e[s+b[11]]=f},()=>{},()=>{},()=>{e.#e[s+b[10]]=f||128},()=>{},()=>{},()=>{e.#e[s+b[93]]=f},()=>{e.#e[s+b[91]]=f},()=>{e.#e[s+b[76]]=f},()=>{e.#e[s+b[77]]=f},()=>{e.#e[s+b[78]]=f},()=>{e.#e[s+b[74]]=f},()=>{e.#e[s+b[71]]=f},()=>{e.#e[s+b[73]]=f},()=>{e.#e[s+b[75]]=f},()=>{e.#e[s+b[72]]=f}][p-16]():p<112||p<114&&[()=>{e.#e[s+b[5]]=f},()=>{e.#e[s+b[65]]=f}][p-112]()))})}).add([66,18,8,0],(r,i)=>{let n=r[0];if(n<32)e.setLetterDisplay(r.subarray(1,33),"NS5R letter display");else{let s=n-32;e.#E=Date.now()+3200,e.#h=10,e.#m.fill(0);let a=r.subarray(1),l=4;a.forEach(function(f,d){let p=d+s,g=p>>4,v=p&15;if(p<80){let k=g>3,$=0,I=g0;)e.#m[v*32+g*7+(I-$)]=k&1,k=k>>1,$++}})}}).add([66,18,48],(r,i,n)=>{o(0,r)}).add([66,18,49],(r,i,n)=>{o(1,r)}).add([66,18,50],(r,i,n)=>{o(2,r)}).add([66,18,51],(r,i,n)=>{o(3,r)}).add([66,18,52],(r,i,n)=>{o(4,r)}).add([66,18,53],(r,i,n)=>{o(5,r)}).add([66,18,54],(r,i,n)=>{o(6,r)}).add([66,18,55],(r,i,n)=>{o(7,r)}).add([66,52],(r,i)=>{e.switchMode("ns5r",!0),e.#g=!1;let n="";O(r,(s,a)=>{a<8?(s>31&&(n+=String.fromCharCode(s)),a==7&&(e.aiEfxName=n)):a<10&&(e.setEffectType(a-8,44,s),e.dispatchEvent(`efx${["reverb","chorus"][a-8]}`,e.getEffectType(a-8)))})}).add([66,53],(r,i)=>{e.switchMode("ns5r",!0),e.#g=!1;let n="";O(r,function(s,a){switch(!0){case a<2944:{let l=e.chRedir(Math.floor(a/92),i,!0),f=l*y.cc;switch(a%92){case 0:{e.#e[f+b[0]]=s,e.dispatchEvent("voice",{part:l});break}case 1:{e.#e[f+b[32]]=s,!s&&!e.#e[f+b[0]]&&(e.#e[f+b[0]]=121),e.dispatchEvent("voice",{part:l});break}case 2:{e.#n[l]=s,s>0&&e.setChActive(l,1),e.dispatchEvent("voice",{part:l});break}case 3:{let d=e.chRedir(s,i,!0);e.#u[l]=d,l!=d&&(console.info(`NS5R CH${l+1} receives from CH${d+1}.`),e.buildRchTree());break}case 7:{e.#s[l]=s,e.dispatchEvent("voice",{part:l});break}case 8:{e.#r[l*y.rpn+3]=s<40||s>88?s+(s>63?-192:64):s,e.#i[y.rpnt*l+2]=1;break}case 9:case 10:{e.#e[f+b[7]]=s;break}case 11:{e.#e[f+b[11]]=s;break}case 14:{e.#e[f+b[10]]=s||128;break}case 19:{e.#e[f+b[93]]=s;break}case 20:{e.#e[f+b[91]]=s;break}case 84:{e.#e[f+b[65]]=s;break}case 85:{e.#e[f+b[5]]=s;break}}break}case a<3096:break;case a<3134:{let l=a-3096;l<8?(s>31&&(n+=String.fromCharCode(s)),l==7&&(e.aiEfxName=n)):l<10&&(e.setEffectType(l-8,44,s),e.dispatchEvent(`efx${["reverb","chorus"][l-8]}`,e.getEffectType(l-8)));break}case a<8566:break}})}).add([66,54],(r,i)=>{e.switchMode("ns5r",!0);let n="",s=80,a=0,l=0,f="MSB PRG LSB NME";O(r,function(d,p){let g=p%158;switch(!0){case g<10:{d>31&&(n+=String.fromCharCode(d));break}case g==10:break;case g==11:{s=d&127;break}case g==12:{l=d&127;break}case g==13:{f+=` +${s} ${a} ${l} ${n.trim().replace("Init Voice","")}`,a++,n="";break}}}),e.userBank.clearRange({msb:80,lsb:0}),e.userBank.load(f),x()&&console.debug(f),e.forceVoiceRefresh()}).add([66,55],(r,i)=>{e.switchMode("ns5r",!0);let n="",s=88,a=0,l=0,f="MSB PRG LSB NME";O(r,function(d,p){let g=p%126;switch(!0){case g<10:{d>31&&(n+=String.fromCharCode(d));break}case g==11:break;case g==12:break;case g==13:{f+=` +${s} ${a} ${l} ${n.trim().replace("Init Combi","")}`,a++,n="";break}}}),e.userBank.clearRange({msb:88,lsb:0}),e.userBank.load(f),x()&&console.debug(f),e.forceVoiceRefresh()}).add([66,125],r=>{e.dispatchEvent("backlight",["green","orange","red",!1,"yellow","blue","purple"][r[0]]||"white")}).add([66,127],r=>{let i=new Uint8Array(5760);O(r,(n,s,a)=>{if(s<720)for(let l=0;l<8;l++)i[s*8+l]=n>>7-l&1}),e.dispatchEvent("screen",{type:"ns5r",data:i})}).add([76],(r,i,n)=>{e.#K.run([66,...r],i,n)}),this.#Z.add([16,0,8,0],(r,i,n)=>{let s=(r[2]<<4)+r[3],a="K11 ";([()=>{e.switchMode("k11",!0),e.#g=!1,e.#M=s?4:0,console.info("MIDI reset: GMega/K11")},()=>{e.setEffectType(0,24,s),console.debug(`${a}reverb type: ${s}`),e.dispatchEvent("efxreverb",e.getEffectType(0))},()=>{console.debug(`${a}reverb time: ${s}`)},()=>{console.debug(`${a}reverb time: ${s}`)},()=>{console.debug(`${a}reverb predelay: ${s}`)},()=>{console.debug(`${a}reverb predelay: ${s}`)},()=>{console.debug(`${a}depth high: ${s}`)},()=>{console.debug(`${a}depth high: ${s}`)},()=>{console.debug(`${a}depth low: ${s}`)},()=>{console.debug(`${a}depth low: ${s}`)}][r[0]]||(()=>{}))()}).add([16,0,8,1],(r,i,n)=>{let s=e.chRedir(r[1],i,!0),a=y.cc*s,l=y.rpn*s,f=(r[3]<<4)+r[4],d=`K11 CH${s+1} `;([()=>{f<128?(e.setChType(s,e.CH_MELODIC,w.k11),e.#e[a+b[0]]=0,e.#n[s]=f):(e.setChType(s,e.CH_DRUMS,w.k11),e.#n[s]=f-128),e.dispatchEvent("voice",{part:s})},()=>{let p=e.chRedir(f,i,!0);e.#u[s]=p,s!=p&&(e.buildRchTree(),console.info(`${d}receives from CH${p+1}`))},()=>{e.#e[a+b[7]]=f},()=>{uupThis.setChActive(s,f)},()=>{e.#e[a+b[10]]=f},()=>{e.#r[l+3]=f+40,e.#i[y.rpnt*s+2]=1},()=>{e.#r[l+1]=f>>1,e.#r[l+2]=f&1,e.#i[y.rpnt*s+1]=1},()=>{e.#e[a+b[91]]=f?127:0},()=>{},()=>{e.#e[a+b[74]]=f},()=>{e.#e[a+b[73]]=f},()=>{e.#e[a+b[72]]=f}][r[0]]||(()=>{}))()}).add([16,0,9,0],(r,i,n)=>{let s=(r[2]<<4)+r[3],a="GMLX ";([()=>{console.debug(`${a}reverb type: ${s}`)},()=>{console.debug(`${a}reverb time: ${s}`)},()=>{console.debug(`${a}reverb predelay: ${s}`)},()=>{console.debug(`${a}depth high: ${s}`)},()=>{console.debug(`${a}depth low: ${s}`)}][r[0]]||(()=>{}))()}).add([16,0,9,3],(r,i,n)=>{let s=(r[2]<<4)+r[3],a=e.chRedir(r[1],i,!0),l=a*y.cc;[()=>{s<128?(e.setChType(a,e.CH_MELODIC,w.k11),e.#e[l+b[0]]=0,e.#e[l+b[32]]=0,e.#n[a]=s):s<160?(e.setChType(a,e.CH_MELODIC,w.k11),e.#e[l+b[0]]=0,e.#e[l+b[32]]=7,e.#n[a]=s-100):(e.setChType(a,e.CH_DRUMS,w.k11),e.#e[l+b[0]]=122,e.#e[l+b[32]]=0,e.#n[a]=s-160),e.dispatchEvent("voice",{part:a})},()=>{let f=e.chRedir(s,i,!0);e.#u[a]=f,a!=f&&(e.buildRchTree(),console.info(`GMLX CH${a+1} receives from CH${f+1}`))}][r[0]]()}).add([16,0,9,4],(r,i,n)=>{let s=(r[2]<<4)+r[3],a=e.chRedir(r[1],i,!0),l=a*y.cc,f=a*y.rpn,d=`GMLX CH${a+1} `;[()=>{e.setChActive(a,s)},()=>{e.#e[l+b[7]]=s},()=>{e.#e[l+b[10]]=s},()=>{e.#e[l+b[91]]=s?127:0},()=>{e.#r[f+3]=s+40,e.#i[y.rpnt*a+2]=1},()=>{e.#r[f+1]=s,e.#i[y.rpnt*a+1]=1},()=>{e.#r[f]=s,e.#i[y.rpnt*a]=1},()=>{}][r[0]]()}),this.#J.add([66,93,64],(r,i,n)=>{let s=r[2];switch(r[0]){case 0:{switch(r[1]){case 4:{e.#f=s*129/16383*100,e.dispatchEvent("mastervolume",e.#f);break}case 5:{s-64;break}case 6:{console.debug(`SG global reverb: ${s?"on":"off"}`);break}case 127:{e.switchMode("sg",!0);break}}break}case 1:{switch(r[1]){case 48:{console.debug(`SG reverb type: ${J[s]}`);break}}break}default:if(r[0]>>4==1){let a=e.chRedir(r[0]&15,i,!0);if(r[1]==2){let l=e.chRedir(s,i,!0);e.#u[a]=l,a!=l&&(e.buildRchTree(),console.info(`SG CH${a+1} receives from CH${l+1}`))}else r[1]==19&&(e.#e[y.cc*a+b[7]]=s)}else console.warn(`Unknown AKAI SG SysEx: ${r}`)}}),this.#ee.add([9],(r,i,n)=>{console.debug(`GZ set effect: ${["stage reverb","hall reverb","room reverb","chorus","tremelo","phaser","rotary speaker","enhancer","flanger","EQ"][r[0]]||"off"}`)}),this.#A.add([127,0],(r,i,n)=>{e.switchMode("motif");let s=new Uint8Array([127,1,...r]);e.#A.run(s,i,n)}).add([127,1,0,0],(r,i,n)=>{e.switchMode("s90es");let s="S90/Motif ES system ",a=r[0];r.subarray(1).forEach((l,f)=>{([()=>{e.#f=l*12900/16383,e.dispatchEvent("mastervolume",e.#f)}][a+f]||(()=>{console.info(`Unrecognized ${s}ID: ${a+f}`)}))()})}).add([127,1,0,0,14],(r,i,n)=>{e.switchMode("s90es");let s="S90/Motif ES bulk header ",a=[];a[95]=(l,f,d)=>{console.debug(`${s}multi edit buffer: ${l[1]}`)},(a[r[0]]||(()=>{console.info(`Unrecognized ${s}ID: ${r[0]}.`)}))(r.subarray(1))}).add([127,1,0,0,15],(r,i,n)=>{e.switchMode("s90es");let s="S90/Motif ES bulk footer ",a=[];a[95]=(l,f,d)=>{console.debug(`${s}multi edit buffer: ${l[1]}`)},(a[r[0]]||(()=>{console.info(`Unrecognized ${s}ID: ${r[0]}.`)}))(r.subarray(1))}).add([127,1,0,58,55],(r,i,n)=>{e.switchMode("s90es");let s=e.chRedir(r[0],i,!0),a=y.cc*s,l=r[1],f=`S90/Motif ES bulk CH${s<16?s+1:"U"+(s-95)} `;console.debug(f,r),!(r[0]>15)&&r.subarray(2).forEach((d,p)=>{([()=>{e.#e[a+b[0]]=d,e.dispatchEvent("voice",{part:s})},()=>{d&&e.setChActive(s,1),e.#e[a+b[32]]=d,e.setChType(s,[32,40].indexOf(d)>-1?e.CH_DRUMS:e.CH_MELODIC,e.#t,!0),e.dispatchEvent("voice",{part:s})},()=>{d&&e.setChActive(s,1),e.#n[s]=d,e.dispatchEvent("voice",{part:s})},()=>{let g=e.chRedir(d,i,!0);e.#u[s]=g,s!=g&&(e.buildRchTree(),console.info(`${f}receives from CH${g+1}`))},()=>{e.#p[s]=d?0:1},!1,!1,!1,!1,!1,!1,!1,!1,()=>{e.#e[a+b[7]]=d},()=>{e.#e[a+b[10]]=d},!1,!1,!1,()=>{e.#e[a+b[91]]=d},()=>{e.#e[a+b[93]]=d},()=>{e.#e[a+b[94]]=d},()=>{e.#e[a+b[128]]=d},()=>{},()=>{e.#e[a+b[74]]=d},()=>{e.#e[a+b[71]]=d},!1,()=>{e.#e[a+b[65]]=d},()=>{e.#e[a+b[5]]=d},()=>{}][l+p]||(()=>{}))()})}).add([127,1,54,16],(r,i,n)=>{e.switchMode("s90es");let s=r[0];r.subarray(1).forEach((a,l)=>{let d=`S90/Motif ES EQ${(l>>2)+1} `;([()=>{let p=a-64},()=>{let p=B[a]},()=>{let p=a/10},()=>{let p=a}][s+l&3]||(()=>{}))()})}),this.#L.add([0,72,18,0,0,0,0],(r,i,n)=>{e.switchMode("sd",!0),console.info("MIDI reset: SD")}).add([0,72,18,16,0],(r,i,n)=>{let s=r[0]>>5,a=r[0]&31;switch(s){case 0:{console.debug(`Unknown SD-90 global effects message: +%o`,r);break}case 1:{let l=e.chRedir(a,i,!0),f=r[1],d=l*y.cc;r.subarray(2).forEach((p,g)=>{let v=f+g;v<37?([()=>{},()=>{},0,()=>{},()=>{switch(e.#e[d+b[0]]=p,p){case 104:case 105:case 106:case 107:case 120:{e.#s[l]||e.setChType(l,e.CH_DRUMS);break}default:e.#s[l]&&e.setChType(l,e.CH_MELODIC)}e.dispatchEvent("voice",{part:l})},()=>{e.#e[d+b[32]]=p,e.dispatchEvent("voice",{part:l})},()=>{e.#n[l]=p,e.dispatchEvent("voice",{part:l})},()=>{e.#e[d+b[7]]=p},()=>{e.#e[d+b[10]]=p},()=>{},()=>{},()=>{p<2&&(e.#p[l]=p)},()=>{p<2&&(e.#e[d+b[68]]=p?127:0)},()=>{},()=>{p<2&&(e.#e[d+b[65]]=p?127:0)},()=>{e.#e[d+b[5]]=p&15<<4|e.#e[d+b[5]]&15},()=>{e.#e[d+b[5]]=p&15|(e.#e[d+b[5]]&240)>>4},()=>{e.#e[d+b[74]]=p},()=>{e.#e[d+b[71]]=p},()=>{e.#e[d+b[73]]=p},()=>{e.#e[d+b[72]]=p},0,0,0,0,0,0,0,()=>{e.#e[d+b[128]]=p},()=>{e.#e[d+b[93]]=p},()=>{e.#e[d+b[91]]=p},0,0,()=>{e.#e[d+b[75]]=p},()=>{e.#e[d+b[76]]=p},()=>{e.#e[d+b[77]]=p},()=>{e.#e[d+b[78]]=p}][v]||(()=>{}))():v<63||(v<64?e.#s[l]?e.#e[d+b[0]]=104|p:e.#e[d+b[0]]=96|p:console.debug(`Unknown SD-90 global CH${l+1} param setup message: +%o`,r))});break}case 2:{let l=e.chRedir(a,i,!0),f=r[1];console.debug(`Unknown SD-90 global CH${l+1} MIDI setup message: +%o`,r.subarray(2));break}default:console.warn(`Unknown SD-90 global part setup message: +%o`,r)}})}};var ne=Ze(Le(),1);var Ie=class{#t=!1;constructor(e,t,c,o){this.#t=e,this.start=t,this.end=c,this.data=o}get duration(){return this.ranged?this.end-this.start:0}get ranged(){return this.#t}},ie=class extends Ie{constructor(e,t,c){super(!0,e,t,c)}},Ue=class extends Ie{constructor(e,t){super(!1,e,e,t)}},se=class extends Array{#t=-1;constructor(){super(...arguments)}resetIndex(e){this.#t=-1}fresh(){this.sort(function(e,t){return e.start==t.start?0:(+(e.start>t.start)<<1)-1}),this.forEach(function(e,t){e.index=t})}step(e,t=!1){let c=[];if(t)for(let o=0;oe);o++){if(this[o].endh.#t&&(c.push(u),h.#t=u.index)})}return c}getRange(e,t){e>t&&([e,t]=[t,e]);let c=[],o=-1,h=Math.ceil(Math.sqrt(this.length)),u=!0;for(let m=0;m=e&&(o=m):o=o<0?m:o;for(;u;)this[o]?.end=e&&c.push(this[o]):u=!1,o++;return c}};var dt=0xffffffffffff,Ne=function(e){let t=new se,c=this,o=e.timeDivision,h=120,u=new se,m=0,r=0;u.push(new ie(0,dt,[120,0])),e.track.forEach(function(a){m=0,a.event.forEach(function(l){m+=l.deltaTime,l.type==255&&l?.metaType==81&&(h=6e7/l.data,u[u.length-1]&&u.push(new ie(m,0xffffffffffff,[h,0])))})}),u.fresh(),u.forEach(function(a,l,f){l>0&&(f[l-1].end=a.start)});let i=120;u.forEach(function(a,l,f){l>0&&(a.end==a.start?f.splice(f.indexOf(a),1):i==a.data[0]&&(f[l-1].end=a.end,f.splice(f.indexOf(a),1)),i=a.data[0])});let n=0,s=120;return u.forEach(function(a){let l=a.start,f=l/s/o*60+n;s=a.data[0],n=f-l/s/o*60,a.data[1]=n}),console.debug("All tempo changes: ",u),h=120,m=0,r=0,e.track.forEach(function(a,l){m=0,r=0;let f=l+1;a.event.forEach(function(d,p){m+=d.deltaTime;let g=u.step(m,!0)[0];g&&(h=g.data[0],r=g.data[1]);let v={type:d.type,data:d.data,track:f,part:0};d.type>14?v.meta=d.metaType:v.part=d.channel,t.push(new Ue(m/h/o*60+r,v))})}),t.fresh(),self.midiEvents=t,console.debug(`Parsed a type ${e.formatType} MIDI sequence.`),t};ne.default.customInterpreter=xe;var S=function(e,t,c){e.addEventListener(c,o=>{t.dispatchEvent(c,o.data)})},Be=class extends K{device;#t;#h={};#E=[];#o="";#m=[];#w=new Uint8ClampedArray(128);#u=new Uint8ClampedArray(128);#s=.5;#e=120;#d=4;#n=4;#l=0;#p=0;smoothingAtk=0;smoothingDcy=0;reset(){let e=this;e.dispatchEvent("reset"),e.#t?.resetIndex(),e.device.init(),e.#o="",e.#s=.5,e.#e=120,e.#d=4,e.#n=4,e.#l=0,e.#p=0,e.dispatchEvent("tempo",e.#e),e.dispatchEvent("title",e.#o)}init(){this.reset(),this.#t=void 0}async loadFile(e){this.#t=Ne(ne.default.parse(new Uint8Array(await e.arrayBuffer())))}async loadMap(e,t){let c=this,o=0,h=0,u=0,m,r;e.split(` +`).forEach((i,n)=>{if(!i)return;let s=i.split(" ");if(n){if(!u)return;let a="",l="";s.forEach((f,d)=>{switch(d){case m:{a=f;break}case r:{l=f;break}}}),!c.#h[a]||t?(c.#h[a]=l,o++):self.debugMode&&console.debug(`Voice "${l}" (${a}) seems to be in conflict with (${c.#h[a]}).`),h++}else s.forEach((a,l)=>{switch(a){case"ID":{m=l,u++;break}case"Name":{r=l,u++;break}default:console.debug(`Unknown map field: ${a}`)}})}),console.debug(`Voice names: ${h} total, ${o} loaded.`),c?.device.forceVoiceRefresh()}async loadEfx(e,t){let c=this,o=0,h=0,u,m,r;e.split(` +`).forEach((i,n)=>{if(i)if(n){let s=0,a;i.split(" ").forEach((l,f)=>{switch(f){case u:{s|=parseInt(l,16)<<8;break}case m:{s|=parseInt(l,16);break}case r:{a=l;break}}}),!c.#E[s]||t?(c.#E[s]=a,o++):self.debugMode&&console.debug(`EFX ID 0x${s.toString(16).padStart(4,"0")} (${a}) seems to be in conflict.`),h++}else i.split(" ").forEach((s,a)=>{switch(s){case"MSB":{u=a;break}case"LSB":{m=a;break}case"Name":{r=a;break}default:console.debug(`Unknown EFX field: ${s}`)}})}),console.debug(`EFX: ${h} total, ${o} loaded.`),c.dispatchEvent("efxreverb",c.device.getEffectType(0)),c.dispatchEvent("efxchorus",c.device.getEffectType(1)),c.dispatchEvent("efxdelay",c.device.getEffectType(2)),c.dispatchEvent("efxinsert0",c.device.getEffectType(3)),c.dispatchEvent("efxinsert1",c.device.getEffectType(4)),c.dispatchEvent("efxinsert2",c.device.getEffectType(5)),c.dispatchEvent("efxinsert3",c.device.getEffectType(6))}switchMode(e,t=!1){this.device.switchMode(e,t)}getMode(){return this.device.getMode()}getVoice(){return this.device.getVoice(...arguments)}getChVoice(e){return this.device.getChVoice(e)}getMapped(e){return this.#h[e]||e}getEfx([e,t]){let c=e<<8|t;return this.#E[c]||`0x${c.toString(16).padStart(4,"0")}`}get noteProgress(){return this.#p/this.#s}get noteOverall(){return this.noteProgress-this.#l}get noteBar(){return Math.floor(this.noteOverall/this.#d)}get noteBeat(){let e=this.noteOverall%this.#d;return e<0&&(e+=this.#d),e}getTimeSig(){return[this.#d,this.#n]}getTempo(){return this.#e}sendCmd(e){this.device.runJson(e)}render(e){e>this.#p&&(this.#p=e);let t=this.#t?.step(e)||[],c=0,o=new Set,h=this,u=[];this.device.getStrength().forEach((p,g)=>{this.#u[g]=p}),h.device.newStrength(),t.forEach(function(p){let g=p.data;g.type==9&&(g.data[1]>0?o.add(g.part*128+g.data[0]):o.has(g.part*128+g.data[0])&&c++),p.data.type==8&&o.has(g.part*128+g.data[0])&&c++;let v=h.device.runJson(g);switch(v?.reply){case"meta":{u.push(v);break}}v?.reply&&delete v.reply}),u?.length>0&&this.dispatchEvent("meta",u);let m=this.device.getActive(),r=[],i=h.device.getPitch(),n=h.device.getCcAll(),s=h.device.getProgram(),a=h.device.getChType(),l=this.device.getStrength();l.forEach(function(p,g,v){v[g]=Math.max(h.#u[g],p);let k=v[g]-h.#w[g],$=b.length*g;if(k>=0){let I=4*.25**(n[$+b[73]]/64);h.#w[g]+=Math.ceil(k-k*h.smoothingAtk**I)}else{let I=4*.25**(n[$+b[72]]/64);h.#w[g]+=Math.floor(k-k*h.smoothingDcy**I)}});let f=0;return m.forEach(function(p,g){p&&(r[g]=h.device.getVel(g),f+=r[g].size)}),{extraPoly:c,curPoly:f,chInUse:m,chKeyPr:r,chPitch:i,chProgr:s,chContr:n,chType:a,eventCount:t.length,title:this.#o,bitmap:this.device.getBitmap(),letter:this.device.getLetter(),texts:this.device.getTexts(),master:this.device.getMaster(),mode:this.device.getMode(),strength:this.#w.slice(),velo:l,rpn:this.device.getRpn(),tSig:this.getTimeSig(),tempo:this.getTempo(),noteBar:this.noteBar,noteBeat:this.noteBeat,ace:this.device.getAce(),efxSink:this.device.getEffectSink()}}constructor(e,t=.5,c=.5){super();let o=this;o.smoothingAtk=t,o.smoothingDcy=c,o.device=e,o.addEventListener("meta",function(h){h?.data?.forEach(function(u){(o.#m[u.meta]||console.debug).call(o,u.meta,u.data)})}),S(o.device,o,"mode"),S(o.device,o,"mastervolume"),S(o.device,o,"channelactive"),S(o.device,o,"channelmin"),S(o.device,o,"channelmax"),S(o.device,o,"channelreset"),S(o.device,o,"channeltoggle"),S(o.device,o,"screen"),S(o.device,o,"metacommit"),S(o.device,o,"voice"),S(o.device,o,"pitch"),S(o.device,o,"note"),S(o.device,o,"reset"),S(o.device,o,"efxreverb"),S(o.device,o,"efxchorus"),S(o.device,o,"efxdelay"),S(o.device,o,"efxinsert0"),S(o.device,o,"efxinsert1"),S(o.device,o,"efxinsert2"),S(o.device,o,"efxinsert3"),S(o.device,o,"partefxtoggle"),o.#m[3]=function(h,u){o.#o?.length<1&&(o.#o=u,o.dispatchEvent("title",o.#o))},o.#m[81]=function(h,u){let m=o.noteProgress,r=o.#s||.5;o.#e=6e7/u,o.#s=u/1e6,o.#l+=m*(r/o.#s)-m,o.dispatchEvent("tempo",o.#e)},o.#m[88]=function(h,u){let m=o.noteProgress,r=o.noteOverall,i=o.noteBar,n=o.noteBeat,s=o.#d,a=o.#n;o.#d=u[0],o.#n=1<=s&&(s{le&&(ce[V]=!ce[V],V++,V>34&&(V=0))},1e3/50);Uint8Array.prototype.render=function(e){let t=0,c=0,o=this.width||5,h=this.height||8;for(let u=0;u=o&&(t=0,c++)};var He=class{#t=[];async load(e,t=!1,c="(internal)"){let o=this,h=0,u=0;console.debug(`Font "${c||"(internal)"}": loading started.`),e.split(` +`).forEach(function(m,r){if(r>0&&m?.length>0){let i=m.split(" "),n=parseInt(i[0],16);if(u++,o.#t[n]&&!t)return;let s=new Uint8Array(40);Array.from(i[1]).forEach(async function(a,l){let f=l%2?4:0,d=Math.floor(l/2),p=parseInt(a,16),g=3;for(;p>0||g>=0;){let v=(f+g)*5+d;s[v]=p&1,p=p>>1,g--}}),o.#t[n]=s,h++}}),console.debug(`Font "${c||"(internal)"}": ${u} total, ${h} loaded.`)}async loadFile(e,t=!1){let c=this;console.debug(`Requested font file from "${e}".`),await c.load(await(await fetch(e)).text(),t,e),le=!1}constructor(...e){le=!0,(async()=>{for(let t=0;t{o.classList.add(s)});let{t:h,l:u,w:m,h:r,i,a:n}=c;return h?.constructor&&(o.style.top=h?.length?h:`${h}px`),u?.constructor&&(o.style.left=u?.length?u:`${u}px`),m?.constructor&&(o.style.width=m?.length?m:`${m}px`),r?.constructor&&(o.style.height=r?.length?r:`${r}px`),i?.constructor&&o.appendChild(document.createTextNode(i)),n?.constructor&&(o.style.textAlign=n),o},M=function(e,t){let c=document.createElementNS("http://www.w3.org/2000/svg",e);for(let o in t)c.setAttribute(o,t[o]);return c},T=function(e,t){t?.forEach(c=>{e.appendChild(c)})},L=function(e,t){t.forEach(c=>{e.classList.contains(c)&&e.classList.remove(c)})},N=function(e,t){t.forEach(c=>{e.classList.contains(c)||e.classList.add(c)})},Fe=new Array(128).fill(0);Fe.forEach((e,t,c)=>{c[t]=Math.floor(24*t/12.7)/10});var de=new Array(128).fill(0);de.forEach((e,t,c)=>{c[t]=Math.abs(Math.round(48*(t-64)/12.7)/10)});var Ve=new Array(11).fill(null);Ve.forEach((e,t,c)=>{c[t]=`${Math.round(t*12/.0128)/100}%`});var mt=new Array(128).fill(null);mt.forEach((e,t,c)=>{c[t]=`${Math.round(t/1.27)/100}`});var P=function(e,t){let c=Fe[t];e.setAttribute("height",c),e.setAttribute("y",24-c)},_e=function(e,t){e.innerText=t,e.rNew=!0;let c=e.measureText(t);e.rWidth=c.width},da=class extends Be{#t=128;#h=!1;#E="";#o;#m=0;#w=0;#u=0;#s=0;#e=1;#d=0;#n=new Uint8Array(1280);#l=new Uint8Array(1280);#p=new Uint8Array(1280);#b=new Uint8Array(512);#v=new Uint8Array(512);#D=new Uint8Array(512);#C;#H;#r;#i;#I;#x="fcdaff";#a={};#$={};#c=[];#y={};#S={};#T=[];#G=[];#O="block";glyphs=new He;#M(e,t,c,o=0,h=0){let u=this,{width:m,height:r}=e.canvas,i,n,s,a,l=u.#e,f=o>3,d=ht.indexOf(t%12)>-1;switch(u.#O){case"block":case"comb":{i=Math.round(t*m/128),n=Math.round((t+1)*m/128),s=n-i,a=l==1?2:1;break}case"piano":{i=Math.round((Math.floor(t/12)*7+Ge[t%12])*m/75*1.0044642857142856),n=Math.round((Math.floor(t/12)*7+Ge[t%12]+1)*m/75*1.0044642857142856)-1,s=n-i,a=l==1?3:1;break}case"line":{let p=t-h;Math.abs(h)>2&&(p=t-Math.sign(h)*2),n=Math.round((t+.5)*m/128),i=Math.round((p+.5)*m/128)}default:}switch(e.fillStyle=`#${d?u.#x:"ffffff"}${(c<<1|c>>6).toString(16).padStart(2,"0")}`,e.strokeStyle=e.fillStyle,e.lineWidth=l==1?4:2,e.lineDashOffset=0,u.#O){case"block":{let p=e.canvas.height-1;e.fillRect(i,1,s,p),f&&e.clearRect(i+a,a+1,s-(a<<1),p-(a<<1));break}case"comb":{let p=(d?Math.round((e.canvas.height<<1)/3):e.canvas.height)-1;e.fillRect(i,1,s,p),f&&e.clearRect(i+a,a+1,s-(a<<1),p-(a<<1));break}case"piano":{let p=(d?0:e.canvas.height>>1)+1,g=(e.canvas.height>>1)-1;e.fillRect(i,p,s,g),f&&e.clearRect(i+a,p+a,s-(a<<1),g-(a<<1));break}case"line":{if(f)switch(l){case 4:{e.setLineDash(oe[2]);break}default:e.setLineDash(oe[1])}else e.setLineDash(oe[0]),l!=4&&self?.document?.mozFullScreen&&(i+=.5,n+=.5);e.beginPath(),e.moveTo(i,(l==4||!f)&&self?.document?.mozFullScreen?2:1),e.lineTo(n,(r>>1)+2),e.lineTo(i,r+2),e.stroke();break}default:}}#f(e,t){let c=this;(e?.chInUse||t).forEach((o,h)=>{if(o){let u=c.#c[h>>4][h&15].cxt;u.clearRect(0,0,u.canvas.width,u.canvas.height),e.chKeyPr[h].forEach(({v:m,s:r},i)=>{c.#M(u,i,m,r,c.device.getPitchShift(h))})}})}#X(e){let t=this;Date.now()-t.#m>4e3&&(t.#w=0,t.#u=142-t.#y.view.clientHeight,(t.#o?.clientWidth||0)>840&&(t.#w=840-t.#o.clientWidth),t.#y.view.style.transform=`translateX(${t.#w}px) translateY(${t.#u}px)`,e&&(t.#m=0))}#z(){let e=self.innerWidth/self.innerHeight,t=1,c=self.innerWidth,o=self.innerHeight;e>=W?(t=Math.round(self.innerHeight/1080*1e4)/1e4,c=Math.ceil(self.innerHeight*W)):e>4,f=a*y.cc,d=e.#c[l][a&15];if(c.chInUse[a]&&l>=e.#d&&ld.metre.canvas.width){d.metre.rNew&&(d.metre.rNew=!1,d.metre.rOffset=t);let g=t-(d.metre.rOffset||0),v=32,k=d.metre.rWidth-d.metre.canvas.width+v,$=g*-25%(d.metre.rWidth+v+48)+48;$>0&&($=0),d.metre.fillText(d.metre.innerText,$,3+e.#I.font4[0]),Math.abs($)>k&&d.metre.fillText(d.metre.innerText,$+d.metre.rWidth+v,3+e.#I.font4[0])}else d.metre.fillText(d.metre.innerText,0,3+e.#I.font4[0]);d.metre.globalCompositeOperation="xor",d.metre.fillRect(0,0,c.strength[a]*121/255,25);let p=c.chContr[f+b[10]];d.pan.setAttribute("width",`${de[p]||0}`),p<64?d.pan.setAttribute("x",`${84-de[p]}`):p>127?(d.pan.setAttribute("x","60"),d.pan.setAttribute("width","48")):d.pan.setAttribute("x","84")}}let m=new Set,r=new Set,i=new Array(y.ch),n={};if(e.#c.forEach((a,l)=>{a.forEach((f,d)=>{f.refresh&&(f.refresh=!1,i[l<<7|d]=!0)})}),["line"].indexOf(e.#O)>-1)for(;e.#G.length>0;){let a=e.#G.shift();i[a.part]=!0}for(;e.#T.length>0;){let a=e.#T.shift(),{part:l,note:f,velo:d,state:p}=a,g=l<<7|f;i[l]=!0,p==0?m.has(g)&&(r.add(g),e.#c[l>>4][l&15].refresh=!0):(m.add(g),n[g]=a)}e.#f(c,i),r.forEach(a=>{let{part:l,note:f,velo:d,state:p}=n[a],g=e.#c[l>>4][l&15].cxt;e.#M(g,f,d,p,e.device.getPitchShift(l))});let s=e.#S.cxt;o>c.bitmap.expire?e.#D.fill(0):c.bitmap.bitmap.length>256?c.bitmap.bitmap.forEach((a,l)=>{e.#D[l]=a?255:0}):c.bitmap.bitmap.forEach((a,l)=>{e.#D[l<<1]=a?255:0,e.#D[l<<1|1]=a?255:0}),e.#p.fill(0),o<=c.letter.expire&&e.glyphs.getStr(c.letter.text).forEach((a,l)=>{let f=(l&15)*5,d=l>>4<<3;a.forEach((p,g)=>{let v=f+g%5,k=d+Math.floor(g/5);e.#p[k*80+v]=p?255:0})}),e.#b.forEach((a,l,f)=>{let d=e.#D[l];d>a?f[l]+=Math.min(d-a,Q):d{let d=e.#p[l];d>a?f[l]+=Math.min(d-a,Q):d{let f=l>>5,d=l&31;e.#v[l]!=a?(s.clearRect(252+(d<<2),f<<2,3,3),a&&(s.fillStyle=`#ffffff${a.toString(16).padStart(2,"0")}`,s.fillRect(252+(d<<2),f<<2,3,3))):self.debugMode&&(s.clearRect(252+(d<<2),f<<2,3,3),a&&(s.fillStyle=`#ff0000${a.toString(16).padStart(2,"0")}`,s.fillRect(252+(d<<2),f<<2,3,3)))}),e.#n.forEach((a,l)=>{let f=Math.floor(l/80),d=l%80;d+=Math.floor(d/5),e.#l[l]!=a?(s.clearRect(d<<2,(f|16)<<2,3,3),a&&(s.fillStyle=`#ffffff${a.toString(16).padStart(2,"0")}`,s.fillRect(d<<2,(f|16)<<2,3,3))):self.debugMode&&(s.clearRect(d<<2,(f|16)<<2,3,3),a&&(s.fillStyle=`#ff0000${a.toString(16).padStart(2,"0")}`,s.fillRect(d<<2,(f|16)<<2,3,3)))}),e.#v.forEach((a,l,f)=>{f[l]=e.#b[l]}),e.#l.forEach((a,l,f)=>{f[l]=e.#n[l]})}#N;#q;get style(){return this.#O}set style(e){let t=this;t.#O=e,t.#f(t.render(t.#C?.currentTime||0)),L(t.#i,["cambiare-style-block","cambiare-style-comb","cambiare-style-piano","cambiare-style-line"]),N(t.#i,[`cambiare-style-${e}`])}setClockSource(e){this.#C=e}setPixelProfile(e){let t=this;if(Xe[e]){let c=Xe[e];t.#I=c,t.#i&&(t.#i.style.setProperty("--pcp-font4",`translate(${c.font4[1]}px, ${c.font4[0]}px)`),t.#i.style.setProperty("--pcp-font7",`translate(${c.font7[1]}px, ${c.font7[0]}px)`))}else throw new Error(`"${e}" is not a valid pixel correction profile`)}setMode(e){let t=this;L(t.#i,["cambiare-mode-gm","cambiare-mode-xg","cambiare-mode-gs","cambiare-mode-ns5r","cambiare-mode-05rw","cambiare-mode-x5d","cambiare-mode-k11","cambiare-mode-sg","cambiare-mode-g2","cambiare-mode-mt32","cambiare-mode-sd","cambiare-mode-krs","cambiare-mode-s90es","cambiare-mode-motif"]),e!="?"&&N(t.#i,[`cambiare-mode-${e}`]),t.#x={xg:"9efaa0",ns5r:"9efaa0",x5d:"9efaa0","05rw":"9efaa0",k11:"9efaa0",s90es:"9efaa0",motif:"9efaa0",gm:"a1f3ff",g2:"a1f3ff",krs:"a1f3ff",gs:"ffe1a5",mt32:"ffe1a5",sd:"ffe1a5",sg:"ffdddd"}[e]||"fcdaff"}#F(e){let t=this,c=t.#e,o=t.#d;t.#c.forEach((h,u)=>{if(u>=o&&u{n.root.style.top=`${s*(c>2?26:52)}px`})}else L(h.root,["port-active"]),h.root.style.top="",h.root.style.left="",h.forEach((m,r)=>{m.root.style.top=""});e&&h.forEach((m,r)=>{m.cxt.canvas.width=t.#e==1?1193:495,m.cxt.canvas.height=t.#e==4?26:52})})}setPort(e){let t=this;L(t.#i,["cambiare-start0","cambiare-start1","cambiare-start2","cambiare-start3","cambiare-start4","cambiare-start5","cambiare-start6","cambiare-start7"]),N(t.#i,[`cambiare-start${e}`]),t.#d=e,t.#F(!1)}setRange(e){let t=this;L(t.#i,["cambiare-port1","cambiare-port2","cambiare-port4","cambiare-compact"]),N(t.#i,[`cambiare-${e}`]),t.#e=parseInt(e.slice(4))||1,t.#F(!0)}attach(e){let t=this;t.#H=e;let c=E("div",["cambiare-container"]);e.appendChild(c),t.#r=c;let o=E("div",["cambiare-canvas","cambiare-port1","cambiare-start0","cambiare-style-block"]);c.appendChild(o),t.#i=o,self.addEventListener("resize",t.#U),t.#U(),t.#q=setInterval(t.#N,20),t.#a.root=E("div",["sect-info"]),t.#a.events=E("span",["field","pcp-font4"],{t:1,l:0,w:35,h:33}),t.#a.curPoly=E("span",["field","pcp-font4"],{t:1,l:52,w:35,h:33}),t.#a.maxPoly=E("span",["field","pcp-font4"],{t:1,l:98,w:35,h:33}),t.#a.sigN=E("span",["field","pcp-font4"],{t:1,l:194,w:23,h:33,a:"right"}),t.#a.sigD=E("span",["field","pcp-font4"],{t:1,l:232,w:23,h:33}),t.#a.barCount=E("span",["field","pcp-font4"],{t:1,l:304,w:35,h:33,a:"right"}),t.#a.barNote=E("span",["field","pcp-font4"],{t:1,l:354,w:23,h:33}),t.#a.tempo=E("span",["field","pcp-font4"],{t:1,l:454,w:64,h:33,a:"right"}),t.#a.volume=E("span",["field","pcp-font4"],{t:1,l:562,w:63,h:33,a:"right"}),t.#a.mode=E("span",["field","pcp-font4"],{t:1,l:708,w:152,h:33}),t.#a.reverb=E("span",["field","pcp-font4"],{t:1,l:1e3,w:190,h:33}),t.#a.chorus=E("span",["field","pcp-font4"],{t:1,l:1240,w:190,h:33}),t.#a.delay=E("span",["field","pcp-font4"],{t:1,l:1475,w:190,h:33}),t.#a.insert=E("span",["field","pcp-font4"],{t:1,l:1706,w:190,h:33}),t.#a.title=E("span",["field","pcp-font4"],{t:35,l:50,w:810,h:33}),o.appendChild(t.#a.root),T(t.#a.root,[t.#a.events,t.#a.curPoly,E("span",["field","field-label","pcp-font4"],{t:1,l:89,w:5,h:33,i:":"}),t.#a.maxPoly,E("span",["field","field-key","pcp-font7"],{t:1,l:148,w:41,h:33,i:"TSig"}),t.#a.sigN,E("span",["field","field-label","pcp-font4"],{t:0,l:221,w:8,h:33,i:"/"}),t.#a.sigD,E("span",["field","field-key","pcp-font7"],{t:1,l:268,w:30,h:33,i:"Bar"}),t.#a.barCount,E("span",["field","field-label","pcp-font4"],{t:0,l:343,w:8,h:33,i:"/"}),t.#a.barNote,E("span",["field","field-key","pcp-font7"],{t:1,l:390,w:61,h:33,i:"Tempo",a:"right"}),t.#a.tempo,E("span",["field","field-key","pcp-font7"],{t:1,l:528,w:29,h:33,i:"Vol"}),t.#a.volume,E("span",["field","field-label","pcp-font4"],{t:1,l:626,w:17,h:33,i:"%"}),E("span",["field","field-key","pcp-font7"],{t:1,l:652,w:52,h:33,i:"Mode"}),t.#a.mode,E("span",["field","field-key","pcp-font7"],{t:1,l:960,w:34,h:33,i:"Rev"}),t.#a.reverb,E("span",["field","field-key","pcp-font7"],{t:1,l:1198,w:36,h:33,i:"Cho"}),t.#a.chorus,E("span",["field","field-key","pcp-font7"],{t:1,l:1438,w:31,h:33,i:"Var"}),t.#a.delay,E("span",["field","field-key","pcp-font7"],{t:1,l:1673,w:27,h:33,i:"Ins"}),t.#a.insert,E("span",["field","field-key","pcp-font7"],{t:35,l:0,w:44,h:33,i:"Title"}),t.#a.title]),t.#$.root=E("div",["sect-mark"]),t.#$.left=E("div",["sect-mark-left","boundary"],{t:0,l:0}),t.#$.right=E("div",["sect-mark-right","boundary"],{t:0,l:960}),o.appendChild(t.#$.root),T(t.#$.root,[t.#$.left,t.#$.right]),T(t.#$.left,[E("span",["field","field-key"],{t:0,l:0,w:26,h:33,i:"CH"}),E("span",["field","field-key"],{t:0,l:30,w:49,h:33,i:"Voice"}),E("span",["field","field-key","mark-send-title"],{t:2,l:164,w:25,h:18,i:"Send"}),E("span",["field","field-label","mark-send-param"],{t:16,l:146,w:58,h:16,i:"VEMRCDBP12",a:"center"}),E("span",["field","field-key"],{t:0,l:212,w:35,h:33,i:"Pan"}),E("span",["field","field-key"],{t:0,l:256,w:45,h:33,i:"Note"})]),T(t.#$.right,[E("span",["field","field-key"],{t:0,l:0,w:26,h:33,i:"CH"}),E("span",["field","field-key"],{t:0,l:30,w:49,h:33,i:"Voice"}),E("span",["field","field-key","mark-send-title"],{t:2,l:164,w:25,h:18,i:"Send"}),E("span",["field","field-label","mark-send-param"],{t:16,l:146,w:58,h:16,i:"VEMRCDBP12",a:"center"}),E("span",["field","field-key"],{t:0,l:212,w:35,h:33,i:"Pan"}),E("span",["field","field-key"],{t:0,l:256,w:45,h:33,i:"Note"})]),t.#c.root=E("div",["sect-part"]);for(let h=0;h>4;h++){let u=h<<4;t.#c[h]=[],t.#c[h].root=E("div",["boundary",`part-port-${h}`]);for(let m=0;m<16;m++){let r=(u|m)+1;r>=100?r=`${Math.floor(r/10).toString(16)}${r%10}`:r=`${r}`.padStart(2,"0"),t.#c[h][m]={root:E("div",["boundary","part-channel"]),major:E("div",["boundary","part-info-major"]),minor:E("div",["boundary","part-info-minor"],{t:26}),keys:E("div",["boundary","part-keys"]),notes:E("div",["boundary","part-keyboard"]),cxt:E("canvas",["field"]).getContext("2d"),number:E("span",["field","field-label","pcp-font4"],{t:1,w:18,h:25,i:r}),voice:E("span",["field"],{l:22,t:1,w:121,h:25}),metre:E("canvas",["field"]).getContext("2d"),type:E("span",["field","field-label","pcp-font4"],{t:1,w:18,h:25}),std:E("span",["field","pcp-font4"],{l:22,t:1,w:20,h:25,a:"center"}),msb:E("span",["field","pcp-font4"],{l:48,t:1,w:27,h:25}),prg:E("span",["field","pcp-font4"],{l:81,t:1,w:27,h:25}),lsb:E("span",["field","pcp-font4"],{l:114,t:1,w:27,h:25}),cc:M("svg",{viewBox:"0 0 108 24",width:108,style:"left: 146px; top: 1px; position: absolute;"}),vol:M("rect",{fill:"var(--accent-color)",width:4,height:24,x:0}),exp:M("rect",{fill:"var(--accent-color)",width:4,height:24,x:6}),mod:M("rect",{fill:"var(--accent-color)",width:4,height:24,x:12}),rev:M("rect",{fill:"var(--accent-color)",width:4,height:24,x:18}),cho:M("rect",{fill:"var(--accent-color)",width:4,height:24,x:24}),var:M("rect",{fill:"var(--accent-color)",width:4,height:24,x:30}),brt:M("rect",{fill:"var(--accent-color)",width:4,height:24,x:36}),por:M("rect",{fill:"var(--accent-color)",width:4,height:24,x:42}),cea:M("rect",{fill:"var(--accent-color)",width:4,height:24,x:48}),ceb:M("rect",{fill:"var(--accent-color)",width:4,height:24,x:54}),pan:M("rect",{fill:"var(--accent-color)",width:0,height:24,x:84})};let i=t.#c[h][m];Ve.forEach(n=>{i.notes.appendChild(E("span",["field","part-csplit"],{l:n}))}),i.notes.appendChild(E("span",["field","part-csplit","part-cdive"],{l:0,w:"100%",h:1})),i.metre.canvas.width=121,i.metre.canvas.height=25,i.metre.fillStyle="#fff",i.metre.textBaseline="top",i.metre.font="20px 'PT Sans Narrow'",T(i.notes,[i.cxt.canvas]),T(i.keys,[i.notes]),T(i.voice,[i.metre.canvas]),T(i.cc,[i.vol,i.exp,i.mod,i.rev,i.cho,i.var,i.brt,i.por,i.cea,i.ceb,i.pan,M("rect",{x:83,y:0,width:1,height:24,fill:"var(--foreground-color)"})]),T(i.major,[i.number,i.voice,i.cc]),T(i.minor,[i.type,i.std,i.msb,i.prg,i.lsb]),T(i.root,[i.major,i.minor,i.keys]),T(t.#c[h].root,[i.root])}t.#c.root.appendChild(t.#c[h].root)}o.appendChild(t.#c.root),t.#y.root=E("div",["sect-meta"]),t.#y.view=E("div",["boundary"]),o.appendChild(t.#y.root),T(t.#y.root,[t.#y.view]),t.#S.root=E("div",["sect-pix","boundary"],{l:1529,t:950,w:379,h:127}),t.#S.cxt=E("canvas",["field"]).getContext("2d"),t.#S.cxt.canvas.width=379,t.#S.cxt.canvas.height=127,T(t.#S.root,[t.#S.cxt.canvas]),o.appendChild(t.#S.root),t.addEventListener("mode",h=>{t.#a.mode.innerText=`${ut[h.data]}`,t.setMode(h.data)}),t.addEventListener("mastervolume",h=>{let u=Math.round(h.data*100)/100;t.#a.volume.innerText=`${Math.floor(u)}.${`${Math.floor(u%1*100)}`.padStart(2,"0")}`}),t.addEventListener("tempo",h=>{let u=Math.round(h.data*100);t.#a.tempo.innerText=`${Math.floor(u/100)}.${`${Math.floor(u%100)}`.padStart(2,"0")}`}),t.addEventListener("tsig",h=>{[t.#a.sigN.innerText,t.#a.sigD.innerText]=h.data}),t.addEventListener("title",h=>{t.#a.title.innerText=h.data||"No Title"}),t.addEventListener("voice",({data:h})=>{let u=t.getChVoice(h.part),m=t.#c[h.part>>4][h.part&15];_e(m.metre,t.getMapped(u.name)),m.type.innerText=ft[t.device.getChType()[h.part]],m.std.innerText=u.standard,m.msb.innerText=`${u.sid[0]}`.padStart(3,"0"),m.prg.innerText=`${u.sid[1]}`.padStart(3,"0"),m.lsb.innerText=`${u.sid[2]}`.padStart(3,"0")}),t.addEventListener("pitch",h=>{let{part:u,pitch:m}=h.data;t.#c[u>>4][u&15].notes.style.transform=`translateX(${m/1.28}%)`}),t.addEventListener("efxreverb",h=>{t.#a.reverb.innerText=t.getEfx(h.data)}),t.addEventListener("efxchorus",h=>{t.#a.chorus.innerText=t.getEfx(h.data)}),t.addEventListener("efxdelay",h=>{t.#a.delay.innerText=t.getEfx(h.data)}),t.addEventListener("efxinsert0",h=>{t.#a.insert.innerText=t.getEfx(h.data)}),t.addEventListener("partefxtoggle",h=>{let{part:u,active:m}=h.data;[L,N][m](t.#c[u>>4][u&15].number,["part-efx"])}),t.addEventListener("channeltoggle",h=>{let{part:u,active:m}=h.data;[L,N][m](t.#c[u>>4][u&15].root,["part-active"])}),t.addEventListener("metacommit",h=>{let u=h.data;if(t.#h&&u.type==t.#E&&t.#o)switch(u.type){case"C.Lyrics":case"KarLyric":case"SGLyrics":{T(t.#o,[E("span",["meta-slice"],{i:u.data})]);break}default:t.#o.childNodes[0].data+=u.data}else if(u.data?.length&&bt.indexOf(u.type)==-1){let m=E("div",["meta-line"]),r=E("span",["field","field-key","meta-type"],{i:pt[u.type]||u.type});switch(u.mask&&(r.style.display="none"),u.type){case"C.Lyrics":case"KarLyric":case"SGLyrics":{t.#o=E("span",["field","meta-data"]),T(t.#o,[E("span",["meta-slice"],{i:u.data})]);break}default:t.#o=E("span",["field","meta-data"],{i:u.data})}for(t.#y.view.appendChild(m),T(m,[r,t.#o]);t.#y.view.children.length>t.#t;)t.#y.view.children[0].remove()}t.#h=u.amend||!1,t.#E=u.type||"",t.#X()}),t.#y.view.style.transform="translateX(0px) translateY(140px)",t.dispatchEvent("mode","?"),t.dispatchEvent("mastervolume",100),t.dispatchEvent("tempo",120),t.dispatchEvent("tsig",[4,4]),t.dispatchEvent("title",""),t.dispatchEvent("efxreverb",t.device.getEffectType(0)),t.dispatchEvent("efxchorus",t.device.getEffectType(1)),t.dispatchEvent("efxdelay",t.device.getEffectType(2)),t.dispatchEvent("efxinsert0",t.device.getEffectType(3)),t.#F(!0)}detach(e){let t=this;self.removeEventListener("resize",t.#U),t.#i.remove(),t.#i=void 0,t.#r.remove(),t.#r=void 0,t.#H=void 0,clearInterval(t.#q)}constructor(e,t){super(new Ae,.1,.75);let c=this;c.#U=c.#z.bind(this),c.#N=c.#_.bind(this),e&&c.attach(e),t&&c.setClockSource(t),c.setPixelProfile("none"),c.addEventListener("reset",()=>{c.#s=0,c.#h=!1,c.#E="",c.#o=null;try{let o=c.#y.view.children;for(let h=o.length-1;h>=0;h--)o[h].remove();c.#y.view.style.transform="translateX(0px) translateY(140px)";for(let h=0;h>4][h&15];L(u.root,["part-active"]),L(u.number,["part-efx"]),_e(u.metre,""),u.type.innerText="",u.std.innerText="",u.msb.innerText="",u.prg.innerText="",u.lsb.innerText="",u.notes.style.transform=""}}catch{}}),c.addEventListener("note",({data:o})=>{c.#T.push(o)}),c.addEventListener("pitch",({data:o})=>{c.#G.push(o)})}};export{da as Cambiare}; diff --git a/dist/state.mjs b/dist/state.mjs index 368c16f7..6000a88d 100644 --- a/dist/state.mjs +++ b/dist/state.mjs @@ -1,8 +1,8 @@ -var K=function(e,a){let o=Math.min(e.length,a.length),h=e.slice(0,o),y=a.slice(0,o),g=0,d=0;for(;d0){let h=this.pool.length,y=1<=1&&d>=0;){if(d<=0)throw new Error("TTL reached.");if(g==h)g-=y;else{let s=K(a,this.pool[g]);switch(s){case 0:{d=0;break}case 1:{g+y<=h&&(g+=y);break}case-1:{g!=0&&(g-=y);break}default:console.warn(`Unexpected result ${s}.`)}}y=y>>1,d--}let t=!0;if(g>=this.pool.length)t=!1;else{let s=this;this.pool[g].forEach(function(n,i,r){t&&n!=a[i]&&(t=!1)}),!t&&K(a,this.pool[g])>0&&g++}return t||o?g:-1}else return o?0:-1},this.add=function(a,o){return a.data=o,this.pool.splice(this.point(a,!0),0,a),this},this.default=function(a){console.warn(`No match in "${this.name||"(unknown)"}" for "${a}". Default action not defined.`)},this.get=function(a){let o=this.point(a);if(o>-1)return this.pool[o].data;this.default(a)},this.run=function(a,...o){let h=this.point(a);h>-1?a.subarray?this.pool[h].data(a.subarray(this.pool[h].length),...o):this.pool[h].data(a.slice(this.pool[h].length),...o):this.default(a,...o)}};var z=class{#t={};addEventListener(e,a){this.#t[e]||(this.#t[e]=[]),this.#t[e].unshift(a)}removeEventListener(e,a){if(this.#t[e]){let o=this.#t[e].indexOf(a);o>-1&&this.#t[e].splice(o,1),this.#t[e].length<1&&delete this.#t[e]}}dispatchEvent(e,a){let o=new Event(e),h=this;o.data=a,this.#t[e]?.length>0&&this.#t[e].forEach(function(y){try{y?.call(h,o)}catch(g){console.error(g)}}),this[`on${e}`]&&this[`on${e}`](o)}};var ue=["MSB","PRG","LSB"],G=function(e){let a=Math.floor(e/10),o=e%10;return`${a.toString(16)}${o}`},B=class{#t;strictMode=!1;get(e=0,a=0,o=0,h){let y=[e,a,o],g,d=Array.from(arguments);switch(h){case"xg":{switch(e){case 0:{o==126?d[2]=125:o==127&&(d[2]=0);break}case 16:{o==126&&(d[2]=0);break}case 32:{o>125&&(d[2]=0),d[2]+=4;break}case 33:case 35:case 36:{o>125&&(d[2]=0),d[2]+=5;break}case 79:case 80:case 81:case 82:case 83:case 84:d[0]+=16;case 95:case 96:case 97:case 98:case 99:case 100:{o==126&&(d[2]=0);break}case 48:case 64:case 126:case 127:{o==126&&(d[2]=0);break}}break}case"gs":{e==0&&o<5?d[2]=0:e>125&&o<5&&o!=2&&(d[2]=e,d[0]=0);break}case"g2":case"sd":{(e>>1==40||e>95&&e<100)&&(d[2]|=16);break}case"sg":{e==8&&o==0&&(d[2]=5);break}case"s90es":{o<8?d[2]+=17:o<32?d[2]+=13:d[2]=(d[2]>>3)+19;break}case"motif":{o<8?d[2]+=28:o<32?d[2]+=13:d[2]=(d[2]>>3)+19;break}}let t=" ",s="M",n=0,i=0;switch(d[0]){case 0:{d[2]==127?s="MT-a":d[2]==126?s="MT-b":d[2]==7?s="GM-k":d[2]==5?s="SG-a":d[2]==4?s="SP-l":d[2]==0||h=="gs"&&d[2]<5?s="GM-a":(s="y",n=3);break}case 8:{h=="sg"?s="GM-s":s="r:";break}case 48:{s=`yM${(d[2]>>3).toString().padStart(2,"0")}`,n=1;break}case 56:{s="GM-b";break}case 61:case 120:{s="rDrm";break}case 62:{s="kDrm";break}case 63:{if(d[2]<17){let l=d[2];s=l<10?"kP:":"kC:",s+=l%10}else d[2]<34?s=["Pre1","Pre2","Pre3","Pre4","Usr1","Usr2","DrmP","DrmU","Plg1","Plg2","Plg3","Pre1","Pre2","Pre3","Pre4","Pre5","Pre6"][d[2]-17]:s="Ds";break}case 64:{s="ySFX";break}case 67:{s="DX:S";break}case 80:case 81:case 82:case 83:{s=`Prg${"UABC"[d[0]-80]}`;break}case 88:case 89:case 90:case 91:{s=`Cmb${"UABC"[d[0]-88]}`;break}case 95:{s=`${["DR","PC"][d[2]]}-d`;break}case 96:{s=d[2]==106?"AP-a":d[2]>>4==1?"SDg":"PF",d[2]>63?i=63:d[2]>>4==1&&(i=16),n=3;break}case 97:{s=d[2]>>4==1?"SDa":"VL:",n=3,d[2]>>4==1?i=16:i=112;break}case 98:{s=d[2]>>4==1?"SDb":"SG-a",n=3,i=16;break}case 99:{s=d[2]>>4==1?"SDc":"DX",d[2]>63?i=63:d[2]>>4==1&&(i=16),n=3;break}case 100:{s="AN",d[2]>63?i=63:d[2]>>4==1&&(i=16),n=3;break}case 104:case 105:case 106:case 107:{s="SDd",i=104;break}case 121:{s=`GM-${d[2]?"":"a"}`,n=3;break}case 122:{s="lDrm";break}case 126:{s="yDrS";break}case 127:{d[2]==127?s="rDrm":s="yDrm";break}default:d[0]<48?s="r:":s="M"}s.length<4&&(s+=`${[e,o,d[0],d[2]][n]-i}`.padStart(4-s.length,"0")),h=="xg"&&(e==0?d[2]<100?s=s.replace("y0","y:"):d[2]==125&&(s="y126"):e==16&&(g=`Voice${(d[2]*128+d[1]+1).toString().padStart(3,"0")}`,t=" "));let r=[d[0],d[1],d[2]];for(;!(g?.length>=0);)g=this.#t[d[1]||0][(d[0]<<7)+d[2]],g||(this.strictMode?(g="",t="?"):this.#t[d[1]||0][d[0]<<7]?d[0]==0?(d[2]=0,t="^"):d[2]<1?(d[0]=0,t="*"):(d[2]--,t="^"):e==48?(d[0]=0,d[2]=0,t="!"):e==62?(d[1]--,t=" ",d[1]<1&&!g?.length&&(d[0]=0,t="!")):e<63?d[0]==0?(d[2]=0,t="^"):d[2]<1?(d[0]=0,t="*"):d[2]--:e==80?(g=`PrgU:${a.toString().padStart(3,"0")}`,t="!"):e==88?(g=`CmbU:${a.toString().padStart(3,"0")}`,t="!"):e==121?(g=`GM2Vox0${o}`,t="#"):e==122?(d[1]==32?d[1]==0:d[1]%=7,g=this.#t[d[1]||0][(d[0]<<7)+d[2]],g?t=" ":(g="",t="*")):d[1]==0?(g=`${e.toString().padStart(3,"0")} ${a.toString().padStart(3,"0")} ${o.toString().padStart(3,"0")}`,t="!"):d[0]==0?(d[2]=0,t="^"):d[2]>0?d[2]--:d[1]>0?(d[1]=0,t="!"):(d[0]=0,t="?"));let c=[d[0],d[1],d[2]];(h=="gs"||h=="ns5r")&&t=="^"&&(t=" "),e==127&&t=="^"&&(t=" "),t!=" "&&self.debugMode&&(g="");let f="??";switch(d[0]){case 0:{d[2]==0?f="GM":d[2]==5||d[2]==7?f="KG":d[2]<126?f="XG":d[2]==127&&(f="MT");break}case 32:case 33:case 35:case 36:{d[2]>4?f=["AP","VL","PF","DX","AN"][d[0]-32]:f="GS";break}case 48:{f="MU";break}case 56:{f="AG";break}case 61:case 80:case 83:case 88:case 89:case 91:{f="AI";break}case 62:case 82:case 90:{f="XD";break}case 63:{d[2]<17?f="KR":d[2]<34?f="ES":f="DS";break}case 64:case 126:{f="XG";break}case 67:case 99:{f=d[2]>>4==1?"SD":"DX";break}case 81:{f="RW";break}case 95:{f=["DR","PC"][d[2]];break}case 96:{f=d[2]==106?"AP":d[2]>>4==1?"SD":"PF";break}case 97:{f=d[2]>>4==1?"SD":"VL";break}case 98:{f=d[2]>>4==1?"SD":"SG";break}case 100:{f="AN";break}case 104:case 105:case 106:case 107:{f="SD";break}case 120:{f="GS";break}case 121:{f=d[2]?"G2":"GM";break}case 122:{f="KG";break}case 127:{f=d[2]==127?"MT":a==0?"GM":"XG";break}default:d[0]<48&&(d[0]==16&&h=="xg"?f="XG":f="GS")}return{name:g||`${G(e||0)} ${G(a||0)} ${G(o||0)}`,iid:r,eid:c,sid:y,ending:t,sect:s,standard:f}}async load(e,a,o){let h=this,y=[],g=0,d=0;e.split(` -`).forEach(function(t,s){let n=t.split(" "),i=[];s==0?n.forEach(function(r,c){y[ue.indexOf(r)]=c}):n.forEach(async function(r,c){c>2?(h.#t[i[y[1]]]=h.#t[i[y[1]]]||[],(!h.#t[i[y[1]]][(i[y[0]]<<7)+i[y[2]]]?.length||a)&&(h.#t[i[y[1]]][(i[y[0]]<<7)+i[y[2]]]=n[3],g++),d++):i.push(parseInt(n[c]))})}),a||console.debug(`Map "${o||"(internal)"}": ${d} total, ${g} loaded.`)}clearRange(e){let a=e.prg!=null?e.prg.constructor==Array?e.prg:[e.prg,e.prg]:[0,127],o=e.msb!=null?e.msb.constructor==Array?e.msb:[e.msb,e.msb]:[0,127],h=e.lsb!=null?e.lsb.constructor==Array?e.lsb:[e.lsb,e.lsb]:[0,127];for(let y=o[0];y<=o[1];y++){let g=y<<7;for(let d=h[0];d<=h[1];d++){let t=g+d;for(let s=a[0];s<=a[1];s++)delete this.#t[s][t]}}}init(){this.#t=[];for(let e=0;e<128;e++)this.#t.push([""])}async loadFiles(...e){this.init();let a=this;e.forEach(async function(o,h){try{await fetch(`./data/bank/${o}.tsv`).then(function(y){return y.text()}).then(y=>{a.load(y,!1,o)})}catch{console.error(`Failed loading "${o}.tsv".`)}})}constructor(...e){this.loadFiles(...e)}};var q=class{#t={};context;set(e,a){this.#t[e]=a}has(e){return!!this.#t[e]}async read(e,a){if(!this.has(e))throw new Error(`No decoder registered for "${e}"`);return await this.#t[e].call(this.context||this,a)}};var pe=function(e,a){let o=!0;return a.forEach((h,y)=>{o=o&&e[y]==h}),o},Q=function(e){let a=0;return e.forEach(o=>{a*=256,a+=o}),a},O=new TextDecoder,H=new q;H.set("s7e",async function(e){let a=new Uint8Array(await e.slice(0,65536).arrayBuffer()),o="MSB LSB PRG NME",h=[0,0,0,0],y=32,g=0,d=0,t=!0,s=[],n=0;for(;t;){let i=a.subarray(g);([()=>{O.decode(i.subarray(0,4))=="YSFC"?(g+=80,d=1):g++},()=>{if(pe(i.subarray(0,4),h))s.forEach((r,c,f)=>{let l=Q(a.subarray(r.start+4,r.start+8));r.length=l}),d=2;else{let r=O.decode(i.subarray(0,4)),c=Q(i.subarray(4,8));s.push({type:r,start:c}),g+=8}},()=>{let r=s[n],c=a.subarray(r.start,r.start+r.length),f=32;switch(r.type){case"ENVC":{let l=y;for(;l=s.length&&(d=3,t=!1)}][d]||(()=>{t=!1}))()}return o});var A=["off","hall","room","stage","plate","delay LCR","delay LR","echo","cross delay","early reflections","gate reverb","reverse gate"].concat(new Array(4),["white room","tunnel","canyon","basement","karaoke"],new Array(43),["pass through","chorus","celeste","flanger","symphonic","rotary speaker","tremelo","auto pan","phaser","distortion","overdrive","amplifier","3-band EQ","2-band EQ","auto wah"],new Array(1),["pitch change","harmonic","touch wah","compressor","noise gate","voice channel","2-way rotary speaker","ensemble detune","ambience"],new Array(4),["talking mod","Lo-Fi","dist + delay","comp + dist + delay","wah + dist + delay","V dist","dual rotor speaker"]),U=["melodic","drums","drum set 1","drum set 2","drum set 3","drum set 4","drum set 5","drum set 6","drum set 7","drum set 8"],be=[17.1,18.6,20.2,21.8,23.3,24.9,26.5,28,29.6,31.2,32.8,34.3,35.9,37.5,39,40.6,42.2,43.7,45.3,46.9,48.4,50],D=[20,22,25,28,32,36,40,45,50,56,63,70,80,90,100,110,125,140,160,180,200,225,250,280,315,355,400,450,500,560,630,700,800,900,1e3,1100,1200,1400,1600,1800,2e3,2200,2500,2800,3200,3600,4e3,4500,5e3,5600,6300,7e3,8e3,9e3,1e4,11e3,12e3,14e3,16e3,18e3,2e4],Y=[0,.04,.08,.13,.17,.21,.25,.29,.34,.38,.42,.46,.51,.55,.59,.63,.67,.72,.76,.8,.84,.88,.93,.97,1.01,1.05,1.09,1.14,1.18,1.22,1.26,1.3,1.35,1.39,1.43,1.47,1.51,1.56,1.6,1.64,1.68,1.72,1.77,1.81,1.85,1.89,1.94,1.98,2.02,2.06,2.1,2.15,2.19,2.23,2.27,2.31,2.36,2.4,2.44,2.48,2.52,2.57,2.61,2.65,2.69,2.78,2.86,2.94,3.03,3.11,3.2,3.28,3.37,3.45,3.53,3.62,3.7,3.87,4.04,4.21,4,37,4.54,4.71,4.88,5.05,5.22,5.38,5.55,5.72,6.06,6.39,6.73,7.07,7.4,7.74,8.08,8.41,8.75,9.08,9.42,9.76,10.1,10.8,11.4,12.1,12.8,13.5,14.1,14.8,15.5,16.2,16.8,17.5,18.2,19.5,20.9,22.2,23.6,24.9,26.2,27.6,28.9,30.3,31.6,33,34.3,37,39.7],W=function(e){let a=.1,o=-.3;return e>66?(a=5,o=315):e>56?(a=1,o=47):e>46&&(a=.5,o=18.5),a*e-o},J=function(e){return e>105?be[e-106]:e>100?e*1.1-100:e/10},Z=",a,i,u,e,o,ka,ki,ku,ke,ko,ky,kw,sa,si,su,se,so,sh,ta,ti,tu,te,to,t,ch,t,s,na,ni,nu,ne,no,ny,nn,ha,hi,hu,he,ho,hy,fa,fi,fu,fe,fo,ma,mi,mu,me,mo,my,mm,ya,yu,ye,yo,ra,ri,ru,re,ro,ry,wa,wi,we,wo,ga,gi,gu,ge,go,gy,gw,za,zi,zu,ze,zo,ja,ji,ju,je,jo,jy,da,di,du,de,do,dy,ba,bi,bu,be,bo,by,va,vi,vu,ve,vo,pa,pi,pu,pe,po,py,nga,ngi,ngu,nge,ngo,ngy,ng,hha,hhi,hhu,hhe,hho,hhy,hhw,*,_,,,~,.".split(","),_={};`hi*, +var z=function(e,s){let o=Math.min(e.length,s.length),d=e.slice(0,o),y=s.slice(0,o),g=0,$=0;for(;$0){let d=this.pool.length,y=1<=1&&$>=0;){if($<=0)throw new Error("TTL reached.");if(g==d)g-=y;else{let n=z(s,this.pool[g]);switch(n){case 0:{$=0;break}case 1:{g+y<=d&&(g+=y);break}case-1:{g!=0&&(g-=y);break}default:console.warn(`Unexpected result ${n}.`)}}y=y>>1,$--}let t=!0;if(g>=this.pool.length)t=!1;else{let n=this;this.pool[g].forEach(function(i,r,a){t&&i!=s[r]&&(t=!1)}),!t&&z(s,this.pool[g])>0&&g++}return t||o?g:-1}else return o?0:-1},this.add=function(s,o){return s.data=o,this.pool.splice(this.point(s,!0),0,s),this},this.default=function(s){console.warn(`No match in "${this.name||"(unknown)"}" for "${s}". Default action not defined.`)},this.get=function(s){let o=this.point(s);if(o>-1)return this.pool[o].data;this.default(s)},this.run=function(s,...o){let d=this.point(s);d>-1?s.subarray?this.pool[d].data(s.subarray(this.pool[d].length),...o):this.pool[d].data(s.slice(this.pool[d].length),...o):this.default(s,...o)}};var q=class{#t={};addEventListener(e,s){this.#t[e]||(this.#t[e]=[]),this.#t[e].unshift(s)}removeEventListener(e,s){if(this.#t[e]){let o=this.#t[e].indexOf(s);o>-1&&this.#t[e].splice(o,1),this.#t[e].length<1&&delete this.#t[e]}}dispatchEvent(e,s){let o=new Event(e),d=this;o.data=s,this.#t[e]?.length>0&&this.#t[e].forEach(function(y){try{y?.call(d,o)}catch(g){console.error(g)}}),this[`on${e}`]&&this[`on${e}`](o)}};var ue=["MSB","PRG","LSB","NME","ELC","DRM"],B=function(e){let s=Math.floor(e/10),o=e%10;return`${s.toString(16)}${o}`},I=class{#t;strictMode=!1;get(e=0,s=0,o=0,d){let y=[e,s,o],g,$=1,t=0,n,i=Array.from(arguments);switch(d){case"xg":{switch(e){case 0:{o==126?i[2]=125:o==127&&(i[2]=0);break}case 16:{o==126&&(i[2]=0);break}case 32:{o>125&&(i[2]=0),i[2]+=4;break}case 33:case 34:case 35:case 36:{o>125&&(i[2]=0),i[2]+=5;break}case 79:case 80:case 81:case 82:case 83:case 84:i[0]+=16;case 95:case 96:case 97:case 98:case 99:case 100:{o==126&&(i[2]=0);break}case 48:case 64:case 126:case 127:{o==126&&(i[2]=0);break}}break}case"gs":{e==0&&o<5?i[2]=0:e>125&&o<5&&o!=2&&(i[2]=e,i[0]=0);break}case"g2":case"sd":{(e>>1==40||e>95&&e<100)&&(i[2]|=16);break}case"sg":{e==8&&o==0&&(i[2]=5);break}case"s90es":{o<8?i[2]+=17:o<32?i[2]+=13:i[2]=(i[2]>>3)+19;break}case"motif":{o<8?i[2]+=28:o<32?i[2]+=13:i[2]=(i[2]>>3)+19;break}}let r=" ",a="M",c=0,f=0;switch(i[0]){case 0:{i[2]==127?a="MT-a":i[2]==126?a="MT-b":i[2]==7?a="GM-k":i[2]==5?a="SG-a":i[2]==4?a="SP-l":i[2]==0||d=="gs"&&i[2]<5?a="GM-a":(a="y",c=3);break}case 8:{d=="sg"?a="GM-s":a="r:";break}case 32:case 33:case 34:case 35:case 36:{d=="xg"&&(a=`${["AP","VL","PF","DX","AN"][e&7]}-${"abcdefgh"[o]}`);break}case 48:{a=`yM${(i[2]>>3).toString().padStart(2,"0")}`,c=1;break}case 56:{a="GM-b";break}case 61:case 120:{a="rDrm";break}case 62:{a="kDrm";break}case 63:{if(i[2]<17){let E=i[2];a=E<10?"kP:":"kC:",a+=E%10}else i[2]<34?a=["Pre1","Pre2","Pre3","Pre4","Usr1","Usr2","DrmP","DrmU","Plg1","Plg2","Plg3","Pre1","Pre2","Pre3","Pre4","Pre5","Pre6"][i[2]-17]:a="Ds";break}case 64:{a="ySFX";break}case 67:{a="DX:S";break}case 80:case 81:case 82:case 83:{a=`Prg${"UABC"[i[0]-80]}`;break}case 88:case 89:case 90:case 91:{a=`Cmb${"UABC"[i[0]-88]}`;break}case 95:{a=`${["DR","PC"][i[2]]}-d`;break}case 96:{a=i[2]==106?"AP-a":i[2]>>4==1?"SDg":"PF",i[2]>63?f=63:i[2]>>4==1&&(f=16),c=3;break}case 97:{a=i[2]>>4==1?"SDa":"VL:",c=3,i[2]>>4==1?f=16:f=112;break}case 98:{a=i[2]>>4==1?"SDb":"SG-a",c=3,f=16;break}case 99:{a=i[2]>>4==1?"SDc":"DX",i[2]>63?f=63:i[2]>>4==1&&(f=16),c=3;break}case 100:{a="AN",i[2]>63?f=63:i[2]>>4==1&&(f=16),c=3;break}case 104:case 105:case 106:case 107:{a="SDd",f=104;break}case 121:{a=`GM-${i[2]?"":"a"}`,c=3;break}case 122:{a="lDrm";break}case 126:{a="yDrS";break}case 127:{i[2]==127?a="rDrm":a="yDrm";break}default:i[0]<48?a="r:":a="M"}a.length<4&&(a+=`${[e,o,i[0],i[2]][c]-f}`.padStart(4-a.length,"0")),d=="xg"&&(e==0?i[2]<100?a=a.replace("y0","y:"):i[2]==125&&(a="y126"):e==16&&(g=`Voice${(i[2]*128+i[1]+1).toString().padStart(3,"0")}`,r=" "));let l=[i[0],i[1],i[2]];for(;!(g?.length>=0);)if(g=this.#t[i[1]||0][(i[0]<<7)+i[2]]?.name,g){let E=this.#t[i[1]||0][(i[0]<<7)+i[2]];$=E?.poly||$,t=E?.type||t,n=E?.drum}else if(this.strictMode)g="",r="?";else if(i[0]==0&&i[1]==0&&i[2]==0)g="Unloaded";else if(this.#t[i[1]||0][i[0]<<7])i[0]==0?(i[2]=0,r="^"):i[2]<1?(i[0]=0,r="*"):(i[2]--,r="^");else if(e==48)i[0]=0,i[2]=0,r="!";else if(e==62)i[1]--,r=" ",i[1]<1&&!g?.length&&(i[0]=0,r="!");else if(e<63)i[0]==0?(i[2]=0,r="^"):i[2]<1?(i[0]=0,r="*"):i[2]--;else if(e==80)g=`PrgU:${s.toString().padStart(3,"0")}`,r="!";else if(e==88)g=`CmbU:${s.toString().padStart(3,"0")}`,r="!";else if(e==121)g=`GM2Vox0${o}`,r="#";else if(e==122)if(i[1]==32?i[1]==0:i[1]%=7,g=this.#t[i[1]||0][(i[0]<<7)+i[2]]?.name,g){r=" ";let E=this.#t[i[1]||0][(i[0]<<7)+i[2]];$=E?.poly||$,t=E?.type||t,n=E?.drum}else g="",r="*";else i[1]==0?(g=`${e.toString().padStart(3,"0")} ${s.toString().padStart(3,"0")} ${o.toString().padStart(3,"0")}`,r="!"):i[0]==0?(i[2]=0,r="^"):i[2]>0?i[2]--:i[1]>0?(i[1]=0,r="!"):(i[0]=0,r="?");let u=[i[0],i[1],i[2]];(d=="gs"||d=="ns5r")&&r=="^"&&(r=" "),e==127&&r=="^"&&(r=" "),r!=" "&&self.debugMode&&(g="");let b="??";switch(i[0]){case 0:{i[2]==0?b="GM":i[2]==5||i[2]==7?b="KG":i[2]<126?b="XG":i[2]==127&&(b="MT");break}case 32:case 33:case 35:case 36:{i[2]>4?b=["AP","VL","PF","DX","AN"][i[0]-32]:b="GS";break}case 48:{b="MU";break}case 56:{b="AG";break}case 61:case 80:case 83:case 88:case 89:case 91:{b="AI";break}case 62:case 82:case 90:{b="XD";break}case 63:{i[2]<17?b="KR":i[2]<34?b="ES":b="DS";break}case 64:case 126:{b="XG";break}case 67:case 99:{b=i[2]>>4==1?"SD":"DX";break}case 81:{b="RW";break}case 95:{b=["DR","PC"][i[2]];break}case 96:{b=i[2]==106?"AP":i[2]>>4==1?"SD":"PF";break}case 97:{b=i[2]>>4==1?"SD":"VL";break}case 98:{b=i[2]>>4==1?"SD":"SG";break}case 100:{b="AN";break}case 104:case 105:case 106:case 107:{b="SD";break}case 120:{b="GS";break}case 121:{b=i[2]?"G2":"GM";break}case 122:{b="KG";break}case 127:{b=i[2]==127?"MT":s==0?"GM":"XG";break}default:i[0]<48&&(i[0]==16&&d=="xg"?b="XG":b="GS")}return{name:g||`${B(e||0)} ${B(s||0)} ${B(o||0)}`,poly:$,type:t,drum:n,iid:l,eid:u,sid:y,ending:r,sect:a,standard:b}}async load(e,s,o="(internal)"){let d=this,y=[],g=0,$=0;e.split(` +`).forEach(function(t,n){let i=t.split(" "),r=[];if(n==0){if(i.forEach(function(a,c){y[ue.indexOf(a)]=c}),y.length<4){console.debug("Debugger launched.");debugger}}else{let a=0,c=0,f=0,l,u=1,b=0,E;i.forEach(async function(k,L){switch(L){case y[0]:{a=parseInt(k);break}case y[1]:{c=parseInt(k);break}case y[2]:{f=parseInt(k);break}case y[3]:{l=k;break}case y[4]:{k=parseInt(k),k<16?u=k+1:b=(k&15)+1;break}case y[5]:{E=k;break}}}),d.#t[c]=d.#t[c]||[];let w=d.#t[c];if(!w[a<<7|f]||s){let k={msb:a,prg:c,lsb:f,name:l,poly:u,type:b,drum:E};w[a<<7|f]=k,g++}$++}}),s||console.debug(`Map "${o}": ${$} total, ${g} loaded.`)}clearRange(e){let s=e.prg!=null?e.prg.constructor==Array?e.prg:[e.prg,e.prg]:[0,127],o=e.msb!=null?e.msb.constructor==Array?e.msb:[e.msb,e.msb]:[0,127],d=e.lsb!=null?e.lsb.constructor==Array?e.lsb:[e.lsb,e.lsb]:[0,127];for(let y=o[0];y<=o[1];y++){let g=y<<7;for(let $=d[0];$<=d[1];$++){let t=g+$;for(let n=s[0];n<=s[1];n++)delete this.#t[n][t]}}}init(){this.#t=[];for(let e=0;e<128;e++)this.#t.push([""])}async loadFiles(...e){this.init();let s=this;e.forEach(async function(o){try{await fetch(`./data/bank/${o}.tsv`).then(function(d){return d.text()}).then(d=>{s.load(d,!1,o)})}catch{console.error(`Failed loading "${o}.tsv".`)}})}constructor(...e){this.loadFiles(...e)}};var Q=class{#t={};context;set(e,s){this.#t[e]=s}has(e){return!!this.#t[e]}async read(e,s){if(!this.has(e))throw new Error(`No decoder registered for "${e}"`);return await this.#t[e].call(this.context||this,s)}};var pe=function(e,s){let o=!0;return s.forEach((d,y)=>{o=o&&e[y]==d}),o},Y=function(e){let s=0;return e.forEach(o=>{s*=256,s+=o}),s},O=new TextDecoder,H=new Q;H.set("s7e",async function(e){let s=new Uint8Array(await e.slice(0,65536).arrayBuffer()),o="MSB LSB PRG NME",d=[0,0,0,0],y=32,g=0,$=0,t=!0,n=[],i=0;for(;t;){let r=s.subarray(g);([()=>{O.decode(r.subarray(0,4))=="YSFC"?(g+=80,$=1):g++},()=>{if(pe(r.subarray(0,4),d))n.forEach((a,c,f)=>{let l=Y(s.subarray(a.start+4,a.start+8));a.length=l}),$=2;else{let a=O.decode(r.subarray(0,4)),c=Y(r.subarray(4,8));n.push({type:a,start:c}),g+=8}},()=>{let a=n[i],c=s.subarray(a.start,a.start+a.length),f=32;switch(a.type){case"ENVC":{let l=y;for(;l=n.length&&($=3,t=!1)}][$]||(()=>{t=!1}))()}return o});var A=["off","hall","room","stage","plate","delay LCR","delay LR","echo","cross delay","early reflections","gate reverb","reverse gate"].concat(new Array(4),["white room","tunnel","canyon","basement","karaoke"],new Array(43),["pass through","chorus","celeste","flanger","symphonic","rotary speaker","tremelo","auto pan","phaser","distortion","overdrive","amplifier","3-band EQ","2-band EQ","auto wah"],new Array(1),["pitch change","harmonic","touch wah","compressor","noise gate","voice channel","2-way rotary speaker","ensemble detune","ambience"],new Array(4),["talking mod","Lo-Fi","dist + delay","comp + dist + delay","wah + dist + delay","V dist","dual rotor speaker"]),U=["melodic","drums","drum set 1","drum set 2","drum set 3","drum set 4","drum set 5","drum set 6","drum set 7","drum set 8"],be=[17.1,18.6,20.2,21.8,23.3,24.9,26.5,28,29.6,31.2,32.8,34.3,35.9,37.5,39,40.6,42.2,43.7,45.3,46.9,48.4,50],D=[20,22,25,28,32,36,40,45,50,56,63,70,80,90,100,110,125,140,160,180,200,225,250,280,315,355,400,450,500,560,630,700,800,900,1e3,1100,1200,1400,1600,1800,2e3,2200,2500,2800,3200,3600,4e3,4500,5e3,5600,6300,7e3,8e3,9e3,1e4,11e3,12e3,14e3,16e3,18e3,2e4],W=[0,.04,.08,.13,.17,.21,.25,.29,.34,.38,.42,.46,.51,.55,.59,.63,.67,.72,.76,.8,.84,.88,.93,.97,1.01,1.05,1.09,1.14,1.18,1.22,1.26,1.3,1.35,1.39,1.43,1.47,1.51,1.56,1.6,1.64,1.68,1.72,1.77,1.81,1.85,1.89,1.94,1.98,2.02,2.06,2.1,2.15,2.19,2.23,2.27,2.31,2.36,2.4,2.44,2.48,2.52,2.57,2.61,2.65,2.69,2.78,2.86,2.94,3.03,3.11,3.2,3.28,3.37,3.45,3.53,3.62,3.7,3.87,4.04,4.21,4,37,4.54,4.71,4.88,5.05,5.22,5.38,5.55,5.72,6.06,6.39,6.73,7.07,7.4,7.74,8.08,8.41,8.75,9.08,9.42,9.76,10.1,10.8,11.4,12.1,12.8,13.5,14.1,14.8,15.5,16.2,16.8,17.5,18.2,19.5,20.9,22.2,23.6,24.9,26.2,27.6,28.9,30.3,31.6,33,34.3,37,39.7],j=function(e){let s=.1,o=-.3;return e>66?(s=5,o=315):e>56?(s=1,o=47):e>46&&(s=.5,o=18.5),s*e-o},J=function(e){return e>105?be[e-106]:e>100?e*1.1-100:e/10},Z=",a,i,u,e,o,ka,ki,ku,ke,ko,ky,kw,sa,si,su,se,so,sh,ta,ti,tu,te,to,t,ch,t,s,na,ni,nu,ne,no,ny,nn,ha,hi,hu,he,ho,hy,fa,fi,fu,fe,fo,ma,mi,mu,me,mo,my,mm,ya,yu,ye,yo,ra,ri,ru,re,ro,ry,wa,wi,we,wo,ga,gi,gu,ge,go,gy,gw,za,zi,zu,ze,zo,ja,ji,ju,je,jo,jy,da,di,du,de,do,dy,ba,bi,bu,be,bo,by,va,vi,vu,ve,vo,pa,pi,pu,pe,po,py,nga,ngi,ngu,nge,ngo,ngy,ng,hha,hhi,hhu,hhe,hho,hhy,hhw,*,_,,,~,.".split(","),_={};`hi*, ka,か ki,き ku,く @@ -139,8 +139,8 @@ o,お ~, ^, _,`.split(` -`).forEach(e=>{let a=e.split(",");_[a[0]]=a[1]});var j=function(e){let a=e;e[0]=="*"&&(a=a.slice(1)),["aa","ii","uu","ee","oo"].forEach(h=>{for(;a.indexOf(h)>-1;)a=a.replace(h,h[0])});for(let h in _)a=a.replaceAll(h,_[h]);a.indexOf("ん")==0&&a.length>1&&(a=a.slice(1));let o=a.indexOf("!");return o>-1&&a.length>1&&(a=a.slice(o+1)),a},ee=function(e){return e?e<96?`cc${e}`:["aftertouch","velocity","pitch bend"][e-96]:"off"};var I=["room 1","room 2","room 3","hall 1","hall 2","plate","delay","panning delay"],te=["chorus 1","chorus 2","chorus 3","chorus 4","feedback","flanger","short delay","short delay feedback"],ae=["delay 1","delay 2","delay 3","delay 4","pan delay 1","pan delay 2","pan delay 3","pan delay 4","delay to reverb","pan repeat"];var ye={0:"thru",256:"stereo EQ",257:"spectrum",258:"enhancer",259:"humanizer",272:"overdrive",273:"distortion",288:"phaser",289:"auto wah",290:"rotary",291:"stereo flanger",292:"step flanger",293:"tremelo",294:"auto pan",304:"compressor",305:"limiter",320:"hexa chorus",321:"tremelo chorus",322:"stereo chorus",323:"space D",324:"3D chorus",336:"stereo delay",337:"modulated delay",338:"3-tap delay",339:"4-tap delay",340:"tremelo control delay",341:"reverb",342:"gate reverb",343:"3D delay",352:"2-pitch shifter",353:"feedback pitch shifter",368:"3D auto",369:"3D manual",370:"Lo-Fi 1",371:"Lo-Fi 2",512:"overdrive - chorus",513:"overdrive - flanger",514:"overdrive - delay",515:"distortion - chorus",516:"distortion - flanger",517:"distortion - delay",518:"enhancer - chorus",519:"enhancer - flanger",520:"enhancer - delay",521:"chorus - delay",522:"flanger - delay",523:"chorus - flanger",524:"rotary multi",1024:"guitar multi 1",1025:"guitar multi 2",1026:"guitar multi 3",1027:"clean guitar multi 1",1028:"clean guitar multi 2",1029:"bass multi",1030:"rhodes multi",1280:"keyboard multi",4352:"chorus / delay",4353:"flanger / delay",4354:"chorus / flanger",4355:"overdrive / distortion",4356:"overdrive / rotary",4357:"overdrive / phaser",4358:"overdrive / auto wah",4359:"phaser / rotary",4360:"phaser / auto wah"},$e={66307:["drive"],66309:["vowel",e=>"aiueo"[e]],94723:["pre-filter"],94724:["Lo-Fi type"],94725:["post-filter"],94979:["Lo-Fi type"],94980:["fill type",e=>["off","LPF","HPF"][e]],94984:["noise type",e=>["white","pink"][e]],94987:["disc type",e=>["LP","SP","EP","RND"]],94990:["hum type",e=>`${e+5}0Hz`],94993:["M/S",e=>["mono","stereo"][e]]},X=function(e){return ye[(e[0]-32<<8)+e[1]]||`0x${e[0].toString(16).padStart(2,"0")}${e[1].toString(16).padStart(2,"0")}`},se=function(e,a,o){let h=(e[0]-32<<16)+(e[1]<<8)+a,y=$e[h]||{},g=y[0];if(g?.length)return g+=`: ${(y[1]||function(){})(o)||o}`,g},V=[68,48,95,78,41,3,110,122,0];var S=function(e=64){return Math.round(2e3*Math.log10(e/64))/100};var F=function(e){let a=0;return e.forEach(o=>{a+=o,a=a&127}),~a+1&127},T=function(e,a){let o=0,h=0;for(let y=0;y>g&1)<<7,t=e[y];t+=d,y%8!=0?(a(t,o,e),o++):h=e[y]}},P=function(e){let a=Math.floor(e*14.2);return a<128?a:0};var M=["?","gm","gs","xg","g2","mt32","ns5r","x5d","05rw","sd","k11","sg","krs","s90es","motif"],re=[[0,0,0,0,121,0,0,82,81,97,0,0,63,63,63],[0,0,4,0,0,127,0,0,0,0,0,0,0,0,0]],R=[120,127,120,127,120,127,61,62,62,105,122,122,120,127,127],ge=[0,3,81,84,88],ie={8:"Off",9:"On",10:"Note aftertouch",11:"cc",12:"pc",13:"Channel aftertouch",14:"Pitch"},ne={0:0,1:1,2:3,5:4},ce={0:0,1:1,2:2,5:3},oe=[[0,24],[0,127],[0,127],[40,88],[0,127],[0,127]],le=[36,37,48,49,52,53],L=[20,21,22,23,24,25,26,28,29,30,31,36,37,48,49,52,53,64,65],fe={26:127,29:0,30:0,31:0,52:12,53:54},N=[0,1,2,4,5,6,7,8,10,11,32,38,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,84,91,92,93,94,95,98,99,100,101,128,12,13,16,17,18,19,14,15,20,21],Ee=[12,13,14,15,16,17,18,19,20,21],me=[33,99,100,32,102,8,9,10],de=[0,16,25,40,32,64,26,48],m={};M.forEach((e,a)=>{m[e]=a});var u={length:N.length};N.forEach((e,a)=>{u[e]=a});var C={length:L.length};L.forEach((e,a)=>{C[e]=a});var k=function(){return!!self.Bun||self.debugMode||!1},ke=function(e){let a=[],o=0;return e?.forEach(function(h,y){h==247?a.push(e.subarray(o,y)):h==240&&(o=y+1)}),a.length||a.push(e.subarray(0)),k()&&console.debug(a),a};var b={ch:128,cc:N.length,nn:128,pl:512,tr:256,cmt:14,rpn:6,rpnt:4,ace:8,drm:8,dpn:L.length,dnc:128,efx:7},Ke=class extends z{NOTE_IDLE=0;NOTE_ATTACK=1;NOTE_DECAY=2;NOTE_SUSTAIN=3;NOTE_HELD=4;NOTE_RELEASE=5;NOTE_SOSTENUTO_ATTACK=8;NOTE_SOSTENUTO_DECAY=9;NOTE_SOSTENUTO_SUSTAIN=10;NOTE_SOSTENUTO_HELD=11;CH_MELODIC=0;CH_DRUMS=1;CH_DRUM1=2;CH_DRUM2=3;CH_DRUM3=4;CH_DRUM4=5;CH_DRUM5=6;CH_DRUM6=7;CH_DRUM7=8;CH_DRUM8=9;#t=0;#p=0;#C=0;#M=new Array(11);get#y(){return this.#M[this.#p]}set#y(e){this.#M[this.#p]=e}#R=new Uint8Array(b.ch);#d=new Uint8Array(b.ch);#s=new Uint8Array(b.ch);#e=new Uint8Array(b.ch*b.cc);#D=new Uint8Array(b.ace);#i=new Uint8Array(b.ch);#o=new Uint8Array(b.ch*b.nn);#$=new Uint8Array(b.ch);#l=new Uint16Array(b.pl);#h=new Uint8Array(b.pl);#U=new Int16Array(b.ch);#x=new Uint8Array(b.ch);#_=0;#a=new Uint8Array(b.ch*b.rpn);#r=new Uint8Array(b.ch*b.rpnt);#Q=new Int8Array(b.ch*le.length);#b=new Uint8Array(b.drm*b.dpn*b.dnc);#T=new Uint8Array(b.ch);#P=new Uint8Array(128);#v=new Uint8Array(b.cmt*8);#Y=new Uint8Array(1024);#N=new Uint8Array(b.cmt*64);#g=new Uint8Array(b.efx*3);#W=new Uint8Array(b.ch);#H=0;#m=0;#n=100;#I=0;#J=500;#Z=0;#L="";#G=0;#ee=0;#j=0;#S=!0;#c=!1;#te;#re=new Uint8Array(2);#E=[];#O=new Uint8Array(b.ch);#B=new Uint8Array(b.tr);baseBank=new B("gm","gm2","xg","gs","ns5r","sd","gmega","plg-150vl","plg-150pf","plg-150dx","plg-150an","plg-150dr","plg-100sg","kross","s90es");userBank=new B("gm");initOnReset=!1;aiEfxName="";chRedir(e,a,o){if(this.#B[a])return(this.#B[a]-1)*16+e;if([2,3].indexOf(this.#m)>-1){if(o==1)return e;let h=0,y=!0;for(;y;)this.#O[e+h]==0?(this.#O[e+h]=a,console.debug(`Assign track ${a} to channel ${e+h+1}.`),y=!1):this.#O[e+h]==a?y=!1:(h+=16,h>=128&&(h=0,y=!1));return e+h}else return e}forceVoiceRefresh(){for(let e=0;e{let o=e*128+a,h=this.#l.lastIndexOf(o);h>-1&&(this.#e[b.cc*e+u[64]]>63?(this.#h[h]=this.NOTE_HELD,this.dispatchEvent("note",{part:e,note:a,velo:this.#o[o],state:this.NOTE_HELD})):this.#e[b.cc*e+u[66]]>63&&this.#h[h]==this.NOTE_SOSTENUTO_SUSTAIN?(this.#h[h]=this.NOTE_SOSTENUTO_HELD,this.dispatchEvent("note",{part:e,note:a,velo:this.#o[o],state:this.NOTE_SOSTENUTO_HELD})):(this.#l[h]=0,this.#o[o]=0,this.#h[h]=this.NOTE_IDLE,this.dispatchEvent("note",{part:e,note:a,velo:0,state:this.NOTE_IDLE})))},nOn:(e,a,o)=>{let h=e*128+a,y=0;for(this.#$[e]&&this.#f.ano(e);this.#h[y]>0&&this.#l[y]!=h;)y++;y{},cAt:(e,a)=>{},hoOf:e=>{this.#h.forEach((a,o)=>{if(a==this.NOTE_HELD){let h=this.#l[o],y=h>>7;e==y&&(this.#h[o]=this.NOTE_IDLE,this.#l[o]=0,this.#o[h]=0,this.dispatchEvent("note",{part:e,note:h&127,velo:0,state:this.NOTE_IDLE}))}})},soOn:e=>{this.#h.forEach((a,o)=>{let h;switch(a){case this.NOTE_ATTACK:{h=this.NOTE_SOSTENUTO_ATTACK;break}case this.NOTE_DECAY:{h=this.NOTE_SOSTENUTO_DECAY;break}case this.NOTE_SUSTAIN:{h=this.NOTE_SOSTENUTO_SUSTAIN;break}}if(h){this.#h[o]=h;let y=this.#l[o];this.dispatchEvent("note",{part:e,note:y&127,velo:this.#o[y],state:h})}})},soOf:e=>{this.#h.forEach((a,o)=>{if(a==this.NOTE_SOSTENUTO_HELD){let h=this.#l[o],y=h>>7;e==y&&(this.#h[o]=this.NOTE_IDLE,this.#l[o]=0,this.#o[h]=0,this.dispatchEvent("note",{part:e,note:h&127,velo:0,state:this.NOTE_IDLE}))}})},ano:e=>{this.#l.forEach((a,o,h)=>{let y=a>>7,g=a&127;a==0&&this.#o[0]==0||y==e&&this.#f.nOff(y,g)})}};#ae={8:function(e){let a=e.channel,o=e.data[0];this.#f.nOff(a,o)},9:function(e){let a=e.channel;this.setChActive(a,1);let o=e.data[0],h=e.data[1];h>0?this.#f.nOn(a,o,h):this.#f.nOff(a,o)},10:function(e){let a=e.channel,o=a*128+e.data[0];this.#l.indexOf(o)>-1&&(this.#o[o]=data[1],this.dispatchEvent("note",{part:a,note:e.data[0],velo:e.data[1],state:this.NOTE_SUSTAIN}))},11:function(e){let a=e.channel;[0,32].indexOf(e.data[0])>-1&&(()=>{switch(this.#t){case m.s90es:case m.motif:{if(e.data[0]==0){[0,63].indexOf(e.data[1])>-1&&this.setChActive(a,1);break}e.data[1]&&this.setChActive(a,1);break}default:{this.setChActive(a,1);break}}})();let o=a*b.cc;switch(e.data[0]){case 96:return;case 97:return;case 120:return;case 121:{this.#f.ano(a),this.#U[a]=0;let h=a*b.cc;this.#e[h+u[1]]=0,this.#e[h+u[5]]=0,this.#e[h+u[64]]=0,this.#e[h+u[65]]=0,this.#e[h+u[66]]=0,this.#e[h+u[67]]=0,this.#e[h+u[11]]=127,this.#e[h+u[101]]=127,this.#e[h+u[100]]=127,this.#e[h+u[99]]=127,this.#e[h+u[98]]=127;return}case 123:{this.#f.ano(a);return}case 124:{this.#f.ano(a);return}case 125:{this.#f.ano(a);return}case 126:{this.#$[a]=1,this.#f.ano(a);return}case 127:{this.#$[a]=0,this.#f.ano(a);return}}if(u[e.data[0]]==null)console.warn(`cc${e.data[0]} is not accepted.`);else{switch(Ee.indexOf(e.data[0])>-1&&this.allocateAce(e.data[0]),e.data[0]){case 0:{switch(k()&&console.debug(`${M[this.#t]}, CH${a+1}: ${e.data[1]}`),this.#t==0?e.data[1]<48?(this.#s[a]>0&&(e.data[1]=this.#e[o],e.data[1]=120,console.debug(`Forced channel ${a+1} to stay drums.`)),e.data[1]>0&&(console.debug(`Roland GS detected with MSB: ${e.data[1]}`),this.switchMode("gs"))):e.data[1]==62?this.switchMode("x5d"):e.data[1]==63?this.switchMode("krs"):(e.data[1]==64||e.data[1]==127)&&this.switchMode("xg"):this.#t==m.gs?e.data[1]<56&&this.#s[a]>0&&(e.data[1]=this.#e[o],e.data[1]=120,console.debug(`Forced channel ${a+1} to stay drums.`)):this.#t==m.gm?e.data[1]<48?this.#s[a]>0&&(e.data[1]=120,this.switchMode("gs",!0),console.debug(`Forced channel ${a+1} to stay drums.`)):(e.data[1]==64||e.data[1]==127)&&this.switchMode("xg",!0):this.#t==m.x5d&&e.data[1]>0&&e.data[1]<8&&this.switchMode("05rw",!0),this.#t){case m.xg:{[126,127].indexOf(e.data[1])>-1?this.#s[a]==0&&(this.setChType(a,this.CH_DRUM2),console.debug(`CH${a+1} set to drums by MSB.`)):this.#s[a]>0&&(this.setChType(a,this.CH_MELODIC),console.debug(`CH${a+1} set to melodic by MSB.`));break}case m["05rw"]:case m.x5d:case m.ns5r:{[61,62,126,127].indexOf(e.data[1])>-1?this.#s[a]==0&&(this.setChType(a,this.CH_DRUM2),console.debug(`CH${a+1} set to drums by MSB.`)):this.#s[a]>0&&(this.setChType(a,this.CH_MELODIC),console.debug(`CH${a+1} set to melodic by MSB.`));break}case m.sd:{[104,105,106,107].indexOf(e.data[1])>-1?this.#s[a]==0&&(this.setChType(a,this.CH_DRUM2),console.debug(`CH${a+1} set to drums by MSB.`)):this.#s[a]>0&&(this.setChType(a,this.CH_MELODIC),console.debug(`CH${a+1} set to melodic by MSB.`));break}case m.g2:{e.data[1]==120?this.#s[a]==0&&(this.setChType(a,this.CH_DRUMS),console.debug(`CH${a+1} set to drums by MSB.`)):this.#s[a]>0&&(this.setChType(a,this.CH_MELODIC),console.debug(`CH${a+1} set to melodic by MSB.`));break}}this.dispatchEvent("voice",{part:a});break}case 6:{if(this.#_){[m.xg,m.gs,m.ns5r].indexOf(this.#t)<0&&console.warn(`NRPN commits are not available under "${M[this.#t]}" mode, even when they are supported in Octavia.`);let h=this.#e[o+u[99]],y=this.#e[o+u[98]];if(h==1){let g=me.indexOf(y);if(g>-1)this.#e[o+u[71+g]]=e.data[1],k()&&console.debug(`Redirected NRPN 1 ${y} to cc${71+g}.`),this.dispatchEvent("cc",{part:a,cc:71+g,data:e.data[1]});else{let d=le.indexOf(y);d>-1?this.#Q[a*10+d]=e.data[1]-64:console.warn(`NRPN 0x01${y.toString(16).padStart(2,"0")} is not supported.`),k()&&console.debug(`CH${a+1} voice NRPN ${y} commit`)}}else{if(L.indexOf(h)<0){let d=`NRPN 0x${h.toString(16).padStart(2,"0")}${y.toString(16).padStart(2,"0")} `;h==127?console.warn(`${d}is not necessary. Consider removing it.`):console.warn(`${d}is not supported.`)}else{let d=this.#s[a]-2;d<0?console.warn(`CH${a+1} cannot accept drum NRPN as type ${U[this.#s[a]]}.`):this.#b[(d*b.dpn+C[h])*b.dnc+y]=e.data[1]}k()&&console.debug(`CH${a+1} (${U[this.#s[a]]}) drum NRPN ${h} commit`)}}else{let h=ne[this.#e[o+u[100]]],y=ce[this.#e[o+u[100]]];this.#e[o+u[101]]==0&&h!=null&&(k()&&console.debug(`CH${a+1} RPN 0 ${this.#e[o+u[100]]} commit: ${e.data[1]}`),e.data[1]=Math.min(Math.max(e.data[1],oe[h][0]),oe[h][1]),this.#a[a*b.rpn+h]=e.data[1],this.#r[a*b.rpnt+y]=1)}break}case 32:{switch(k()&&console.debug(`${M[this.#t]}, CH${a+1} LSB: ${e.data[1]}`),this.#t){case m.s90es:case m.motif:{this.setChType(a,[32,40].indexOf(e.data[1])>-1?this.CH_DRUMS:this.CH_MELODIC,this.#t,!0);break}}this.dispatchEvent("voice",{part:a});break}case 38:{if(!this.#_){let h=ne[this.#e[o+100]],y=ce[this.#e[o+100]];this.#e[o+101]==0&&h!=null&&(this.#a[a*b.rpn+h+1]=e.data[1],this.#r[a*b.rpnt+y]=1)}break}case 64:{e.data[1]<64&&this.#f.hoOf(a);break}case 66:{e.data[1]>>6?this.#f.soOn(a):this.#f.soOf(a);break}case 98:case 99:{this.#_=1;break}case 100:case 101:{this.#_=0;break}}this.#e[o+u[e.data[0]]]=e.data[1],this.dispatchEvent("cc",{part:a,cc:e.data[0],data:e.data[1]})}},12:function(e){let a=e.channel;switch(this.#t){case m.s90es:case m.motif:{e.data&&this.setChActive(a,1);break}default:this.setChActive(a,1)}this.#i[a]=e.data,this.#T[a]=0,k()&&console.debug(`T:${e.track} C:${a} P:${e.data}`),this.dispatchEvent("voice",{part:a})},13:function(e){let a=this,o=e.channel;this.#l.forEach(function(h){let y=h>>7;o==y&&(a.#o[h]=e.data,a.dispatchEvent("note",{part:o,note:h&127,velo:e.data,state:a.NOTE_SUSTAIN}))})},14:function(e){let a=e.channel;this.#U[a]=e.data[1]*128+e.data[0]-8192,this.dispatchEvent("pitch",{part:a,pitch:this.getPitchShift(a)})},15:function(e){ke(e.data).forEach(a=>{let o=a[0],h=a[1];(this.#se[o]||function(){console.debug(`Unknown manufacturer ${o}.`)})(h,a.subarray(2),e.track)})},248:function(e){},250:function(e){},251:function(e){},252:function(e){},254:function(e){},255:function(e){(this.#u[e.meta]||function(o,h,y){}).call(this,e.data,e.track,e.meta),e.meta!=32&&(this.#I=0);let a=ge.indexOf(e.meta)>-1;if(k()&&console.debug(e),a)return e.reply="meta",e}};#se={64:(e,a,o)=>{this.#K.run(a,o,e)},65:(e,a,o)=>{if(a[0]<16)if(a[1]==72){let h=a[a.length-1],y=F(a.subarray(3,a.length-1));h==y?this.#w.run(a.subarray(0,a.length-1),o,e):console.warn(`Bad SD checksum ${h}. Should be ${y}.`)}else this.#w.run(a,o,e);else{let h=a[a.length-1],y=F(a.subarray(2,a.length-1));h==y?this.#w.run(a.subarray(0,a.length-1),o,e):console.warn(`Bad GS checksum ${h}. Should be ${y}.`)}},66:(e,a,o)=>{this.#A.run(a,o,e)},67:(e,a,o)=>{this.#k.run(a,o,e)},68:(e,a,o)=>{this.#q.run(a,o,e)},71:(e,a,o)=>{this.#z.run(a,o,e)},126:(e,a,o)=>{this.#V.run(a,o,e)},127:(e,a,o)=>{this.switchMode("gm"),this.#F.run(a,o,e)}};#V;#F;#k;#w;#A;#K;#z;#q;buildRchTree(){let e=[];this.#d.forEach((a,o)=>{a0&&!h&&(this.#e[e*b.cc+u[0]]=R[o])}setChActive(e,a=0){this.#R[e]!=a&&this.dispatchEvent("channeltoggle",{part:e,active:a}),this.#R[e]=a}getPitch(){return this.#U}getProgram(){return this.#i}getTexts(){return this.#E.slice()}getVel(e){let a=new Map,o=this;return o.#l.forEach(function(h,y){let g=Math.floor(h/128),d=h%128;e==g&&o.#o[h]>0&&a.set(d,{v:o.#o[h],s:o.#h[y]})}),a}getBitmap(){return{bitmap:this.#y,expire:this.#C}}getLetter(){return{text:this.#L,set:this.#ee,expire:this.#G}}getMode(){return M[this.#t]}getMaster(){return{volume:this.#n}}getRawStrength(){let e=this;return this.#l.forEach(function(a){let o=Math.floor(a/128);e.#o[a]>e.#x[o]&&(e.#x[o]=e.#o[a])}),this.#x}getStrength(){let e=[],a=this;return this.getRawStrength().forEach(function(o,h){e[h]=Math.floor(o*a.#e[h*b.cc+u[7]]*a.#e[h*b.cc+u[11]]*a.#n/803288)}),e}getRpn(){return this.#a}getNrpn(){return this.#Q}getVoice(e,a,o,h){let y=e||this.#H,g=a,d=o||this.#m;M[this.#t]=="ns5r"&&y>0&&y<56&&(d=3);let t=this.userBank.get(y,g,d,h);if(M[this.#t]=="mt32"&&t.name.indexOf("MT-m:")==0){let s=parseInt(t.name.slice(5)),n=s*b.cmt,i="";this.#N.subarray(n,n+10).forEach(r=>{r>31&&(i+=String.fromCharCode(r))}),this.userBank.load(`MSB LSB PRG -0 127 ${g} ${i}`,!0),t.name=i,t.ending=" "}return(t.ending!=" "||!t.name.length)&&(t=this.baseBank.get(y,g,d,h)),t}getChVoice(e){let a=this.getVoice(this.#e[e*b.cc+u[0]],this.#i[e],this.#e[e*b.cc+u[32]],M[this.#t]);if(this.#T[e])switch(this.#t){case m.mt32:a.ending="~",a.name="",this.#v.subarray(14*(e-1),14*(e-1)+10).forEach(o=>{o>31&&(a.name+=String.fromCharCode(o))})}return a}getPitchShift(e){let a=this,o=e*b.rpn,h=a.#a[o];return a.#r[e*b.rpnt]||a.#t==m.mt32&&(h=12),a.#U[e]/8192*h+(a.#a[o+3]-64)+((a.#a[o+1]<<7)+a.#a[o+2]-8192)/8192}getEffectType(e=0){let a=3*e+1;return this.#g.subarray(a,a+2)}setEffectTypeRaw(e=0,a,o){let h=3*e;this.#g[h]=1,this.#g[h+1+ +a]=o}setEffectType(e=0,a,o){this.setEffectTypeRaw(e,!1,a),this.setEffectTypeRaw(e,!0,o)}getEffectSink(){return this.#W}setLetterDisplay(e,a,o=0,h=3200){let y=this,g;y.#L=" ".repeat(o),e.forEach(d=>{y.#L+=String.fromCharCode(d>31?d:32),d<32&&(g=g||new Set,g.add(d))}),y.#ee=Date.now(),y.#G=Date.now()+h,g&&(g=Array.from(g),g.forEach((d,t,s)=>{s[t]=d.toString(16).padStart(2,"0")}),console.warn(`${a}${a?" ":""}invalid code point${g.length>1?"s":""}: 0x${g.join(", 0x")}`))}allocateAce(e){if(!e||e>95){console.warn(`cc${e} cannot be allocated as an active custom effect.`);return}let a=!0,o=0;for(;a&&o=b.ace&&console.warn("ACE slots are full.")}getAce(){return this.#D}getChAce(e,a){if(a<0||a>=b.ace)throw new RangeError("No such ACE slot");let o=this.#D[a];if(o){if(N.indexOf(o)>=0)return this.#e[e*b.cc+u[o]];throw new Error(`Invalid ACE source: ${o}`)}else return 0}initDrums(){let e=this;e.#b.fill(64);for(let a=0;a-1){if(o.#t==0||a){let y=o.#t;o.initOnReset&&a&&(this.init(1),y=m["?"]),o.#t=h,o.#p=0,o.#H=re[0][h],o.#m=re[1][h];for(let d=0;d0&&o.#e[d*b.cc+u[0]]==R[y]&&(o.#e[d*b.cc]=R[h]);switch(h){case m.mt32:{V.forEach((d,t)=>{let s=t+1;o.#R[s]||(o.#i[s]=d,o.#e[s*b.cc+u[91]]=127)});for(let d=1;d<10;d++)o.dispatchEvent("voice",{part:d});break}}let g;switch(h){case m["?"]:case m.xg:{g=[1,0,65,0,5,0,0,0];break}case m.gm:case m.gs:case m.g2:case m.sd:{g=[40,4,40,18,40,32,32,0];break}case m["05rw"]:case m.x5d:case m.ns5r:{g=[44,1,44,19,44,0,44,0];break}case m.k11:case m.sg:{g=[24,0,0,0,0,0,0,0];break}case m.mt32:{g=[40,4,0,0,0,0,0,0];break}default:g=[0,0,0,0,0,0,0,0]}for(let d=0;d<4;d++)o.#g[3*d]||(o.#g[3*d+1]=g[2*d],o.#g[3*d+2]=g[2*d+1],o.dispatchEvent(`efx${["reverb","chorus","delay","insert"][d]}`,o.getEffectType(d)));o.dispatchEvent("mode",e),o.forceVoiceRefresh()}}else throw new Error(`Unknown mode ${e}`)}newStrength(){this.#x.fill(0)}runJson(e){if(e.type>14)return e.type==15&&e.data.constructor!=Uint8Array&&(e.data=Uint8Array.from(e.data)),this.#ae[e.type].call(this,e);{let a=this.chRedir(e.part,e.track),o=!1;this.#te[a]?.forEach(h=>{e.channel=h,o=!0,this.#ae[e.type].call(this,e)}),o||console.warn(`${ie[e.type]?ie[e.type]:e.type}${[11,12].includes(e.type)?(e.data[0]!=null?e.data[0]:e.data).toString():""} event sent to CH${a+1} without any recipient.`)}this.#E.length>100&&this.#E.splice(100,this.#E.length-99)}runRaw(e){}async loadBank(e,a){let o=this;switch(e=e.toLowerCase(),e){case"s7e":{o.userBank.clearRange({msb:63,lsb:[21,22]}),o.userBank.clearRange({msb:63,lsb:[24,27]});break}default:throw new Error(`Unknown bank format ${e}`)}switch(e){case"s7e":{H.context=this,o.userBank.load(await H.read(e,a));break}}o.forceVoiceRefresh()}constructor(){super();let e=this;this.#y=new Uint8Array(256),this.#M[10]=new Uint8Array(512),this.#X=new x,this.userBank.strictMode=!0,this.userBank.load(`MSB PRG LSB NME +`).forEach(e=>{let s=e.split(",");_[s[0]]=s[1]});var ee=function(e){let s=e;e[0]=="*"&&(s=s.slice(1)),["aa","ii","uu","ee","oo"].forEach(d=>{for(;s.indexOf(d)>-1;)s=s.replace(d,d[0])});for(let d in _)s=s.replaceAll(d,_[d]);s.indexOf("ん")==0&&s.length>1&&(s=s.slice(1));let o=s.indexOf("!");return o>-1&&s.length>1&&(s=s.slice(o+1)),s},te=function(e){return e?e<96?`cc${e}`:["aftertouch","velocity","pitch bend"][e-96]:"off"};var X=["room 1","room 2","room 3","hall 1","hall 2","plate","delay","panning delay"],ae=["chorus 1","chorus 2","chorus 3","chorus 4","feedback","flanger","short delay","short delay feedback"],se=["delay 1","delay 2","delay 3","delay 4","pan delay 1","pan delay 2","pan delay 3","pan delay 4","delay to reverb","pan repeat"];var ye={0:"thru",256:"stereo EQ",257:"spectrum",258:"enhancer",259:"humanizer",272:"overdrive",273:"distortion",288:"phaser",289:"auto wah",290:"rotary",291:"stereo flanger",292:"step flanger",293:"tremelo",294:"auto pan",304:"compressor",305:"limiter",320:"hexa chorus",321:"tremelo chorus",322:"stereo chorus",323:"space D",324:"3D chorus",336:"stereo delay",337:"modulated delay",338:"3-tap delay",339:"4-tap delay",340:"tremelo control delay",341:"reverb",342:"gate reverb",343:"3D delay",352:"2-pitch shifter",353:"feedback pitch shifter",368:"3D auto",369:"3D manual",370:"Lo-Fi 1",371:"Lo-Fi 2",512:"overdrive - chorus",513:"overdrive - flanger",514:"overdrive - delay",515:"distortion - chorus",516:"distortion - flanger",517:"distortion - delay",518:"enhancer - chorus",519:"enhancer - flanger",520:"enhancer - delay",521:"chorus - delay",522:"flanger - delay",523:"chorus - flanger",524:"rotary multi",1024:"guitar multi 1",1025:"guitar multi 2",1026:"guitar multi 3",1027:"clean guitar multi 1",1028:"clean guitar multi 2",1029:"bass multi",1030:"rhodes multi",1280:"keyboard multi",4352:"chorus / delay",4353:"flanger / delay",4354:"chorus / flanger",4355:"overdrive / distortion",4356:"overdrive / rotary",4357:"overdrive / phaser",4358:"overdrive / auto wah",4359:"phaser / rotary",4360:"phaser / auto wah"},ge={66307:["drive"],66309:["vowel",e=>"aiueo"[e]],94723:["pre-filter"],94724:["Lo-Fi type"],94725:["post-filter"],94979:["Lo-Fi type"],94980:["fill type",e=>["off","LPF","HPF"][e]],94984:["noise type",e=>["white","pink"][e]],94987:["disc type",e=>["LP","SP","EP","RND"]],94990:["hum type",e=>`${e+5}0Hz`],94993:["M/S",e=>["mono","stereo"][e]]},V=function(e){return ye[(e[0]-32<<8)+e[1]]||`0x${e[0].toString(16).padStart(2,"0")}${e[1].toString(16).padStart(2,"0")}`},re=function(e,s,o){let d=(e[0]-32<<16)+(e[1]<<8)+s,y=ge[d]||{},g=y[0];if(g?.length)return g+=`: ${(y[1]||function(){})(o)||o}`,g},F=[68,48,95,78,41,3,110,122,0];var S=function(e=64){return Math.round(2e3*Math.log10(e/64))/100};var K=function(e){let s=0;return e.forEach(o=>{s+=o,s=s&127}),~s+1&127},T=function(e,s){let o=0,d=0;for(let y=0;y>g&1)<<7,t=e[y];t+=$,y%8!=0?(s(t,o,e),o++):d=e[y]}},P=function(e){let s=Math.floor(e*14.2);return s<128?s:0};var M=["?","gm","gs","xg","g2","mt32","ns5r","x5d","05rw","sd","k11","sg","krs","s90es","motif"],$e=["melodic","drum","menu"],ie=[[0,0,0,0,121,0,0,82,81,97,0,0,63,63,63],[0,0,4,0,0,127,0,0,0,0,0,0,0,0,0]],R=[120,127,120,127,120,127,61,62,62,105,122,122,120,127,127],Ee=[0,3,81,84,88],ne={8:"Off",9:"On",10:"Note aftertouch",11:"cc",12:"pc",13:"Channel aftertouch",14:"Pitch"},ce={0:0,1:1,2:3,5:4},oe={0:0,1:1,2:2,5:3},le=[[0,24],[0,127],[0,127],[40,88],[0,127],[0,127]],fe=[36,37,48,49,52,53],G=[20,21,22,23,24,25,26,28,29,30,31,36,37,48,49,52,53,64,65],de={26:127,29:0,30:0,31:0,52:12,53:54},N=[0,1,2,4,5,6,7,8,10,11,32,38,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,84,91,92,93,94,95,98,99,100,101,128,12,13,16,17,18,19,14,15,20,21,26,28],me=[12,13,14,15,16,17,18,19,20,21],ke=[33,99,100,32,102,8,9,10],he=[0,16,25,40,32,64,26,48],m={};M.forEach((e,s)=>{m[e]=s});var h={length:N.length};N.forEach((e,s)=>{h[e]=s});var C={length:G.length};G.forEach((e,s)=>{C[e]=s});var ve={};$e.forEach((e,s)=>{ve[e]=s});var v=function(){return!!self.Bun||self.debugMode||!1},we=function(e){let s=[],o=0;return e?.forEach(function(d,y){d==247?s.push(e.subarray(o,y)):d==240&&(o=y+1)}),s.length||s.push(e.subarray(0)),v()&&console.debug(s),s};var p={ch:128,cc:N.length,nn:128,pl:512,tr:256,cmt:14,rpn:6,rpnt:4,ace:8,drm:8,dpn:G.length,dnc:128,efx:7},qe=class extends q{NOTE_IDLE=0;NOTE_ATTACK=1;NOTE_DECAY=2;NOTE_SUSTAIN=3;NOTE_HELD=4;NOTE_RELEASE=5;NOTE_SOSTENUTO_ATTACK=8;NOTE_SOSTENUTO_DECAY=9;NOTE_SOSTENUTO_SUSTAIN=10;NOTE_SOSTENUTO_HELD=11;CH_MELODIC=0;CH_DRUMS=1;CH_DRUM1=2;CH_DRUM2=3;CH_DRUM3=4;CH_DRUM4=5;CH_DRUM5=6;CH_DRUM6=7;CH_DRUM7=8;CH_DRUM8=9;#t=0;#p=0;#C=0;#M=new Array(11);get#y(){return this.#M[this.#p]}set#y(e){this.#M[this.#p]=e}#R=new Uint8Array(p.ch);#d=new Uint8Array(p.ch);#s=new Uint8Array(p.ch);#e=new Uint8Array(p.ch*p.cc);#D=new Uint8Array(p.ace);#i=new Uint8Array(p.ch);#o=new Uint8Array(p.ch*p.nn);#g=new Uint8Array(p.ch);#l=new Uint16Array(p.pl);#h=new Uint8Array(p.pl);#U=new Int16Array(p.ch);#x=new Uint8Array(p.ch);#I=0;#a=new Uint8Array(p.ch*p.rpn);#r=new Uint8Array(p.ch*p.rpnt);#Q=new Int8Array(p.ch*fe.length);#b=new Uint8Array(p.drm*p.dpn*p.dnc);#T=new Uint8Array(p.ch);#P=new Uint8Array(128);#w=new Uint8Array(p.cmt*8);#Y=new Uint8Array(1024);#N=new Uint8Array(p.cmt*64);#$=new Uint8Array(p.efx*3);#W=new Uint8Array(p.ch);#L=0;#m=0;#n=100;#_=0;#j=500;#J=0;#H="";#G=0;#ee=0;#Z=0;#S=!0;#c=!1;#te;#re=new Uint8Array(2);#E=[];#O=new Uint8Array(p.ch);#B=new Uint8Array(p.tr);baseBank=new I("gm","gm2","xg","gs","ns5r","sd","gmega","plg-150vl","plg-150pf","plg-150dx","plg-150an","plg-150dr","plg-100sg","kross","s90es");userBank=new I("gm");initOnReset=!1;aiEfxName="";chRedir(e,s,o){if(this.#B[s])return(this.#B[s]-1)*16+e;if([2,3].indexOf(this.#m)>-1){if(o==1)return e;let d=0,y=!0;for(;y;)this.#O[e+d]==0?(this.#O[e+d]=s,console.debug(`Assign track ${s} to channel ${e+d+1}.`),y=!1):this.#O[e+d]==s?y=!1:(d+=16,d>=128&&(d=0,y=!1));return e+d}else return e}forceVoiceRefresh(){for(let e=0;e{let o=e*128+s,d=this.#l.lastIndexOf(o);d>-1&&(this.#e[p.cc*e+h[64]]>63?(this.#h[d]=this.NOTE_HELD,this.dispatchEvent("note",{part:e,note:s,velo:this.#o[o],state:this.NOTE_HELD})):this.#e[p.cc*e+h[66]]>63&&this.#h[d]==this.NOTE_SOSTENUTO_SUSTAIN?(this.#h[d]=this.NOTE_SOSTENUTO_HELD,this.dispatchEvent("note",{part:e,note:s,velo:this.#o[o],state:this.NOTE_SOSTENUTO_HELD})):(this.#l[d]=0,this.#o[o]=0,this.#h[d]=this.NOTE_IDLE,this.dispatchEvent("note",{part:e,note:s,velo:0,state:this.NOTE_IDLE})))},nOn:(e,s,o)=>{let d=e*128+s,y=0;for(this.#g[e]&&this.#f.ano(e);this.#h[y]>0&&this.#l[y]!=d;)y++;y{},cAt:(e,s)=>{},hoOf:e=>{this.#h.forEach((s,o)=>{if(s==this.NOTE_HELD){let d=this.#l[o],y=d>>7;e==y&&(this.#h[o]=this.NOTE_IDLE,this.#l[o]=0,this.#o[d]=0,this.dispatchEvent("note",{part:e,note:d&127,velo:0,state:this.NOTE_IDLE}))}})},soOn:e=>{this.#h.forEach((s,o)=>{let d;switch(s){case this.NOTE_ATTACK:{d=this.NOTE_SOSTENUTO_ATTACK;break}case this.NOTE_DECAY:{d=this.NOTE_SOSTENUTO_DECAY;break}case this.NOTE_SUSTAIN:{d=this.NOTE_SOSTENUTO_SUSTAIN;break}}if(d){this.#h[o]=d;let y=this.#l[o];this.dispatchEvent("note",{part:e,note:y&127,velo:this.#o[y],state:d})}})},soOf:e=>{this.#h.forEach((s,o)=>{if(s==this.NOTE_SOSTENUTO_HELD){let d=this.#l[o],y=d>>7;e==y&&(this.#h[o]=this.NOTE_IDLE,this.#l[o]=0,this.#o[d]=0,this.dispatchEvent("note",{part:e,note:d&127,velo:0,state:this.NOTE_IDLE}))}})},ano:e=>{this.#l.forEach((s,o,d)=>{let y=s>>7,g=s&127;s==0&&this.#o[0]==0||y==e&&this.#f.nOff(y,g)})}};#ae={8:function(e){let s=e.channel,o=e.data[0];this.#f.nOff(s,o)},9:function(e){let s=e.channel;this.setChActive(s,1);let o=e.data[0],d=e.data[1];d>0?this.#f.nOn(s,o,d):this.#f.nOff(s,o)},10:function(e){let s=e.channel,o=s*128+e.data[0];this.#l.indexOf(o)>-1&&(this.#o[o]=data[1],this.dispatchEvent("note",{part:s,note:e.data[0],velo:e.data[1],state:this.NOTE_SUSTAIN}))},11:function(e){let s=e.channel;[0,32].indexOf(e.data[0])>-1&&(()=>{switch(this.#t){case m.s90es:case m.motif:{if(e.data[0]==0){[0,63].indexOf(e.data[1])>-1&&this.setChActive(s,1);break}e.data[1]&&this.setChActive(s,1);break}default:{this.setChActive(s,1);break}}})();let o=s*p.cc;switch(e.data[0]){case 96:return;case 97:return;case 120:return;case 121:{this.#f.ano(s),this.#U[s]=0;let d=s*p.cc;this.#e[d+h[1]]=0,this.#e[d+h[5]]=0,this.#e[d+h[64]]=0,this.#e[d+h[65]]=0,this.#e[d+h[66]]=0,this.#e[d+h[67]]=0,this.#e[d+h[11]]=127,this.#e[d+h[101]]=127,this.#e[d+h[100]]=127,this.#e[d+h[99]]=127,this.#e[d+h[98]]=127;return}case 123:{this.#f.ano(s);return}case 124:{this.#f.ano(s);return}case 125:{this.#f.ano(s);return}case 126:{this.#g[s]=1,this.#f.ano(s);return}case 127:{this.#g[s]=0,this.#f.ano(s);return}}if(h[e.data[0]]==null)console.warn(`cc${e.data[0]} is not accepted.`);else{switch(me.indexOf(e.data[0])>-1&&this.allocateAce(e.data[0]),e.data[0]){case 0:{switch(v()&&console.debug(`${M[this.#t]}, CH${s+1}: ${e.data[1]}`),this.#t==0?e.data[1]<48?(this.#s[s]>0&&(e.data[1]=this.#e[o],e.data[1]=120,console.debug(`Forced channel ${s+1} to stay drums.`)),e.data[1]>0&&(console.debug(`Roland GS detected with MSB: ${e.data[1]}`),this.switchMode("gs"))):e.data[1]==62?this.switchMode("x5d"):e.data[1]==63?this.switchMode("krs"):(e.data[1]==64||e.data[1]==127)&&this.switchMode("xg"):this.#t==m.gs?e.data[1]<56&&this.#s[s]>0&&(e.data[1]=this.#e[o],e.data[1]=120,console.debug(`Forced channel ${s+1} to stay drums.`)):this.#t==m.gm?e.data[1]<48?this.#s[s]>0&&(e.data[1]=120,this.switchMode("gs",!0),console.debug(`Forced channel ${s+1} to stay drums.`)):(e.data[1]==64||e.data[1]==127)&&this.switchMode("xg",!0):this.#t==m.x5d&&e.data[1]>0&&e.data[1]<8&&this.switchMode("05rw",!0),this.#t){case m.xg:{[79,95,126,127].indexOf(e.data[1])>-1?this.#s[s]==0&&(this.setChType(s,this.CH_DRUM2),console.debug(`CH${s+1} set to drums by MSB.`)):this.#s[s]>0&&(this.setChType(s,this.CH_MELODIC),console.debug(`CH${s+1} set to melodic by MSB.`));break}case m["05rw"]:case m.x5d:case m.ns5r:{[61,62,126,127].indexOf(e.data[1])>-1?this.#s[s]==this.CH_MELODIC&&(this.setChType(s,this.CH_DRUM2),console.debug(`CH${s+1} set to drums by MSB.`)):[80,81,82,83].indexOf(e.data[1])>-1||this.#s[s]!=this.CH_MELODIC&&(this.setChType(s,this.CH_MELODIC),console.debug(`CH${s+1} set to melodic by MSB.`));break}case m.sd:{[104,105,106,107].indexOf(e.data[1])>-1?this.#s[s]==0&&(this.setChType(s,this.CH_DRUM2),console.debug(`CH${s+1} set to drums by MSB.`)):this.#s[s]>0&&(this.setChType(s,this.CH_MELODIC),console.debug(`CH${s+1} set to melodic by MSB.`));break}case m.g2:{e.data[1]==120?this.#s[s]==0&&(this.setChType(s,this.CH_DRUMS),console.debug(`CH${s+1} set to drums by MSB.`)):this.#s[s]>0&&(this.setChType(s,this.CH_MELODIC),console.debug(`CH${s+1} set to melodic by MSB.`));break}}this.dispatchEvent("voice",{part:s});break}case 6:{if(this.#I){[m.xg,m.gs,m.ns5r].indexOf(this.#t)<0&&console.warn(`NRPN commits are not available under "${M[this.#t]}" mode, even when they are supported in Octavia.`);let d=this.#e[o+h[99]],y=this.#e[o+h[98]];if(d==1){let g=ke.indexOf(y);if(g>-1)this.#e[o+h[71+g]]=e.data[1],v()&&console.debug(`Redirected NRPN 1 ${y} to cc${71+g}.`),this.dispatchEvent("cc",{part:s,cc:71+g,data:e.data[1]});else{let $=fe.indexOf(y);$>-1?this.#Q[s*10+$]=e.data[1]-64:console.warn(`NRPN 0x01${y.toString(16).padStart(2,"0")} is not supported.`),v()&&console.debug(`CH${s+1} voice NRPN ${y} commit`)}}else{if(G.indexOf(d)<0){let $=`NRPN 0x${d.toString(16).padStart(2,"0")}${y.toString(16).padStart(2,"0")} `;d==127?console.warn(`${$}is not necessary. Consider removing it.`):console.warn(`${$}is not supported.`)}else{let $=this.#s[s]-2;$<0?console.warn(`CH${s+1} cannot accept drum NRPN as type ${U[this.#s[s]]}.`):this.#b[($*p.dpn+C[d])*p.dnc+y]=e.data[1]}v()&&console.debug(`CH${s+1} (${U[this.#s[s]]}) drum NRPN ${d} commit`)}}else{let d=ce[this.#e[o+h[100]]],y=oe[this.#e[o+h[100]]];this.#e[o+h[101]]==0&&d!=null&&(v()&&console.debug(`CH${s+1} RPN 0 ${this.#e[o+h[100]]} commit: ${e.data[1]}`),e.data[1]=Math.min(Math.max(e.data[1],le[d][0]),le[d][1]),this.#a[s*p.rpn+d]=e.data[1],this.#r[s*p.rpnt+y]=1)}break}case 32:{switch(v()&&console.debug(`${M[this.#t]}, CH${s+1} LSB: ${e.data[1]}`),this.#t){case m.s90es:case m.motif:{this.setChType(s,[32,40].indexOf(e.data[1])>-1?this.CH_DRUMS:this.CH_MELODIC,this.#t,!0);break}}this.dispatchEvent("voice",{part:s});break}case 38:{if(!this.#I){let d=ce[this.#e[o+100]],y=oe[this.#e[o+100]];this.#e[o+101]==0&&d!=null&&(this.#a[s*p.rpn+d+1]=e.data[1],this.#r[s*p.rpnt+y]=1)}break}case 64:{e.data[1]<64&&this.#f.hoOf(s);break}case 66:{e.data[1]>>6?this.#f.soOn(s):this.#f.soOf(s);break}case 98:case 99:{this.#I=1;break}case 100:case 101:{this.#I=0;break}}this.#e[o+h[e.data[0]]]=e.data[1],this.dispatchEvent("cc",{part:s,cc:e.data[0],data:e.data[1]})}},12:function(e){let s=e.channel;switch(this.#t){case m.s90es:case m.motif:{e.data&&this.setChActive(s,1);break}default:this.setChActive(s,1)}this.#i[s]=e.data,this.#T[s]=0,v()&&console.debug(`T:${e.track} C:${s} P:${e.data}`),this.dispatchEvent("voice",{part:s})},13:function(e){let s=this,o=e.channel;this.#l.forEach(function(d){let y=d>>7;o==y&&(s.#o[d]=e.data,s.dispatchEvent("note",{part:o,note:d&127,velo:e.data,state:s.NOTE_SUSTAIN}))})},14:function(e){let s=e.channel;this.#U[s]=e.data[1]*128+e.data[0]-8192,this.dispatchEvent("pitch",{part:s,pitch:this.getPitchShift(s)})},15:function(e){we(e.data).forEach(s=>{let o=s[0],d=s[1];(this.#se[o]||function(){console.debug(`Unknown manufacturer ${o}.`)})(d,s.subarray(2),e.track)})},248:function(e){},250:function(e){},251:function(e){},252:function(e){},254:function(e){},255:function(e){(this.#u[e.meta]||function(o,d,y){}).call(this,e.data,e.track,e.meta),e.meta!=32&&(this.#_=0);let s=Ee.indexOf(e.meta)>-1;if(v()&&console.debug(e),s)return e.reply="meta",e}};#se={64:(e,s,o)=>{this.#K.run(s,o,e)},65:(e,s,o)=>{if(s[0]<16)if(s[1]==72){let d=s[s.length-1],y=K(s.subarray(3,s.length-1));d==y?this.#v.run(s.subarray(0,s.length-1),o,e):console.warn(`Bad SD checksum ${d}. Should be ${y}.`)}else this.#v.run(s,o,e);else{let d=s[s.length-1],y=K(s.subarray(2,s.length-1));d==y?this.#v.run(s.subarray(0,s.length-1),o,e):console.warn(`Bad GS checksum ${d}. Should be ${y}.`)}},66:(e,s,o)=>{this.#A.run(s,o,e)},67:(e,s,o)=>{this.#k.run(s,o,e)},68:(e,s,o)=>{this.#q.run(s,o,e)},71:(e,s,o)=>{this.#z.run(s,o,e)},126:(e,s,o)=>{this.#V.run(s,o,e)},127:(e,s,o)=>{this.switchMode("gm"),this.#F.run(s,o,e)}};#V;#F;#k;#v;#A;#K;#z;#q;buildRchTree(){let e=[];this.#d.forEach((s,o)=>{s0&&!d&&(this.#e[e*p.cc+h[0]]=R[o])}setChActive(e,s=0){this.#R[e]!=s&&this.dispatchEvent("channeltoggle",{part:e,active:s}),this.#R[e]=s}getPitch(){return this.#U}getProgram(){return this.#i}getTexts(){return this.#E.slice()}getVel(e){let s=new Map,o=this;return o.#l.forEach(function(d,y){let g=Math.floor(d/128),$=d%128;e==g&&o.#o[d]>0&&s.set($,{v:o.#o[d],s:o.#h[y]})}),s}getBitmap(){return{bitmap:this.#y,expire:this.#C}}getLetter(){return{text:this.#H,set:this.#ee,expire:this.#G}}getMode(){return M[this.#t]}getMaster(){return{volume:this.#n}}getRawStrength(){let e=this;return this.#l.forEach(function(s){let o=Math.floor(s/128);e.#o[s]>e.#x[o]&&(e.#x[o]=e.#o[s])}),this.#x}getStrength(){let e=[],s=this;return this.getRawStrength().forEach(function(o,d){e[d]=Math.floor(o*s.#e[d*p.cc+h[7]]*s.#e[d*p.cc+h[11]]*s.#n/803288)}),e}getRpn(){return this.#a}getNrpn(){return this.#Q}getVoice(e,s,o,d){let y=e||this.#L,g=s,$=o||this.#m;M[this.#t]=="ns5r"&&y>0&&y<56&&($=3);let t=this.userBank.get(y,g,$,d);if(M[this.#t]=="mt32"&&t.name.indexOf("MT-m:")==0){let n=parseInt(t.name.slice(5)),i=n*p.cmt,r="";this.#N.subarray(i,i+10).forEach(c=>{c>31&&(r+=String.fromCharCode(c))});let a=`MSB LSB PRG NME +0 127 ${g} ${r}`;this.userBank.load(a,!0),t.name=r,t.ending=" "}return(t.ending!=" "||!t.name.length)&&(t=this.baseBank.get(y,g,$,d)),t}getChVoice(e){let s=this.getVoice(this.#e[e*p.cc+h[0]],this.#i[e],this.#e[e*p.cc+h[32]],M[this.#t]);if(this.#T[e])switch(this.#t){case m.mt32:s.ending="~",s.name="",this.#w.subarray(14*(e-1),14*(e-1)+10).forEach(o=>{o>31&&(s.name+=String.fromCharCode(o))})}return s}getPitchShift(e){let s=this,o=e*p.rpn,d=s.#a[o];return s.#r[e*p.rpnt]||s.#t==m.mt32&&(d=12),s.#U[e]/8192*d+(s.#a[o+3]-64)+((s.#a[o+1]<<7)+s.#a[o+2]-8192)/8192}getEffectType(e=0){let s=3*e+1;return this.#$.subarray(s,s+2)}setEffectTypeRaw(e=0,s,o){let d=3*e;this.#$[d]=1,this.#$[d+1+ +s]=o}setEffectType(e=0,s,o){this.setEffectTypeRaw(e,!1,s),this.setEffectTypeRaw(e,!0,o)}getEffectSink(){return this.#W}setLetterDisplay(e,s,o=0,d=3200){let y=this,g;y.#H=" ".repeat(o),e.forEach($=>{y.#H+=String.fromCharCode($>31?$:32),$<32&&(g=g||new Set,g.add($))}),y.#ee=Date.now(),y.#G=Date.now()+d,g&&(g=Array.from(g),g.forEach(($,t,n)=>{n[t]=$.toString(16).padStart(2,"0")}),console.warn(`${s}${s?" ":""}invalid code point${g.length>1?"s":""}: 0x${g.join(", 0x")}`))}allocateAce(e){if(!e||e>95){console.warn(`cc${e} cannot be allocated as an active custom effect.`);return}let s=!0,o=0;for(;s&&o=p.ace&&console.warn("ACE slots are full.")}getAce(){return this.#D}getChAce(e,s){if(s<0||s>=p.ace)throw new RangeError("No such ACE slot");let o=this.#D[s];if(o){if(N.indexOf(o)>=0)return this.#e[e*p.cc+h[o]];throw new Error(`Invalid ACE source: ${o}`)}else return 0}initDrums(){let e=this;e.#b.fill(64);for(let s=0;s-1){if(o.#t==0||s){let y=o.#t;o.initOnReset&&s&&(this.init(1),y=m["?"]),o.#t=d,o.#p=0,o.#L=ie[0][d],o.#m=ie[1][d];for(let $=0;$0&&o.#e[$*p.cc+h[0]]==R[y]&&(o.#e[$*p.cc]=R[d]);switch(d){case m.mt32:{F.forEach(($,t)=>{let n=t+1;o.#R[n]||(o.#i[n]=$,o.#e[n*p.cc+h[91]]=127)});for(let $=1;$<10;$++)o.dispatchEvent("voice",{part:$});break}}let g;switch(d){case m["?"]:case m.xg:{g=[1,0,65,0,5,0,0,0];break}case m.gm:case m.gs:case m.g2:case m.sd:{g=[40,4,40,18,40,32,32,0];break}case m["05rw"]:case m.x5d:case m.ns5r:{g=[44,1,44,19,44,0,44,0];break}case m.k11:case m.sg:{g=[24,0,0,0,0,0,0,0];break}case m.mt32:{g=[40,4,0,0,0,0,0,0];break}default:g=[0,0,0,0,0,0,0,0]}for(let $=0;$<4;$++)o.#$[3*$]||(o.#$[3*$+1]=g[2*$],o.#$[3*$+2]=g[2*$+1],o.dispatchEvent(`efx${["reverb","chorus","delay","insert"][$]}`,o.getEffectType($)));o.dispatchEvent("mode",e),o.forceVoiceRefresh()}}else throw new Error(`Unknown mode ${e}`)}newStrength(){this.#x.fill(0)}runJson(e){if(e.type>14)return e.type==15&&e.data.constructor!=Uint8Array&&(e.data=Uint8Array.from(e.data)),this.#ae[e.type].call(this,e);{let s=this.chRedir(e.part,e.track),o=!1;this.#te[s]?.forEach(d=>{e.channel=d,o=!0,this.#ae[e.type].call(this,e)}),o||console.warn(`${ne[e.type]?ne[e.type]:e.type}${[11,12].includes(e.type)?(e.data[0]!=null?e.data[0]:e.data).toString():""} event sent to CH${s+1} without any recipient.`)}this.#E.length>100&&this.#E.splice(100,this.#E.length-99)}runRaw(e){}async loadBank(e,s){let o=this;switch(e=e.toLowerCase(),e){case"s7e":{o.userBank.clearRange({msb:63,lsb:[21,22]}),o.userBank.clearRange({msb:63,lsb:[24,27]});break}default:throw new Error(`Unknown bank format ${e}`)}switch(e){case"s7e":{H.context=this,o.userBank.load(await H.read(e,s));break}}o.forceVoiceRefresh()}constructor(){super();let e=this;this.#y=new Uint8Array(256),this.#M[10]=new Uint8Array(512),this.#X=new x,this.userBank.strictMode=!0,this.userBank.load(`MSB PRG LSB NME 062 000 000 122 000 000 122 001 000 @@ -148,18 +148,18 @@ _,`.split(` 122 003 000 122 004 000 122 005 000 -122 006 000 `),this.addEventListener("metacommit",function(t){let{data:s}=t;e.#E[0]?.type==s.type&&e.#E[0]?.amend?(e.#E[0].amend=s.amend,e.#E[0].data+=s.data):e.#E.unshift(s)}),this.#u[1]=function(t){switch(t=t.replaceAll(`\r +122 006 000 `),this.addEventListener("metacommit",function(t){let{data:n}=t;e.#E[0]?.type==n.type&&e.#E[0]?.amend?(e.#E[0].amend=n.amend,e.#E[0].data+=n.data):e.#E.unshift(n)}),this.#u[1]=function(t){switch(t=t.replaceAll(`\r `,` `).replaceAll("\r",` -`),t.slice(0,2)){case"@I":{this.#c=!0,this.dispatchEvent("metacommit",{type:"Kar.Info",data:t.slice(2)?.trimLeft()});break}case"@K":{this.#c=!0,this.dispatchEvent("metacommit",{type:"Kar.Mode",data:t.slice(2)?.trimLeft()}),console.debug(`Karaoke mode active: ${t.slice(2)}`);break}case"@L":{this.#c=!0,this.dispatchEvent("metacommit",{type:"Kar.Lang",data:t.slice(2)?.trimLeft()});break}case"@T":{this.#c=!0,this.dispatchEvent("metacommit",{type:"KarTitle",data:t.slice(2)?.trimLeft()});break}case"@V":{this.#c=!0,this.dispatchEvent("metacommit",{type:"Kar.Ver.",data:t.slice(2)?.trimLeft()});break}case"XF":{let s=t.slice(2).split(":");switch(s[0]){case"hd":{s.slice(1).forEach((n,i)=>{n.length&&this.dispatchEvent("metacommit",{type:["XfSngDte","XfSngRgn","XfSngCat","XfSongBt","XfSngIns","XfSngVoc","XfSngCmp","XfSngLrc","XfSngArr","XfSngPer","XfSngPrg","XfSngTag"][i],data:n})});break}case"ln":{s.slice(1).forEach((n,i)=>{n.length&&this.dispatchEvent("metacommit",{type:["XfKarLng","XfKarNme","XfKarCmp","XfKarLrc","XfKarArr","XfKarPer","XfKarPrg"][i],data:n})});break}default:this.dispatchEvent("metacommit",{type:"XfUnData",data:t})}break}default:this.#c?t[0]=="\\"?(this.dispatchEvent("metacommit",{type:"KarLyric",data:"",amend:!1}),this.dispatchEvent("metacommit",{type:"KarLyric",data:t.slice(1),amend:!0})):t[0]=="/"?(this.dispatchEvent("metacommit",{type:"KarLyric",data:"",mask:!0,amend:!1}),this.dispatchEvent("metacommit",{type:"KarLyric",data:t.slice(1),mask:!0,amend:!0})):this.dispatchEvent("metacommit",{type:"KarLyric",data:t,amend:!0}):t.split(` -`).forEach((s,n)=>{this.dispatchEvent("metacommit",{type:"Cmn.Text",data:s,mask:n!=0})})}},this.#u[2]=function(t){this.dispatchEvent("metacommit",{type:"Copyrite",data:t})},this.#u[3]=function(t,s){s<1&&this.#I<1&&this.dispatchEvent("metacommit",{type:"TrkTitle",data:t})},this.#u[4]=function(t,s){this.dispatchEvent("metacommit",{type:"Instrmnt",data:t})},this.#u[5]=function(t){t.trim()==""?this.dispatchEvent("metacommit",{type:"C.Lyrics",data:"",amend:!1}):this.dispatchEvent("metacommit",{type:"C.Lyrics",data:t,amend:!0})},this.#u[6]=function(t){this.dispatchEvent("metacommit",{type:"C.Marker",data:t})},this.#u[7]=function(t){this.dispatchEvent("metacommit",{type:"CuePoint",data:t})},this.#u[32]=function(t){this.#I=t[0]+1},this.#u[33]=function(t,s){e.#B[s]=t+1},this.#u[81]=function(t,s){e.#J=t/1e3},this.#u[127]=function(t,s){e.#X.run(t,s)},this.#X.default=function(t){console.warn(`Unrecognized sequencer-specific byte sequence: ${t}`)},this.#X.add([67,0,1],function(t,s){e.#B[s]=t[0]+1}),this.#V=new x("universal non-realtime"),this.#F=new x("universal realtime"),this.#k=new x("Yamaha"),this.#w=new x("Roland"),this.#A=new x("Korg"),this.#K=new x("Kawai"),this.#z=new x("Akai"),this.#q=new x("Casio");let a=function(t){console.info(`Unrecognized SysEx in "${this.name}" set. -%o`,t)};this.#V.default=a,this.#F.default=a,this.#k.default=a,this.#w.default=a,this.#A.default=a,this.#K.default=a,this.#z.default=a,this.#q.default=a,this.#V.add([9],t=>{e.switchMode(["gm","?","g2"][t[0]-1],!0),e.#c=e.#c||!1,console.info(`MIDI reset: ${["GM","Init","GM2"][t[0]-1]}`),t[0]==2&&e.init()}),this.#F.add([4,1],t=>{e.#n=((t[1]<<7)+t[0])/16383*100,e.dispatchEvent("mastervolume",e.#n)}).add([4,3],t=>((t[1]<<7)+t[0]-8192)/8192).add([4,4],t=>t[1]-64),this.#k.add([76,0,0],t=>{switch(t[0]){case 125:{e.initDrums(),console.info(`XG drum setup reset: ${t}`);break}case 126:{e.switchMode("xg",!0),e.#c=!1,console.info("MIDI reset: XG");break}default:{let s=[0,0,0,0],n=(i,r)=>{s[r]=i};if(t.subarray(1).forEach((i,r)=>{let c=r+t[0];([n,n,n,n,f=>{this.#n=f*129/16383*100,e.dispatchEvent("mastervolume",e.#n)},f=>{},f=>{}][c]||(()=>{}))(i,r)}),t[0]<4){let i=0;s.forEach(r=>{i=i<<4,i+=r}),i-=1024}}}}).add([76,2,1],t=>{let s="XG ";t[0]<32?(s+="reverb ",t.subarray(1).forEach((n,i)=>{([r=>{e.setEffectTypeRaw(0,!1,r),console.info(`${s}main type: ${A[r]}`),e.dispatchEvent("efxreverb",e.getEffectType(0))},r=>{e.setEffectTypeRaw(0,!0,r),console.debug(`${s}sub type: ${r+1}`),e.dispatchEvent("efxreverb",e.getEffectType(0))},r=>{console.debug(`${s}time: ${W(r)}s`)},r=>{console.debug(`${s}diffusion: ${r}`)},r=>{console.debug(`${s}initial delay: ${r}`)},r=>{console.debug(`${s}HPF cutoff: ${D[r]}Hz`)},r=>{console.debug(`${s}LPF cutoff: ${D[r]}Hz`)},r=>{console.debug(`${s}width: ${r}`)},r=>{console.debug(`${s}height: ${r}`)},r=>{console.debug(`${s}depth: ${r}`)},r=>{console.debug(`${s}wall type: ${r}`)},r=>{console.debug(`${s}dry/wet: ${r}`)},r=>{console.debug(`${s}send: ${S(r)}dB`)},r=>{console.debug(`${s}pan: ${r-64}`)},!1,!1,r=>{console.debug(`${s}delay: ${r}`)},r=>{console.debug(`${s}density: ${r}`)},r=>{console.debug(`${s}balance: ${r}`)},r=>{},r=>{console.debug(`${s}feedback: ${r}`)},r=>{}][t[0]+i]||function(){console.warn(`Unknown XG reverb address: ${t[0]}.`)})(n)})):t[0]<64?(s+="chorus ",t.subarray(1).forEach((n,i)=>{([r=>{e.setEffectTypeRaw(1,!1,r),console.info(`${s}main type: ${A[r]}`),e.dispatchEvent("efxchorus",e.getEffectType(1))},r=>{e.setEffectTypeRaw(1,!0,r),console.debug(`${s}sub type: ${r+1}`),e.dispatchEvent("efxchorus",e.getEffectType(1))},r=>{console.debug(`${s}LFO: ${Y[r]}Hz`)},r=>{},r=>{console.debug(`${s}feedback: ${r}`)},r=>{console.debug(`${s}delay offset: ${J(r)}ms`)},r=>{},r=>{console.debug(`${s}low: ${D[r]}Hz`)},r=>{console.debug(`${s}low: ${r-64}dB`)},r=>{console.debug(`${s}high: ${D[r]}Hz`)},r=>{console.debug(`${s}high: ${r-64}dB`)},r=>{console.debug(`${s}dry/wet: ${r}`)},r=>{console.debug(`${s}send: ${S(r)}dB`)},r=>{console.debug(`${s}pan: ${r-64}`)},r=>{console.debug(`${s}to reverb: ${S(r)}dB`)},!1,r=>{},r=>{},r=>{},r=>{console.debug(`${s}LFO phase diff: ${(r-64)*3}deg`)},r=>{console.debug(`${s}input mode: ${r?"stereo":"mono"}`)},r=>{}][t[0]-32+i]||function(){console.warn(`Unknown XG chorus address: ${t[0]}.`)})(n)})):t[0]<86?(s+="variation ",t.subarray(1).forEach((n,i)=>{([r=>{e.setEffectTypeRaw(2,!1,r),console.info(`${s}main type: ${A[r]}`),e.dispatchEvent("efxdelay",e.getEffectType(2))},r=>{e.setEffectTypeRaw(2,!0,r),console.debug(`${s}sub type: ${r+1}`),e.dispatchEvent("efxdelay",e.getEffectType(2))}][t[0]-64+i]||function(){})(n)})):t[0]<97?(s+="variation ",t.subarray(1).forEach((n,i)=>{[r=>{console.debug(`${s}send: ${S(r)}dB`)},r=>{console.debug(`${s}pan: ${r-64}`)},r=>{console.debug(`${s}to reverb: ${S(r)}dB`)},r=>{console.debug(`${s}to chorus: ${S(r)}dB`)},r=>{console.debug(`${s}connection: ${r?"system":"insertion"}`)},r=>{console.debug(`${s}channel: CH${r+1}`)},r=>{console.debug(`${s}mod wheel: ${r-64}`)},r=>{console.debug(`${s}bend wheel: ${r-64}`)},r=>{console.debug(`${s}channel after touch: ${r-64}`)},r=>{console.debug(`${s}AC1: ${r-64}`)},r=>{console.debug(`${s}AC2: ${r-64}`)}][t[0]-86+i](n)})):t[0]>111&&t[0]<118?s+="variation ":console.warn(`Unknown XG variation address: ${t[0]}`)}).add([76,2,64],t=>{t.subarray(1).forEach((s,n)=>{let i=n+t[0];if(i==0)console.debug(`XG EQ preset: ${["flat","jazz","pop","rock","classic"][s]}`);else{let r=i-1>>2,c=i-1&3,f=`XG EQ ${r} ${["gain","freq","Q","shape"][c]}: `;[()=>{console.debug(`${f}${s-64}dB`)},()=>{console.debug(`${f}${s} (raw)`)},()=>{console.debug(`${f}${s/10}`)},()=>{console.debug(`${f}${["shelf","peak"][+!!s]}`)}][c]()}})}).add([76,3],t=>{let s=t[0],n=t[1],i=`XG Insertion ${t[0]+1} `;t.subarray(2).forEach((r,c)=>{([f=>{e.setEffectTypeRaw(3+s,!1,f),console.info(`${i}main type: ${A[f]}`),e.dispatchEvent(`efxinsert${s}`,e.getEffectType(3+s))},f=>{e.setEffectTypeRaw(3+s,!0,f),console.debug(`${i}sub type: ${f+1}`),e.dispatchEvent(`efxinsert${s}`,e.getEffectType(3+s))}][n+c]||function(){})(r)})}).add([76,6,0],t=>{let s=t[0];s<64?e.setLetterDisplay(t.subarray(1),"XG letter display",s):e.#G=Date.now()}).add([76,7,0],t=>{let s=t[0];e.#p=0,e.#C=Date.now()+3200,e.#y.fill(0);let n=t.subarray(1);for(let i=0;i>6-$&1,$++})}).add([76,8],(t,s)=>{let n=e.chRedir(t[0],s,!0),i=t[1],r=b.cc*n,c=`XG CH${n+1} `,f=`Unknown XG part address ${i}.`;t.subarray(2).forEach((l,p)=>{i<1?console.debug(f):i<41?([()=>{e.#e[r+u[0]]=l,e.dispatchEvent("voice",{part:n})},()=>{e.#e[r+u[32]]=l,e.dispatchEvent("voice",{part:n})},()=>{e.#i[n]=l,e.dispatchEvent("voice",{part:n})},()=>{let $=e.chRedir(l,s,!0);e.#d[n]=$,n!=$&&(e.buildRchTree(),console.info(`${c}receives from CH${$+1}`))},()=>{e.#$[n]=+!l},()=>{},()=>{e.setChType(n,l,m.xg),console.debug(`${c}type: ${U[l]||l}`)},()=>{e.#a[b.rpn*n+3]=l,e.#r[b.rpnt*n+2]=1},!1,!1,()=>{e.#e[r+u[7]]=l},!1,!1,()=>{e.#e[r+u[10]]=l||128},!1,!1,()=>{e.#e[r+u[128]]=l},()=>{e.#e[r+u[93]]=l},()=>{e.#e[r+u[91]]=l},()=>{e.#e[r+u[94]]=l},()=>{e.#e[r+u[76]]=l},()=>{e.#e[r+u[77]]=l},()=>{e.#e[r+u[78]]=l},()=>{e.#e[r+u[74]]=l},()=>{e.#e[r+u[71]]=l},()=>{e.#e[r+u[73]]=l},()=>{e.#e[r+u[75]]=l},()=>{e.#e[r+u[72]]=l}][i+p-1]||(()=>{}))():i<48?console.debug(f):i<111?i>102&&i<105&&(e.#e[r+u[[5,65][i&1]]]=l):i<114?console.debug(f):i<116?console.debug(`${c}EQ ${["bass","treble"][i&1]} gain: ${l-64}dB`):i<118?console.debug(f):i<120?console.debug(`${c}EQ ${["bass","treble"][i&1]} freq: ${l}`):console.debug(f)})}).add([76,9],(t,s)=>{let n=e.chRedir(t[0],s,!0),i=t[1],r=`PLG-150VL CH${n+1} `;t.subarray(2).forEach((c,f)=>{let l=f+i;switch(l){case 1:{console.info(`${r}breath mode: ${["system","breath","velocity","touch EG"][c]}`);break}case 0:case 27:case 28:break;default:if(l<27){let p=["pressure","embouchure","tonguing","scream","breath noise","growl","throat formant","harmonic enhancer","damping","absorption","amplification","brightness"][l-3>>1];l&1?l<23?(console.debug(`${r}${p} control source: ${ee(c)}`),c&&c<96&&e.allocateAce(c)):console.debug(`${r}${p} scale break point: ${c}`):console.debug(`${r}${p} depth: ${c-64}`)}}})}).add([76,10],t=>{}).add([76,16],t=>{}).add([76,17,0,0],t=>{}).add([76,112],t=>{console.debug(`XG enable PLG-1${["50VL","00SG","50DX"][t[0]]} for CH${t[2]+1}.`)}).add([73,0,0],(t,s)=>{let n=t[0],i="MU1000 System: ";t.subarray(1).forEach((r,c)=>{let f=n+c;f==8?console.debug(`${i}LCD contrast set to ${r}.`):f==18?(e.#m=r?126:0,console.debug(`${i}bank defaults to ${r?"MU100 Native":"MU Basic"}.`)):f>=64&&f<69&&[()=>{e.dispatchEvent("channelactive",r)},()=>{r<8?(e.dispatchEvent("channelmin",r<<4),console.debug(`Octavia System: Minimum CH${(r<<4)+1}`)):(e.dispatchEvent("channelreset"),console.info("Octavia System: Clear channel ranges"))},()=>{r<8?(e.dispatchEvent("channelmax",(r<<4)+15),console.debug(`Octavia System: Maximum CH${(r<<4)+16}`)):(e.dispatchEvent("channelreset"),console.info("Octavia System: Clear channel ranges"))},()=>{e.dispatchEvent("channelreset"),console.info("Octavia System: Clear channel ranges")},()=>{e.#S=!!r,console.info(`Octavia System: RS receiving ${["dis","en"][r]}abled.`)}][f-64]()})}).add([73,10,0],(t,s)=>{let n=t[0],i=`MU1000 RS${e.#S?"":" (ignored)"}: `;if(n<16)switch(n){case 2:{let r=e.chRedir(0,s,!0);e.#S&&(e.dispatchEvent("channelmin",r),e.dispatchEvent("channelmax",r+63)),console.info(`${i}Show CH1~64`);break}case 3:{let r=e.chRedir(t[1]<<5,s,!0);e.#S&&e.dispatchEvent("channelmin",r),e.#S&&e.dispatchEvent("channelmax",r+31),console.info(`${i}Show CH${r+1}~CH${r+32}`);break}default:console.debug(`${i}unknown switch ${n} invoked.`)}else if(n<32){if(e.#S){let r=e.chRedir(n-16+(e.#j<<4),s,!0);e.dispatchEvent("channelactive",r)}}else if(n<36){let r=e.chRedir(n-32<<4,s,!0);e.#S&&(e.dispatchEvent("channelmin",r),e.dispatchEvent("channelmax",r+15),e.#j=n-32),console.info(`${i}Show CH${r+1}~CH${r+16}`)}}).add([93,3],(t,s)=>{let n=e.chRedir(t[0],s,!0),i=`PLG-100SG CH${n+1} `,r=Date.now();if(t[1]==0){let c="",f=0;t.subarray(2).forEach((l,p)=>{p%2==0?c+=Z[l]||l.toString().padStart("0"):f+=l*13}),r>=e.#Z&&this.dispatchEvent("metacommit",{type:"SGLyrics",data:"",amend:!1}),this.dispatchEvent("metacommit",{type:"SGLyrics",data:`${j(c)}`,amend:!0}),e.#Z=r+Math.ceil(f/2)+e.#J,k()&&console.debug(`${i}vocals: ${c}`)}else console.warn(`Unknown PLG-100SG data: ${t}`)});let o=function(t,s,n,i){},h=function(t,s){let n=t*b.dpn,i=s[0],r=s[1];s.subarray(2).forEach((c,f)=>{let l=f+r,p=-1;l<16?([()=>{p=24},()=>{p=25},()=>{p=26},()=>{},()=>{p=28},()=>{p=29},()=>{p=30},()=>{p=31},()=>{},()=>{},()=>{},()=>{p=20},()=>{p=21},()=>{p=22},()=>{p=23},()=>{}][l]||(()=>{console.debug(`Unknown XG-style drum param ${l} on set ${t+1}.`)}))():l<32||(l<40?([()=>{p=48},()=>{p=49},!1,!1,()=>{p=52},()=>{p=53}][l-32]||(()=>{console.debug(`Unknown XG-style drum param ${l} on set ${t+1}.`)}))():l<80||([()=>{p=36}][l-80]||(()=>{console.debug(`Unknown XG-style drum param ${l} on set ${t+1}.`)}))()),p>=0?(k()&&console.debug(n,p,i,c),e.#b[(n+C[p])*b.dnc+i]=c):k()&&console.debug(`XG-style drum param ${l} has no writes.`)})},y=function(t,s,n){let i=t*b.dpn,r=(s<<7)+n[0];n.subarray(1).forEach((c,f)=>{let l=f+r,p=l&127,$=l>>7,E=-1;$>1&&([()=>{E=26},()=>{},()=>{E=28},()=>{E=29},()=>{E=30},()=>{},()=>{},()=>{E=31}][$-2]||(()=>{console.debug(`Unknown GS-style drum param ${$} on set ${t+1}.`)}))(),E>-1?(k()&&console.debug(i,E,p,c),e.#b[(i+C[E])*b.dnc+p]=c):k()&&console.debug(`GS-style drum param ${$} has no writes.`)})};this.#k.add([76,48],(t,s,n)=>{h(0,t)}).add([76,49],(t,s,n)=>{h(1,t)}).add([76,50],(t,s,n)=>{h(2,t)}).add([76,51],(t,s,n)=>{h(3,t)}).add([76,52],(t,s,n)=>{h(4,t)}).add([76,53],(t,s,n)=>{h(5,t)}).add([76,54],(t,s,n)=>{h(6,t)}).add([76,55],(t,s,n)=>{h(7,t)}),this.#k.add([89,0],(t,s,n)=>{if(e.eprom){let i=t[0],r=(t[1]<<14)+(t[2]<<7)+t[3]+(e.eprom.offset||0);k()&&console.debug(`MU1000 EPROM trail to 0x${r.toString(16).padStart(6,"0")}, ${i} bytes.`);let c=e.eprom.data;t.subarray(4).forEach((f,l)=>{let p=l>>3,$=l&7;if($==7)for(let E=0;E<7;E++)c[r+7*p+E]+=(f>>6-E&1)<<7;else c[r+7*p+$]=f})}}).add([89,1],(t,s,n)=>{let i=(t[0]<<21)+(t[1]<<14)+(t[2]<<7)+t[3];k()&&console.debug(`MU1000 EPROM jump to 0x${i.toString(16).padStart(6,"0")}.`),e.eprom&&(e.eprom.offset=i)}).add([89,2],(t,s,n)=>{if(e.eprom){let i=(t[0]<<21)+(t[1]<<14)+(t[2]<<7)+t[3]+(e.eprom.offset||0);k()&&console.debug(`MU1000 EPROM write to 0x${i.toString(16).padStart(6,"0")}.`);let r=e.eprom.data;t.subarray(4).forEach((c,f)=>{let l=f>>3,p=f&7;if(p==7)for(let $=0;$<7;$++)r[i+7*l+$]+=(c>>6-$&1)<<7;else r[i+7*l+p]=c})}}).add([89,3],(t,s,n)=>{}),this.#k.add([39,48],(t,s,n)=>{}).add([43,0,0],(t,s,n)=>{let i=[0,0,0,0],r=(c,f)=>{i[f]=c};if(t.subarray(1).forEach((c,f)=>{let l=f+t[0];[r,r,r,r,()=>{this.#n=c*129/16383*100,e.dispatchEvent("mastervolume",e.#n)},()=>c-64,()=>c||128,()=>c,()=>c,()=>{console.debug(`TG300 variation on cc${c}.`)}][l](c,l)}),t[0]<4){let c=0;i.forEach(f=>{c=c<<4,c+=f}),c-=1024}}).add([43,1,0],(t,s,n)=>{}).add([43,2],(t,s,n)=>{let i=e.chRedir(t[0],s,!0),r=t[1],c=b.cc*i,f=`TG300 CH${i+1} `;t.subarray(2).forEach((l,p)=>{p<5?([()=>{},()=>{e.#e[c+u[0]]=l,e.dispatchEvent("voice",{part:i})},()=>{e.#e[c+u[32]]=l,e.dispatchEvent("voice",{part:i})},()=>{e.#i[i]=l,e.dispatchEvent("voice",{part:i})},()=>{let $=e.chRedir(l,s,!0);e.#d[i]=$,i!=$&&(e.buildRchTree(),console.info(`${f}receives from CH${$+1}`))}][p+r]||(()=>{}))(l,p+r):p<21||(p<47?([()=>{e.#$[i]=+!l},()=>{},()=>{},()=>{e.#a[b.rpn*i+3]=l,e.#r[b.rpnt*i+2]=1},()=>{},()=>{e.#e[c+u[7]]=l},!1,!1,()=>{e.#e[c+u[10]]=l||128},!1,!1,()=>{console.debug(`${f} AC1 at cc${l}`)},()=>{console.debug(`${f} AC2 at cc${l}`)},()=>{e.#e[c+u[128]]=l},()=>{e.#e[c+u[93]]=l},()=>{e.#e[c+u[91]]=l},()=>{e.#e[c+u[94]]=l},()=>{e.#e[c+u[76]]=l},()=>{e.#e[c+u[77]]=l},()=>{e.#e[c+u[74]]=l},()=>{e.#e[c+u[71]]=l},()=>{e.#e[c+u[73]]=l},()=>{e.#e[c+u[75]]=l},()=>{e.#e[c+u[72]]=l},()=>{e.#e[c+u[78]]=l}][p+r-21]||(()=>{}))(l,p+r):p<95||([()=>{e.#e[c+u[65]]=l},()=>{e.#e[c+u[5]]=l}][p+r-95]||(()=>{}))(l,p+r))})}).add([43,7,0],(t,s,n)=>{let i=t[0];e.setLetterDisplay(t.subarray(1),"TG300 letter display",i)}).add([43,7,1],(t,s,n)=>{e.#p=0,e.#C=Date.now()+3200,e.#y.fill(0),t.forEach(function(i,r){let c=Math.floor(r/16),f=r%16,l=(f*3+c)*7,p=7,$=0;for(l-=f*5,c==2&&(p=2);$>6-$&1,$++})}),this.#w.add([66,18,0,0,127],(t,s,n)=>{e.switchMode("gs",!0),e.#e[b.cc*9]=120,e.#e[b.cc*25]=120,e.#e[b.cc*41]=120,e.#e[b.cc*57]=120,e.#m=3,e.#c=!1,e.#O.fill(0),console.info(`GS system to ${["single","dual"][t[0]]} mode.`)}).add([66,18,64,0],(t,s,n)=>{switch(t[0]){case 127:{e.switchMode("gs",!0),e.#e[b.cc*9]=120,e.#e[b.cc*25]=120,e.#e[b.cc*41]=120,e.#e[b.cc*57]=120,e.#c=!1,e.#O.fill(0),console.info("MIDI reset: GS");break}default:{let i=[0,0,0,0],r=(c,f)=>{i[f]=c};if(t.subarray(1).forEach((c,f)=>{let l=f+t[0];[r,r,r,r,p=>{this.#n=p*129/16383*100,e.dispatchEvent("mastervolume",e.#n)},p=>{},p=>{}][l](c,f)}),t[0]<4){let c=0;i.forEach(f=>{c=c<<4,c+=f}),c-=1024}}}}).add([66,18,64,1],t=>{let s=t[0];if(s<16){let n="".padStart(s," ");t.subarray(1).forEach((i,r)=>{n+=String.fromCharCode(Math.max(32,i))}),n=n.padEnd(16," "),console.debug(`GS patch name: ${n}`)}else s<48||(s<65?t.subarray(1).forEach((n,i)=>{let r=`GS ${s+i>55?"chorus":"reverb"} `;([()=>{console.info(`${r}type: ${I[n]}`),e.setEffectType(0,40,n),e.dispatchEvent("efxreverb",e.getEffectType(0))},()=>{},()=>{},()=>{},()=>{},()=>{},!1,()=>{console.debug(`${r}predelay: ${n}ms`)},()=>{console.info(`${r}type: ${te[n]}`),e.setEffectType(1,40,16+n),e.dispatchEvent("efxchorus",e.getEffectType(1))},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{console.debug(`${r}to reverb: ${S(n)}`)},()=>{console.debug(`${r}to delay: ${S(n)}`)}][s+i-48]||(()=>{}))()}):s<80?console.debug(`Unknown GS patch address: ${s}`):s<91?t.subarray(1).forEach((n,i)=>{let r="GS delay ";([()=>{console.info(`${r}type: ${ae[n]}`),e.setEffectType(2,40,32+n),e.dispatchEvent("efxdelay",e.getEffectType(2))},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{console.debug(`${r}to reverb: ${S(n)}`)}][s+i-80]||(()=>{}))()}):console.debug(`Unknown GS patch address: ${s}`))}).add([66,18,64,2],t=>{let s="GS EQ ";t.subarray(1).forEach((n,i)=>{([()=>{console.debug(`${s}low freq: ${[200,400][n]}Hz`)},()=>{console.debug(`${s}low gain: ${n-64}dB`)},()=>{console.debug(`${s}high freq: ${[3e3,6e3][n]}Hz`)},()=>{console.debug(`${s}high gain: ${n-64}dB`)}][t[0]+i]||function(){console.warn(`Unknown GS EQ address: ${t[0]+i}`)})()})}).add([66,18,64,3],t=>{let s="GS EFX ",n=function(i,r){let c=se(e.#g.subarray(10,12),r,i);c&&console.debug(`${s}${X(e.#g.subarray(10,12))} ${c}`)};t.subarray(1).forEach((i,r)=>{([()=>{e.setEffectTypeRaw(3,!1,32+i),e.dispatchEvent("efxinsert0",e.getEffectType(3))},()=>{e.setEffectTypeRaw(3,!0,i),console.info(`${s}type: ${X(e.#g.subarray(10,12))}`),e.dispatchEvent("efxinsert0",e.getEffectType(3))},!1,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,()=>{console.debug(`${s}to reverb: ${S(i)}dB`)},()=>{console.debug(`${s}to chorus: ${S(i)}dB`)},()=>{console.debug(`${s}to delay: ${S(i)}dB`)},!1,()=>{console.debug(`${s}1 source: ${i}`),i&&i<96&&e.allocateAce(i)},()=>{console.debug(`${s}1 depth: ${i-64}`)},()=>{console.debug(`${s}2 source: ${i}`),i&&i<96&&e.allocateAce(i)},()=>{console.debug(`${s}2 depth: ${i-64}`)},()=>{console.debug(`${s}to EQ: ${i?"ON":"OFF"}`)}][t[0]+r]||function(c,f){console.warn(`Unknown GS EFX address: ${f}`)})(i,t[0]+r)})}).add([66,18,65],t=>{y((t[0]>>4)+1<<1,t[0]&15,t.subarray(1))}).add([69,18,16],t=>{switch(t[0]){case 0:{let s=t[1];e.setLetterDisplay(t.subarray(2),"GS display text",s);break}case 32:{e.#C=Date.now()+3200,t[1]==0&&(e.#p=Math.max(Math.min(t[2]-1,9),0),k()&&console.debug(`GS switch display page ${t[2]-1}.`));break}default:if(t[0]<6){e.#p>9&&(e.#p=0);let s=t[0]-1<<1|t[1]>>6;e.#p==s&&(e.#C=Date.now()+3200),e.#M[s]?.length||(e.#M[s]=new Uint8Array(256));let n=e.#M[s];k()&&console.debug(`GS frame draw page ${s}.`);let i=t[1]&63;n.fill(0),t.subarray(2).forEach(function(c,f){let l=f+i,p=Math.floor(l/16),$=l%16,E=($*4+p)*5,w=5,v=0;for(E-=$*4,p==3&&(w=1);v>4-v&1,v++})}else console.warn(`Unknown GS display section: ${t[0]}`)}});let g=function(t,s,n){let i=t[0],r=b.cc*s,c=b.rpn*s,f=`GS CH${s+1} `;i<3?(t.subarray(1).forEach((l,p)=>{[()=>{e.#e[r+u[0]]=l},()=>{e.#i[s]=l},()=>{let $=0;l<16?$=e.chRedir(l,n,!0):$=b.ch,e.#d[s]=$,s!=$&&(e.buildRchTree(),console.info(`${f}receives from CH${$+1}`))}][i+p]()}),e.dispatchEvent("voice",{part:s})):i<19||(i<44?t.subarray(1).forEach((l,p)=>{([()=>{e.#$[s]=+!l},!1,()=>{e.setChType(s,l<<1,m.gs),console.debug(`${f}type: ${l?"drum ":"melodic"}${l||""}`)},()=>{e.#a[c+3]=l,e.#r[b.rpnt*s+2]=1},!1,()=>{e.#e[r+u[7]]=l},!1,!1,()=>{e.#e[r+u[10]]=l||128},!1,!1,()=>{console.debug(`${f}CC 1: cc${l}`)},()=>{console.debug(`${f}CC 2: cc${l}`)},()=>{e.#e[r+u[93]]=l},()=>{e.#e[r+u[91]]=l},!1,!1,()=>{e.#a[c+1]=l,e.#r[b.rpnt*s+1]=1},()=>{e.#a[c+2]=l,e.#r[b.rpnt*s+1]=1},()=>{e.#e[r+u[94]]=l}][i+p-19]||(()=>{}))()}):i<76||console.debug(`Unknown GS part address: ${i}`))},d=function(t,s){let n=t[0],i=`GS CH${s+1} `;n<2?t.subarray(1).forEach((r,c)=>{[()=>{e.#e[b.cc*s+u[32]]=r},()=>{}][n+c]()}):n<32?console.warn(`Unknown GS misc address: ${n}`):n<35?t.subarray(1).forEach((r,c)=>{[()=>{console.debug(`${i}EQ: o${["ff","n"][r]}`)},()=>{},()=>{console.debug(`${i}EFX: o${["ff","n"][r]}`),e.#W[s]=r,e.dispatchEvent("partefxtoggle",{part:s,active:r})}][n+c-32]()}):console.warn(`Unknown GS misc address: ${n}`)};this.#w.add([66,18,64,16],(t,s)=>{g(t,e.chRedir(9,s,!0),s)}).add([66,18,64,17],(t,s)=>{g(t,e.chRedir(0,s,!0),s)}).add([66,18,64,18],(t,s)=>{g(t,e.chRedir(1,s,!0),s)}).add([66,18,64,19],(t,s)=>{g(t,e.chRedir(2,s,!0),s)}).add([66,18,64,20],(t,s)=>{g(t,e.chRedir(3,s,!0),s)}).add([66,18,64,21],(t,s)=>{g(t,e.chRedir(4,s,!0),s)}).add([66,18,64,22],(t,s)=>{g(t,e.chRedir(5,s,!0),s)}).add([66,18,64,23],(t,s)=>{g(t,e.chRedir(6,s,!0),s)}).add([66,18,64,24],(t,s)=>{g(t,e.chRedir(7,s,!0),s)}).add([66,18,64,25],(t,s)=>{g(t,e.chRedir(8,s,!0),s)}).add([66,18,64,26],(t,s)=>{g(t,e.chRedir(10,s,!0),s)}).add([66,18,64,27],(t,s)=>{g(t,e.chRedir(11,s,!0),s)}).add([66,18,64,28],(t,s)=>{g(t,e.chRedir(12,s,!0),s)}).add([66,18,64,29],(t,s)=>{g(t,e.chRedir(13,s,!0),s)}).add([66,18,64,30],(t,s)=>{g(t,e.chRedir(14,s,!0),s)}).add([66,18,64,31],(t,s)=>{g(t,e.chRedir(15,s,!0),s)}).add([66,18,64,64],(t,s)=>{d(t,e.chRedir(9,s,!0))}).add([66,18,64,65],(t,s)=>{d(t,e.chRedir(0,s,!0))}).add([66,18,64,66],(t,s)=>{d(t,e.chRedir(1,s,!0))}).add([66,18,64,67],(t,s)=>{d(t,e.chRedir(2,s,!0))}).add([66,18,64,68],(t,s)=>{d(t,e.chRedir(3,s,!0))}).add([66,18,64,69],(t,s)=>{d(t,e.chRedir(4,s,!0))}).add([66,18,64,70],(t,s)=>{d(t,e.chRedir(5,s,!0))}).add([66,18,64,71],(t,s)=>{d(t,e.chRedir(6,s,!0))}).add([66,18,64,72],(t,s)=>{d(t,e.chRedir(7,s,!0))}).add([66,18,64,73],(t,s)=>{d(t,e.chRedir(8,s,!0))}).add([66,18,64,74],(t,s)=>{d(t,e.chRedir(10,s,!0))}).add([66,18,64,75],(t,s)=>{d(t,e.chRedir(11,s,!0))}).add([66,18,64,76],(t,s)=>{d(t,e.chRedir(12,s,!0))}).add([66,18,64,77],(t,s)=>{d(t,e.chRedir(13,s,!0))}).add([66,18,64,78],(t,s)=>{d(t,e.chRedir(14,s,!0))}).add([66,18,64,79],(t,s)=>{d(t,e.chRedir(15,s,!0))}),this.#A.add([54,65],(t,s)=>{e.switchMode("x5d");let n=(t[1]<<7)+t[0],i=(t[3]<<7)+t[2],r=e.chRedir(n&15,s,!0),c=b.cc*r;[()=>{i<1||(i<101?(e.setChType(r,e.CH_MELODIC,m.x5d),e.#i[r]=i-1,e.#e[c+u[0]]=82):i<229?(e.setChType(r,e.CH_MELODIC,m.x5d),e.#i[r]=i-101,e.#e[c+u[0]]=56):(e.setChType(r,e.CH_DRUMS,m.x5d),e.#i[r]=de[i-229]||0,e.#e[c+u[0]]=62)),e.dispatchEvent("voice",{part:r})},()=>{e.#e[c+u[7]]=i},()=>{i<31&&(e.#e[c+u[10]]=Math.round((i-15)*4.2+64))},()=>{e.#e[c+u[93]]=P(i)},()=>{e.#e[c+u[91]]=P(i)},()=>{e.#a[r*b.rpn+3]=i>8191?i-16320:64+i,e.#r[b.rpnt*r+2]=1},()=>{e.#a[r*b.rpn+1]=i>8191?i-16320:64+i,e.#r[b.rpnt*r+1]=1},()=>{i>0&&(e.#a[r*b.rpn]=i,e.#r[b.rpnt*r]=1)},()=>{}][n>>4]()}).add([54,76,0],(t,s)=>{e.switchMode("x5d",!0);let n="",i=82,r=0,c=0,f="MSB PRG LSB NME";T(t,function(l,p){if(p<16400){let $=p%164;switch(!0){case $<10:{l>31&&(n+=String.fromCharCode(l));break}case $==11:{f+=` -${i} ${r} ${c} ${n.trim().replace("Init Voice","")}`,r++,n="";break}}r>99&&(i=90,r=0)}}),e.userBank.clearRange({msb:82,prg:[0,99],lsb:0}),e.userBank.load(f),k()&&console.debug(f),e.forceVoiceRefresh()}).add([54,77,0],(t,s)=>{e.switchMode("x5d",!0);let n="",i=90,r=0,c=0,f="MSB PRG LSB NME";T(t,function(l,p){if(p<13600){let $=p%136;switch(!0){case $<10:{l>31&&(n+=String.fromCharCode(l));break}case $==11:{f+=` -${i} ${r} ${c} ${n.trim().replace("Init Combi","")}`,r++,n="";break}}}}),e.userBank.clearRange({msb:90,prg:[0,99],lsb:0}),e.userBank.load(f),k()&&console.debug(f),e.forceVoiceRefresh()}).add([54,78],(t,s)=>{e.switchMode("x5d",!0),console.debug(`X5D mode switch requested: ${["combi","combi edit","prog","prog edit","multi","global"][t[0]]} mode.`)}).add([54,85],(t,s)=>{e.switchMode("x5d",!0),T(t,(n,i)=>{i>0&&i<3&&(e.setEffectType(i-1,44,n),e.dispatchEvent(`efx${["reverb","chorus"][i-1]}`,e.getEffectType(i-1)))})}).add([54,104],(t,s)=>{e.switchMode("x5d",!0),T(t,function(n,i,r,c){if(i<192){let f=e.chRedir(Math.floor(i/12),s,!0),l=f*b.cc;switch(i%12){case 0:{n<128?(e.setChType(f,e.CH_MELODIC,m.x5d),e.#e[l+u[0]]=82,e.#i[f]=n):(e.setChType(f,e.CH_DRUMS,m.x5d),e.#e[l+u[0]]=62,e.#i[f]=de[n-128]),n>0&&e.setChActive(f,1),e.dispatchEvent("voice",{part:f});break}case 1:{e.#e[l+u[7]]=n;break}case 2:{e.#a[f*b.rpn+3]=n>127?n-192:64+n,e.#r[b.rpnt*f+2]=1;break}case 3:{e.#a[f*b.rpn+1]=n>127?n-192:64+n,e.#r[b.rpnt*f+1]=1;break}case 4:{n<31&&(e.#e[l+u[10]]=Math.round((n-15)*4.2+64));break}case 5:{let p=n>>4,$=n&15;e.#e[l+u[91]]=P($),e.#e[l+u[93]]=P(p);break}case 10:break;case 11:{let p=e.chRedir(n&15,s,!0),$=n>>4;e.#d[f]=n,(p!=f||$)&&(console.info(`X5D Part CH${f+1} receives from CH${p+1}.`),e.buildRchTree())}}}else{let f=e.chRedir(i-192,s,!0)}})}),this.#w.add([22,18,127],t=>{e.switchMode("mt32",!0),e.#c=!1,e.userBank.clearRange({msb:0,lsb:127,prg:[0,127]}),console.info("MIDI reset: MT-32")}).add([22,18,0],(t,s,n)=>{e.switchMode("mt32");let i=e.chRedir(n,s,!0),r=t[1];t.subarray(2).forEach((c,f)=>{let l=f+r;e.#P[l+(i-1)*16]=c,([!1,()=>{let p=e.#P[i-1<<4];if(p<3){if(e.#T[i]=1,p==2)for(let $=0;${e.#a[i*b.rpn+3]=c+40,e.#r[b.rpnt*i+2]=1},()=>{e.#a[i*b.rpn+1]=c+14,e.#r[b.rpnt*i+1]=1},()=>{e.#a[i*b.rpn]=c,e.#r[b.rpnt*i]=1},!1,()=>{e.#e[b.cc*i+u[91]]=c?127:0},!1,()=>{e.#e[b.cc*i+u[7]]=c},()=>{e.#e[b.cc*i+u[10]]=Math.ceil(c*9.05)}][l]||(()=>{}))()})}).add([22,18,1],(t,s,n)=>{e.switchMode("mt32");let i=n&7;console.debug(`MT-32 slot #${n+1} Drum: ${t}`);let r=t[0]<<7|t[1];t.subarray(2).forEach((c,f)=>{let l=f+r,p=(l>>2)+24,$=l&3,E=i*b.dpn;if(k()&&console.debug(`MT-32 temp drum note ${p} param ${$}: ${c}`),p<24){console.warn(`MT-32 dev drum write attempted on an OOB note: ${p}`);return}[()=>{},()=>{e.#b[(E+C[26])*b.dnc+p]=Math.round(c*1.27)},()=>{e.#b[(E+C[26])*b.dnc+p]=c*9+1&127},()=>{e.#b[(E+C[26])*b.dnc+p]=c?127:0}][$]()})}).add([22,18,2],(t,s,n)=>{e.switchMode("mt32");let i=e.chRedir(n,s,!0),r=t[1]+(t[0]<<7);r<10&&(e.#T[i]=1),t.subarray(2).forEach((c,f)=>{let l=f+r;l<14&&(e.#v[(i-1)*b.cmt+l]=c)}),e.dispatchEvent("voice",{part:i})}).add([22,18,3],(t,s,n)=>{e.switchMode("mt32");let i=n&7;if(t[0]){let r=(t[0]-1<<7)+t[1]-16;t.subarray(2).forEach((c,f)=>{let l=f+r,p=(l>>2)+24,$=l&3,E=i*b.dpn;if(k()&&console.debug(`MT-32 dev drum note ${p} param ${$}: ${c}`),p<24){console.warn(`MT-32 dev drum write attempted on an OOB note: ${p}`);return}[()=>{},()=>{e.#b[(E+C[26])*b.dnc+p]=Math.round(c*1.27)},()=>{e.#b[(E+C[26])*b.dnc+p]=c*9+1&127},()=>{e.#b[(E+C[26])*b.dnc+p]=c?127:0}][$]()})}else{let r=t[1];t.subarray(2).forEach((c,f)=>{let l=f+r;e.#P[l]=c;let p=e.chRedir(1+(l>>4),s,!0),$=l&15;([!1,()=>{let E=e.#P[p-1<<4];if(E<3)if(e.#T[p]=1,E==2)for(let w=0;w{e.#a[p*b.rpn+3]=c+40,e.#r[b.rpnt*p+2]=1},()=>{e.#a[p*b.rpn+1]=c+14,e.#r[b.rpnt*p+1]=1},()=>{e.#a[p*b.rpn]=c,e.#r[b.rpnt*p]=1},!1,()=>{e.#e[b.cc*p+u[91]]=c?127:0},!1,()=>{e.#e[b.cc*p+u[7]]=c},()=>{e.#e[b.cc*p+u[10]]=Math.ceil(c*9.05)}][$]||(()=>{}))()})}}).add([22,18,4],(t,s,n)=>{e.switchMode("mt32");let i=t[1]+(t[0]<<7),r=[];t.subarray(2).forEach((c,f)=>{let l=f+i,p=e.chRedir(Math.floor(l/246+1),s,!0),$=l%246;$<14&&(e.#v[(p-1)*b.cmt+$]=c),$<10&&(e.#T[p]=1),r.indexOf(p)<0&&r.push(p)}),r.forEach(c=>{e.dispatchEvent("voice",{part:c})})}).add([22,18,5],(t,s,n)=>{e.switchMode("mt32");let i=(t[0]<<7)+t[1];t.subarray(2).forEach((r,c)=>{let f=i+c,l=Math.floor(f/8),p=f&7,$=l*8;e.#Y[f]=r,([!1,()=>{let E=e.#Y[$];if(E<3){let w="";if(E==2){let v=b.cmt*l;w=`MT-m:${r.toString().padStart(3,"0")}`}else w=e.baseBank.get(0,r+(E<<6),127,"mt32").name;e.userBank.clearRange({msb:0,lsb:127,prg:l}),e.userBank.load(`MSB LSB PRG NME -000 127 ${l} ${w}`,!0)}}][p]||(()=>{}))()}),e.forceVoiceRefresh()}).add([22,18,8],(t,s,n)=>{e.switchMode("mt32");let i=((t[0]&1)<<7)+t[1];t.subarray(2).forEach((r,c)=>{let f=i+c;f>1)*b.cmt+f]=r)}),e.forceVoiceRefresh()}).add([22,18,16],(t,s,n)=>{e.switchMode("mt32");let i=t[1],r=!1,c=function(f,l){e.#d[l-12]=f,r=!0};t.subarray(2).forEach((f,l)=>{let p=l+i;([!1,!1,!1,!1,!1,!1,!1,!1,!1,!1,!1,!1,!1,c,c,c,c,c,c,c,c,c,()=>{e.#n=f,e.dispatchEvent("mastervolume",e.#n)}][p]||(()=>{}))(f,l)}),r&&e.buildRchTree()}).add([22,18,32],t=>{e.switchMode("mt32");let s=t[1],n=" ".repeat(s);t.subarray(2).forEach(i=>{i>31?n+=String.fromCharCode(i):n+=" "}),e.#L=n.padStart(20," "),e.#G=Date.now()+3200}).add([22,18,82],(t,s)=>{let n=e.chRedir(0,s,!0);for(let i=0;i<16;i++)e.#f.ano(n+i),i&&i<10&&(e.#i[n+i]=V[i-1]);console.info("MT-32 alt reset complete.")}),this.#A.add([66,0],(t,s)=>{e.switchMode("ns5r",!0),e.#c=!1,console.debug(`NS5R mode switch requested: ${["global","multi","prog edit","comb edit","drum edit","effect edit"][t[0]]} mode.`)}).add([66,1],(t,s)=>{e.switchMode(["ns5r","05rw"][t[0]],!0),e.#c=!1}).add([66,18,0,0],(t,s)=>{let n=t[0];switch(n){case 124:case 126:case 127:{e.switchMode("ns5r",!0),e.#c=!1;break}case 125:{e.initDrums(),console.info(`NS5R drum setup reset: ${t}`);break}default:if(n<10){let i=[0,0,0,0],r=(c,f)=>{i[f]=c};if(t.subarray(1).forEach((c,f)=>{[r,r,r,r,()=>{e.#n=c*129/16383*100,e.dispatchEvent("mastervolume",e.#n)},()=>c-64,()=>c-64,()=>{},()=>{},()=>{}][n+f]()}),t[0]<4){let c=0;i.forEach(f=>{c=c<<4,c+=f}),c-=1024}}}}).add([66,18,0,1],(t,s)=>{}).add([66,18,0,2],(t,s)=>{}).add([66,18,1],(t,s)=>{let n=e.chRedir(t[0],s,!0),i=n*b.cc,r=t[1],c=`NS5R CH${n+1} `;t.subarray(2).forEach((f,l)=>{let p=r+l;p<3?([()=>{e.#e[i+u[0]]=f||121},()=>{e.#e[i+u[32]]=f},()=>{e.#i[n]=f}][p](),e.dispatchEvent("voice",{part:n})):p<8||(p<14?[()=>{let $=e.chRedir(f,s,!0);e.#d[n]=$,n!=$&&(e.buildRchTree(),console.info(`${c}receives from CH${$+1}`))},()=>{e.#$[n]=+!f},()=>{e.setChType(n,f,m.ns5r),console.debug(`${c}type: ${U[f]}`)},()=>{e.#a[b.rpn*n+3]=f,e.#r[b.rpnt*n+2]=1},()=>{},()=>{}][p-8]():p<16||(p<33?[()=>{e.#e[i+u[7]]=f},()=>{e.#e[i+u[11]]=f},()=>{},()=>{},()=>{e.#e[i+u[10]]=f||128},()=>{},()=>{},()=>{e.#e[i+u[93]]=f},()=>{e.#e[i+u[91]]=f},()=>{e.#e[i+u[76]]=f},()=>{e.#e[i+u[77]]=f},()=>{e.#e[i+u[78]]=f},()=>{e.#e[i+u[74]]=f},()=>{e.#e[i+u[71]]=f},()=>{e.#e[i+u[73]]=f},()=>{e.#e[i+u[75]]=f},()=>{e.#e[i+u[72]]=f}][p-16]():p<112||p<114&&[()=>{e.#e[i+u[5]]=f},()=>{e.#e[i+u[65]]=f}][p-112]()))})}).add([66,18,8,0],(t,s)=>{let n=t[0];if(n<32)e.setLetterDisplay(t.subarray(1,33),"NS5R letter display");else{let i=n-32;e.#C=Date.now()+3200,e.#p=10,e.#y.fill(0);let r=t.subarray(1),c=4;r.forEach(function(f,l){let p=l+i,$=p>>4,E=p&15;if(p<80){let w=$>3,v=0,he=$0;)e.#y[E*32+$*7+(he-v)]=w&1,w=w>>1,v++}})}}).add([66,18,48],(t,s,n)=>{h(0,t)}).add([66,18,49],(t,s,n)=>{h(1,t)}).add([66,18,50],(t,s,n)=>{h(2,t)}).add([66,18,51],(t,s,n)=>{h(3,t)}).add([66,18,52],(t,s,n)=>{h(4,t)}).add([66,18,53],(t,s,n)=>{h(5,t)}).add([66,18,54],(t,s,n)=>{h(6,t)}).add([66,18,55],(t,s,n)=>{h(7,t)}).add([66,52],(t,s)=>{e.switchMode("ns5r",!0),e.#c=!1;let n="";T(t,(i,r)=>{r<8?(i>31&&(n+=String.fromCharCode(i)),r==7&&(e.aiEfxName=n)):r<10&&(e.setEffectType(r-8,44,i),e.dispatchEvent(`efx${["reverb","chorus"][r-8]}`,e.getEffectType(r-8)))})}).add([66,53],(t,s)=>{e.switchMode("ns5r",!0),e.#c=!1,T(t,function(n,i){switch(!0){case i<2944:{let r=e.chRedir(Math.floor(i/92),s,!0),c=r*b.cc;switch(i%92){case 0:{e.#e[c+u[0]]=n||121,e.dispatchEvent("voice",{part:r});break}case 1:{e.#e[c+u[32]]=n,e.dispatchEvent("voice",{part:r});break}case 2:{e.#i[r]=n,n>0&&e.setChActive(r,1),e.dispatchEvent("voice",{part:r});break}case 3:{let f=e.chRedir(n,s,!0);e.#d[r]=f,r!=f&&(console.info(`NS5R CH${r+1} receives from CH${f+1}.`),e.buildRchTree())}case 7:break;case 8:{e.#a[r*b.rpn+3]=n<40||n>88?n+(n>63?-192:64):n,e.#r[b.rpnt*r+2]=1;break}case 9:case 10:{e.#e[c+u[7]]=n;break}case 11:{e.#e[c+u[11]]=n;break}case 14:{e.#e[c+u[10]]=n||128;break}case 19:{e.#e[c+u[93]]=n;break}case 20:{e.#e[c+u[91]]=n;break}case 84:{e.#e[c+u[65]]=n;break}case 85:{e.#e[c+u[5]]=n;break}}break}case i<3096:break;case i<3134:break;case i<8566:break}})}).add([66,54],(t,s)=>{e.switchMode("ns5r",!0);let n="",i=80,r=0,c=0,f="MSB PRG LSB NME";T(t,function(l,p){let $=p%158;switch(!0){case $<10:{l>31&&(n+=String.fromCharCode(l));break}case $==11:{i=l&127;break}case $==12:{c=l&127;break}case $==13:{f+=` -${i} ${r} ${c} ${n.trim().replace("Init Voice","")}`,r++,n="";break}}}),e.userBank.clearRange({msb:80,lsb:0}),e.userBank.load(f),k()&&console.debug(f),e.forceVoiceRefresh()}).add([66,55],(t,s)=>{e.switchMode("ns5r",!0);let n="",i=88,r=0,c=0,f="MSB PRG LSB NME";T(t,function(l,p){let $=p%126;switch(!0){case $<10:{l>31&&(n+=String.fromCharCode(l));break}case $==11:break;case $==12:break;case $==13:{f+=` -${i} ${r} ${c} ${n.trim().replace("Init Combi","")}`,r++,n="";break}}}),e.userBank.clearRange({msb:88,lsb:0}),e.userBank.load(f),k()&&console.debug(f),e.forceVoiceRefresh()}).add([66,125],t=>{e.dispatchEvent("backlight",["green","orange","red",!1,"yellow","blue","purple"][t[0]]||"white")}).add([66,127],t=>{let s=new Uint8Array(5760);T(t,(n,i,r)=>{if(i<720)for(let c=0;c<8;c++)s[i*8+c]=n>>7-c&1}),e.dispatchEvent("screen",{type:"ns5r",data:s})}).add([76],(t,s,n)=>{e.#A.run([66,...t],s,n)}),this.#K.add([16,0,8,0],(t,s,n)=>{let i=(t[2]<<4)+t[3],r="K11 ";([()=>{e.switchMode("k11",!0),e.#c=!1,e.#m=i?4:0,console.info("MIDI reset: GMega/K11")},()=>{e.setEffectType(0,24,i),console.debug(`${r}reverb type: ${i}`),e.dispatchEvent("efxreverb",e.getEffectType(0))},()=>{console.debug(`${r}reverb time: ${i}`)},()=>{console.debug(`${r}reverb time: ${i}`)},()=>{console.debug(`${r}reverb predelay: ${i}`)},()=>{console.debug(`${r}reverb predelay: ${i}`)},()=>{console.debug(`${r}depth high: ${i}`)},()=>{console.debug(`${r}depth high: ${i}`)},()=>{console.debug(`${r}depth low: ${i}`)},()=>{console.debug(`${r}depth low: ${i}`)}][t[0]]||(()=>{}))()}).add([16,0,8,1],(t,s,n)=>{let i=e.chRedir(t[1],s,!0),r=b.cc*i,c=b.rpn*i,f=(t[3]<<4)+t[4],l=`K11 CH${i+1} `;([()=>{f<128?(e.setChType(i,e.CH_MELODIC,m.k11),e.#e[r+u[0]]=0,e.#i[i]=f):(e.setChType(i,e.CH_DRUMS,m.k11),e.#i[i]=f-128),e.dispatchEvent("voice",{part:i})},()=>{let p=e.chRedir(f,s,!0);e.#d[i]=p,i!=p&&(e.buildRchTree(),console.info(`${l}receives from CH${p+1}`))},()=>{e.#e[r+u[7]]=f},()=>{uupThis.setChActive(i,f)},()=>{e.#e[r+u[10]]=f},()=>{e.#a[c+3]=f+40,e.#r[b.rpnt*i+2]=1},()=>{e.#a[c+1]=f>>1,e.#a[c+2]=f&1,e.#r[b.rpnt*i+1]=1},()=>{e.#e[r+u[91]]=f?127:0},()=>{},()=>{e.#e[r+u[74]]=f},()=>{e.#e[r+u[73]]=f},()=>{e.#e[r+u[72]]=f}][t[0]]||(()=>{}))()}).add([16,0,9,0],(t,s,n)=>{let i=(t[2]<<4)+t[3],r="GMLX ";([()=>{console.debug(`${r}reverb type: ${i}`)},()=>{console.debug(`${r}reverb time: ${i}`)},()=>{console.debug(`${r}reverb predelay: ${i}`)},()=>{console.debug(`${r}depth high: ${i}`)},()=>{console.debug(`${r}depth low: ${i}`)}][t[0]]||(()=>{}))()}).add([16,0,9,3],(t,s,n)=>{let i=(t[2]<<4)+t[3],r=e.chRedir(t[1],s,!0),c=r*b.cc;[()=>{i<128?(e.setChType(r,e.CH_MELODIC,m.k11),e.#e[c+u[0]]=0,e.#e[c+u[32]]=0,e.#i[r]=i):i<160?(e.setChType(r,e.CH_MELODIC,m.k11),e.#e[c+u[0]]=0,e.#e[c+u[32]]=7,e.#i[r]=i-100):(e.setChType(r,e.CH_DRUMS,m.k11),e.#e[c+u[0]]=122,e.#e[c+u[32]]=0,e.#i[r]=i-160),e.dispatchEvent("voice",{part:r})},()=>{let f=e.chRedir(i,s,!0);e.#d[r]=f,r!=f&&(e.buildRchTree(),console.info(`GMLX CH${r+1} receives from CH${f+1}`))}][t[0]]()}).add([16,0,9,4],(t,s,n)=>{let i=(t[2]<<4)+t[3],r=e.chRedir(t[1],s,!0),c=r*b.cc,f=r*b.rpn,l=`GMLX CH${r+1} `;[()=>{e.setChActive(r,i)},()=>{e.#e[c+u[7]]=i},()=>{e.#e[c+u[10]]=i},()=>{e.#e[c+u[91]]=i?127:0},()=>{e.#a[f+3]=i+40,e.#r[b.rpnt*r+2]=1},()=>{e.#a[f+1]=i,e.#r[b.rpnt*r+1]=1},()=>{e.#a[f]=i,e.#r[b.rpnt*r]=1},()=>{}][t[0]]()}),this.#z.add([66,93,64],(t,s,n)=>{let i=t[2];switch(t[0]){case 0:{switch(t[1]){case 4:{e.#n=i*129/16383*100,e.dispatchEvent("mastervolume",e.#n);break}case 5:{i-64;break}case 6:{console.debug(`SG global reverb: ${i?"on":"off"}`);break}case 127:{e.switchMode("sg",!0);break}}break}case 1:{switch(t[1]){case 48:{console.debug(`SG reverb type: ${I[i]}`);break}}break}default:if(t[0]>>4==1){let r=e.chRedir(t[0]&15,s,!0);if(t[1]==2){let c=e.chRedir(i,s,!0);e.#d[r]=c,r!=c&&(e.buildRchTree(),console.info(`SG CH${r+1} receives from CH${c+1}`))}else t[1]==19&&(e.#e[b.cc*r+u[7]]=i)}else console.warn(`Unknown AKAI SG SysEx: ${t}`)}}),this.#q.add([9],(t,s,n)=>{console.debug(`GZ set effect: ${["stage reverb","hall reverb","room reverb","chorus","tremelo","phaser","rotary speaker","enhancer","flanger","EQ"][t[0]]||"off"}`)}),this.#k.add([127,0],(t,s,n)=>{e.switchMode("motif");let i=new Uint8Array([127,1,...t]);e.#k.run(i,s,n)}).add([127,1,0,0],(t,s,n)=>{e.switchMode("s90es");let i="S90/Motif ES system ",r=t[0];t.subarray(1).forEach((c,f)=>{([()=>{e.#n=c*12900/16383,e.dispatchEvent("mastervolume",e.#n)}][r+f]||(()=>{console.info(`Unrecognized ${i}ID: ${r+f}`)}))()})}).add([127,1,0,0,14],(t,s,n)=>{e.switchMode("s90es");let i="S90/Motif ES bulk header ",r=[];r[95]=(c,f,l)=>{console.debug(`${i}multi edit buffer: ${c[1]}`)},(r[t[0]]||(()=>{console.info(`Unrecognized ${i}ID: ${t[0]}.`)}))(t.subarray(1))}).add([127,1,0,0,15],(t,s,n)=>{e.switchMode("s90es");let i="S90/Motif ES bulk footer ",r=[];r[95]=(c,f,l)=>{console.debug(`${i}multi edit buffer: ${c[1]}`)},(r[t[0]]||(()=>{console.info(`Unrecognized ${i}ID: ${t[0]}.`)}))(t.subarray(1))}).add([127,1,0,58,55],(t,s,n)=>{e.switchMode("s90es");let i=e.chRedir(t[0],s,!0),r=b.cc*i,c=t[1],f=`S90/Motif ES bulk CH${i<16?i+1:"U"+(i-95)} `;console.debug(f,t),!(t[0]>15)&&t.subarray(2).forEach((l,p)=>{([()=>{e.#e[r+u[0]]=l,e.dispatchEvent("voice",{part:i})},()=>{l&&e.setChActive(i,1),e.#e[r+u[32]]=l,e.setChType(i,[32,40].indexOf(l)>-1?e.CH_DRUMS:e.CH_MELODIC,e.#t,!0),e.dispatchEvent("voice",{part:i})},()=>{l&&e.setChActive(i,1),e.#i[i]=l,e.dispatchEvent("voice",{part:i})},()=>{let $=e.chRedir(l,s,!0);e.#d[i]=$,i!=$&&(e.buildRchTree(),console.info(`${f}receives from CH${$+1}`))},()=>{e.#$[i]=l?0:1},!1,!1,!1,!1,!1,!1,!1,!1,()=>{e.#e[r+u[7]]=l},()=>{e.#e[r+u[10]]=l},!1,!1,!1,()=>{e.#e[r+u[91]]=l},()=>{e.#e[r+u[93]]=l},()=>{e.#e[r+u[94]]=l},()=>{e.#e[r+u[128]]=l},()=>{},()=>{e.#e[r+u[74]]=l},()=>{e.#e[r+u[71]]=l},!1,()=>{e.#e[r+u[65]]=l},()=>{e.#e[r+u[5]]=l},()=>{}][c+p]||(()=>{}))()})}).add([127,1,54,16],(t,s,n)=>{e.switchMode("s90es");let i=t[0];t.subarray(1).forEach((r,c)=>{let l=`S90/Motif ES EQ${(c>>2)+1} `;([()=>{let p=r-64},()=>{let p=D[r]},()=>{let p=r/10},()=>{let p=r}][i+c&3]||(()=>{}))()})}),this.#w.add([0,72,18,0,0,0,0],(t,s,n)=>{e.switchMode("sd",!0),console.info("MIDI reset: SD")}).add([0,72,18,16,0],(t,s,n)=>{let i=t[0]>>5,r=t[0]&31;switch(i){case 0:{console.debug(`Unknown SD-90 global effects message: -%o`,t);break}case 1:{let c=e.chRedir(r,s,!0),f=t[1],l=c*b.cc;t.subarray(2).forEach((p,$)=>{let E=f+$;E<37?([()=>{},()=>{},0,()=>{},()=>{switch(e.#e[l+u[0]]=p,p){case 104:case 105:case 106:case 107:case 120:{e.#s[c]||e.setChType(c,e.CH_DRUMS);break}default:e.#s[c]&&e.setChType(c,e.CH_MELODIC)}e.dispatchEvent("voice",{part:c})},()=>{e.#e[l+u[32]]=p,e.dispatchEvent("voice",{part:c})},()=>{e.#i[c]=p,e.dispatchEvent("voice",{part:c})},()=>{e.#e[l+u[7]]=p},()=>{e.#e[l+u[10]]=p},()=>{},()=>{},()=>{p<2&&(e.#$[c]=p)},()=>{p<2&&(e.#e[l+u[68]]=p?127:0)},()=>{},()=>{p<2&&(e.#e[l+u[65]]=p?127:0)},()=>{e.#e[l+u[5]]=p&15<<4|e.#e[l+u[5]]&15},()=>{e.#e[l+u[5]]=p&15|(e.#e[l+u[5]]&240)>>4},()=>{e.#e[l+u[74]]=p},()=>{e.#e[l+u[71]]=p},()=>{e.#e[l+u[73]]=p},()=>{e.#e[l+u[72]]=p},0,0,0,0,0,0,0,()=>{e.#e[l+u[128]]=p},()=>{e.#e[l+u[93]]=p},()=>{e.#e[l+u[91]]=p},0,0,()=>{e.#e[l+u[75]]=p},()=>{e.#e[l+u[76]]=p},()=>{e.#e[l+u[77]]=p},()=>{e.#e[l+u[78]]=p}][E]||(()=>{}))():E<63||(E<64?e.#s[c]?e.#e[l+u[0]]=104|p:e.#e[l+u[0]]=96|p:console.debug(`Unknown SD-90 global CH${c+1} param setup message: -%o`,t))});break}case 2:{let c=e.chRedir(r,s,!0),f=t[1];console.debug(`Unknown SD-90 global CH${c+1} MIDI setup message: +`),t.slice(0,2)){case"@I":{this.#c=!0,this.dispatchEvent("metacommit",{type:"Kar.Info",data:t.slice(2)?.trimLeft()});break}case"@K":{this.#c=!0,this.dispatchEvent("metacommit",{type:"Kar.Mode",data:t.slice(2)?.trimLeft()}),console.debug(`Karaoke mode active: ${t.slice(2)}`);break}case"@L":{this.#c=!0,this.dispatchEvent("metacommit",{type:"Kar.Lang",data:t.slice(2)?.trimLeft()});break}case"@T":{this.#c=!0,this.dispatchEvent("metacommit",{type:"KarTitle",data:t.slice(2)?.trimLeft()});break}case"@V":{this.#c=!0,this.dispatchEvent("metacommit",{type:"Kar.Ver.",data:t.slice(2)?.trimLeft()});break}case"XF":{let n=t.slice(2).split(":");switch(n[0]){case"hd":{n.slice(1).forEach((i,r)=>{i.length&&this.dispatchEvent("metacommit",{type:["XfSngDte","XfSngRgn","XfSngCat","XfSongBt","XfSngIns","XfSngVoc","XfSngCmp","XfSngLrc","XfSngArr","XfSngPer","XfSngPrg","XfSngTag"][r],data:i})});break}case"ln":{n.slice(1).forEach((i,r)=>{i.length&&this.dispatchEvent("metacommit",{type:["XfKarLng","XfKarNme","XfKarCmp","XfKarLrc","XfKarArr","XfKarPer","XfKarPrg"][r],data:i})});break}default:this.dispatchEvent("metacommit",{type:"XfUnData",data:t})}break}default:this.#c?t[0]=="\\"?(this.dispatchEvent("metacommit",{type:"KarLyric",data:"",amend:!1}),this.dispatchEvent("metacommit",{type:"KarLyric",data:t.slice(1),amend:!0})):t[0]=="/"?(this.dispatchEvent("metacommit",{type:"KarLyric",data:"",mask:!0,amend:!1}),this.dispatchEvent("metacommit",{type:"KarLyric",data:t.slice(1),mask:!0,amend:!0})):this.dispatchEvent("metacommit",{type:"KarLyric",data:t,amend:!0}):t.split(` +`).forEach((n,i)=>{this.dispatchEvent("metacommit",{type:"Cmn.Text",data:n,mask:i!=0})})}},this.#u[2]=function(t){this.dispatchEvent("metacommit",{type:"Copyrite",data:t})},this.#u[3]=function(t,n){n<1&&this.#_<1&&this.dispatchEvent("metacommit",{type:"TrkTitle",data:t})},this.#u[4]=function(t,n){this.dispatchEvent("metacommit",{type:"Instrmnt",data:t})},this.#u[5]=function(t){t.trim()==""?this.dispatchEvent("metacommit",{type:"C.Lyrics",data:"",amend:!1}):this.dispatchEvent("metacommit",{type:"C.Lyrics",data:t,amend:!0})},this.#u[6]=function(t){this.dispatchEvent("metacommit",{type:"C.Marker",data:t})},this.#u[7]=function(t){this.dispatchEvent("metacommit",{type:"CuePoint",data:t})},this.#u[32]=function(t){this.#_=t[0]+1},this.#u[33]=function(t,n){e.#B[n]=t+1},this.#u[81]=function(t,n){e.#j=t/1e3},this.#u[127]=function(t,n){e.#X.run(t,n)},this.#X.default=function(t){console.warn(`Unrecognized sequencer-specific byte sequence: ${t}`)},this.#X.add([67,0,1],function(t,n){e.#B[n]=t[0]+1}),this.#V=new x("universal non-realtime"),this.#F=new x("universal realtime"),this.#k=new x("Yamaha"),this.#v=new x("Roland"),this.#A=new x("Korg"),this.#K=new x("Kawai"),this.#z=new x("Akai"),this.#q=new x("Casio");let s=function(t){console.info(`Unrecognized SysEx in "${this.name}" set. +%o`,t)};this.#V.default=s,this.#F.default=s,this.#k.default=s,this.#v.default=s,this.#A.default=s,this.#K.default=s,this.#z.default=s,this.#q.default=s,this.#V.add([9],t=>{e.switchMode(["gm","?","g2"][t[0]-1],!0),e.#c=e.#c||!1,console.info(`MIDI reset: ${["GM","Init","GM2"][t[0]-1]}`),t[0]==2&&e.init()}),this.#F.add([4,1],t=>{e.#n=((t[1]<<7)+t[0])/16383*100,e.dispatchEvent("mastervolume",e.#n)}).add([4,3],t=>((t[1]<<7)+t[0]-8192)/8192).add([4,4],t=>t[1]-64),this.#k.add([76,0,0],t=>{switch(t[0]){case 125:{e.initDrums(),console.info(`XG drum setup reset: ${t}`);break}case 126:{e.switchMode("xg",!0),e.#c=!1,console.info("MIDI reset: XG");break}default:{let n=[0,0,0,0],i=(r,a)=>{n[a]=r};if(t.subarray(1).forEach((r,a)=>{let c=a+t[0];([i,i,i,i,f=>{this.#n=f*129/16383*100,e.dispatchEvent("mastervolume",e.#n)},f=>{},f=>{}][c]||(()=>{}))(r,a)}),t[0]<4){let r=0;n.forEach(a=>{r=r<<4,r+=a}),r-=1024}}}}).add([76,2,1],t=>{let n="XG ";t[0]<32?(n+="reverb ",t.subarray(1).forEach((i,r)=>{([a=>{e.setEffectTypeRaw(0,!1,a),console.info(`${n}main type: ${A[a]}`),e.dispatchEvent("efxreverb",e.getEffectType(0))},a=>{e.setEffectTypeRaw(0,!0,a),console.debug(`${n}sub type: ${a+1}`),e.dispatchEvent("efxreverb",e.getEffectType(0))},a=>{console.debug(`${n}time: ${j(a)}s`)},a=>{console.debug(`${n}diffusion: ${a}`)},a=>{console.debug(`${n}initial delay: ${a}`)},a=>{console.debug(`${n}HPF cutoff: ${D[a]}Hz`)},a=>{console.debug(`${n}LPF cutoff: ${D[a]}Hz`)},a=>{console.debug(`${n}width: ${a}`)},a=>{console.debug(`${n}height: ${a}`)},a=>{console.debug(`${n}depth: ${a}`)},a=>{console.debug(`${n}wall type: ${a}`)},a=>{console.debug(`${n}dry/wet: ${a}`)},a=>{console.debug(`${n}send: ${S(a)}dB`)},a=>{console.debug(`${n}pan: ${a-64}`)},!1,!1,a=>{console.debug(`${n}delay: ${a}`)},a=>{console.debug(`${n}density: ${a}`)},a=>{console.debug(`${n}balance: ${a}`)},a=>{},a=>{console.debug(`${n}feedback: ${a}`)},a=>{}][t[0]+r]||function(){console.warn(`Unknown XG reverb address: ${t[0]}.`)})(i)})):t[0]<64?(n+="chorus ",t.subarray(1).forEach((i,r)=>{([a=>{e.setEffectTypeRaw(1,!1,a),console.info(`${n}main type: ${A[a]}`),e.dispatchEvent("efxchorus",e.getEffectType(1))},a=>{e.setEffectTypeRaw(1,!0,a),console.debug(`${n}sub type: ${a+1}`),e.dispatchEvent("efxchorus",e.getEffectType(1))},a=>{console.debug(`${n}LFO: ${W[a]}Hz`)},a=>{},a=>{console.debug(`${n}feedback: ${a}`)},a=>{console.debug(`${n}delay offset: ${J(a)}ms`)},a=>{},a=>{console.debug(`${n}low: ${D[a]}Hz`)},a=>{console.debug(`${n}low: ${a-64}dB`)},a=>{console.debug(`${n}high: ${D[a]}Hz`)},a=>{console.debug(`${n}high: ${a-64}dB`)},a=>{console.debug(`${n}dry/wet: ${a}`)},a=>{console.debug(`${n}send: ${S(a)}dB`)},a=>{console.debug(`${n}pan: ${a-64}`)},a=>{console.debug(`${n}to reverb: ${S(a)}dB`)},!1,a=>{},a=>{},a=>{},a=>{console.debug(`${n}LFO phase diff: ${(a-64)*3}deg`)},a=>{console.debug(`${n}input mode: ${a?"stereo":"mono"}`)},a=>{}][t[0]-32+r]||function(){console.warn(`Unknown XG chorus address: ${t[0]}.`)})(i)})):t[0]<86?(n+="variation ",t.subarray(1).forEach((i,r)=>{([a=>{e.setEffectTypeRaw(2,!1,a),console.info(`${n}main type: ${A[a]}`),e.dispatchEvent("efxdelay",e.getEffectType(2))},a=>{e.setEffectTypeRaw(2,!0,a),console.debug(`${n}sub type: ${a+1}`),e.dispatchEvent("efxdelay",e.getEffectType(2))}][t[0]-64+r]||function(){})(i)})):t[0]<97?(n+="variation ",t.subarray(1).forEach((i,r)=>{[a=>{console.debug(`${n}send: ${S(a)}dB`)},a=>{console.debug(`${n}pan: ${a-64}`)},a=>{console.debug(`${n}to reverb: ${S(a)}dB`)},a=>{console.debug(`${n}to chorus: ${S(a)}dB`)},a=>{console.debug(`${n}connection: ${a?"system":"insertion"}`)},a=>{console.debug(`${n}channel: CH${a+1}`)},a=>{console.debug(`${n}mod wheel: ${a-64}`)},a=>{console.debug(`${n}bend wheel: ${a-64}`)},a=>{console.debug(`${n}channel after touch: ${a-64}`)},a=>{console.debug(`${n}AC1: ${a-64}`)},a=>{console.debug(`${n}AC2: ${a-64}`)}][t[0]-86+r](i)})):t[0]>111&&t[0]<118?n+="variation ":console.warn(`Unknown XG variation address: ${t[0]}`)}).add([76,2,64],t=>{t.subarray(1).forEach((n,i)=>{let r=i+t[0];if(r==0)console.debug(`XG EQ preset: ${["flat","jazz","pop","rock","classic"][n]}`);else{let a=r-1>>2,c=r-1&3,f=`XG EQ ${a} ${["gain","freq","Q","shape"][c]}: `;[()=>{console.debug(`${f}${n-64}dB`)},()=>{console.debug(`${f}${n} (raw)`)},()=>{console.debug(`${f}${n/10}`)},()=>{console.debug(`${f}${["shelf","peak"][+!!n]}`)}][c]()}})}).add([76,3],t=>{let n=t[0],i=t[1],r=`XG Insertion ${t[0]+1} `;t.subarray(2).forEach((a,c)=>{([f=>{e.setEffectTypeRaw(3+n,!1,f),console.info(`${r}main type: ${A[f]}`),e.dispatchEvent(`efxinsert${n}`,e.getEffectType(3+n))},f=>{e.setEffectTypeRaw(3+n,!0,f),console.debug(`${r}sub type: ${f+1}`),e.dispatchEvent(`efxinsert${n}`,e.getEffectType(3+n))}][i+c]||function(){})(a)})}).add([76,6,0],t=>{let n=t[0];n<64?e.setLetterDisplay(t.subarray(1),"XG letter display",n):e.#G=Date.now()}).add([76,7,0],t=>{let n=t[0];e.#p=0,e.#C=Date.now()+3200,e.#y.fill(0);let i=t.subarray(1);for(let r=0;r>6-b&1,b++})}).add([76,8],(t,n)=>{let i=e.chRedir(t[0],n,!0),r=t[1],a=p.cc*i,c=`XG CH${i+1} `,f=`Unknown XG part address ${r}.`;t.subarray(2).forEach((l,u)=>{r<1?console.debug(f):r<41?([()=>{e.#e[a+h[0]]=l,e.dispatchEvent("voice",{part:i})},()=>{e.#e[a+h[32]]=l,e.dispatchEvent("voice",{part:i})},()=>{e.#i[i]=l,e.dispatchEvent("voice",{part:i})},()=>{let b=e.chRedir(l,n,!0);e.#d[i]=b,i!=b&&(e.buildRchTree(),console.info(`${c}receives from CH${b+1}`))},()=>{e.#g[i]=+!l},()=>{},()=>{e.setChType(i,l,m.xg),console.debug(`${c}type: ${U[l]||l}`)},()=>{e.#a[p.rpn*i+3]=l,e.#r[p.rpnt*i+2]=1},!1,!1,()=>{e.#e[a+h[7]]=l},!1,!1,()=>{e.#e[a+h[10]]=l||128},!1,!1,()=>{e.#e[a+h[128]]=l},()=>{e.#e[a+h[93]]=l},()=>{e.#e[a+h[91]]=l},()=>{e.#e[a+h[94]]=l},()=>{e.#e[a+h[76]]=l},()=>{e.#e[a+h[77]]=l},()=>{e.#e[a+h[78]]=l},()=>{e.#e[a+h[74]]=l},()=>{e.#e[a+h[71]]=l},()=>{e.#e[a+h[73]]=l},()=>{e.#e[a+h[75]]=l},()=>{e.#e[a+h[72]]=l}][r+u-1]||(()=>{}))():r<48?console.debug(f):r<111?r>102&&r<105&&(e.#e[a+h[[5,65][r&1]]]=l):r<114?console.debug(f):r<116?console.debug(`${c}EQ ${["bass","treble"][r&1]} gain: ${l-64}dB`):r<118?console.debug(f):r<120?console.debug(`${c}EQ ${["bass","treble"][r&1]} freq: ${l}`):console.debug(f)})}).add([76,9],(t,n)=>{let i=e.chRedir(t[0],n,!0),r=t[1],a=`PLG-150VL CH${i+1} `;t.subarray(2).forEach((c,f)=>{let l=f+r;switch(l){case 1:{console.info(`${a}breath mode: ${["system","breath","velocity","touch EG"][c]}`);break}case 0:case 27:case 28:break;default:if(l<27){let u=["pressure","embouchure","tonguing","scream","breath noise","growl","throat formant","harmonic enhancer","damping","absorption","amplification","brightness"][l-3>>1];l&1?l<23?(console.debug(`${a}${u} control source: ${te(c)}`),c&&c<96&&e.allocateAce(c)):console.debug(`${a}${u} scale break point: ${c}`):console.debug(`${a}${u} depth: ${c-64}`)}}})}).add([76,10],t=>{}).add([76,16],t=>{}).add([76,17,0,0],t=>{}).add([76,112],t=>{console.debug(`XG enable PLG1${["50-VL","00-SG","50-DX","50-AN","50-PF","50-DR","50-PC","50-AP"][t[0]]} for CH${t[2]+1}.`)}).add([73,0,0],(t,n)=>{let i=t[0],r="MU1000 System: ";t.subarray(1).forEach((a,c)=>{let f=i+c;f==8?console.debug(`${r}LCD contrast set to ${a}.`):f==18?(e.#m=a?126:0,console.debug(`${r}bank defaults to ${a?"MU100 Native":"MU Basic"}.`)):f>=64&&f<69&&[()=>{e.dispatchEvent("channelactive",a)},()=>{a<8?(e.dispatchEvent("channelmin",a<<4),console.debug(`Octavia System: Minimum CH${(a<<4)+1}`)):(e.dispatchEvent("channelreset"),console.info("Octavia System: Clear channel ranges"))},()=>{a<8?(e.dispatchEvent("channelmax",(a<<4)+15),console.debug(`Octavia System: Maximum CH${(a<<4)+16}`)):(e.dispatchEvent("channelreset"),console.info("Octavia System: Clear channel ranges"))},()=>{e.dispatchEvent("channelreset"),console.info("Octavia System: Clear channel ranges")},()=>{e.#S=!!a,console.info(`Octavia System: RS receiving ${["dis","en"][a]}abled.`)}][f-64]()})}).add([73,10,0],(t,n)=>{let i=t[0],r=`MU1000 RS${e.#S?"":" (ignored)"}: `;if(i<16)switch(i){case 2:{let a=e.chRedir(0,n,!0);e.#S&&(e.dispatchEvent("channelmin",a),e.dispatchEvent("channelmax",a+63)),console.info(`${r}Show CH1~64`);break}case 3:{let a=e.chRedir(t[1]<<5,n,!0);e.#S&&e.dispatchEvent("channelmin",a),e.#S&&e.dispatchEvent("channelmax",a+31),console.info(`${r}Show CH${a+1}~CH${a+32}`);break}default:console.debug(`${r}unknown switch ${i} invoked.`)}else if(i<32){if(e.#S){let a=e.chRedir(i-16+(e.#Z<<4),n,!0);e.dispatchEvent("channelactive",a)}}else if(i<36){let a=e.chRedir(i-32<<4,n,!0);e.#S&&(e.dispatchEvent("channelmin",a),e.dispatchEvent("channelmax",a+15),e.#Z=i-32),console.info(`${r}Show CH${a+1}~CH${a+16}`)}}).add([93,3],(t,n)=>{let i=e.chRedir(t[0],n,!0),r=`PLG-100SG CH${i+1} `,a=Date.now();if(t[1]==0){let c="",f=0;t.subarray(2).forEach((l,u)=>{u%2==0?c+=Z[l]||l.toString().padStart("0"):f+=l*13}),a>=e.#J&&this.dispatchEvent("metacommit",{type:"SGLyrics",data:"",amend:!1}),this.dispatchEvent("metacommit",{type:"SGLyrics",data:`${ee(c)}`,amend:!0}),e.#J=a+Math.ceil(f/2)+e.#j,v()&&console.debug(`${r}vocals: ${c}`)}else console.warn(`Unknown PLG-100SG data: ${t}`)});let o=function(t,n,i,r){},d=function(t,n){let i=t*p.dpn,r=n[0],a=n[1];n.subarray(2).forEach((c,f)=>{let l=f+a,u=-1;l<16?([()=>{u=24},()=>{u=25},()=>{u=26},()=>{},()=>{u=28},()=>{u=29},()=>{u=30},()=>{u=31},()=>{},()=>{},()=>{},()=>{u=20},()=>{u=21},()=>{u=22},()=>{u=23},()=>{}][l]||(()=>{console.debug(`Unknown XG-style drum param ${l} on set ${t+1}.`)}))():l<32||(l<40?([()=>{u=48},()=>{u=49},!1,!1,()=>{u=52},()=>{u=53}][l-32]||(()=>{console.debug(`Unknown XG-style drum param ${l} on set ${t+1}.`)}))():l<80||([()=>{u=36}][l-80]||(()=>{console.debug(`Unknown XG-style drum param ${l} on set ${t+1}.`)}))()),u>=0?(v()&&console.debug(i,u,r,c),e.#b[(i+C[u])*p.dnc+r]=c):v()&&console.debug(`XG-style drum param ${l} has no writes.`)})},y=function(t,n,i){let r=t*p.dpn,a=(n<<7)+i[0];i.subarray(1).forEach((c,f)=>{let l=f+a,u=l&127,b=l>>7,E=-1;b>1&&([()=>{E=26},()=>{},()=>{E=28},()=>{E=29},()=>{E=30},()=>{},()=>{},()=>{E=31}][b-2]||(()=>{console.debug(`Unknown GS-style drum param ${b} on set ${t+1}.`)}))(),E>-1?(v()&&console.debug(r,E,u,c),e.#b[(r+C[E])*p.dnc+u]=c):v()&&console.debug(`GS-style drum param ${b} has no writes.`)})};this.#k.add([76,48],(t,n,i)=>{d(0,t)}).add([76,49],(t,n,i)=>{d(1,t)}).add([76,50],(t,n,i)=>{d(2,t)}).add([76,51],(t,n,i)=>{d(3,t)}).add([76,52],(t,n,i)=>{d(4,t)}).add([76,53],(t,n,i)=>{d(5,t)}).add([76,54],(t,n,i)=>{d(6,t)}).add([76,55],(t,n,i)=>{d(7,t)}),this.#k.add([89,0],(t,n,i)=>{if(e.eprom){let r=t[0],a=(t[1]<<14)+(t[2]<<7)+t[3]+(e.eprom.offset||0);v()&&console.debug(`MU1000 EPROM trail to 0x${a.toString(16).padStart(6,"0")}, ${r} bytes.`);let c=e.eprom.data;t.subarray(4).forEach((f,l)=>{let u=l>>3,b=l&7;if(b==7)for(let E=0;E<7;E++)c[a+7*u+E]+=(f>>6-E&1)<<7;else c[a+7*u+b]=f})}}).add([89,1],(t,n,i)=>{let r=(t[0]<<21)+(t[1]<<14)+(t[2]<<7)+t[3];v()&&console.debug(`MU1000 EPROM jump to 0x${r.toString(16).padStart(6,"0")}.`),e.eprom&&(e.eprom.offset=r)}).add([89,2],(t,n,i)=>{if(e.eprom){let r=(t[0]<<21)+(t[1]<<14)+(t[2]<<7)+t[3]+(e.eprom.offset||0);v()&&console.debug(`MU1000 EPROM write to 0x${r.toString(16).padStart(6,"0")}.`);let a=e.eprom.data;t.subarray(4).forEach((c,f)=>{let l=f>>3,u=f&7;if(u==7)for(let b=0;b<7;b++)a[r+7*l+b]+=(c>>6-b&1)<<7;else a[r+7*l+u]=c})}}).add([89,3],(t,n,i)=>{}),this.#k.add([39,48],(t,n,i)=>{}).add([43,0,0],(t,n,i)=>{let r=[0,0,0,0],a=(c,f)=>{r[f]=c};if(t.subarray(1).forEach((c,f)=>{let l=f+t[0];[a,a,a,a,()=>{this.#n=c*129/16383*100,e.dispatchEvent("mastervolume",e.#n)},()=>c-64,()=>c||128,()=>c,()=>c,()=>{console.debug(`TG300 variation on cc${c}.`)}][l](c,l)}),t[0]<4){let c=0;r.forEach(f=>{c=c<<4,c+=f}),c-=1024}}).add([43,1,0],(t,n,i)=>{}).add([43,2],(t,n,i)=>{let r=e.chRedir(t[0],n,!0),a=t[1],c=p.cc*r,f=`TG300 CH${r+1} `;t.subarray(2).forEach((l,u)=>{u<5?([()=>{},()=>{e.#e[c+h[0]]=l,e.dispatchEvent("voice",{part:r})},()=>{e.#e[c+h[32]]=l,e.dispatchEvent("voice",{part:r})},()=>{e.#i[r]=l,e.dispatchEvent("voice",{part:r})},()=>{let b=e.chRedir(l,n,!0);e.#d[r]=b,r!=b&&(e.buildRchTree(),console.info(`${f}receives from CH${b+1}`))}][u+a]||(()=>{}))(l,u+a):u<21||(u<47?([()=>{e.#g[r]=+!l},()=>{},()=>{},()=>{e.#a[p.rpn*r+3]=l,e.#r[p.rpnt*r+2]=1},()=>{},()=>{e.#e[c+h[7]]=l},!1,!1,()=>{e.#e[c+h[10]]=l||128},!1,!1,()=>{console.debug(`${f} AC1 at cc${l}`)},()=>{console.debug(`${f} AC2 at cc${l}`)},()=>{e.#e[c+h[128]]=l},()=>{e.#e[c+h[93]]=l},()=>{e.#e[c+h[91]]=l},()=>{e.#e[c+h[94]]=l},()=>{e.#e[c+h[76]]=l},()=>{e.#e[c+h[77]]=l},()=>{e.#e[c+h[74]]=l},()=>{e.#e[c+h[71]]=l},()=>{e.#e[c+h[73]]=l},()=>{e.#e[c+h[75]]=l},()=>{e.#e[c+h[72]]=l},()=>{e.#e[c+h[78]]=l}][u+a-21]||(()=>{}))(l,u+a):u<95||([()=>{e.#e[c+h[65]]=l},()=>{e.#e[c+h[5]]=l}][u+a-95]||(()=>{}))(l,u+a))})}).add([43,7,0],(t,n,i)=>{let r=t[0];e.setLetterDisplay(t.subarray(1),"TG300 letter display",r)}).add([43,7,1],(t,n,i)=>{e.#p=0,e.#C=Date.now()+3200,e.#y.fill(0),t.forEach(function(r,a){let c=Math.floor(a/16),f=a%16,l=(f*3+c)*7,u=7,b=0;for(l-=f*5,c==2&&(u=2);b>6-b&1,b++})}),this.#v.add([66,18,0,0,127],(t,n,i)=>{e.switchMode("gs",!0),e.#e[p.cc*9]=120,e.#e[p.cc*25]=120,e.#e[p.cc*41]=120,e.#e[p.cc*57]=120,e.#m=3,e.#c=!1,e.#O.fill(0),console.info(`GS system to ${["single","dual"][t[0]]} mode.`)}).add([66,18,64,0],(t,n,i)=>{switch(t[0]){case 127:{e.switchMode("gs",!0),e.#e[p.cc*9]=120,e.#e[p.cc*25]=120,e.#e[p.cc*41]=120,e.#e[p.cc*57]=120,e.#c=!1,e.#O.fill(0),console.info("MIDI reset: GS");break}default:{let r=[0,0,0,0],a=(c,f)=>{r[f]=c};if(t.subarray(1).forEach((c,f)=>{let l=f+t[0];[a,a,a,a,u=>{this.#n=u*129/16383*100,e.dispatchEvent("mastervolume",e.#n)},u=>{},u=>{}][l](c,f)}),t[0]<4){let c=0;r.forEach(f=>{c=c<<4,c+=f}),c-=1024}}}}).add([66,18,64,1],t=>{let n=t[0];if(n<16){let i="".padStart(n," ");t.subarray(1).forEach((r,a)=>{i+=String.fromCharCode(Math.max(32,r))}),i=i.padEnd(16," "),console.debug(`GS patch name: ${i}`)}else n<48||(n<65?t.subarray(1).forEach((i,r)=>{let a=`GS ${n+r>55?"chorus":"reverb"} `;([()=>{console.info(`${a}type: ${X[i]}`),e.setEffectType(0,40,i),e.dispatchEvent("efxreverb",e.getEffectType(0))},()=>{},()=>{},()=>{},()=>{},()=>{},!1,()=>{console.debug(`${a}predelay: ${i}ms`)},()=>{console.info(`${a}type: ${ae[i]}`),e.setEffectType(1,40,16+i),e.dispatchEvent("efxchorus",e.getEffectType(1))},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{console.debug(`${a}to reverb: ${S(i)}`)},()=>{console.debug(`${a}to delay: ${S(i)}`)}][n+r-48]||(()=>{}))()}):n<80?console.debug(`Unknown GS patch address: ${n}`):n<91?t.subarray(1).forEach((i,r)=>{let a="GS delay ";([()=>{console.info(`${a}type: ${se[i]}`),e.setEffectType(2,40,32+i),e.dispatchEvent("efxdelay",e.getEffectType(2))},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{},()=>{console.debug(`${a}to reverb: ${S(i)}`)}][n+r-80]||(()=>{}))()}):console.debug(`Unknown GS patch address: ${n}`))}).add([66,18,64,2],t=>{let n="GS EQ ";t.subarray(1).forEach((i,r)=>{([()=>{console.debug(`${n}low freq: ${[200,400][i]}Hz`)},()=>{console.debug(`${n}low gain: ${i-64}dB`)},()=>{console.debug(`${n}high freq: ${[3e3,6e3][i]}Hz`)},()=>{console.debug(`${n}high gain: ${i-64}dB`)}][t[0]+r]||function(){console.warn(`Unknown GS EQ address: ${t[0]+r}`)})()})}).add([66,18,64,3],t=>{let n="GS EFX ",i=function(r,a){let c=re(e.#$.subarray(10,12),a,r);c&&console.debug(`${n}${V(e.#$.subarray(10,12))} ${c}`)};t.subarray(1).forEach((r,a)=>{([()=>{e.setEffectTypeRaw(3,!1,32+r),e.dispatchEvent("efxinsert0",e.getEffectType(3))},()=>{e.setEffectTypeRaw(3,!0,r),console.info(`${n}type: ${V(e.#$.subarray(10,12))}`),e.dispatchEvent("efxinsert0",e.getEffectType(3))},!1,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,()=>{console.debug(`${n}to reverb: ${S(r)}dB`)},()=>{console.debug(`${n}to chorus: ${S(r)}dB`)},()=>{console.debug(`${n}to delay: ${S(r)}dB`)},!1,()=>{console.debug(`${n}1 source: ${r}`),r&&r<96&&e.allocateAce(r)},()=>{console.debug(`${n}1 depth: ${r-64}`)},()=>{console.debug(`${n}2 source: ${r}`),r&&r<96&&e.allocateAce(r)},()=>{console.debug(`${n}2 depth: ${r-64}`)},()=>{console.debug(`${n}to EQ: ${r?"ON":"OFF"}`)}][t[0]+a]||function(c,f){console.warn(`Unknown GS EFX address: ${f}`)})(r,t[0]+a)})}).add([66,18,65],t=>{y((t[0]>>4)+1<<1,t[0]&15,t.subarray(1))}).add([69,18,16],t=>{switch(t[0]){case 0:{let n=t[1];e.setLetterDisplay(t.subarray(2),"GS display text",n);break}case 32:{e.#C=Date.now()+3200,t[1]==0&&(e.#p=Math.max(Math.min(t[2]-1,9),0),v()&&console.debug(`GS switch display page ${t[2]-1}.`));break}default:if(t[0]<6){e.#p>9&&(e.#p=0);let n=t[0]-1<<1|t[1]>>6;e.#p==n&&(e.#C=Date.now()+3200),e.#M[n]?.length||(e.#M[n]=new Uint8Array(256));let i=e.#M[n];v()&&console.debug(`GS frame draw page ${n}.`);let r=t[1]&63;i.fill(0),t.subarray(2).forEach(function(c,f){let l=f+r,u=Math.floor(l/16),b=l%16,E=(b*4+u)*5,w=5,k=0;for(E-=b*4,u==3&&(w=1);k>4-k&1,k++})}else console.warn(`Unknown GS display section: ${t[0]}`)}});let g=function(t,n,i){let r=t[0],a=p.cc*n,c=p.rpn*n,f=`GS CH${n+1} `;r<3?(t.subarray(1).forEach((l,u)=>{[()=>{e.#e[a+h[0]]=l},()=>{e.#i[n]=l},()=>{let b=0;l<16?b=e.chRedir(l,i,!0):b=p.ch,e.#d[n]=b,n!=b&&(e.buildRchTree(),console.info(`${f}receives from CH${b+1}`))}][r+u]()}),e.dispatchEvent("voice",{part:n})):r<19||(r<44?t.subarray(1).forEach((l,u)=>{([()=>{e.#g[n]=+!l},!1,()=>{e.setChType(n,l<<1,m.gs),console.debug(`${f}type: ${l?"drum ":"melodic"}${l||""}`)},()=>{e.#a[c+3]=l,e.#r[p.rpnt*n+2]=1},!1,()=>{e.#e[a+h[7]]=l},!1,!1,()=>{e.#e[a+h[10]]=l||128},!1,!1,()=>{console.debug(`${f}CC 1: cc${l}`)},()=>{console.debug(`${f}CC 2: cc${l}`)},()=>{e.#e[a+h[93]]=l},()=>{e.#e[a+h[91]]=l},!1,!1,()=>{e.#a[c+1]=l,e.#r[p.rpnt*n+1]=1},()=>{e.#a[c+2]=l,e.#r[p.rpnt*n+1]=1},()=>{e.#e[a+h[94]]=l}][r+u-19]||(()=>{}))()}):r<76||console.debug(`Unknown GS part address: ${r}`))},$=function(t,n){let i=t[0],r=`GS CH${n+1} `;i<2?t.subarray(1).forEach((a,c)=>{[()=>{e.#e[p.cc*n+h[32]]=a},()=>{}][i+c]()}):i<32?console.warn(`Unknown GS misc address: ${i}`):i<35?t.subarray(1).forEach((a,c)=>{[()=>{console.debug(`${r}EQ: o${["ff","n"][a]}`)},()=>{},()=>{console.debug(`${r}EFX: o${["ff","n"][a]}`),e.#W[n]=a,e.dispatchEvent("partefxtoggle",{part:n,active:a})}][i+c-32]()}):console.warn(`Unknown GS misc address: ${i}`)};this.#v.add([66,18,64,16],(t,n)=>{g(t,e.chRedir(9,n,!0),n)}).add([66,18,64,17],(t,n)=>{g(t,e.chRedir(0,n,!0),n)}).add([66,18,64,18],(t,n)=>{g(t,e.chRedir(1,n,!0),n)}).add([66,18,64,19],(t,n)=>{g(t,e.chRedir(2,n,!0),n)}).add([66,18,64,20],(t,n)=>{g(t,e.chRedir(3,n,!0),n)}).add([66,18,64,21],(t,n)=>{g(t,e.chRedir(4,n,!0),n)}).add([66,18,64,22],(t,n)=>{g(t,e.chRedir(5,n,!0),n)}).add([66,18,64,23],(t,n)=>{g(t,e.chRedir(6,n,!0),n)}).add([66,18,64,24],(t,n)=>{g(t,e.chRedir(7,n,!0),n)}).add([66,18,64,25],(t,n)=>{g(t,e.chRedir(8,n,!0),n)}).add([66,18,64,26],(t,n)=>{g(t,e.chRedir(10,n,!0),n)}).add([66,18,64,27],(t,n)=>{g(t,e.chRedir(11,n,!0),n)}).add([66,18,64,28],(t,n)=>{g(t,e.chRedir(12,n,!0),n)}).add([66,18,64,29],(t,n)=>{g(t,e.chRedir(13,n,!0),n)}).add([66,18,64,30],(t,n)=>{g(t,e.chRedir(14,n,!0),n)}).add([66,18,64,31],(t,n)=>{g(t,e.chRedir(15,n,!0),n)}).add([66,18,64,64],(t,n)=>{$(t,e.chRedir(9,n,!0))}).add([66,18,64,65],(t,n)=>{$(t,e.chRedir(0,n,!0))}).add([66,18,64,66],(t,n)=>{$(t,e.chRedir(1,n,!0))}).add([66,18,64,67],(t,n)=>{$(t,e.chRedir(2,n,!0))}).add([66,18,64,68],(t,n)=>{$(t,e.chRedir(3,n,!0))}).add([66,18,64,69],(t,n)=>{$(t,e.chRedir(4,n,!0))}).add([66,18,64,70],(t,n)=>{$(t,e.chRedir(5,n,!0))}).add([66,18,64,71],(t,n)=>{$(t,e.chRedir(6,n,!0))}).add([66,18,64,72],(t,n)=>{$(t,e.chRedir(7,n,!0))}).add([66,18,64,73],(t,n)=>{$(t,e.chRedir(8,n,!0))}).add([66,18,64,74],(t,n)=>{$(t,e.chRedir(10,n,!0))}).add([66,18,64,75],(t,n)=>{$(t,e.chRedir(11,n,!0))}).add([66,18,64,76],(t,n)=>{$(t,e.chRedir(12,n,!0))}).add([66,18,64,77],(t,n)=>{$(t,e.chRedir(13,n,!0))}).add([66,18,64,78],(t,n)=>{$(t,e.chRedir(14,n,!0))}).add([66,18,64,79],(t,n)=>{$(t,e.chRedir(15,n,!0))}),this.#A.add([54,65],(t,n)=>{e.switchMode("x5d");let i=(t[1]<<7)+t[0],r=(t[3]<<7)+t[2],a=e.chRedir(i&15,n,!0),c=p.cc*a;[()=>{r<1||(r<101?(e.setChType(a,e.CH_MELODIC,m.x5d),e.#i[a]=r-1,e.#e[c+h[0]]=82):r<229?(e.setChType(a,e.CH_MELODIC,m.x5d),e.#i[a]=r-101,e.#e[c+h[0]]=56):(e.setChType(a,e.CH_DRUMS,m.x5d),e.#i[a]=he[r-229]||0,e.#e[c+h[0]]=62)),e.dispatchEvent("voice",{part:a})},()=>{e.#e[c+h[7]]=r},()=>{r<31&&(e.#e[c+h[10]]=Math.round((r-15)*4.2+64))},()=>{e.#e[c+h[93]]=P(r)},()=>{e.#e[c+h[91]]=P(r)},()=>{e.#a[a*p.rpn+3]=r>8191?r-16320:64+r,e.#r[p.rpnt*a+2]=1},()=>{e.#a[a*p.rpn+1]=r>8191?r-16320:64+r,e.#r[p.rpnt*a+1]=1},()=>{r>0&&(e.#a[a*p.rpn]=r,e.#r[p.rpnt*a]=1)},()=>{}][i>>4]()}).add([54,76,0],(t,n)=>{e.switchMode("x5d",!0);let i="",r=82,a=0,c=0,f="MSB PRG LSB NME";T(t,function(l,u){if(u<16400){let b=u%164;switch(!0){case b<10:{l>31&&(i+=String.fromCharCode(l));break}case b==10:break;case b==11:{f+=` +${r} ${a} ${c} ${i.trim().replace("Init Voice","")}`,a++,i="";break}}a>99&&(r=90,a=0)}}),e.userBank.clearRange({msb:82,prg:[0,99],lsb:0}),e.userBank.load(f),v()&&console.debug(f),e.forceVoiceRefresh()}).add([54,77,0],(t,n)=>{e.switchMode("x5d",!0);let i="",r=90,a=0,c=0,f="MSB PRG LSB NME";T(t,function(l,u){if(u<13600){let b=u%136;switch(!0){case b<10:{l>31&&(i+=String.fromCharCode(l));break}case b==11:{f+=` +${r} ${a} ${c} ${i.trim().replace("Init Combi","")}`,a++,i="";break}}}}),e.userBank.clearRange({msb:90,prg:[0,99],lsb:0}),e.userBank.load(f),v()&&console.debug(f),e.forceVoiceRefresh()}).add([54,78],(t,n)=>{e.switchMode("x5d",!0),console.debug(`X5D mode switch requested: ${["combi","combi edit","prog","prog edit","multi","global"][t[0]]} mode.`)}).add([54,85],(t,n)=>{e.switchMode("x5d",!0),T(t,(i,r)=>{r>0&&r<3&&(e.setEffectType(r-1,44,i),e.dispatchEvent(`efx${["reverb","chorus"][r-1]}`,e.getEffectType(r-1)))})}).add([54,104],(t,n)=>{e.switchMode("x5d",!0),T(t,function(i,r,a,c){if(r<192){let f=e.chRedir(Math.floor(r/12),n,!0),l=f*p.cc;switch(r%12){case 0:{i<128?(e.setChType(f,e.CH_MELODIC,m.x5d),e.#e[l+h[0]]=82,e.#i[f]=i):(e.setChType(f,e.CH_DRUMS,m.x5d),e.#e[l+h[0]]=62,e.#i[f]=he[i-128]),i>0&&e.setChActive(f,1),e.dispatchEvent("voice",{part:f});break}case 1:{e.#e[l+h[7]]=i;break}case 2:{e.#a[f*p.rpn+3]=i>127?i-192:64+i,e.#r[p.rpnt*f+2]=1;break}case 3:{e.#a[f*p.rpn+1]=i>127?i-192:64+i,e.#r[p.rpnt*f+1]=1;break}case 4:{i<31&&(e.#e[l+h[10]]=Math.round((i-15)*4.2+64));break}case 5:{let u=i>>4,b=i&15;e.#e[l+h[91]]=P(b),e.#e[l+h[93]]=P(u);break}case 10:break;case 11:{let u=e.chRedir(i&15,n,!0),b=i>>4;e.#d[f]=i,(u!=f||b)&&(console.info(`X5D Part CH${f+1} receives from CH${u+1}.`),e.buildRchTree())}}}else{let f=e.chRedir(r-192,n,!0)}})}),this.#v.add([22,18,127],t=>{e.switchMode("mt32",!0),e.#c=!1,e.userBank.clearRange({msb:0,lsb:127,prg:[0,127]}),console.info("MIDI reset: MT-32")}).add([22,18,0],(t,n,i)=>{e.switchMode("mt32");let r=e.chRedir(i,n,!0),a=t[1];t.subarray(2).forEach((c,f)=>{let l=f+a;e.#P[l+(r-1)*16]=c,([!1,()=>{let u=e.#P[r-1<<4];if(u<3){if(e.#T[r]=1,u==2)for(let b=0;b{e.#a[r*p.rpn+3]=c+40,e.#r[p.rpnt*r+2]=1},()=>{e.#a[r*p.rpn+1]=c+14,e.#r[p.rpnt*r+1]=1},()=>{e.#a[r*p.rpn]=c,e.#r[p.rpnt*r]=1},!1,()=>{e.#e[p.cc*r+h[91]]=c?127:0},!1,()=>{e.#e[p.cc*r+h[7]]=c},()=>{e.#e[p.cc*r+h[10]]=Math.ceil(c*9.05)}][l]||(()=>{}))()})}).add([22,18,1],(t,n,i)=>{e.switchMode("mt32");let r=i&7;console.debug(`MT-32 slot #${i+1} Drum: ${t}`);let a=t[0]<<7|t[1];t.subarray(2).forEach((c,f)=>{let l=f+a,u=(l>>2)+24,b=l&3,E=r*p.dpn;if(v()&&console.debug(`MT-32 temp drum note ${u} param ${b}: ${c}`),u<24){console.warn(`MT-32 dev drum write attempted on an OOB note: ${u}`);return}[()=>{},()=>{e.#b[(E+C[26])*p.dnc+u]=Math.round(c*1.27)},()=>{e.#b[(E+C[26])*p.dnc+u]=c*9+1&127},()=>{e.#b[(E+C[26])*p.dnc+u]=c?127:0}][b]()})}).add([22,18,2],(t,n,i)=>{e.switchMode("mt32");let r=e.chRedir(i,n,!0),a=t[1]+(t[0]<<7);a<10&&(e.#T[r]=1),t.subarray(2).forEach((c,f)=>{let l=f+a;l<14&&(e.#w[(r-1)*p.cmt+l]=c)}),e.dispatchEvent("voice",{part:r})}).add([22,18,3],(t,n,i)=>{e.switchMode("mt32");let r=i&7;if(t[0]){let a=(t[0]-1<<7)+t[1]-16;t.subarray(2).forEach((c,f)=>{let l=f+a,u=(l>>2)+24,b=l&3,E=r*p.dpn;if(v()&&console.debug(`MT-32 dev drum note ${u} param ${b}: ${c}`),u<24){console.warn(`MT-32 dev drum write attempted on an OOB note: ${u}`);return}[()=>{},()=>{e.#b[(E+C[26])*p.dnc+u]=Math.round(c*1.27)},()=>{e.#b[(E+C[26])*p.dnc+u]=c*9+1&127},()=>{e.#b[(E+C[26])*p.dnc+u]=c?127:0}][b]()})}else{let a=t[1];t.subarray(2).forEach((c,f)=>{let l=f+a;e.#P[l]=c;let u=e.chRedir(1+(l>>4),n,!0),b=l&15;([!1,()=>{let E=e.#P[u-1<<4];if(E<3)if(e.#T[u]=1,E==2)for(let w=0;w{e.#a[u*p.rpn+3]=c+40,e.#r[p.rpnt*u+2]=1},()=>{e.#a[u*p.rpn+1]=c+14,e.#r[p.rpnt*u+1]=1},()=>{e.#a[u*p.rpn]=c,e.#r[p.rpnt*u]=1},!1,()=>{e.#e[p.cc*u+h[91]]=c?127:0},!1,()=>{e.#e[p.cc*u+h[7]]=c},()=>{e.#e[p.cc*u+h[10]]=Math.ceil(c*9.05)}][b]||(()=>{}))()})}}).add([22,18,4],(t,n,i)=>{e.switchMode("mt32");let r=t[1]+(t[0]<<7),a=[];t.subarray(2).forEach((c,f)=>{let l=f+r,u=e.chRedir(Math.floor(l/246+1),n,!0),b=l%246;b<14&&(e.#w[(u-1)*p.cmt+b]=c),b<10&&(e.#T[u]=1),a.indexOf(u)<0&&a.push(u)}),a.forEach(c=>{e.dispatchEvent("voice",{part:c})})}).add([22,18,5],(t,n,i)=>{e.switchMode("mt32");let r=(t[0]<<7)+t[1];t.subarray(2).forEach((a,c)=>{let f=r+c,l=Math.floor(f/8),u=f&7,b=l*8;e.#Y[f]=a,([!1,()=>{let E=e.#Y[b];if(E<3){let w="";if(E==2){let L=p.cmt*l;w=`MT-m:${a.toString().padStart(3,"0")}`}else w=e.baseBank.get(0,a+(E<<6),127,"mt32").name;e.userBank.clearRange({msb:0,lsb:127,prg:l});let k=`MSB LSB PRG NME +000 127 ${l} ${w}`;e.userBank.load(k,!0)}}][u]||(()=>{}))()}),e.forceVoiceRefresh()}).add([22,18,8],(t,n,i)=>{e.switchMode("mt32");let r=((t[0]&1)<<7)+t[1];t.subarray(2).forEach((a,c)=>{let f=r+c;f>1)*p.cmt+f]=a)}),e.forceVoiceRefresh()}).add([22,18,16],(t,n,i)=>{e.switchMode("mt32");let r=t[1],a=!1,c=function(f,l){e.#d[l-12]=f,a=!0};t.subarray(2).forEach((f,l)=>{let u=l+r;([!1,!1,!1,!1,!1,!1,!1,!1,!1,!1,!1,!1,!1,c,c,c,c,c,c,c,c,c,()=>{e.#n=f,e.dispatchEvent("mastervolume",e.#n)}][u]||(()=>{}))(f,l)}),a&&e.buildRchTree()}).add([22,18,32],t=>{e.switchMode("mt32");let n=t[1],i=" ".repeat(n);t.subarray(2).forEach(r=>{r>31?i+=String.fromCharCode(r):i+=" "}),e.#H=i.padStart(20," "),e.#G=Date.now()+3200}).add([22,18,82],(t,n)=>{let i=e.chRedir(0,n,!0);for(let r=0;r<16;r++)e.#f.ano(i+r),r&&r<10&&(e.#i[i+r]=F[r-1]);console.info("MT-32 alt reset complete.")}),this.#A.add([66,0],(t,n)=>{e.switchMode("ns5r",!0),e.#c=!1,console.debug(`NS5R mode switch requested: ${["global","multi","prog edit","comb edit","drum edit","effect edit"][t[0]]} mode.`)}).add([66,1],(t,n)=>{e.switchMode(["ns5r","05rw"][t[0]],!0),e.#c=!1}).add([66,18,0,0],(t,n)=>{let i=t[0];switch(i){case 124:case 126:case 127:{e.switchMode("ns5r",!0),e.#c=!1;break}case 125:{e.initDrums(),console.info(`NS5R drum setup reset: ${t}`);break}default:if(i<10){let r=[0,0,0,0],a=(c,f)=>{r[f]=c};if(t.subarray(1).forEach((c,f)=>{[a,a,a,a,()=>{e.#n=c*129/16383*100,e.dispatchEvent("mastervolume",e.#n)},()=>c-64,()=>c-64,()=>{},()=>{},()=>{}][i+f]()}),t[0]<4){let c=0;r.forEach(f=>{c=c<<4,c+=f}),c-=1024}}}}).add([66,18,0,1],(t,n)=>{}).add([66,18,0,2],(t,n)=>{}).add([66,18,1],(t,n)=>{let i=e.chRedir(t[0],n,!0),r=i*p.cc,a=t[1],c=`NS5R CH${i+1} `;t.subarray(2).forEach((f,l)=>{let u=a+l;u<3?([()=>{e.#e[r+h[0]]=f||121},()=>{e.#e[r+h[32]]=f},()=>{e.#i[i]=f}][u](),e.dispatchEvent("voice",{part:i})):u<8||(u<14?[()=>{let b=e.chRedir(f,n,!0);e.#d[i]=b,i!=b&&(e.buildRchTree(),console.info(`${c}receives from CH${b+1}`))},()=>{e.#g[i]=+!f},()=>{e.setChType(i,f,m.ns5r),console.debug(`${c}type: ${U[f]}`)},()=>{e.#a[p.rpn*i+3]=f,e.#r[p.rpnt*i+2]=1},()=>{},()=>{}][u-8]():u<16||(u<33?[()=>{e.#e[r+h[7]]=f},()=>{e.#e[r+h[11]]=f},()=>{},()=>{},()=>{e.#e[r+h[10]]=f||128},()=>{},()=>{},()=>{e.#e[r+h[93]]=f},()=>{e.#e[r+h[91]]=f},()=>{e.#e[r+h[76]]=f},()=>{e.#e[r+h[77]]=f},()=>{e.#e[r+h[78]]=f},()=>{e.#e[r+h[74]]=f},()=>{e.#e[r+h[71]]=f},()=>{e.#e[r+h[73]]=f},()=>{e.#e[r+h[75]]=f},()=>{e.#e[r+h[72]]=f}][u-16]():u<112||u<114&&[()=>{e.#e[r+h[5]]=f},()=>{e.#e[r+h[65]]=f}][u-112]()))})}).add([66,18,8,0],(t,n)=>{let i=t[0];if(i<32)e.setLetterDisplay(t.subarray(1,33),"NS5R letter display");else{let r=i-32;e.#C=Date.now()+3200,e.#p=10,e.#y.fill(0);let a=t.subarray(1),c=4;a.forEach(function(f,l){let u=l+r,b=u>>4,E=u&15;if(u<80){let w=b>3,k=0,L=b0;)e.#y[E*32+b*7+(L-k)]=w&1,w=w>>1,k++}})}}).add([66,18,48],(t,n,i)=>{d(0,t)}).add([66,18,49],(t,n,i)=>{d(1,t)}).add([66,18,50],(t,n,i)=>{d(2,t)}).add([66,18,51],(t,n,i)=>{d(3,t)}).add([66,18,52],(t,n,i)=>{d(4,t)}).add([66,18,53],(t,n,i)=>{d(5,t)}).add([66,18,54],(t,n,i)=>{d(6,t)}).add([66,18,55],(t,n,i)=>{d(7,t)}).add([66,52],(t,n)=>{e.switchMode("ns5r",!0),e.#c=!1;let i="";T(t,(r,a)=>{a<8?(r>31&&(i+=String.fromCharCode(r)),a==7&&(e.aiEfxName=i)):a<10&&(e.setEffectType(a-8,44,r),e.dispatchEvent(`efx${["reverb","chorus"][a-8]}`,e.getEffectType(a-8)))})}).add([66,53],(t,n)=>{e.switchMode("ns5r",!0),e.#c=!1;let i="";T(t,function(r,a){switch(!0){case a<2944:{let c=e.chRedir(Math.floor(a/92),n,!0),f=c*p.cc;switch(a%92){case 0:{e.#e[f+h[0]]=r,e.dispatchEvent("voice",{part:c});break}case 1:{e.#e[f+h[32]]=r,!r&&!e.#e[f+h[0]]&&(e.#e[f+h[0]]=121),e.dispatchEvent("voice",{part:c});break}case 2:{e.#i[c]=r,r>0&&e.setChActive(c,1),e.dispatchEvent("voice",{part:c});break}case 3:{let l=e.chRedir(r,n,!0);e.#d[c]=l,c!=l&&(console.info(`NS5R CH${c+1} receives from CH${l+1}.`),e.buildRchTree());break}case 7:{e.#s[c]=r,e.dispatchEvent("voice",{part:c});break}case 8:{e.#a[c*p.rpn+3]=r<40||r>88?r+(r>63?-192:64):r,e.#r[p.rpnt*c+2]=1;break}case 9:case 10:{e.#e[f+h[7]]=r;break}case 11:{e.#e[f+h[11]]=r;break}case 14:{e.#e[f+h[10]]=r||128;break}case 19:{e.#e[f+h[93]]=r;break}case 20:{e.#e[f+h[91]]=r;break}case 84:{e.#e[f+h[65]]=r;break}case 85:{e.#e[f+h[5]]=r;break}}break}case a<3096:break;case a<3134:{let c=a-3096;c<8?(r>31&&(i+=String.fromCharCode(r)),c==7&&(e.aiEfxName=i)):c<10&&(e.setEffectType(c-8,44,r),e.dispatchEvent(`efx${["reverb","chorus"][c-8]}`,e.getEffectType(c-8)));break}case a<8566:break}})}).add([66,54],(t,n)=>{e.switchMode("ns5r",!0);let i="",r=80,a=0,c=0,f="MSB PRG LSB NME";T(t,function(l,u){let b=u%158;switch(!0){case b<10:{l>31&&(i+=String.fromCharCode(l));break}case b==10:break;case b==11:{r=l&127;break}case b==12:{c=l&127;break}case b==13:{f+=` +${r} ${a} ${c} ${i.trim().replace("Init Voice","")}`,a++,i="";break}}}),e.userBank.clearRange({msb:80,lsb:0}),e.userBank.load(f),v()&&console.debug(f),e.forceVoiceRefresh()}).add([66,55],(t,n)=>{e.switchMode("ns5r",!0);let i="",r=88,a=0,c=0,f="MSB PRG LSB NME";T(t,function(l,u){let b=u%126;switch(!0){case b<10:{l>31&&(i+=String.fromCharCode(l));break}case b==11:break;case b==12:break;case b==13:{f+=` +${r} ${a} ${c} ${i.trim().replace("Init Combi","")}`,a++,i="";break}}}),e.userBank.clearRange({msb:88,lsb:0}),e.userBank.load(f),v()&&console.debug(f),e.forceVoiceRefresh()}).add([66,125],t=>{e.dispatchEvent("backlight",["green","orange","red",!1,"yellow","blue","purple"][t[0]]||"white")}).add([66,127],t=>{let n=new Uint8Array(5760);T(t,(i,r,a)=>{if(r<720)for(let c=0;c<8;c++)n[r*8+c]=i>>7-c&1}),e.dispatchEvent("screen",{type:"ns5r",data:n})}).add([76],(t,n,i)=>{e.#A.run([66,...t],n,i)}),this.#K.add([16,0,8,0],(t,n,i)=>{let r=(t[2]<<4)+t[3],a="K11 ";([()=>{e.switchMode("k11",!0),e.#c=!1,e.#m=r?4:0,console.info("MIDI reset: GMega/K11")},()=>{e.setEffectType(0,24,r),console.debug(`${a}reverb type: ${r}`),e.dispatchEvent("efxreverb",e.getEffectType(0))},()=>{console.debug(`${a}reverb time: ${r}`)},()=>{console.debug(`${a}reverb time: ${r}`)},()=>{console.debug(`${a}reverb predelay: ${r}`)},()=>{console.debug(`${a}reverb predelay: ${r}`)},()=>{console.debug(`${a}depth high: ${r}`)},()=>{console.debug(`${a}depth high: ${r}`)},()=>{console.debug(`${a}depth low: ${r}`)},()=>{console.debug(`${a}depth low: ${r}`)}][t[0]]||(()=>{}))()}).add([16,0,8,1],(t,n,i)=>{let r=e.chRedir(t[1],n,!0),a=p.cc*r,c=p.rpn*r,f=(t[3]<<4)+t[4],l=`K11 CH${r+1} `;([()=>{f<128?(e.setChType(r,e.CH_MELODIC,m.k11),e.#e[a+h[0]]=0,e.#i[r]=f):(e.setChType(r,e.CH_DRUMS,m.k11),e.#i[r]=f-128),e.dispatchEvent("voice",{part:r})},()=>{let u=e.chRedir(f,n,!0);e.#d[r]=u,r!=u&&(e.buildRchTree(),console.info(`${l}receives from CH${u+1}`))},()=>{e.#e[a+h[7]]=f},()=>{uupThis.setChActive(r,f)},()=>{e.#e[a+h[10]]=f},()=>{e.#a[c+3]=f+40,e.#r[p.rpnt*r+2]=1},()=>{e.#a[c+1]=f>>1,e.#a[c+2]=f&1,e.#r[p.rpnt*r+1]=1},()=>{e.#e[a+h[91]]=f?127:0},()=>{},()=>{e.#e[a+h[74]]=f},()=>{e.#e[a+h[73]]=f},()=>{e.#e[a+h[72]]=f}][t[0]]||(()=>{}))()}).add([16,0,9,0],(t,n,i)=>{let r=(t[2]<<4)+t[3],a="GMLX ";([()=>{console.debug(`${a}reverb type: ${r}`)},()=>{console.debug(`${a}reverb time: ${r}`)},()=>{console.debug(`${a}reverb predelay: ${r}`)},()=>{console.debug(`${a}depth high: ${r}`)},()=>{console.debug(`${a}depth low: ${r}`)}][t[0]]||(()=>{}))()}).add([16,0,9,3],(t,n,i)=>{let r=(t[2]<<4)+t[3],a=e.chRedir(t[1],n,!0),c=a*p.cc;[()=>{r<128?(e.setChType(a,e.CH_MELODIC,m.k11),e.#e[c+h[0]]=0,e.#e[c+h[32]]=0,e.#i[a]=r):r<160?(e.setChType(a,e.CH_MELODIC,m.k11),e.#e[c+h[0]]=0,e.#e[c+h[32]]=7,e.#i[a]=r-100):(e.setChType(a,e.CH_DRUMS,m.k11),e.#e[c+h[0]]=122,e.#e[c+h[32]]=0,e.#i[a]=r-160),e.dispatchEvent("voice",{part:a})},()=>{let f=e.chRedir(r,n,!0);e.#d[a]=f,a!=f&&(e.buildRchTree(),console.info(`GMLX CH${a+1} receives from CH${f+1}`))}][t[0]]()}).add([16,0,9,4],(t,n,i)=>{let r=(t[2]<<4)+t[3],a=e.chRedir(t[1],n,!0),c=a*p.cc,f=a*p.rpn,l=`GMLX CH${a+1} `;[()=>{e.setChActive(a,r)},()=>{e.#e[c+h[7]]=r},()=>{e.#e[c+h[10]]=r},()=>{e.#e[c+h[91]]=r?127:0},()=>{e.#a[f+3]=r+40,e.#r[p.rpnt*a+2]=1},()=>{e.#a[f+1]=r,e.#r[p.rpnt*a+1]=1},()=>{e.#a[f]=r,e.#r[p.rpnt*a]=1},()=>{}][t[0]]()}),this.#z.add([66,93,64],(t,n,i)=>{let r=t[2];switch(t[0]){case 0:{switch(t[1]){case 4:{e.#n=r*129/16383*100,e.dispatchEvent("mastervolume",e.#n);break}case 5:{r-64;break}case 6:{console.debug(`SG global reverb: ${r?"on":"off"}`);break}case 127:{e.switchMode("sg",!0);break}}break}case 1:{switch(t[1]){case 48:{console.debug(`SG reverb type: ${X[r]}`);break}}break}default:if(t[0]>>4==1){let a=e.chRedir(t[0]&15,n,!0);if(t[1]==2){let c=e.chRedir(r,n,!0);e.#d[a]=c,a!=c&&(e.buildRchTree(),console.info(`SG CH${a+1} receives from CH${c+1}`))}else t[1]==19&&(e.#e[p.cc*a+h[7]]=r)}else console.warn(`Unknown AKAI SG SysEx: ${t}`)}}),this.#q.add([9],(t,n,i)=>{console.debug(`GZ set effect: ${["stage reverb","hall reverb","room reverb","chorus","tremelo","phaser","rotary speaker","enhancer","flanger","EQ"][t[0]]||"off"}`)}),this.#k.add([127,0],(t,n,i)=>{e.switchMode("motif");let r=new Uint8Array([127,1,...t]);e.#k.run(r,n,i)}).add([127,1,0,0],(t,n,i)=>{e.switchMode("s90es");let r="S90/Motif ES system ",a=t[0];t.subarray(1).forEach((c,f)=>{([()=>{e.#n=c*12900/16383,e.dispatchEvent("mastervolume",e.#n)}][a+f]||(()=>{console.info(`Unrecognized ${r}ID: ${a+f}`)}))()})}).add([127,1,0,0,14],(t,n,i)=>{e.switchMode("s90es");let r="S90/Motif ES bulk header ",a=[];a[95]=(c,f,l)=>{console.debug(`${r}multi edit buffer: ${c[1]}`)},(a[t[0]]||(()=>{console.info(`Unrecognized ${r}ID: ${t[0]}.`)}))(t.subarray(1))}).add([127,1,0,0,15],(t,n,i)=>{e.switchMode("s90es");let r="S90/Motif ES bulk footer ",a=[];a[95]=(c,f,l)=>{console.debug(`${r}multi edit buffer: ${c[1]}`)},(a[t[0]]||(()=>{console.info(`Unrecognized ${r}ID: ${t[0]}.`)}))(t.subarray(1))}).add([127,1,0,58,55],(t,n,i)=>{e.switchMode("s90es");let r=e.chRedir(t[0],n,!0),a=p.cc*r,c=t[1],f=`S90/Motif ES bulk CH${r<16?r+1:"U"+(r-95)} `;console.debug(f,t),!(t[0]>15)&&t.subarray(2).forEach((l,u)=>{([()=>{e.#e[a+h[0]]=l,e.dispatchEvent("voice",{part:r})},()=>{l&&e.setChActive(r,1),e.#e[a+h[32]]=l,e.setChType(r,[32,40].indexOf(l)>-1?e.CH_DRUMS:e.CH_MELODIC,e.#t,!0),e.dispatchEvent("voice",{part:r})},()=>{l&&e.setChActive(r,1),e.#i[r]=l,e.dispatchEvent("voice",{part:r})},()=>{let b=e.chRedir(l,n,!0);e.#d[r]=b,r!=b&&(e.buildRchTree(),console.info(`${f}receives from CH${b+1}`))},()=>{e.#g[r]=l?0:1},!1,!1,!1,!1,!1,!1,!1,!1,()=>{e.#e[a+h[7]]=l},()=>{e.#e[a+h[10]]=l},!1,!1,!1,()=>{e.#e[a+h[91]]=l},()=>{e.#e[a+h[93]]=l},()=>{e.#e[a+h[94]]=l},()=>{e.#e[a+h[128]]=l},()=>{},()=>{e.#e[a+h[74]]=l},()=>{e.#e[a+h[71]]=l},!1,()=>{e.#e[a+h[65]]=l},()=>{e.#e[a+h[5]]=l},()=>{}][c+u]||(()=>{}))()})}).add([127,1,54,16],(t,n,i)=>{e.switchMode("s90es");let r=t[0];t.subarray(1).forEach((a,c)=>{let l=`S90/Motif ES EQ${(c>>2)+1} `;([()=>{let u=a-64},()=>{let u=D[a]},()=>{let u=a/10},()=>{let u=a}][r+c&3]||(()=>{}))()})}),this.#v.add([0,72,18,0,0,0,0],(t,n,i)=>{e.switchMode("sd",!0),console.info("MIDI reset: SD")}).add([0,72,18,16,0],(t,n,i)=>{let r=t[0]>>5,a=t[0]&31;switch(r){case 0:{console.debug(`Unknown SD-90 global effects message: +%o`,t);break}case 1:{let c=e.chRedir(a,n,!0),f=t[1],l=c*p.cc;t.subarray(2).forEach((u,b)=>{let E=f+b;E<37?([()=>{},()=>{},0,()=>{},()=>{switch(e.#e[l+h[0]]=u,u){case 104:case 105:case 106:case 107:case 120:{e.#s[c]||e.setChType(c,e.CH_DRUMS);break}default:e.#s[c]&&e.setChType(c,e.CH_MELODIC)}e.dispatchEvent("voice",{part:c})},()=>{e.#e[l+h[32]]=u,e.dispatchEvent("voice",{part:c})},()=>{e.#i[c]=u,e.dispatchEvent("voice",{part:c})},()=>{e.#e[l+h[7]]=u},()=>{e.#e[l+h[10]]=u},()=>{},()=>{},()=>{u<2&&(e.#g[c]=u)},()=>{u<2&&(e.#e[l+h[68]]=u?127:0)},()=>{},()=>{u<2&&(e.#e[l+h[65]]=u?127:0)},()=>{e.#e[l+h[5]]=u&15<<4|e.#e[l+h[5]]&15},()=>{e.#e[l+h[5]]=u&15|(e.#e[l+h[5]]&240)>>4},()=>{e.#e[l+h[74]]=u},()=>{e.#e[l+h[71]]=u},()=>{e.#e[l+h[73]]=u},()=>{e.#e[l+h[72]]=u},0,0,0,0,0,0,0,()=>{e.#e[l+h[128]]=u},()=>{e.#e[l+h[93]]=u},()=>{e.#e[l+h[91]]=u},0,0,()=>{e.#e[l+h[75]]=u},()=>{e.#e[l+h[76]]=u},()=>{e.#e[l+h[77]]=u},()=>{e.#e[l+h[78]]=u}][E]||(()=>{}))():E<63||(E<64?e.#s[c]?e.#e[l+h[0]]=104|u:e.#e[l+h[0]]=96|u:console.debug(`Unknown SD-90 global CH${c+1} param setup message: +%o`,t))});break}case 2:{let c=e.chRedir(a,n,!0),f=t[1];console.debug(`Unknown SD-90 global CH${c+1} MIDI setup message: %o`,t.subarray(2));break}default:console.warn(`Unknown SD-90 global part setup message: -%o`,t)}})}};export{Ke as OctaviaDevice,b as allocated,u as ccToPos,C as dnToPos}; +%o`,t)}})}};export{qe as OctaviaDevice,p as allocated,h as ccToPos,C as dnToPos}; diff --git a/dist/state_skim.mjs b/dist/state_skim.mjs index 6dc54ff8..77f6b496 100644 --- a/dist/state_skim.mjs +++ b/dist/state_skim.mjs @@ -1,7 +1,7 @@ -var U=function(e,t){let s=Math.min(e.length,t.length),i=e.slice(0,s),r=t.slice(0,s),n=0,a=0;for(;a0){let i=this.pool.length,r=1<=1&&a>=0;){if(a<=0)throw new Error("TTL reached.");if(n==i)n-=r;else{let c=U(t,this.pool[n]);switch(c){case 0:{a=0;break}case 1:{n+r<=i&&(n+=r);break}case-1:{n!=0&&(n-=r);break}default:console.warn(`Unexpected result ${c}.`)}}r=r>>1,a--}let o=!0;if(n>=this.pool.length)o=!1;else{let c=this;this.pool[n].forEach(function(u,f,p){o&&u!=t[f]&&(o=!1)}),!o&&U(t,this.pool[n])>0&&n++}return o||s?n:-1}else return s?0:-1},this.add=function(t,s){return t.data=s,this.pool.splice(this.point(t,!0),0,t),this},this.default=function(t){console.warn(`No match in "${this.name||"(unknown)"}" for "${t}". Default action not defined.`)},this.get=function(t){let s=this.point(t);if(s>-1)return this.pool[s].data;this.default(t)},this.run=function(t,...s){let i=this.point(t);i>-1?t.subarray?this.pool[i].data(t.subarray(this.pool[i].length),...s):this.pool[i].data(t.slice(this.pool[i].length),...s):this.default(t,...s)}};var M=class{#t={};addEventListener(e,t){this.#t[e]||(this.#t[e]=[]),this.#t[e].unshift(t)}removeEventListener(e,t){if(this.#t[e]){let s=this.#t[e].indexOf(t);s>-1&&this.#t[e].splice(s,1),this.#t[e].length<1&&delete this.#t[e]}}dispatchEvent(e,t){let s=new Event(e),i=this;s.data=t,this.#t[e]?.length>0&&this.#t[e].forEach(function(r){try{r?.call(i,s)}catch(n){console.error(n)}}),this[`on${e}`]&&this[`on${e}`](s)}};var P=class{#t={};context;set(e,t){this.#t[e]=t}has(e){return!!this.#t[e]}async read(e,t){if(!this.has(e))throw new Error(`No decoder registered for "${e}"`);return await this.#t[e].call(this.context||this,t)}};var X=function(e,t){let s=!0;return t.forEach((i,r)=>{s=s&&e[r]==i}),s},N=function(e){let t=0;return e.forEach(s=>{t*=256,t+=s}),t},S=new TextDecoder,L=new P;L.set("s7e",async function(e){let t=new Uint8Array(await e.slice(0,65536).arrayBuffer()),s="MSB LSB PRG NME",i=[0,0,0,0],r=32,n=0,a=0,o=!0,c=[],u=0;for(;o;){let f=t.subarray(n);([()=>{S.decode(f.subarray(0,4))=="YSFC"?(n+=80,a=1):n++},()=>{if(X(f.subarray(0,4),i))c.forEach((p,g,d)=>{let b=N(t.subarray(p.start+4,p.start+8));p.length=b}),a=2;else{let p=S.decode(f.subarray(0,4)),g=N(f.subarray(4,8));c.push({type:p,start:g}),n+=8}},()=>{let p=c[u],g=t.subarray(p.start,p.start+p.length),d=32;switch(p.type){case"ENVC":{let b=r;for(;b=c.length&&(a=3,o=!1)}][a]||(()=>{o=!1}))()}return s});var K=["off","hall","room","stage","plate","delay LCR","delay LR","echo","cross delay","early reflections","gate reverb","reverse gate"].concat(new Array(4),["white room","tunnel","canyon","basement","karaoke"],new Array(43),["pass through","chorus","celeste","flanger","symphonic","rotary speaker","tremelo","auto pan","phaser","distortion","overdrive","amplifier","3-band EQ","2-band EQ","auto wah"],new Array(1),["pitch change","harmonic","touch wah","compressor","noise gate","voice channel","2-way rotary speaker","ensemble detune","ambience"],new Array(4),["talking mod","Lo-Fi","dist + delay","comp + dist + delay","wah + dist + delay","V dist","dual rotor speaker"]);var V=",a,i,u,e,o,ka,ki,ku,ke,ko,ky,kw,sa,si,su,se,so,sh,ta,ti,tu,te,to,t,ch,t,s,na,ni,nu,ne,no,ny,nn,ha,hi,hu,he,ho,hy,fa,fi,fu,fe,fo,ma,mi,mu,me,mo,my,mm,ya,yu,ye,yo,ra,ri,ru,re,ro,ry,wa,wi,we,wo,ga,gi,gu,ge,go,gy,gw,za,zi,zu,ze,zo,ja,ji,ju,je,jo,jy,da,di,du,de,do,dy,ba,bi,bu,be,bo,by,va,vi,vu,ve,vo,pa,pi,pu,pe,po,py,nga,ngi,ngu,nge,ngo,ngy,ng,hha,hhi,hhu,hhe,hho,hhy,hhw,*,_,,,~,.".split(","),F={};`hi*, +var N=function(e,t){let a=Math.min(e.length,t.length),s=e.slice(0,a),r=t.slice(0,a),n=0,l=0;for(;l0){let s=this.pool.length,r=1<=1&&l>=0;){if(l<=0)throw new Error("TTL reached.");if(n==s)n-=r;else{let p=N(t,this.pool[n]);switch(p){case 0:{l=0;break}case 1:{n+r<=s&&(n+=r);break}case-1:{n!=0&&(n-=r);break}default:console.warn(`Unexpected result ${p}.`)}}r=r>>1,l--}let u=!0;if(n>=this.pool.length)u=!1;else{let p=this;this.pool[n].forEach(function(i,h,c){u&&i!=t[h]&&(u=!1)}),!u&&N(t,this.pool[n])>0&&n++}return u||a?n:-1}else return a?0:-1},this.add=function(t,a){return t.data=a,this.pool.splice(this.point(t,!0),0,t),this},this.default=function(t){console.warn(`No match in "${this.name||"(unknown)"}" for "${t}". Default action not defined.`)},this.get=function(t){let a=this.point(t);if(a>-1)return this.pool[a].data;this.default(t)},this.run=function(t,...a){let s=this.point(t);s>-1?t.subarray?this.pool[s].data(t.subarray(this.pool[s].length),...a):this.pool[s].data(t.slice(this.pool[s].length),...a):this.default(t,...a)}};var T=class{#t={};addEventListener(e,t){this.#t[e]||(this.#t[e]=[]),this.#t[e].unshift(t)}removeEventListener(e,t){if(this.#t[e]){let a=this.#t[e].indexOf(t);a>-1&&this.#t[e].splice(a,1),this.#t[e].length<1&&delete this.#t[e]}}dispatchEvent(e,t){let a=new Event(e),s=this;a.data=t,this.#t[e]?.length>0&&this.#t[e].forEach(function(r){try{r?.call(s,a)}catch(n){console.error(n)}}),this[`on${e}`]&&this[`on${e}`](a)}};var L=class{#t={};context;set(e,t){this.#t[e]=t}has(e){return!!this.#t[e]}async read(e,t){if(!this.has(e))throw new Error(`No decoder registered for "${e}"`);return await this.#t[e].call(this.context||this,t)}};var F=function(e,t){let a=!0;return t.forEach((s,r)=>{a=a&&e[r]==s}),a},I=function(e){let t=0;return e.forEach(a=>{t*=256,t+=a}),t},x=new TextDecoder,G=new L;G.set("s7e",async function(e){let t=new Uint8Array(await e.slice(0,65536).arrayBuffer()),a="MSB LSB PRG NME",s=[0,0,0,0],r=32,n=0,l=0,u=!0,p=[],i=0;for(;u;){let h=t.subarray(n);([()=>{x.decode(h.subarray(0,4))=="YSFC"?(n+=80,l=1):n++},()=>{if(F(h.subarray(0,4),s))p.forEach((c,b,g)=>{let y=I(t.subarray(c.start+4,c.start+8));c.length=y}),l=2;else{let c=x.decode(h.subarray(0,4)),b=I(h.subarray(4,8));p.push({type:c,start:b}),n+=8}},()=>{let c=p[i],b=t.subarray(c.start,c.start+c.length),g=32;switch(c.type){case"ENVC":{let y=r;for(;y=p.length&&(l=3,u=!1)}][l]||(()=>{u=!1}))()}return a});var z=["off","hall","room","stage","plate","delay LCR","delay LR","echo","cross delay","early reflections","gate reverb","reverse gate"].concat(new Array(4),["white room","tunnel","canyon","basement","karaoke"],new Array(43),["pass through","chorus","celeste","flanger","symphonic","rotary speaker","tremelo","auto pan","phaser","distortion","overdrive","amplifier","3-band EQ","2-band EQ","auto wah"],new Array(1),["pitch change","harmonic","touch wah","compressor","noise gate","voice channel","2-way rotary speaker","ensemble detune","ambience"],new Array(4),["talking mod","Lo-Fi","dist + delay","comp + dist + delay","wah + dist + delay","V dist","dual rotor speaker"]);var q=",a,i,u,e,o,ka,ki,ku,ke,ko,ky,kw,sa,si,su,se,so,sh,ta,ti,tu,te,to,t,ch,t,s,na,ni,nu,ne,no,ny,nn,ha,hi,hu,he,ho,hy,fa,fi,fu,fe,fo,ma,mi,mu,me,mo,my,mm,ya,yu,ye,yo,ra,ri,ru,re,ro,ry,wa,wi,we,wo,ga,gi,gu,ge,go,gy,gw,za,zi,zu,ze,zo,ja,ji,ju,je,jo,jy,da,di,du,de,do,dy,ba,bi,bu,be,bo,by,va,vi,vu,ve,vo,pa,pi,pu,pe,po,py,nga,ngi,ngu,nge,ngo,ngy,ng,hha,hhi,hhu,hhe,hho,hhy,hhw,*,_,,,~,.".split(","),Q={};`hi*, ka,か ki,き ku,く @@ -138,9 +138,9 @@ o,お ~, ^, _,`.split(` -`).forEach(e=>{let t=e.split(",");F[t[0]]=t[1]});var z=["?","gm","gs","xg","g2","mt32","ns5r","x5d","05rw","sd","k11","sg","krs","s90es","motif"];var T=[20,21,22,23,24,25,26,28,29,30,31,36,37,48,49,52,53,64,65];var R=[0,1,2,4,5,6,7,8,10,11,32,38,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,84,91,92,93,94,95,98,99,100,101,128,12,13,16,17,18,19,14,15,20,21];var q={};z.forEach((e,t)=>{q[e]=t});var Q={length:R.length};R.forEach((e,t)=>{Q[e]=t});var Y={length:T.length};T.forEach((e,t)=>{Y[e]=t});var Le={ch:128,cc:R.length,nn:128,pl:512,tr:256,cmt:14,rpn:6,rpnt:4,ace:8,drm:8,dpn:T.length,dnc:128,efx:7};var W=["MSB","PRG","LSB"],O=function(e){let t=Math.floor(e/10),s=e%10;return`${t.toString(16)}${s}`},x=class{#t;strictMode=!1;get(e=0,t=0,s=0,i){let r=[e,t,s],n,a=Array.from(arguments);switch(i){case"xg":{switch(e){case 0:{s==126?a[2]=125:s==127&&(a[2]=0);break}case 16:{s==126&&(a[2]=0);break}case 32:{s>125&&(a[2]=0),a[2]+=4;break}case 33:case 35:case 36:{s>125&&(a[2]=0),a[2]+=5;break}case 79:case 80:case 81:case 82:case 83:case 84:a[0]+=16;case 95:case 96:case 97:case 98:case 99:case 100:{s==126&&(a[2]=0);break}case 48:case 64:case 126:case 127:{s==126&&(a[2]=0);break}}break}case"gs":{e==0&&s<5?a[2]=0:e>125&&s<5&&s!=2&&(a[2]=e,a[0]=0);break}case"g2":case"sd":{(e>>1==40||e>95&&e<100)&&(a[2]|=16);break}case"sg":{e==8&&s==0&&(a[2]=5);break}case"s90es":{s<8?a[2]+=17:s<32?a[2]+=13:a[2]=(a[2]>>3)+19;break}case"motif":{s<8?a[2]+=28:s<32?a[2]+=13:a[2]=(a[2]>>3)+19;break}}let o=" ",c="M",u=0,f=0;switch(a[0]){case 0:{a[2]==127?c="MT-a":a[2]==126?c="MT-b":a[2]==7?c="GM-k":a[2]==5?c="SG-a":a[2]==4?c="SP-l":a[2]==0||i=="gs"&&a[2]<5?c="GM-a":(c="y",u=3);break}case 8:{i=="sg"?c="GM-s":c="r:";break}case 48:{c=`yM${(a[2]>>3).toString().padStart(2,"0")}`,u=1;break}case 56:{c="GM-b";break}case 61:case 120:{c="rDrm";break}case 62:{c="kDrm";break}case 63:{if(a[2]<17){let b=a[2];c=b<10?"kP:":"kC:",c+=b%10}else a[2]<34?c=["Pre1","Pre2","Pre3","Pre4","Usr1","Usr2","DrmP","DrmU","Plg1","Plg2","Plg3","Pre1","Pre2","Pre3","Pre4","Pre5","Pre6"][a[2]-17]:c="Ds";break}case 64:{c="ySFX";break}case 67:{c="DX:S";break}case 80:case 81:case 82:case 83:{c=`Prg${"UABC"[a[0]-80]}`;break}case 88:case 89:case 90:case 91:{c=`Cmb${"UABC"[a[0]-88]}`;break}case 95:{c=`${["DR","PC"][a[2]]}-d`;break}case 96:{c=a[2]==106?"AP-a":a[2]>>4==1?"SDg":"PF",a[2]>63?f=63:a[2]>>4==1&&(f=16),u=3;break}case 97:{c=a[2]>>4==1?"SDa":"VL:",u=3,a[2]>>4==1?f=16:f=112;break}case 98:{c=a[2]>>4==1?"SDb":"SG-a",u=3,f=16;break}case 99:{c=a[2]>>4==1?"SDc":"DX",a[2]>63?f=63:a[2]>>4==1&&(f=16),u=3;break}case 100:{c="AN",a[2]>63?f=63:a[2]>>4==1&&(f=16),u=3;break}case 104:case 105:case 106:case 107:{c="SDd",f=104;break}case 121:{c=`GM-${a[2]?"":"a"}`,u=3;break}case 122:{c="lDrm";break}case 126:{c="yDrS";break}case 127:{a[2]==127?c="rDrm":c="yDrm";break}default:a[0]<48?c="r:":c="M"}c.length<4&&(c+=`${[e,s,a[0],a[2]][u]-f}`.padStart(4-c.length,"0")),i=="xg"&&(e==0?a[2]<100?c=c.replace("y0","y:"):a[2]==125&&(c="y126"):e==16&&(n=`Voice${(a[2]*128+a[1]+1).toString().padStart(3,"0")}`,o=" "));let p=[a[0],a[1],a[2]];for(;!(n?.length>=0);)n=this.#t[a[1]||0][(a[0]<<7)+a[2]],n||(this.strictMode?(n="",o="?"):this.#t[a[1]||0][a[0]<<7]?a[0]==0?(a[2]=0,o="^"):a[2]<1?(a[0]=0,o="*"):(a[2]--,o="^"):e==48?(a[0]=0,a[2]=0,o="!"):e==62?(a[1]--,o=" ",a[1]<1&&!n?.length&&(a[0]=0,o="!")):e<63?a[0]==0?(a[2]=0,o="^"):a[2]<1?(a[0]=0,o="*"):a[2]--:e==80?(n=`PrgU:${t.toString().padStart(3,"0")}`,o="!"):e==88?(n=`CmbU:${t.toString().padStart(3,"0")}`,o="!"):e==121?(n=`GM2Vox0${s}`,o="#"):e==122?(a[1]==32?a[1]==0:a[1]%=7,n=this.#t[a[1]||0][(a[0]<<7)+a[2]],n?o=" ":(n="",o="*")):a[1]==0?(n=`${e.toString().padStart(3,"0")} ${t.toString().padStart(3,"0")} ${s.toString().padStart(3,"0")}`,o="!"):a[0]==0?(a[2]=0,o="^"):a[2]>0?a[2]--:a[1]>0?(a[1]=0,o="!"):(a[0]=0,o="?"));let g=[a[0],a[1],a[2]];(i=="gs"||i=="ns5r")&&o=="^"&&(o=" "),e==127&&o=="^"&&(o=" "),o!=" "&&self.debugMode&&(n="");let d="??";switch(a[0]){case 0:{a[2]==0?d="GM":a[2]==5||a[2]==7?d="KG":a[2]<126?d="XG":a[2]==127&&(d="MT");break}case 32:case 33:case 35:case 36:{a[2]>4?d=["AP","VL","PF","DX","AN"][a[0]-32]:d="GS";break}case 48:{d="MU";break}case 56:{d="AG";break}case 61:case 80:case 83:case 88:case 89:case 91:{d="AI";break}case 62:case 82:case 90:{d="XD";break}case 63:{a[2]<17?d="KR":a[2]<34?d="ES":d="DS";break}case 64:case 126:{d="XG";break}case 67:case 99:{d=a[2]>>4==1?"SD":"DX";break}case 81:{d="RW";break}case 95:{d=["DR","PC"][a[2]];break}case 96:{d=a[2]==106?"AP":a[2]>>4==1?"SD":"PF";break}case 97:{d=a[2]>>4==1?"SD":"VL";break}case 98:{d=a[2]>>4==1?"SD":"SG";break}case 100:{d="AN";break}case 104:case 105:case 106:case 107:{d="SD";break}case 120:{d="GS";break}case 121:{d=a[2]?"G2":"GM";break}case 122:{d="KG";break}case 127:{d=a[2]==127?"MT":t==0?"GM":"XG";break}default:a[0]<48&&(a[0]==16&&i=="xg"?d="XG":d="GS")}return{name:n||`${O(e||0)} ${O(t||0)} ${O(s||0)}`,iid:p,eid:g,sid:r,ending:o,sect:c,standard:d}}async load(e,t,s){let i=this,r=[],n=0,a=0;e.split(` -`).forEach(function(o,c){let u=o.split(" "),f=[];c==0?u.forEach(function(p,g){r[W.indexOf(p)]=g}):u.forEach(async function(p,g){g>2?(i.#t[f[r[1]]]=i.#t[f[r[1]]]||[],(!i.#t[f[r[1]]][(f[r[0]]<<7)+f[r[2]]]?.length||t)&&(i.#t[f[r[1]]][(f[r[0]]<<7)+f[r[2]]]=u[3],n++),a++):f.push(parseInt(u[g]))})}),t||console.debug(`Map "${s||"(internal)"}": ${a} total, ${n} loaded.`)}clearRange(e){let t=e.prg!=null?e.prg.constructor==Array?e.prg:[e.prg,e.prg]:[0,127],s=e.msb!=null?e.msb.constructor==Array?e.msb:[e.msb,e.msb]:[0,127],i=e.lsb!=null?e.lsb.constructor==Array?e.lsb:[e.lsb,e.lsb]:[0,127];for(let r=s[0];r<=s[1];r++){let n=r<<7;for(let a=i[0];a<=i[1];a++){let o=n+a;for(let c=t[0];c<=t[1];c++)delete this.#t[c][o]}}}init(){this.#t=[];for(let e=0;e<128;e++)this.#t.push([""])}async loadFiles(...e){this.init();let t=this;e.forEach(async function(s,i){try{await fetch(`./data/bank/${s}.tsv`).then(function(r){return r.text()}).then(r=>{t.load(r,!1,s)})}catch{console.error(`Failed loading "${s}.tsv".`)}})}constructor(...e){this.loadFiles(...e)}};var w=["?","gm","gs","xg","g2","mt32","ns5r","ag10","x5d","05rw","krs","k11","sg"],G=[[0,0,0,0,121,0,0,56,82,81,63,0,0],[0,0,4,0,0,127,0,0,0,0,0,0,0]],v=[120,127,120,127,120,127,61,62,62,62,120,122,122],J=[0,3,81,84,88],B={8:"Off",9:"On",10:"Note aftertouch",11:"cc",12:"pc",13:"Channel aftertouch",14:"Pitch"},D={0:0,1:1,2:3,5:4},H=[[0,24],[0,127],[0,127],[40,88],[0,127],[0,127]],I=[36,37];var A=[0,1,2,4,5,6,7,8,10,11,32,38,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,84,91,92,93,94,95,98,99,100,101,12,13,16,17,18,19],Z=[33,99,100,32,102,8,9,10];var E={};w.forEach((e,t)=>{E[e]=t});var h={length:A.length};A.forEach((e,t)=>{h[e]=t});var k=function(){return!!self.Bun||self.debugMode||!1},j=function(e){let t=[],s=0;return e?.forEach(function(i,r){i==247?t.push(e.subarray(s,r)):i==240&&(s=r+1)}),t.length||t.push(e.subarray(0)),k(),t},_=function(e,t="",s="",i=2){return e?`${t}${e.toString().padStart(i,"0")}${s}`:""},l={ch:128,cc:A.length,nn:128,pl:512,tr:256,cmt:14,rpn:6},Fe=class extends M{#t=0;#w=0;#b=0;#g=new Array(11);get#h(){return this.#g[this.#w]}set#h(e){this.#g[this.#w]=e}#y=new Uint8Array(l.ch);#B=new Uint8Array(l.ch);#e=new Uint8ClampedArray(l.ch*l.cc);#$=new Uint8ClampedArray(l.ch);#o=new Uint8ClampedArray(l.ch*l.nn);#D=new Uint8Array(l.ch);#n=new Uint16Array(l.pl);#f=new Uint8Array(l.pl);#C=new Int16Array(l.ch);#d=new Uint8Array(l.ch);#x=0;#l=new Uint8Array(l.ch*l.rpn);#A=new Int8Array(l.ch*I.length);#U=new Uint8Array(l.ch);#V=new Uint8Array(128);#H=new Uint8Array(l.cmt*8);#F=new Uint8Array(1024);#I=new Uint8Array(l.cmt*64);#k=0;#u=0;#M=100;#m=0;#_=500;#z=0;#i="";#p=0;#q=0;#Q=!0;#a=!1;#X;#Y=new Uint8Array(2);#s=[];#E=new Uint8Array(l.ch);#v=new Uint8Array(l.tr);baseBank=new x("gm","gm2","xg","gs","ns5r","gmega","plg-150vl","plg-150pf","plg-150dx","plg-150an","plg-150dr","plg-100sg","kross");userBank=new x("gm");initOnReset=!1;chRedir(e,t,s){if(this.#v[t])return(this.#v[t]-1)*16+e;if([E.gs,E.ns5r].indexOf(this.#t)>-1){if(s==1)return e;let i=0,r=!0;for(;r;)this.#E[e+i]==0?(this.#E[e+i]=t,console.debug(`Assign track ${t} to channel ${e+i+1}.`),r=!1):this.#E[e+i]==t?r=!1:(i+=16,i>=128&&(i=0,r=!1));return e+i}else return e}#c=[];#T;#r={nOff:(e,t)=>{let s=e*128+t,i=this.#n.lastIndexOf(s);i>-1&&(this.#e[l.cc*e+h[64]]>63&&!this.config?.disableCc64?this.#f[i]=4:(this.#n[i]=0,this.#o[s]=0,this.#f[i]=0))},nOn:(e,t,s)=>{let i=e*128+t,r=0;for(this.#D[e]&&this.#r.ano(e);this.#f[r]>0&&this.#n[r]!=i;)r++;r{},cAt:(e,t)=>{},hoOf:e=>{this.#f.forEach((t,s)=>{if(t==4){let i=this.#n[s],r=i>>7;e==r&&(this.#f[s]=0,this.#n[s]=0,this.#o[i]=0)}})},soOf:e=>{},ano:e=>{this.#n.forEach((t,s,i)=>{let r=t>>7,n=t&127;t==0&&this.#o[0]==0||r==e&&this.#r.nOff(r,n)})}};#K={8:function(e){let t=e.channel,s=e.data[0];this.#r.nOff(t,s)},9:function(e){let t=e.channel;this.#y[t]=1;let s=e.data[0],i=e.data[1];i>0?this.#r.nOn(t,s,i):this.#r.nOff(t,s)},10:function(e){let s=e.channel*128+e.data[0];this.#n.indexOf(s)>-1&&(this.#o[s]=data[1])},11:function(e){let t=e.channel;this.#y[t]=1;let s=t*l.cc;switch(e.data[0]){case 96:return;case 97:return;case 120:return;case 121:{this.#r.ano(t),this.#C[t]=0;let i=t*l.cc;this.#e[i+h[1]]=0,this.#e[i+h[5]]=0,this.#e[i+h[64]]=0,this.#e[i+h[65]]=0,this.#e[i+h[66]]=0,this.#e[i+h[67]]=0,this.#e[i+h[11]]=127,this.#e[i+h[101]]=127,this.#e[i+h[100]]=127,this.#e[i+h[99]]=127,this.#e[i+h[98]]=127;return}case 123:{this.#r.ano(t);return}case 124:{this.#r.ano(t);return}case 125:{this.#r.ano(t);return}case 126:{this.#D[t]=1,this.#r.ano(t);return}case 127:{this.#D[t]=0,this.#r.ano(t);return}}if(h[e.data[0]]==null)console.warn(`cc${e.data[0]} is not accepted.`);else{switch(e.data[0]){case 0:{if(k()&&console.debug(`${w[this.#t]}, CH${t+1}: ${e.data[1]}`),this.#t==0)e.data[1]<48?(this.#e[s]>119&&(e.data[1]=this.#e[s],e.data[1]=120,console.debug(`Forced channel ${t+1} to stay drums.`)),e.data[1]>0&&(console.debug(`Roland GS detected with MSB: ${e.data[1]}`),this.switchMode("gs"))):e.data[1]==62?this.switchMode("x5d"):e.data[1]==63?this.switchMode("krs"):(e.data[1]==64||e.data[1]==127)&&this.switchMode("xg");else if(this.#t==E.gs)e.data[1]<56&&this.#e[s]>119&&(e.data[1]=this.#e[s],e.data[1]=120,console.debug(`Forced channel ${t+1} to stay drums.`));else if(this.#t==E.gm)e.data[1]<48?this.#e[s]>119&&(e.data[1]=120,this.switchMode("gs",!0),console.debug(`Forced channel ${t+1} to stay drums.`)):(e.data[1]==64||e.data[1]==127)&&this.switchMode("xg",!0);else if(this.#t==E.x5d){if(e.data[1]>0&&e.data[1]<8)this.switchMode("05rw",!0);else if(e.data[1]==56){let i=0;for(let r=0;r<16;r++){let n=this.#e[l.cc*r];(n==56||n==62)&&i++}i>14&&this.switchMode("ag10",!0)}}break}case 6:{if(this.#x){let i=this.#e[s+h[99]],r=this.#e[s+h[98]];if(i==1){let n=Z.indexOf(r);if(n>-1)this.#e[s+h[71+n]]=e.data[1],k()&&console.debug(`Redirected NRPN 1 ${r} to cc${71+n}.`);else{let a=I.indexOf(r);a>-1&&(this.#A[t*10+a]=e.data[1]-64),k()&&console.debug(`CH${t+1} voice NRPN ${r} commit`)}}}else{let i=D[this.#e[s+h[100]]];this.#e[s+h[101]]==0&&i!=null&&(k()&&console.debug(`CH${t+1} RPN 0 ${this.#e[s+h[100]]} commit: ${e.data[1]}`),e.data[1]=Math.min(Math.max(e.data[1],H[i][0]),H[i][1]),this.#l[t*l.rpn+i]=e.data[1])}break}case 38:{this.#x||this.#e[s+101]==0&&D[this.#e[s+100]]!=null&&(this.#l[t*l.rpn+D[this.#e[s+100]]+1]=e.data[1]);break}case 64:{e.data[1]<64&&this.#r.hoOf(t);break}case 66:{console.debug(`Sostenuto pedal: ${e.data[1]}`);break}case 98:case 99:{this.#x=1;break}case 100:case 101:{this.#x=0;break}}this.#e[s+h[e.data[0]]]=e.data[1]}},12:function(e){let t=e.channel;this.#y[t]=1,this.#$[t]=e.data,this.#U[t]=0,k()&&console.debug(`T:${e.track} C:${t} P:${e.data}`)},13:function(e){let t=this,s=e.channel;this.#n.forEach(function(i){let r=i>>7;s==r&&(t.#o[i]=e.data)})},14:function(e){let t=e.channel;this.#C[t]=e.data[1]*128+e.data[0]-8192},15:function(e){j(e.data).forEach(t=>{let s=t[0],i=t[1];(this.#W[s]||function(){console.debug(`Unknown manufacturer ${s}.`)})(i,t.subarray(2),e.track)})},248:function(e){},250:function(e){},251:function(e){},252:function(e){},254:function(e){},255:function(e){if((this.#c[e.meta]||function(s,i,r){}).call(this,e.data,e.track,e.meta),e.meta!=32&&(this.#m=0),J.indexOf(e.meta)>-1)return e.reply="meta",e;k()&&console.debug(e)}};#W={64:(e,t,s)=>{this.#L.run(t,s,e)},65:(e,t,s)=>{if(t[0]<16)this.#S.run(t,s,e),console.warn("Unknown device SysEx!");else{let i=t[t.length-1],r=gsChecksum(t.subarray(2,t.length-1));i==r?this.#S.run(t.subarray(0,t.length-1),s,e):console.warn(`Bad GS checksum ${i}. Should be ${r}.`)}},66:(e,t,s)=>{this.#O.run(t,s,e)},67:(e,t,s)=>{this.#R.run(t,s,e)},68:(e,t,s)=>{this.#J.run(t,s,e)},71:(e,t,s)=>{this.#G.run(t,s,e)},126:(e,t,s)=>{this.#P.run(t,s,e)},127:(e,t,s)=>{this.switchMode("gm"),this.#N.run(t,s,e)}};#P;#N;#R;#S;#O;#L;#G;#J;buildRchTree(){let e=[];this.#B.forEach((t,s)=>{e[t]?.constructor||(e[t]=[]),e[t].push(s)}),this.#X=e}getActive(){let e=this.#y.slice();return this.#t==E.mt32,e}getCc(e){let t=e*l.cc,s=this.#e.slice(t,t+l.cc);return s[h[0]]=s[h[0]]||this.#k,s[h[32]]=s[h[32]]||this.#u,s}getCcAll(){let e=this.#e.slice();for(let t=0;t0&&t.set(a,{v:s.#o[i],s:s.#f[r]})}),t}getBitmap(){return{bitmap:this.#h,expire:this.#b}}getLetter(){return{text:this.#i,expire:this.#p}}getMode(){return w[this.#t]}getMaster(){return{volume:this.#M}}getRawStrength(){let e=this;return this.#n.forEach(function(t){let s=Math.floor(t/128);e.#o[t]>e.#d[s]&&(e.#d[s]=e.#o[t])}),this.#d}getStrength(){let e=[],t=this;return this.getRawStrength().forEach(function(s,i){e[i]=Math.floor(s*t.#e[i*l.cc+h[7]]*t.#e[i*l.cc+h[11]]*t.#M/803288)}),e}getRpn(){return this.#l}getNrpn(){return this.#A}getVoice(e,t,s,i){let r=e||this.#k,n=t,a=s||this.#u;w[this.#t]=="ns5r"&&r>0&&r<56&&(a=3);let o=this.userBank.get(r,n,a,i);if(w[this.#t]=="mt32"&&o.name.indexOf("MT-m:")==0){let c=parseInt(o.name.slice(5)),u=c*l.cmt,f="";this.#I.subarray(u,u+10).forEach(p=>{p>31&&(f+=String.fromCharCode(p))}),this.userBank.load(`MSB LSB PRG -0 127 ${n} ${f}`,!0),o.name=f,o.ending=" "}return(o.ending!=" "||!o.name.length)&&(o=this.baseBank.get(r,n,a,i)),o}getChVoice(e){let t=this.getVoice(this.#e[e*l.cc+h[0]],this.#$[e],this.#e[e*l.cc+h[32]],w[this.#t]);if(this.#U[e])switch(this.#t){case E.mt32:t.ending="~",t.name="",this.#H.subarray(14*(e-1),14*(e-1)+10).forEach(s=>{s>31&&(t.name+=String.fromCharCode(s))})}return t}init(e=0){this.dispatchEvent("mode","?"),this.#t=0,this.#k=0,this.#u=0,this.#m=0,this.#y.fill(0),this.#e.fill(0),this.#$.fill(0),this.#o.fill(0),this.#n.fill(0),this.#d.fill(0),this.#C.fill(0),this.#A.fill(0),this.#M=100,this.#s=[],this.#_=500,this.#z=0,this.#p=0,this.#i="",this.#b=0,this.#w=0,this.#h.fill(0),this.#a=!1,this.#q=0,this.#Q=!0,this.#B.forEach(function(t,s,i){i[s]=s}),this.buildRchTree(),e==0&&(this.#E.fill(0),this.#v.fill(0)),this.#e[l.cc*9]=v[0],this.#e[l.cc*25]=v[0],this.#e[l.cc*41]=v[0],this.#e[l.cc*57]=v[0],this.#Y.fill(0),this.#F.fill(0),this.#I.fill(0),this.#V.fill(0),this.#H.fill(0),this.#U.fill(0),this.userBank.clearRange({msb:0,lsb:127,prg:[0,127]});for(let t=0;t-1){if(this.#t==0||t){this.#t=s,this.#w=0,this.#k=G[0][s],this.#u=G[1][s];for(let i=0;i-1&&(this.#e[i*l.cc]=v[s]);switch(this.initOnReset,s){case E.mt32:{mt32DefProg.forEach((i,r)=>{let n=r+1;this.#y[n]||(this.#$[n]=i,this.#e[n*l.cc+h[91]]=127)});break}}this.dispatchEvent("mode",e)}}else throw new Error(`Unknown mode ${e}`)}newStrength(){this.#d.fill(0)}runJson(e){if(e.type>14)return e.type==15&&e.data.constructor!=Uint8Array&&(e.data=Uint8Array.from(e.data)),this.#K[e.type].call(this,e);{let t=this.chRedir(e.part,e.track),s=!1;this.#X[t]?.forEach(i=>{e.channel=i,s=!0,this.#K[e.type].call(this,e)}),s||console.warn(`${B[e.type]?B[e.type]:e.type}${[11,12].includes(e.type)?(e.data[0]!=null?e.data[0]:e.data).toString():""} event sent to CH${t+1} without any recipient.`)}this.#s.length>100&&this.#s.splice(100,this.#s.length-99)}runRaw(e){}constructor(){super();let e=this;this.#h=new Uint8Array(256),this.#g[10]=new Uint8Array(512),this.#T=new m,this.userBank.strictMode=!0,this.userBank.load(`MSB PRG LSB NME +`).forEach(e=>{let t=e.split(",");Q[t[0]]=t[1]});var Y=["?","gm","gs","xg","g2","mt32","ns5r","x5d","05rw","sd","k11","sg","krs","s90es","motif"],W=["melodic","drum","menu"];var R=[20,21,22,23,24,25,26,28,29,30,31,36,37,48,49,52,53,64,65];var O=[0,1,2,4,5,6,7,8,10,11,32,38,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,84,91,92,93,94,95,98,99,100,101,128,12,13,16,17,18,19,14,15,20,21,26,28];var J={};Y.forEach((e,t)=>{J[e]=t});var Z={length:O.length};O.forEach((e,t)=>{Z[e]=t});var j={length:R.length};R.forEach((e,t)=>{j[e]=t});var ee={};W.forEach((e,t)=>{ee[e]=t});var _e={ch:128,cc:O.length,nn:128,pl:512,tr:256,cmt:14,rpn:6,rpnt:4,ace:8,drm:8,dpn:R.length,dnc:128,efx:7};var te=["MSB","PRG","LSB","NME","ELC","DRM"],D=function(e){let t=Math.floor(e/10),a=e%10;return`${t.toString(16)}${a}`},M=class{#t;strictMode=!1;get(e=0,t=0,a=0,s){let r=[e,t,a],n,l=1,u=0,p,i=Array.from(arguments);switch(s){case"xg":{switch(e){case 0:{a==126?i[2]=125:a==127&&(i[2]=0);break}case 16:{a==126&&(i[2]=0);break}case 32:{a>125&&(i[2]=0),i[2]+=4;break}case 33:case 34:case 35:case 36:{a>125&&(i[2]=0),i[2]+=5;break}case 79:case 80:case 81:case 82:case 83:case 84:i[0]+=16;case 95:case 96:case 97:case 98:case 99:case 100:{a==126&&(i[2]=0);break}case 48:case 64:case 126:case 127:{a==126&&(i[2]=0);break}}break}case"gs":{e==0&&a<5?i[2]=0:e>125&&a<5&&a!=2&&(i[2]=e,i[0]=0);break}case"g2":case"sd":{(e>>1==40||e>95&&e<100)&&(i[2]|=16);break}case"sg":{e==8&&a==0&&(i[2]=5);break}case"s90es":{a<8?i[2]+=17:a<32?i[2]+=13:i[2]=(i[2]>>3)+19;break}case"motif":{a<8?i[2]+=28:a<32?i[2]+=13:i[2]=(i[2]>>3)+19;break}}let h=" ",c="M",b=0,g=0;switch(i[0]){case 0:{i[2]==127?c="MT-a":i[2]==126?c="MT-b":i[2]==7?c="GM-k":i[2]==5?c="SG-a":i[2]==4?c="SP-l":i[2]==0||s=="gs"&&i[2]<5?c="GM-a":(c="y",b=3);break}case 8:{s=="sg"?c="GM-s":c="r:";break}case 32:case 33:case 34:case 35:case 36:{s=="xg"&&(c=`${["AP","VL","PF","DX","AN"][e&7]}-${"abcdefgh"[a]}`);break}case 48:{c=`yM${(i[2]>>3).toString().padStart(2,"0")}`,b=1;break}case 56:{c="GM-b";break}case 61:case 120:{c="rDrm";break}case 62:{c="kDrm";break}case 63:{if(i[2]<17){let $=i[2];c=$<10?"kP:":"kC:",c+=$%10}else i[2]<34?c=["Pre1","Pre2","Pre3","Pre4","Usr1","Usr2","DrmP","DrmU","Plg1","Plg2","Plg3","Pre1","Pre2","Pre3","Pre4","Pre5","Pre6"][i[2]-17]:c="Ds";break}case 64:{c="ySFX";break}case 67:{c="DX:S";break}case 80:case 81:case 82:case 83:{c=`Prg${"UABC"[i[0]-80]}`;break}case 88:case 89:case 90:case 91:{c=`Cmb${"UABC"[i[0]-88]}`;break}case 95:{c=`${["DR","PC"][i[2]]}-d`;break}case 96:{c=i[2]==106?"AP-a":i[2]>>4==1?"SDg":"PF",i[2]>63?g=63:i[2]>>4==1&&(g=16),b=3;break}case 97:{c=i[2]>>4==1?"SDa":"VL:",b=3,i[2]>>4==1?g=16:g=112;break}case 98:{c=i[2]>>4==1?"SDb":"SG-a",b=3,g=16;break}case 99:{c=i[2]>>4==1?"SDc":"DX",i[2]>63?g=63:i[2]>>4==1&&(g=16),b=3;break}case 100:{c="AN",i[2]>63?g=63:i[2]>>4==1&&(g=16),b=3;break}case 104:case 105:case 106:case 107:{c="SDd",g=104;break}case 121:{c=`GM-${i[2]?"":"a"}`,b=3;break}case 122:{c="lDrm";break}case 126:{c="yDrS";break}case 127:{i[2]==127?c="rDrm":c="yDrm";break}default:i[0]<48?c="r:":c="M"}c.length<4&&(c+=`${[e,a,i[0],i[2]][b]-g}`.padStart(4-c.length,"0")),s=="xg"&&(e==0?i[2]<100?c=c.replace("y0","y:"):i[2]==125&&(c="y126"):e==16&&(n=`Voice${(i[2]*128+i[1]+1).toString().padStart(3,"0")}`,h=" "));let y=[i[0],i[1],i[2]];for(;!(n?.length>=0);)if(n=this.#t[i[1]||0][(i[0]<<7)+i[2]]?.name,n){let $=this.#t[i[1]||0][(i[0]<<7)+i[2]];l=$?.poly||l,u=$?.type||u,p=$?.drum}else if(this.strictMode)n="",h="?";else if(i[0]==0&&i[1]==0&&i[2]==0)n="Unloaded";else if(this.#t[i[1]||0][i[0]<<7])i[0]==0?(i[2]=0,h="^"):i[2]<1?(i[0]=0,h="*"):(i[2]--,h="^");else if(e==48)i[0]=0,i[2]=0,h="!";else if(e==62)i[1]--,h=" ",i[1]<1&&!n?.length&&(i[0]=0,h="!");else if(e<63)i[0]==0?(i[2]=0,h="^"):i[2]<1?(i[0]=0,h="*"):i[2]--;else if(e==80)n=`PrgU:${t.toString().padStart(3,"0")}`,h="!";else if(e==88)n=`CmbU:${t.toString().padStart(3,"0")}`,h="!";else if(e==121)n=`GM2Vox0${a}`,h="#";else if(e==122)if(i[1]==32?i[1]==0:i[1]%=7,n=this.#t[i[1]||0][(i[0]<<7)+i[2]]?.name,n){h=" ";let $=this.#t[i[1]||0][(i[0]<<7)+i[2]];l=$?.poly||l,u=$?.type||u,p=$?.drum}else n="",h="*";else i[1]==0?(n=`${e.toString().padStart(3,"0")} ${t.toString().padStart(3,"0")} ${a.toString().padStart(3,"0")}`,h="!"):i[0]==0?(i[2]=0,h="^"):i[2]>0?i[2]--:i[1]>0?(i[1]=0,h="!"):(i[0]=0,h="?");let m=[i[0],i[1],i[2]];(s=="gs"||s=="ns5r")&&h=="^"&&(h=" "),e==127&&h=="^"&&(h=" "),h!=" "&&self.debugMode&&(n="");let d="??";switch(i[0]){case 0:{i[2]==0?d="GM":i[2]==5||i[2]==7?d="KG":i[2]<126?d="XG":i[2]==127&&(d="MT");break}case 32:case 33:case 35:case 36:{i[2]>4?d=["AP","VL","PF","DX","AN"][i[0]-32]:d="GS";break}case 48:{d="MU";break}case 56:{d="AG";break}case 61:case 80:case 83:case 88:case 89:case 91:{d="AI";break}case 62:case 82:case 90:{d="XD";break}case 63:{i[2]<17?d="KR":i[2]<34?d="ES":d="DS";break}case 64:case 126:{d="XG";break}case 67:case 99:{d=i[2]>>4==1?"SD":"DX";break}case 81:{d="RW";break}case 95:{d=["DR","PC"][i[2]];break}case 96:{d=i[2]==106?"AP":i[2]>>4==1?"SD":"PF";break}case 97:{d=i[2]>>4==1?"SD":"VL";break}case 98:{d=i[2]>>4==1?"SD":"SG";break}case 100:{d="AN";break}case 104:case 105:case 106:case 107:{d="SD";break}case 120:{d="GS";break}case 121:{d=i[2]?"G2":"GM";break}case 122:{d="KG";break}case 127:{d=i[2]==127?"MT":t==0?"GM":"XG";break}default:i[0]<48&&(i[0]==16&&s=="xg"?d="XG":d="GS")}return{name:n||`${D(e||0)} ${D(t||0)} ${D(a||0)}`,poly:l,type:u,drum:p,iid:y,eid:m,sid:r,ending:h,sect:c,standard:d}}async load(e,t,a="(internal)"){let s=this,r=[],n=0,l=0;e.split(` +`).forEach(function(u,p){let i=u.split(" "),h=[];if(p==0){if(i.forEach(function(c,b){r[te.indexOf(c)]=b}),r.length<4){console.debug("Debugger launched.");debugger}}else{let c=0,b=0,g=0,y,m=1,d=0,$;i.forEach(async function(E,V){switch(V){case r[0]:{c=parseInt(E);break}case r[1]:{b=parseInt(E);break}case r[2]:{g=parseInt(E);break}case r[3]:{y=E;break}case r[4]:{E=parseInt(E),E<16?m=E+1:d=(E&15)+1;break}case r[5]:{$=E;break}}}),s.#t[b]=s.#t[b]||[];let P=s.#t[b];if(!P[c<<7|g]||t){let E={msb:c,prg:b,lsb:g,name:y,poly:m,type:d,drum:$};P[c<<7|g]=E,n++}l++}}),t||console.debug(`Map "${a}": ${l} total, ${n} loaded.`)}clearRange(e){let t=e.prg!=null?e.prg.constructor==Array?e.prg:[e.prg,e.prg]:[0,127],a=e.msb!=null?e.msb.constructor==Array?e.msb:[e.msb,e.msb]:[0,127],s=e.lsb!=null?e.lsb.constructor==Array?e.lsb:[e.lsb,e.lsb]:[0,127];for(let r=a[0];r<=a[1];r++){let n=r<<7;for(let l=s[0];l<=s[1];l++){let u=n+l;for(let p=t[0];p<=t[1];p++)delete this.#t[p][u]}}}init(){this.#t=[];for(let e=0;e<128;e++)this.#t.push([""])}async loadFiles(...e){this.init();let t=this;e.forEach(async function(a){try{await fetch(`./data/bank/${a}.tsv`).then(function(s){return s.text()}).then(s=>{t.load(s,!1,a)})}catch{console.error(`Failed loading "${a}.tsv".`)}})}constructor(...e){this.loadFiles(...e)}};var v=["?","gm","gs","xg","g2","mt32","ns5r","ag10","x5d","05rw","krs","k11","sg"],H=[[0,0,0,0,121,0,0,56,82,81,63,0,0],[0,0,4,0,0,127,0,0,0,0,0,0,0]],C=[120,127,120,127,120,127,61,62,62,62,120,122,122],ae=[0,3,81,84,88],B={8:"Off",9:"On",10:"Note aftertouch",11:"cc",12:"pc",13:"Channel aftertouch",14:"Pitch"},A={0:0,1:1,2:3,5:4},_=[[0,24],[0,127],[0,127],[40,88],[0,127],[0,127]],X=[36,37];var U=[0,1,2,4,5,6,7,8,10,11,32,38,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,84,91,92,93,94,95,98,99,100,101,12,13,16,17,18,19],se=[33,99,100,32,102,8,9,10];var k={};v.forEach((e,t)=>{k[e]=t});var f={length:U.length};U.forEach((e,t)=>{f[e]=t});var S=function(){return!!self.Bun||self.debugMode||!1},ie=function(e){let t=[],a=0;return e?.forEach(function(s,r){s==247?t.push(e.subarray(a,r)):s==240&&(a=r+1)}),t.length||t.push(e.subarray(0)),S(),t},K=function(e,t="",a="",s=2){return e?`${t}${e.toString().padStart(s,"0")}${a}`:""},o={ch:128,cc:U.length,nn:128,pl:512,tr:256,cmt:14,rpn:6},We=class extends T{#t=0;#w=0;#b=0;#g=new Array(11);get#h(){return this.#g[this.#w]}set#h(e){this.#g[this.#w]=e}#y=new Uint8Array(o.ch);#G=new Uint8Array(o.ch);#e=new Uint8ClampedArray(o.ch*o.cc);#$=new Uint8ClampedArray(o.ch);#o=new Uint8ClampedArray(o.ch*o.nn);#D=new Uint8Array(o.ch);#n=new Uint16Array(o.pl);#f=new Uint8Array(o.pl);#C=new Int16Array(o.ch);#d=new Uint8Array(o.ch);#x=0;#l=new Uint8Array(o.ch*o.rpn);#A=new Int8Array(o.ch*X.length);#U=new Uint8Array(o.ch);#V=new Uint8Array(128);#H=new Uint8Array(o.cmt*8);#F=new Uint8Array(1024);#B=new Uint8Array(o.cmt*64);#k=0;#u=0;#M=100;#m=0;#_=500;#z=0;#i="";#p=0;#q=0;#Q=!0;#s=!1;#X;#Y=new Uint8Array(2);#a=[];#E=new Uint8Array(o.ch);#v=new Uint8Array(o.tr);baseBank=new M("gm","gm2","xg","gs","ns5r","gmega","plg-150vl","plg-150pf","plg-150dx","plg-150an","plg-150dr","plg-100sg","kross");userBank=new M("gm");initOnReset=!1;chRedir(e,t,a){if(this.#v[t])return(this.#v[t]-1)*16+e;if([k.gs,k.ns5r].indexOf(this.#t)>-1){if(a==1)return e;let s=0,r=!0;for(;r;)this.#E[e+s]==0?(this.#E[e+s]=t,console.debug(`Assign track ${t} to channel ${e+s+1}.`),r=!1):this.#E[e+s]==t?r=!1:(s+=16,s>=128&&(s=0,r=!1));return e+s}else return e}#c=[];#T;#r={nOff:(e,t)=>{let a=e*128+t,s=this.#n.lastIndexOf(a);s>-1&&(this.#e[o.cc*e+f[64]]>63&&!this.config?.disableCc64?this.#f[s]=4:(this.#n[s]=0,this.#o[a]=0,this.#f[s]=0))},nOn:(e,t,a)=>{let s=e*128+t,r=0;for(this.#D[e]&&this.#r.ano(e);this.#f[r]>0&&this.#n[r]!=s;)r++;r{},cAt:(e,t)=>{},hoOf:e=>{this.#f.forEach((t,a)=>{if(t==4){let s=this.#n[a],r=s>>7;e==r&&(this.#f[a]=0,this.#n[a]=0,this.#o[s]=0)}})},soOf:e=>{},ano:e=>{this.#n.forEach((t,a,s)=>{let r=t>>7,n=t&127;t==0&&this.#o[0]==0||r==e&&this.#r.nOff(r,n)})}};#K={8:function(e){let t=e.channel,a=e.data[0];this.#r.nOff(t,a)},9:function(e){let t=e.channel;this.#y[t]=1;let a=e.data[0],s=e.data[1];s>0?this.#r.nOn(t,a,s):this.#r.nOff(t,a)},10:function(e){let a=e.channel*128+e.data[0];this.#n.indexOf(a)>-1&&(this.#o[a]=data[1])},11:function(e){let t=e.channel;this.#y[t]=1;let a=t*o.cc;switch(e.data[0]){case 96:return;case 97:return;case 120:return;case 121:{this.#r.ano(t),this.#C[t]=0;let s=t*o.cc;this.#e[s+f[1]]=0,this.#e[s+f[5]]=0,this.#e[s+f[64]]=0,this.#e[s+f[65]]=0,this.#e[s+f[66]]=0,this.#e[s+f[67]]=0,this.#e[s+f[11]]=127,this.#e[s+f[101]]=127,this.#e[s+f[100]]=127,this.#e[s+f[99]]=127,this.#e[s+f[98]]=127;return}case 123:{this.#r.ano(t);return}case 124:{this.#r.ano(t);return}case 125:{this.#r.ano(t);return}case 126:{this.#D[t]=1,this.#r.ano(t);return}case 127:{this.#D[t]=0,this.#r.ano(t);return}}if(f[e.data[0]]==null)console.warn(`cc${e.data[0]} is not accepted.`);else{switch(e.data[0]){case 0:{if(S()&&console.debug(`${v[this.#t]}, CH${t+1}: ${e.data[1]}`),this.#t==0)e.data[1]<48?(this.#e[a]>119&&(e.data[1]=this.#e[a],e.data[1]=120,console.debug(`Forced channel ${t+1} to stay drums.`)),e.data[1]>0&&(console.debug(`Roland GS detected with MSB: ${e.data[1]}`),this.switchMode("gs"))):e.data[1]==62?this.switchMode("x5d"):e.data[1]==63?this.switchMode("krs"):(e.data[1]==64||e.data[1]==127)&&this.switchMode("xg");else if(this.#t==k.gs)e.data[1]<56&&this.#e[a]>119&&(e.data[1]=this.#e[a],e.data[1]=120,console.debug(`Forced channel ${t+1} to stay drums.`));else if(this.#t==k.gm)e.data[1]<48?this.#e[a]>119&&(e.data[1]=120,this.switchMode("gs",!0),console.debug(`Forced channel ${t+1} to stay drums.`)):(e.data[1]==64||e.data[1]==127)&&this.switchMode("xg",!0);else if(this.#t==k.x5d){if(e.data[1]>0&&e.data[1]<8)this.switchMode("05rw",!0);else if(e.data[1]==56){let s=0;for(let r=0;r<16;r++){let n=this.#e[o.cc*r];(n==56||n==62)&&s++}s>14&&this.switchMode("ag10",!0)}}break}case 6:{if(this.#x){let s=this.#e[a+f[99]],r=this.#e[a+f[98]];if(s==1){let n=se.indexOf(r);if(n>-1)this.#e[a+f[71+n]]=e.data[1],S()&&console.debug(`Redirected NRPN 1 ${r} to cc${71+n}.`);else{let l=X.indexOf(r);l>-1&&(this.#A[t*10+l]=e.data[1]-64),S()&&console.debug(`CH${t+1} voice NRPN ${r} commit`)}}}else{let s=A[this.#e[a+f[100]]];this.#e[a+f[101]]==0&&s!=null&&(S()&&console.debug(`CH${t+1} RPN 0 ${this.#e[a+f[100]]} commit: ${e.data[1]}`),e.data[1]=Math.min(Math.max(e.data[1],_[s][0]),_[s][1]),this.#l[t*o.rpn+s]=e.data[1])}break}case 38:{this.#x||this.#e[a+101]==0&&A[this.#e[a+100]]!=null&&(this.#l[t*o.rpn+A[this.#e[a+100]]+1]=e.data[1]);break}case 64:{e.data[1]<64&&this.#r.hoOf(t);break}case 66:{console.debug(`Sostenuto pedal: ${e.data[1]}`);break}case 98:case 99:{this.#x=1;break}case 100:case 101:{this.#x=0;break}}this.#e[a+f[e.data[0]]]=e.data[1]}},12:function(e){let t=e.channel;this.#y[t]=1,this.#$[t]=e.data,this.#U[t]=0,S()&&console.debug(`T:${e.track} C:${t} P:${e.data}`)},13:function(e){let t=this,a=e.channel;this.#n.forEach(function(s){let r=s>>7;a==r&&(t.#o[s]=e.data)})},14:function(e){let t=e.channel;this.#C[t]=e.data[1]*128+e.data[0]-8192},15:function(e){ie(e.data).forEach(t=>{let a=t[0],s=t[1];(this.#W[a]||function(){console.debug(`Unknown manufacturer ${a}.`)})(s,t.subarray(2),e.track)})},248:function(e){},250:function(e){},251:function(e){},252:function(e){},254:function(e){},255:function(e){if((this.#c[e.meta]||function(a,s,r){}).call(this,e.data,e.track,e.meta),e.meta!=32&&(this.#m=0),ae.indexOf(e.meta)>-1)return e.reply="meta",e;S()&&console.debug(e)}};#W={64:(e,t,a)=>{this.#L.run(t,a,e)},65:(e,t,a)=>{if(t[0]<16)this.#S.run(t,a,e),console.warn("Unknown device SysEx!");else{let s=t[t.length-1],r=gsChecksum(t.subarray(2,t.length-1));s==r?this.#S.run(t.subarray(0,t.length-1),a,e):console.warn(`Bad GS checksum ${s}. Should be ${r}.`)}},66:(e,t,a)=>{this.#O.run(t,a,e)},67:(e,t,a)=>{this.#R.run(t,a,e)},68:(e,t,a)=>{this.#J.run(t,a,e)},71:(e,t,a)=>{this.#I.run(t,a,e)},126:(e,t,a)=>{this.#P.run(t,a,e)},127:(e,t,a)=>{this.switchMode("gm"),this.#N.run(t,a,e)}};#P;#N;#R;#S;#O;#L;#I;#J;buildRchTree(){let e=[];this.#G.forEach((t,a)=>{e[t]?.constructor||(e[t]=[]),e[t].push(a)}),this.#X=e}getActive(){let e=this.#y.slice();return this.#t==k.mt32,e}getCc(e){let t=e*o.cc,a=this.#e.slice(t,t+o.cc);return a[f[0]]=a[f[0]]||this.#k,a[f[32]]=a[f[32]]||this.#u,a}getCcAll(){let e=this.#e.slice();for(let t=0;t0&&t.set(l,{v:a.#o[s],s:a.#f[r]})}),t}getBitmap(){return{bitmap:this.#h,expire:this.#b}}getLetter(){return{text:this.#i,expire:this.#p}}getMode(){return v[this.#t]}getMaster(){return{volume:this.#M}}getRawStrength(){let e=this;return this.#n.forEach(function(t){let a=Math.floor(t/128);e.#o[t]>e.#d[a]&&(e.#d[a]=e.#o[t])}),this.#d}getStrength(){let e=[],t=this;return this.getRawStrength().forEach(function(a,s){e[s]=Math.floor(a*t.#e[s*o.cc+f[7]]*t.#e[s*o.cc+f[11]]*t.#M/803288)}),e}getRpn(){return this.#l}getNrpn(){return this.#A}getVoice(e,t,a,s){let r=e||this.#k,n=t,l=a||this.#u;v[this.#t]=="ns5r"&&r>0&&r<56&&(l=3);let u=this.userBank.get(r,n,l,s);if(v[this.#t]=="mt32"&&u.name.indexOf("MT-m:")==0){let p=parseInt(u.name.slice(5)),i=p*o.cmt,h="";this.#B.subarray(i,i+10).forEach(c=>{c>31&&(h+=String.fromCharCode(c))}),this.userBank.load(`MSB LSB PRG +0 127 ${n} ${h}`,!0),u.name=h,u.ending=" "}return(u.ending!=" "||!u.name.length)&&(u=this.baseBank.get(r,n,l,s)),u}getChVoice(e){let t=this.getVoice(this.#e[e*o.cc+f[0]],this.#$[e],this.#e[e*o.cc+f[32]],v[this.#t]);if(this.#U[e])switch(this.#t){case k.mt32:t.ending="~",t.name="",this.#H.subarray(14*(e-1),14*(e-1)+10).forEach(a=>{a>31&&(t.name+=String.fromCharCode(a))})}return t}init(e=0){this.dispatchEvent("mode","?"),this.#t=0,this.#k=0,this.#u=0,this.#m=0,this.#y.fill(0),this.#e.fill(0),this.#$.fill(0),this.#o.fill(0),this.#n.fill(0),this.#d.fill(0),this.#C.fill(0),this.#A.fill(0),this.#M=100,this.#a=[],this.#_=500,this.#z=0,this.#p=0,this.#i="",this.#b=0,this.#w=0,this.#h.fill(0),this.#s=!1,this.#q=0,this.#Q=!0,this.#G.forEach(function(t,a,s){s[a]=a}),this.buildRchTree(),e==0&&(this.#E.fill(0),this.#v.fill(0)),this.#e[o.cc*9]=C[0],this.#e[o.cc*25]=C[0],this.#e[o.cc*41]=C[0],this.#e[o.cc*57]=C[0],this.#Y.fill(0),this.#F.fill(0),this.#B.fill(0),this.#V.fill(0),this.#H.fill(0),this.#U.fill(0),this.userBank.clearRange({msb:0,lsb:127,prg:[0,127]});for(let t=0;t-1){if(this.#t==0||t){this.#t=a,this.#w=0,this.#k=H[0][a],this.#u=H[1][a];for(let s=0;s-1&&(this.#e[s*o.cc]=C[a]);switch(this.initOnReset,a){case k.mt32:{mt32DefProg.forEach((s,r)=>{let n=r+1;this.#y[n]||(this.#$[n]=s,this.#e[n*o.cc+f[91]]=127)});break}}this.dispatchEvent("mode",e)}}else throw new Error(`Unknown mode ${e}`)}newStrength(){this.#d.fill(0)}runJson(e){if(e.type>14)return e.type==15&&e.data.constructor!=Uint8Array&&(e.data=Uint8Array.from(e.data)),this.#K[e.type].call(this,e);{let t=this.chRedir(e.part,e.track),a=!1;this.#X[t]?.forEach(s=>{e.channel=s,a=!0,this.#K[e.type].call(this,e)}),a||console.warn(`${B[e.type]?B[e.type]:e.type}${[11,12].includes(e.type)?(e.data[0]!=null?e.data[0]:e.data).toString():""} event sent to CH${t+1} without any recipient.`)}this.#a.length>100&&this.#a.splice(100,this.#a.length-99)}runRaw(e){}constructor(){super();let e=this;this.#h=new Uint8Array(256),this.#g[10]=new Uint8Array(512),this.#T=new w,this.userBank.strictMode=!0,this.userBank.load(`MSB PRG LSB NME 062 000 000 122 000 000 122 001 000 @@ -148,4 +148,4 @@ _,`.split(` 122 003 000 122 004 000 122 005 000 -122 006 000 `),this.#c[1]=function(t){switch(t.slice(0,2)){case"@I":{this.#a=!0,this.#s.unshift(`Kar.Info: ${t.slice(2)}`);break}case"@K":{this.#a=!0,this.#s.unshift("Karaoke mode active."),console.debug(`Karaoke mode active: ${t.slice(2)}`);break}case"@L":{this.#a=!0,this.#s.unshift(`Language: ${t.slice(2)}`);break}case"@T":{this.#a=!0,this.#s.unshift(`Ka.Title: ${t.slice(2)}`);break}case"@V":{this.#a=!0,this.#s.unshift(`Kara.Ver: ${t.slice(2)}`);break}case"XF":{let s=t.slice(2).split(":");switch(s[0]){case"hd":{s.slice(1).forEach((i,r)=>{i.length&&this.#s.unshift(`${["SongDate","SnRegion","SongCat.","SongBeat","SongInst","Sn.Vocal","SongCmp.","SongLrc.","SongArr.","SongPerf","SongPrg.","SongTags"][r]}: ${i}`)});break}case"ln":{s.slice(1).forEach((i,r)=>{i.length&&this.#s.unshift(`${["Kar.Lang","Kar.Name","Kar.Cmp.","Kar.Lrc.","kar.Arr.","Kar.Perf","Kar.Prg."][r]}: ${i}`)});break}default:this.#s.unshift(`XGF_Data: ${t}`)}break}default:this.#a?t[0]=="\\"?this.#s.unshift(`@ ${t.slice(1)}`):t[0]=="/"?this.#s.unshift(t.slice(1)):this.#s[0]+=t:(this.#s[0]=t,this.#s.unshift(""))}},this.#c[2]=function(t){this.#s.unshift(`Copyrite: ${t}`)},this.#c[3]=function(t,s){s<1&&this.#m<1&&this.#s.unshift(`TrkTitle: ${t}`)},this.#c[4]=function(t,s){this.#s.unshift(`${_(this.#m,""," ")}Instrmnt: ${t}`)},this.#c[5]=function(t){t.trim()==""?this.#s.unshift(""):this.#s[0]+=`${t}`},this.#c[6]=function(t){this.#s.unshift(`${_(this.#m,""," ")}C.Marker: ${t}`)},this.#c[7]=function(t){this.#s.unshift(`CuePoint: ${t}`)},this.#c[32]=function(t){this.#m=t[0]+1},this.#c[33]=function(t,s){console.debug(`Track ${s} requests to get assigned to output ${t}.`),e.#v[s]=t+1},this.#c[81]=function(t,s){e.#_=t/1e3},this.#c[127]=function(t,s){e.#T.run(t,s)},this.#T.default=function(t){console.warn(`Unrecognized sequencer-specific byte sequence: ${t}`)},this.#T.add([67,0,1],function(t,s){e.#v[s]=t[0]+1}),this.#P=new m,this.#N=new m,this.#R=new m,this.#S=new m,this.#O=new m,this.#L=new m,this.#G=new m,this.#P.add([9],t=>{e.switchMode(["gm","?","g2"][t[0]-1],!0),e.#a=e.#a||!1,console.info(`MIDI reset: ${["GM","Init","GM2"][t[0]-1]}`),t[0]==2&&e.init()}),this.#N.add([4,1],t=>{e.#M=((t[1]<<7)+t[0])/16383*100}).add([4,3],t=>((t[1]<<7)+t[0]-8192)/8192).add([4,4],t=>t[1]-64),this.#R.add([76,0,0],t=>{switch(t[0]){case 126:{e.switchMode("xg",!0),e.#a=!1,console.info("MIDI reset: XG");break}}}).add([76,6,0],t=>{let s=t[0];s<64?(e.#i=" ".repeat(s),e.#p=Date.now()+3200,t.subarray(1).forEach(function(i){e.#i+=String.fromCharCode(i)}),e.#i=e.#i.padEnd(32," ")):e.#p=Date.now()}).add([76,7,0],t=>{let s=t[0];e.#b=Date.now()+3200,e.#h.fill(0);let i=t.subarray(1);for(let r=0;r>6-f&1,f++})}),this.#R.add([43,7,0],(t,s,i)=>{e.#i=" ".repeat(offset),e.#p=Date.now()+3200,t.subarray(1).forEach(function(r){e.#i+=String.fromCharCode(r)}),e.#i=e.#i.padEnd(32," ")}).add([43,7,1],(t,s,i)=>{e.#b=Date.now()+3200,e.#h.fill(0),t.forEach(function(r,n){let a=Math.floor(n/16),o=n%16,c=(o*3+a)*7,u=7,f=0;for(c-=o*5,a==2&&(u=2);f>6-f&1,f++})}),this.#S.add([66,18,0,0,127],(t,s,i)=>{e.switchMode("gs",!0),e.#e[l.cc*9]=120,e.#e[l.cc*25]=120,e.#e[l.cc*41]=120,e.#e[l.cc*57]=120,e.#u=3,e.#a=!1,e.#E.fill(0),console.info(`GS system to ${["single","dual"][t[0]]} mode.`)}).add([66,18,64,0],(t,s,i)=>{switch(t[0]){case 127:{e.switchMode("gs",!0),e.#e[l.cc*9]=120,e.#e[l.cc*25]=120,e.#e[l.cc*41]=120,e.#e[l.cc*57]=120,e.#a=!1,e.#E.fill(0),console.info("MIDI reset: GS");break}}}).add([69,18,16],t=>{switch(t[0]){case 0:{e.#p=Date.now()+3200;let s=t[1];e.#i=" ".repeat(s),t.subarray(2).forEach(function(i){i<128&&(e.#i+=String.fromCharCode(i))});break}case 32:{e.#b=Date.now()+3200,t[1]==0&&(e.#w=Math.max(Math.min(t[2]-1,9),0));break}default:if(t[0]<11){e.#b=Date.now()+3200,e.#g[t[0]-1]?.length||(e.#g[t[0]-1]=new Uint8Array(256));let s=e.#g[t[0]-1],i=t[1];s.fill(0);let r=t.subarray(2);for(let n=0;n>4-p&1,p++})}else console.warn(`Unknown GS display section: ${t[0]}`)}}),this.#S.add([22,18,127],t=>{e.switchMode("mt32",!0),e.#a=!1,e.userBank.clearRange({msb:0,lsb:127,prg:[0,127]}),console.info("MIDI reset: MT-32")}).add([22,18,32],t=>{e.switchMode("mt32");let s=t[1],i=" ".repeat(s);t.subarray(2).forEach(r=>{r>31&&(i+=String.fromCharCode(r))}),e.#i=i.padStart(20," "),e.#p=Date.now()+3200}).add([22,18,82],(t,s)=>{let i=e.chRedir(0,s,!0);for(let r=0;r<16;r++)e.#r.ano(i+r),r&&r<10&&(e.#$[i+r]=mt32DefProg[r-1]);console.info("MT-32 alt reset complete.")}),this.#O.add([66,0],(t,s)=>{e.switchMode("ns5r",!0),e.#a=!1,console.debug(`NS5R mode switch requested: ${["global","multi","prog edit","comb edit","drum edit","effect edit"][t[0]]} mode.`)}).add([66,1],(t,s)=>{e.switchMode(["ns5r","05rw"][t[0]],!0),e.#a=!1}).add([66,18,0,0],(t,s)=>{switch(t[0]){case 124:case 126:case 127:{e.switchMode("ns5r",!0),e.#a=!1;break}}}).add([66,18,8,0],(t,s)=>{}).add([66,125],t=>{e.dispatchEvent("backlight",["green","orange","red",!1,"yellow","blue","purple"][t[0]]||"white")}).add([66,127],t=>{let s=new Uint8Array(5760);korgFilter(t,(i,r,n)=>{if(r<720)for(let a=0;a<8;a++)s[r*8+a]=i>>7-a&1}),e.dispatchEvent("screen",{type:"ns5r",data:s})}).add([76],(t,s,i)=>{e.#O.run([66,...t],s,i)}),this.#L.add([16,0,8,0],(t,s,i)=>{let r=(t[2]<<4)+t[3],n="K11 ";([()=>{e.switchMode("k11",!0),e.#a=!1,e.#u=r?4:0,console.info("MIDI reset: GMega/K11")}][t[0]]||(()=>{}))()}),this.#G.add([66,93,64],(t,s,i)=>{let r=t[2];switch(t[0]){case 0:{switch(t[1]){case 127:{e.switchMode("sg",!0);break}}break}}})}};export{Fe as OctaviaDevice,l as allocated,h as ccToPos}; +122 006 000 `),this.#c[1]=function(t){switch(t.slice(0,2)){case"@I":{this.#s=!0,this.#a.unshift(`Kar.Info: ${t.slice(2)}`);break}case"@K":{this.#s=!0,this.#a.unshift("Karaoke mode active."),console.debug(`Karaoke mode active: ${t.slice(2)}`);break}case"@L":{this.#s=!0,this.#a.unshift(`Language: ${t.slice(2)}`);break}case"@T":{this.#s=!0,this.#a.unshift(`Ka.Title: ${t.slice(2)}`);break}case"@V":{this.#s=!0,this.#a.unshift(`Kara.Ver: ${t.slice(2)}`);break}case"XF":{let a=t.slice(2).split(":");switch(a[0]){case"hd":{a.slice(1).forEach((s,r)=>{s.length&&this.#a.unshift(`${["SongDate","SnRegion","SongCat.","SongBeat","SongInst","Sn.Vocal","SongCmp.","SongLrc.","SongArr.","SongPerf","SongPrg.","SongTags"][r]}: ${s}`)});break}case"ln":{a.slice(1).forEach((s,r)=>{s.length&&this.#a.unshift(`${["Kar.Lang","Kar.Name","Kar.Cmp.","Kar.Lrc.","kar.Arr.","Kar.Perf","Kar.Prg."][r]}: ${s}`)});break}default:this.#a.unshift(`XGF_Data: ${t}`)}break}default:this.#s?t[0]=="\\"?this.#a.unshift(`@ ${t.slice(1)}`):t[0]=="/"?this.#a.unshift(t.slice(1)):this.#a[0]+=t:(this.#a[0]=t,this.#a.unshift(""))}},this.#c[2]=function(t){this.#a.unshift(`Copyrite: ${t}`)},this.#c[3]=function(t,a){a<1&&this.#m<1&&this.#a.unshift(`TrkTitle: ${t}`)},this.#c[4]=function(t,a){this.#a.unshift(`${K(this.#m,""," ")}Instrmnt: ${t}`)},this.#c[5]=function(t){t.trim()==""?this.#a.unshift(""):this.#a[0]+=`${t}`},this.#c[6]=function(t){this.#a.unshift(`${K(this.#m,""," ")}C.Marker: ${t}`)},this.#c[7]=function(t){this.#a.unshift(`CuePoint: ${t}`)},this.#c[32]=function(t){this.#m=t[0]+1},this.#c[33]=function(t,a){console.debug(`Track ${a} requests to get assigned to output ${t}.`),e.#v[a]=t+1},this.#c[81]=function(t,a){e.#_=t/1e3},this.#c[127]=function(t,a){e.#T.run(t,a)},this.#T.default=function(t){console.warn(`Unrecognized sequencer-specific byte sequence: ${t}`)},this.#T.add([67,0,1],function(t,a){e.#v[a]=t[0]+1}),this.#P=new w,this.#N=new w,this.#R=new w,this.#S=new w,this.#O=new w,this.#L=new w,this.#I=new w,this.#P.add([9],t=>{e.switchMode(["gm","?","g2"][t[0]-1],!0),e.#s=e.#s||!1,console.info(`MIDI reset: ${["GM","Init","GM2"][t[0]-1]}`),t[0]==2&&e.init()}),this.#N.add([4,1],t=>{e.#M=((t[1]<<7)+t[0])/16383*100}).add([4,3],t=>((t[1]<<7)+t[0]-8192)/8192).add([4,4],t=>t[1]-64),this.#R.add([76,0,0],t=>{switch(t[0]){case 126:{e.switchMode("xg",!0),e.#s=!1,console.info("MIDI reset: XG");break}}}).add([76,6,0],t=>{let a=t[0];a<64?(e.#i=" ".repeat(a),e.#p=Date.now()+3200,t.subarray(1).forEach(function(s){e.#i+=String.fromCharCode(s)}),e.#i=e.#i.padEnd(32," ")):e.#p=Date.now()}).add([76,7,0],t=>{let a=t[0];e.#b=Date.now()+3200,e.#h.fill(0);let s=t.subarray(1);for(let r=0;r>6-h&1,h++})}),this.#R.add([43,7,0],(t,a,s)=>{e.#i=" ".repeat(offset),e.#p=Date.now()+3200,t.subarray(1).forEach(function(r){e.#i+=String.fromCharCode(r)}),e.#i=e.#i.padEnd(32," ")}).add([43,7,1],(t,a,s)=>{e.#b=Date.now()+3200,e.#h.fill(0),t.forEach(function(r,n){let l=Math.floor(n/16),u=n%16,p=(u*3+l)*7,i=7,h=0;for(p-=u*5,l==2&&(i=2);h>6-h&1,h++})}),this.#S.add([66,18,0,0,127],(t,a,s)=>{e.switchMode("gs",!0),e.#e[o.cc*9]=120,e.#e[o.cc*25]=120,e.#e[o.cc*41]=120,e.#e[o.cc*57]=120,e.#u=3,e.#s=!1,e.#E.fill(0),console.info(`GS system to ${["single","dual"][t[0]]} mode.`)}).add([66,18,64,0],(t,a,s)=>{switch(t[0]){case 127:{e.switchMode("gs",!0),e.#e[o.cc*9]=120,e.#e[o.cc*25]=120,e.#e[o.cc*41]=120,e.#e[o.cc*57]=120,e.#s=!1,e.#E.fill(0),console.info("MIDI reset: GS");break}}}).add([69,18,16],t=>{switch(t[0]){case 0:{e.#p=Date.now()+3200;let a=t[1];e.#i=" ".repeat(a),t.subarray(2).forEach(function(s){s<128&&(e.#i+=String.fromCharCode(s))});break}case 32:{e.#b=Date.now()+3200,t[1]==0&&(e.#w=Math.max(Math.min(t[2]-1,9),0));break}default:if(t[0]<11){e.#b=Date.now()+3200,e.#g[t[0]-1]?.length||(e.#g[t[0]-1]=new Uint8Array(256));let a=e.#g[t[0]-1],s=t[1];a.fill(0);let r=t.subarray(2);for(let n=0;n>4-c&1,c++})}else console.warn(`Unknown GS display section: ${t[0]}`)}}),this.#S.add([22,18,127],t=>{e.switchMode("mt32",!0),e.#s=!1,e.userBank.clearRange({msb:0,lsb:127,prg:[0,127]}),console.info("MIDI reset: MT-32")}).add([22,18,32],t=>{e.switchMode("mt32");let a=t[1],s=" ".repeat(a);t.subarray(2).forEach(r=>{r>31&&(s+=String.fromCharCode(r))}),e.#i=s.padStart(20," "),e.#p=Date.now()+3200}).add([22,18,82],(t,a)=>{let s=e.chRedir(0,a,!0);for(let r=0;r<16;r++)e.#r.ano(s+r),r&&r<10&&(e.#$[s+r]=mt32DefProg[r-1]);console.info("MT-32 alt reset complete.")}),this.#O.add([66,0],(t,a)=>{e.switchMode("ns5r",!0),e.#s=!1,console.debug(`NS5R mode switch requested: ${["global","multi","prog edit","comb edit","drum edit","effect edit"][t[0]]} mode.`)}).add([66,1],(t,a)=>{e.switchMode(["ns5r","05rw"][t[0]],!0),e.#s=!1}).add([66,18,0,0],(t,a)=>{switch(t[0]){case 124:case 126:case 127:{e.switchMode("ns5r",!0),e.#s=!1;break}}}).add([66,18,8,0],(t,a)=>{}).add([66,125],t=>{e.dispatchEvent("backlight",["green","orange","red",!1,"yellow","blue","purple"][t[0]]||"white")}).add([66,127],t=>{let a=new Uint8Array(5760);korgFilter(t,(s,r,n)=>{if(r<720)for(let l=0;l<8;l++)a[r*8+l]=s>>7-l&1}),e.dispatchEvent("screen",{type:"ns5r",data:a})}).add([76],(t,a,s)=>{e.#O.run([66,...t],a,s)}),this.#L.add([16,0,8,0],(t,a,s)=>{let r=(t[2]<<4)+t[3],n="K11 ";([()=>{e.switchMode("k11",!0),e.#s=!1,e.#u=r?4:0,console.info("MIDI reset: GMega/K11")}][t[0]]||(()=>{}))()}),this.#I.add([66,93,64],(t,a,s)=>{let r=t[2];switch(t[0]){case 0:{switch(t[1]){case 127:{e.switchMode("sg",!0);break}}break}}})}};export{We as OctaviaDevice,o as allocated,f as ccToPos}; diff --git a/src/disp/disp_psr.mjs b/src/disp/disp_psr.mjs index 5adabe01..68ae3570 100644 --- a/src/disp/disp_psr.mjs +++ b/src/disp/disp_psr.mjs @@ -98,6 +98,22 @@ let PsrDisplay = class extends RootDisplay { F: new Uint8Array([0, 1, 1, 1, 0, 0, 0, 1]), G: new Uint8Array([0, 0, 1, 1, 1, 1, 0, 1]), H: new Uint8Array([0, 1, 1, 1, 0, 1, 1, 0]), + I: new Uint8Array([0, 0, 1, 1, 0, 0, 0, 0]), + J: new Uint8Array([0, 0, 0, 0, 1, 1, 1, 0]), + K: new Uint8Array([0, 1, 1, 1, 0, 0, 1, 0]), + L: new Uint8Array([0, 0, 1, 1, 1, 0, 0, 0]), + M: new Uint8Array([0, 1, 0, 1, 0, 1, 0, 1]), + N: new Uint8Array([0, 1, 0, 1, 0, 1, 0, 0]), + O: new Uint8Array([0, 1, 0, 1, 1, 1, 0, 0]), + P: new Uint8Array([0, 1, 1, 1, 0, 0, 1, 1]), + Q: new Uint8Array([0, 1, 1, 0, 0, 1, 1, 1]), + R: new Uint8Array([0, 1, 0, 1, 0, 0, 0, 0]), + S: new Uint8Array([0, 0, 1, 0, 1, 1, 0, 1]), + T: new Uint8Array([0, 1, 1, 1, 1, 0, 0, 0]), + U: new Uint8Array([0, 0, 1, 1, 1, 1, 1, 0]), + X: new Uint8Array([0, 0, 1, 1, 0, 1, 1, 0]), + Y: new Uint8Array([0, 1, 1, 0, 1, 1, 1, 0]), + Z: new Uint8Array([0, 0, 0, 1, 1, 0, 1, 1]), "-": new Uint8Array([0, 1, 0, 0, 0, 0, 0, 0]) }; Array.from(str).forEach((e, i) => { diff --git a/src/fakePsr/index.js b/src/fakePsr/index.js index f6769f4a..735aceca 100644 --- a/src/fakePsr/index.js +++ b/src/fakePsr/index.js @@ -190,24 +190,26 @@ visualizer.addEventListener("reset", function (e) { // Listen to mode switches visualizer.addEventListener("mode", function (ev) { stSwitch.to(stSwitchMode.indexOf(ev.data)); - let textCmd = [67, 16, 76, 6, 0, 0, 77, 79, 68, 69, 58, 32]; - let modeText = { - gm: [71, 77], - gs: [71, 83], - xg: [88, 71], - g2: [71, 77, 50], - sd: [83, 68], - mt32: [77, 84, 45, 51, 50], - ns5r: [78, 83, 53, 82], - "05rw": [48, 53, 82, 47, 87], - x5d: [88, 53, 68], - k11: [71, 77, 101, 103, 97], - sg: [83, 71], - krs: [75, 82, 79, 83, 83], - s90es: [83, 57, 48, 32, 69, 83], - motif: [77, 111, 116, 105, 102, 32, 69, 83] - }; - visualizer.sendCmd({type: 15, track: 0, data: textCmd.concat(modeText[visualizer.getMode()])}); + if (visualizer.getMode() != "?") { + let textCmd = [67, 16, 76, 6, 0, 0, 77, 79, 68, 69, 58, 32]; + let modeText = { + gm: [71, 77], + gs: [71, 83], + xg: [88, 71], + g2: [71, 77, 50], + sd: [83, 68], + mt32: [77, 84, 45, 51, 50], + ns5r: [78, 83, 53, 82], + "05rw": [48, 53, 82, 47, 87], + x5d: [88, 53, 68], + k11: [71, 77, 101, 103, 97], + sg: [83, 71], + krs: [75, 82, 79, 83, 83], + s90es: [83, 57, 48, 32, 69, 83], + motif: [77, 111, 116, 105, 102, 32, 69, 83] + }; + visualizer.sendCmd({type: 15, track: 0, data: textCmd.concat(modeText[visualizer.getMode()])}); + } }); // Open the files