spessasynth_lib 3.23.2 → 3.23.3

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.
@@ -20,7 +20,7 @@ export class BasicSoundFont {
20
20
  * @type {Object<string, string|IndexedByteArray>}
21
21
  */
22
22
  soundFontInfo: {
23
- [x: string]: string | IndexedByteArray;
23
+ [x: string]: any;
24
24
  };
25
25
  /**
26
26
  * The soundfont's presets
@@ -19,6 +19,6 @@ export class DLSSample extends BasicSample {
19
19
  * @type {Float32Array}
20
20
  */
21
21
  sampleData: Float32Array;
22
- getRawData(): Uint8Array;
22
+ getRawData(): Uint8Array<ArrayBuffer>;
23
23
  }
24
24
  import { BasicSample } from "../basic_soundfont/basic_sample.js";
@@ -30,8 +30,8 @@ export class LoadedSample extends BasicSample {
30
30
  isSampleLoaded: boolean;
31
31
  sampleID: number;
32
32
  sampleLength: number;
33
- sampleDataArray: Float32Array | IndexedByteArray;
34
- sampleData: Float32Array;
33
+ sampleDataArray: Float32Array<ArrayBuffer> | IndexedByteArray;
34
+ sampleData: Float32Array<ArrayBuffer>;
35
35
  isDataRaw: boolean;
36
36
  /**
37
37
  * Get raw data, whether it's compressed or not as we simply write it to the file
@@ -4,6 +4,12 @@ export class KeyModifierManager {
4
4
  */
5
5
  constructor(synth: Synthetizer);
6
6
  synth: Synthetizer;
7
+ /**
8
+ * The velocity override mappings for MIDI keys
9
+ * @type {KeyModifier[][]}
10
+ * @private
11
+ */
12
+ private _keyModifiers;
7
13
  /**
8
14
  * @private
9
15
  * @param type {workletKeyModifierMessageType}
@@ -29,6 +35,13 @@ export class KeyModifierManager {
29
35
  program: number;
30
36
  } | undefined;
31
37
  }): void;
38
+ /**
39
+ * Gets a key modifier
40
+ * @param channel {number} the channel affected. Usually 0-15
41
+ * @param midiNote {number} the MIDI note to change. 0-127
42
+ * @returns {KeyModifier|undefined}
43
+ */
44
+ getModifier(channel: number, midiNote: number): KeyModifier | undefined;
32
45
  /**
33
46
  * Deletes a key modifier
34
47
  * @param channel {number} the channel affected. Usually 0-15
@@ -40,3 +53,4 @@ export class KeyModifierManager {
40
53
  */
41
54
  clearModifiers(): void;
42
55
  }
56
+ import { KeyModifier } from "./worklet_system/worklet_methods/worklet_key_modifier.js";
@@ -1,6 +1,6 @@
1
1
  export const NON_CC_INDEX_OFFSET: 128;
2
2
  export const CONTROLLER_TABLE_SIZE: 147;
3
- export const resetArray: Int16Array;
3
+ export const resetArray: Int16Array<ArrayBuffer>;
4
4
  export function setResetValue(i: any, v: any): number;
5
5
  export namespace customControllers {
6
6
  let channelTuning: number;
@@ -10,7 +10,7 @@ export namespace customControllers {
10
10
  let channelTuningSemitones: number;
11
11
  }
12
12
  export const CUSTOM_CONTROLLER_TABLE_SIZE: number;
13
- export const customResetArray: Float32Array;
13
+ export const customResetArray: Float32Array<ArrayBuffer>;
14
14
  export type dataEntryStates = number;
15
15
  export namespace dataEntryStates {
16
16
  let Idle: number;
@@ -7,7 +7,7 @@ export function combineArrays(arrs: (IndexedByteArray | Uint8Array)[]): IndexedB
7
7
  * indexed_array.js
8
8
  * purpose: exteds Uint8Array with a currentIndex property
9
9
  */
10
- export class IndexedByteArray extends Uint8Array {
10
+ export class IndexedByteArray extends Uint8Array<ArrayBuffer> {
11
11
  /**
12
12
  * Creates a new instance of an Uint8Array with a currentIndex property
13
13
  * @param args {any} same as for Uint8Array
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spessasynth_lib",
3
- "version": "3.23.2",
3
+ "version": "3.23.3",
4
4
  "description": "MIDI and SoundFont2/DLS library with no compromises",
5
5
  "browser": "index.js",
6
6
  "types": "@types/index.d.ts",
@@ -9,6 +9,12 @@ export class KeyModifierManager
9
9
  constructor(synth)
10
10
  {
11
11
  this.synth = synth;
12
+ /**
13
+ * The velocity override mappings for MIDI keys
14
+ * @type {KeyModifier[][]}
15
+ * @private
16
+ */
17
+ this._keyModifiers = [];
12
18
  }
13
19
 
14
20
  /**
@@ -44,12 +50,29 @@ export class KeyModifierManager
44
50
  const velocity = options?.velocity ?? -1;
45
51
  const program = options?.patch?.program ?? -1;
46
52
  const bank = options?.patch?.bank ?? -1;
53
+ const mod = new KeyModifier(velocity, bank, program);
54
+ if (this._keyModifiers[channel] === undefined)
55
+ {
56
+ this._keyModifiers[channel] = [];
57
+ }
58
+ this._keyModifiers[channel][midiNote] = mod;
47
59
  this._sendToWorklet(
48
60
  workletKeyModifierMessageType.addMapping,
49
- [channel, midiNote, new KeyModifier(velocity, bank, program)]
61
+ [channel, midiNote, mod]
50
62
  );
51
63
  }
52
64
 
65
+ /**
66
+ * Gets a key modifier
67
+ * @param channel {number} the channel affected. Usually 0-15
68
+ * @param midiNote {number} the MIDI note to change. 0-127
69
+ * @returns {KeyModifier|undefined}
70
+ */
71
+ getModifier(channel, midiNote)
72
+ {
73
+ return this._keyModifiers?.[channel]?.[midiNote];
74
+ }
75
+
53
76
  /**
54
77
  * Deletes a key modifier
55
78
  * @param channel {number} the channel affected. Usually 0-15
@@ -61,6 +84,11 @@ export class KeyModifierManager
61
84
  workletKeyModifierMessageType.deleteMapping,
62
85
  [channel, midiNote]
63
86
  );
87
+ if (this._keyModifiers[channel]?.[midiNote] === undefined)
88
+ {
89
+ return;
90
+ }
91
+ this._keyModifiers[channel][midiNote] = undefined;
64
92
  }
65
93
 
66
94
  /**
@@ -69,5 +97,6 @@ export class KeyModifierManager
69
97
  clearModifiers()
70
98
  {
71
99
  this._sendToWorklet(workletKeyModifierMessageType.clearMappings, undefined);
100
+ this._keyModifiers = [];
72
101
  }
73
102
  }