spessasynth_lib 3.23.13 → 3.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,7 @@ import { NON_CC_INDEX_OFFSET } from "../worklet_utilities/controller_tables.js";
6
6
  /**
7
7
  * Calls synth event from the worklet side
8
8
  * @param eventName {EventTypes} the event name
9
- * @param eventData {any}
9
+ * @param eventData {EventCallbackData}
10
10
  * @this {SpessaSynthProcessor}
11
11
  */
12
12
  export function callEvent(eventName, eventData)
@@ -36,6 +36,16 @@ function getTuning(byte1, byte2, byte3)
36
36
  return { midiNote: midiNote, centTuning: fraction * 0.0061 };
37
37
  }
38
38
 
39
+ /**
40
+ * The text types for the synth display
41
+ * @enum {number}
42
+ */
43
+ export const SynthDisplayType = {
44
+ SoundCanvasText: 0,
45
+ XGText: 1,
46
+ SoundCanvasDotDisplay: 2
47
+ };
48
+
39
49
 
40
50
  /**
41
51
  * Executes a system exclusive
@@ -471,6 +481,56 @@ export function systemExclusive(messageData, channelOffset = 0)
471
481
  notRecognized();
472
482
  return;
473
483
  }
484
+ else if (messageData[2] === 0x45 && messageData[3] === 0x12)
485
+ {
486
+ // 0x45: GS Display Data, 0x12: DT1 (Device Transmit)
487
+ // check for embedded copyright
488
+ // (roland SC display sysex) http://www.bandtrax.com.au/sysex.htm
489
+
490
+ if (
491
+ messageData[4] === 0x10 && // Sound Canvas Display
492
+ messageData[6] === 0x00 // Data follows
493
+ )
494
+ {
495
+ if (messageData[5] === 0x00) // Display letters
496
+ {
497
+ // get the text
498
+ // and header ends with (checksum) F7
499
+ const text = new Uint8Array(messageData.slice(7, messageData.length - 2));
500
+ this.callEvent(
501
+ "synthdisplay",
502
+ {
503
+ displayData: text,
504
+ displayType: SynthDisplayType.SoundCanvasText
505
+ }
506
+ );
507
+ }
508
+ else if (messageData[5] === 0x01) // Matrix display
509
+ {
510
+ // get the data
511
+ // and header ends with (checksum) F7
512
+ const dotMatrixData = new Uint8Array(messageData.slice(7, messageData.length - 3));
513
+ this.callEvent(
514
+ "synthdisplay",
515
+ {
516
+ displayData: dotMatrixData,
517
+ displayType: SynthDisplayType.SoundCanvasDotDisplay
518
+ }
519
+ );
520
+ SpessaSynthInfo(
521
+ `%cRoland SC Display Dot Matrix via: %c${arrayToHexString(
522
+ messageData)}`,
523
+ consoleColors.info,
524
+ consoleColors.value
525
+ );
526
+ }
527
+ else
528
+ {
529
+ // this is some other GS sysex...
530
+ notRecognized();
531
+ }
532
+ }
533
+ }
474
534
  else if (messageData[2] === 0x16 && messageData[3] === 0x12 && messageData[4] === 0x10)
475
535
  {
476
536
  // this is a roland master volume message
@@ -495,6 +555,7 @@ export function systemExclusive(messageData, channelOffset = 0)
495
555
  );
496
556
  return;
497
557
  }
558
+ break;
498
559
 
499
560
  // yamaha
500
561
  // http://www.studio4all.de/htmle/main91.html
@@ -615,6 +676,22 @@ export function systemExclusive(messageData, channelOffset = 0)
615
676
  );
616
677
  }
617
678
  }
679
+ else if (
680
+ messageData[3] === 0x06 && // XG System parameter
681
+ messageData[4] === 0x00 // System Byte
682
+ )
683
+ {
684
+ // displayed letters (remove F7 at the end)
685
+ // include byte 5 as it seems to be line information (useful)
686
+ const textData = new Uint8Array(messageData.slice(5, messageData.length - 1));
687
+ this.callEvent(
688
+ "synthdisplay",
689
+ {
690
+ displayData: textData,
691
+ displayType: SynthDisplayType.XGText
692
+ }
693
+ );
694
+ }
618
695
  else if (this.system === "xg")
619
696
  {
620
697
  SpessaSynthWarn(
package/utils/other.js CHANGED
@@ -29,8 +29,10 @@ export function formatTitle(fileName)
29
29
  return fileName
30
30
  .trim()
31
31
  .replaceAll(".mid", "")
32
+ .replaceAll(".kar", "")
32
33
  .replaceAll(".rmi", "")
33
- .replaceAll("_", " ");
34
+ .replaceAll("_", " ")
35
+ .trim();
34
36
  }
35
37
 
36
38
  /**
@@ -52,6 +54,31 @@ export function arrayToHexString(arr)
52
54
  return hexString;
53
55
  }
54
56
 
57
+ /**
58
+ * @param eventData {Uint8Array}
59
+ * @returns {Uint8Array}
60
+ */
61
+ export function sanitizeKarLyrics(eventData)
62
+ {
63
+ // for KAR files:
64
+ // https://www.mixagesoftware.com/en/midikit/help/HTML/karaoke_formats.html
65
+ // "/" is the newline character
66
+ // "\" is also the newline character
67
+ // "\" ASCII code is 92
68
+ // "/" ASCII code is 47
69
+ // newline ASCII code is 10
70
+ const sanitized = [];
71
+ for (let byte of eventData)
72
+ {
73
+ if (byte === 47 || byte === 92)
74
+ {
75
+ byte = 10;
76
+ }
77
+ sanitized.push(byte);
78
+ }
79
+ return new Uint8Array(sanitized);
80
+ }
81
+
55
82
  export const consoleColors = {
56
83
  warn: "color: orange;",
57
84
  unrecognized: "color: red;",