spessasynth_lib 3.24.0 → 3.24.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.
Files changed (72) hide show
  1. package/@types/sequencer/sequencer.d.ts +63 -28
  2. package/@types/sequencer/worklet_sequencer/sequencer_message.d.ts +1 -0
  3. package/@types/synthetizer/audio_effects/effects_config.d.ts +20 -8
  4. package/@types/synthetizer/synthetizer.d.ts +17 -23
  5. package/LICENSE +0 -0
  6. package/README.md +0 -0
  7. package/external_midi/README.md +0 -0
  8. package/external_midi/midi_handler.js +0 -0
  9. package/external_midi/web_midi_link.js +0 -0
  10. package/externals/stbvorbis_sync/@types/stbvorbis_sync.d.ts +0 -0
  11. package/externals/stbvorbis_sync/LICENSE +0 -0
  12. package/externals/stbvorbis_sync/stbvorbis_sync.min.js +0 -0
  13. package/midi_parser/README.md +0 -0
  14. package/midi_parser/midi_message.js +0 -0
  15. package/midi_parser/midi_writer.js +0 -0
  16. package/midi_parser/used_keys_loaded.js +0 -0
  17. package/package.json +1 -1
  18. package/sequencer/README.md +0 -0
  19. package/sequencer/sequencer.js +134 -77
  20. package/sequencer/worklet_sequencer/process_event.js +4 -1
  21. package/sequencer/worklet_sequencer/process_tick.js +4 -4
  22. package/sequencer/worklet_sequencer/sequencer_message.js +2 -1
  23. package/soundfont/README.md +0 -0
  24. package/soundfont/basic_soundfont/basic_instrument.js +0 -0
  25. package/soundfont/basic_soundfont/write_sf2/ibag.js +0 -0
  26. package/soundfont/basic_soundfont/write_sf2/imod.js +0 -0
  27. package/soundfont/basic_soundfont/write_sf2/inst.js +0 -0
  28. package/soundfont/basic_soundfont/write_sf2/pbag.js +0 -0
  29. package/soundfont/basic_soundfont/write_sf2/phdr.js +0 -0
  30. package/soundfont/basic_soundfont/write_sf2/pmod.js +0 -0
  31. package/soundfont/basic_soundfont/write_sf2/sdta.js +0 -0
  32. package/soundfont/basic_soundfont/write_sf2/shdr.js +0 -0
  33. package/soundfont/basic_soundfont/write_sf2/soundfont_trimmer.js +0 -0
  34. package/soundfont/dls/dls_destinations.js +0 -0
  35. package/soundfont/dls/dls_preset.js +0 -0
  36. package/soundfont/dls/dls_sources.js +0 -0
  37. package/soundfont/dls/read_instrument_list.js +0 -0
  38. package/soundfont/load_soundfont.js +0 -0
  39. package/soundfont/read_sf2/generators.js +0 -0
  40. package/soundfont/read_sf2/instruments.js +0 -0
  41. package/soundfont/read_sf2/modulators.js +0 -0
  42. package/soundfont/read_sf2/presets.js +0 -0
  43. package/soundfont/read_sf2/zones.js +0 -0
  44. package/synthetizer/README.md +0 -0
  45. package/synthetizer/audio_effects/effects_config.js +10 -6
  46. package/synthetizer/audio_effects/fancy_chorus.js +9 -16
  47. package/synthetizer/audio_effects/reverb.js +1 -1
  48. package/synthetizer/synthetizer.js +43 -37
  49. package/synthetizer/worklet_processor.min.js +8 -8
  50. package/synthetizer/worklet_system/README.md +0 -0
  51. package/synthetizer/worklet_system/message_protocol/message_sending.js +0 -0
  52. package/synthetizer/worklet_system/snapshot/snapshot.js +1 -1
  53. package/synthetizer/worklet_system/worklet_methods/data_entry.js +0 -0
  54. package/synthetizer/worklet_system/worklet_methods/note_on.js +5 -2
  55. package/synthetizer/worklet_system/worklet_methods/system_exclusive.js +0 -0
  56. package/synthetizer/worklet_system/worklet_methods/tuning_control.js +0 -0
  57. package/synthetizer/worklet_system/worklet_methods/vibrato_control.js +0 -0
  58. package/synthetizer/worklet_system/worklet_methods/worklet_soundfont_manager/sfman_message.js +0 -0
  59. package/synthetizer/worklet_system/worklet_processor.js +0 -0
  60. package/synthetizer/worklet_system/worklet_utilities/controller_tables.js +0 -0
  61. package/synthetizer/worklet_system/worklet_utilities/lfo.js +0 -0
  62. package/synthetizer/worklet_system/worklet_utilities/modulator_curves.js +0 -0
  63. package/synthetizer/worklet_system/worklet_utilities/unit_converter.js +0 -0
  64. package/synthetizer/worklet_system/worklet_utilities/volume_envelope.js +0 -0
  65. package/synthetizer/worklet_system/worklet_utilities/wavetable_oscillator.js +0 -0
  66. package/synthetizer/worklet_url.js +0 -0
  67. package/utils/README.md +0 -0
  68. package/utils/byte_functions/big_endian.js +0 -0
  69. package/utils/byte_functions/little_endian.js +0 -0
  70. package/utils/byte_functions/variable_length_quantity.js +0 -0
  71. package/utils/indexed_array.js +0 -0
  72. package/utils/loggin.js +0 -0
@@ -25,7 +25,7 @@ export class Sequencer {
25
25
  * Fires on text event
26
26
  * @type {function}
27
27
  * @param data {Uint8Array} the data text
28
- * @param type {number} the status byte of the message (the meta status byte)
28
+ * @param type {number} the status byte of the message (the meta-status byte)
29
29
  * @param lyricsIndex {number} if the text is a lyric, the index of the lyric in midiData.lyrics, otherwise -1
30
30
  */
31
31
  onTextEvent: Function;
@@ -40,47 +40,58 @@ export class Sequencer {
40
40
  * @private
41
41
  */
42
42
  private onSongEnded;
43
- ignoreEvents: boolean;
44
- synth: Synthetizer;
45
- highResTimeOffset: number;
46
43
  /**
47
- * Absolute playback startTime, bases on the synth's time
48
- * @type {number}
44
+ * Fires on tempo change
45
+ * @type {Object<string, function(number)>}
49
46
  */
50
- absoluteStartTime: number;
47
+ onTempoChange: {
48
+ [x: string]: (arg0: number) => any;
49
+ };
51
50
  /**
52
- * @type {function(BasicMIDI)}
53
- * @private
51
+ * Current song's tempo in BPM
52
+ * @type {number}
54
53
  */
55
- private _getMIDIResolve;
54
+ currentTempo: number;
56
55
  /**
57
- * Controls the playback's rate
56
+ * Current song index
58
57
  * @type {number}
59
58
  */
60
- _playbackRate: number;
61
59
  songIndex: number;
62
60
  /**
63
- * Indicates if the current midiData property has dummy data in it (not yet loaded)
61
+ * @type {function(BasicMIDI)}
62
+ * @private
63
+ */
64
+ private _getMIDIResolve;
65
+ /**
66
+ * Indicates if the current midiData property has fake data in it (not yet loaded)
64
67
  * @type {boolean}
65
68
  */
66
69
  hasDummyData: boolean;
67
- _loop: boolean;
68
70
  /**
69
71
  * Indicates whether the sequencer has finished playing a sequence
70
72
  * @type {boolean}
71
73
  */
72
74
  isFinished: boolean;
75
+ /**
76
+ * The current sequence's length, in seconds
77
+ * @type {number}
78
+ */
79
+ duration: number;
73
80
  /**
74
81
  * Indicates if the sequencer is paused.
75
82
  * Paused if a number, undefined if playing
76
83
  * @type {undefined|number}
84
+ * @private
77
85
  */
78
- pausedTime: undefined | number;
86
+ private pausedTime;
87
+ ignoreEvents: boolean;
88
+ synth: Synthetizer;
89
+ highResTimeOffset: number;
79
90
  /**
80
- * The current sequence's length, in seconds
91
+ * Absolute playback startTime, bases on the synth's time
81
92
  * @type {number}
82
93
  */
83
- duration: number;
94
+ absoluteStartTime: number;
84
95
  /**
85
96
  * @type {boolean}
86
97
  * @private
@@ -91,6 +102,28 @@ export class Sequencer {
91
102
  * @private
92
103
  */
93
104
  private _preservePlaybackState;
105
+ /**
106
+ * Internal loop marker
107
+ * @type {boolean}
108
+ * @private
109
+ */
110
+ private _loop;
111
+ set loop(value: boolean);
112
+ get loop(): boolean;
113
+ /**
114
+ * Controls the playback's rate
115
+ * @type {number}
116
+ * @private
117
+ */
118
+ private _playbackRate;
119
+ /**
120
+ * @param value {number}
121
+ */
122
+ set playbackRate(value: number);
123
+ /**
124
+ * @returns {number}
125
+ */
126
+ get playbackRate(): number;
94
127
  /**
95
128
  * Indicates if the sequencer should skip to first note on
96
129
  * @param val {boolean}
@@ -118,21 +151,11 @@ export class Sequencer {
118
151
  * @returns {number} Current playback time, in seconds
119
152
  */
120
153
  get currentTime(): number;
121
- set loop(value: boolean);
122
- get loop(): boolean;
123
154
  /**
124
155
  * Use for visualization as it's not affected by the audioContext stutter
125
156
  * @returns {number}
126
157
  */
127
158
  get currentHighResolutionTime(): number;
128
- /**
129
- * @param value {number}
130
- */
131
- set playbackRate(value: number);
132
- /**
133
- * @returns {number}
134
- */
135
- get playbackRate(): number;
136
159
  /**
137
160
  * true if paused, false if playing or stopped
138
161
  * @returns {boolean}
@@ -156,6 +179,12 @@ export class Sequencer {
156
179
  * @param id {string} must be unique
157
180
  */
158
181
  addOnTimeChangeEvent(callback: (arg0: number) => any, id: string): void;
182
+ /**
183
+ * Adds a new event that gets called when the tempo changes
184
+ * @param callback {function(number)} the new tempo, in BPM
185
+ * @param id {string} must be unique
186
+ */
187
+ addOnTempoChangeEvent(callback: (arg0: number) => any, id: string): void;
159
188
  resetMIDIOut(): void;
160
189
  /**
161
190
  * @param messageType {WorkletSequencerMessageType}
@@ -165,6 +194,12 @@ export class Sequencer {
165
194
  private _sendMessage;
166
195
  nextSong(): void;
167
196
  previousSong(): void;
197
+ /**
198
+ * @param type {Object<string, function>}
199
+ * @param params {any}
200
+ * @private
201
+ */
202
+ private _callEvents;
168
203
  /**
169
204
  * @param {WorkletSequencerReturnMessageType} messageType
170
205
  * @param {any} messageData
@@ -199,7 +234,7 @@ export class Sequencer {
199
234
  unpause(): void;
200
235
  /**
201
236
  * Starts the playback
202
- * @param resetTime {boolean} If true, time is set to 0s
237
+ * @param resetTime {boolean} If true, time is set to 0 s
203
238
  */
204
239
  play(resetTime?: boolean): void;
205
240
  /**
@@ -27,4 +27,5 @@ export namespace WorkletSequencerReturnMessageType {
27
27
  let getMIDI_1: number;
28
28
  export { getMIDI_1 as getMIDI };
29
29
  export let midiError: number;
30
+ export let tempoChange: number;
30
31
  }
@@ -1,15 +1,18 @@
1
1
  /**
2
- * @typedef {Object} EffectsConfig
2
+ * @typedef {Object} SynthConfig
3
3
  * @property {boolean} chorusEnabled - indicates if the chorus effect is enabled.
4
- * @property {ChorusConfig} chorusConfig - the configuration for chorus. Pass undefined to use defaults
4
+ * @property {ChorusConfig?} chorusConfig - the configuration for chorus. Pass undefined to use defaults
5
5
  * @property {boolean} reverbEnabled - indicates if the reverb effect is enabled.
6
- * @property {AudioBuffer} reverbImpulseResponse - the impulse response for the reverb. Pass undefined to use defaults
6
+ * @property {AudioBuffer?} reverbImpulseResponse - the impulse response for the reverb. Pass undefined to use defaults
7
+ * @property {{
8
+ * worklet: function(context: object, name: string, options?: Object)
9
+ * }} audioNodeCreators - custom audio node creation functions for Web Audio wrappers.
7
10
  */
8
11
  /**
9
- * @type {EffectsConfig}
12
+ * @type {SynthConfig}
10
13
  */
11
- export const DEFAULT_EFFECTS_CONFIG: EffectsConfig;
12
- export type EffectsConfig = {
14
+ export const DEFAULT_SYNTH_CONFIG: SynthConfig;
15
+ export type SynthConfig = {
13
16
  /**
14
17
  * - indicates if the chorus effect is enabled.
15
18
  */
@@ -17,7 +20,7 @@ export type EffectsConfig = {
17
20
  /**
18
21
  * - the configuration for chorus. Pass undefined to use defaults
19
22
  */
20
- chorusConfig: ChorusConfig;
23
+ chorusConfig: ChorusConfig | null;
21
24
  /**
22
25
  * - indicates if the reverb effect is enabled.
23
26
  */
@@ -25,5 +28,14 @@ export type EffectsConfig = {
25
28
  /**
26
29
  * - the impulse response for the reverb. Pass undefined to use defaults
27
30
  */
28
- reverbImpulseResponse: AudioBuffer;
31
+ reverbImpulseResponse: AudioBuffer | null;
32
+ /**
33
+ * )
34
+ * }} audioNodeCreators - custom audio node creation functions for Web Audio wrappers.
35
+ */
36
+ "": {
37
+ worklet: (arg0: context) => object;
38
+ name: string;
39
+ options?: any;
40
+ };
29
41
  };
@@ -6,7 +6,8 @@
6
6
  * @typedef {Object} StartRenderingDataConfig
7
7
  * @property {BasicMIDI} parsedMIDI - the MIDI to render
8
8
  * @property {SynthesizerSnapshot} snapshot - the snapshot to apply
9
- * @property {boolean|undefined} oneOutput - if synth should use one output with 32 channels (2 audio channels for each midi channel). this disables chorus and reverb.
9
+ * @property {boolean|undefined} oneOutput - if synth should use one output with 32 channels (2 audio channels for each midi channel).
10
+ * this disabled chorus and reverb.
10
11
  * @property {number|undefined} loopCount - the times to loop the song
11
12
  */
12
13
  export const WORKLET_PROCESSOR_NAME: "spessasynth-worklet-system";
@@ -14,14 +15,6 @@ export const VOICE_CAP: 350;
14
15
  export const DEFAULT_PERCUSSION: 9;
15
16
  export const MIDI_CHANNEL_COUNT: 16;
16
17
  export const DEFAULT_SYNTH_MODE: "gs";
17
- /**
18
- * Creates a new instance of the SpessaSynth synthesizer
19
- * @param targetNode {AudioNode}
20
- * @param soundFontBuffer {ArrayBuffer} the soundfont file array buffer
21
- * @param enableEventSystem {boolean} enables the event system. Defaults to true
22
- * @param startRenderingData {StartRenderingDataConfig} if set, starts playing this immediately and restores the values
23
- * @param effectsConfig {EffectsConfig} optional configuration for the audio effects.
24
- */
25
18
  export class Synthetizer {
26
19
  /**
27
20
  * Creates a new instance of the SpessaSynth synthesizer
@@ -29,13 +22,13 @@ export class Synthetizer {
29
22
  * @param soundFontBuffer {ArrayBuffer} the soundfont file array buffer
30
23
  * @param enableEventSystem {boolean} enables the event system. Defaults to true
31
24
  * @param startRenderingData {StartRenderingDataConfig} if set, starts playing this immediately and restores the values
32
- * @param effectsConfig {EffectsConfig} optional configuration for the audio effects.
25
+ * @param synthConfig {SynthConfig} optional configuration for the synthesizer.
33
26
  */
34
- constructor(targetNode: AudioNode, soundFontBuffer: ArrayBuffer, enableEventSystem?: boolean, startRenderingData?: StartRenderingDataConfig, effectsConfig?: EffectsConfig);
27
+ constructor(targetNode: AudioNode, soundFontBuffer: ArrayBuffer, enableEventSystem?: boolean, startRenderingData?: StartRenderingDataConfig, synthConfig?: SynthConfig);
35
28
  context: BaseAudioContext;
36
29
  targetNode: AudioNode;
37
30
  /**
38
- * Allows to set up custom event listeners for the synthesizer
31
+ * Allows setting up custom event listeners for the synthesizer
39
32
  * @type {EventHandler}
40
33
  */
41
34
  eventHandler: EventHandler;
@@ -43,13 +36,13 @@ export class Synthetizer {
43
36
  _destroyed: boolean;
44
37
  /**
45
38
  * the new channels will have their audio sent to the moduled output by this constant.
46
- * what does that mean? e.g. if outputsAmount is 16, then channel's 16 audio will be sent to channel 0
39
+ * what does that mean? e.g., if outputsAmount is 16, then channel's 16 audio data will be sent to channel 0
47
40
  * @type {number}
48
41
  * @private
49
42
  */
50
43
  private _outputsAmount;
51
44
  /**
52
- * the amount of midi channels
45
+ * the number of midi channels
53
46
  * @type {number}
54
47
  */
55
48
  channelsAmount: number;
@@ -74,10 +67,10 @@ export class Synthetizer {
74
67
  */
75
68
  _highPerformanceMode: boolean;
76
69
  /**
77
- * @type {EffectsConfig}
70
+ * @type {SynthConfig}
78
71
  */
79
- effectsConfig: EffectsConfig;
80
- worklet: AudioWorkletNode;
72
+ effectsConfig: SynthConfig;
73
+ worklet: any;
81
74
  /**
82
75
  * The synth's soundfont manager
83
76
  * @type {SoundfontManager}
@@ -101,12 +94,12 @@ export class Synthetizer {
101
94
  reverbProcessor: ConvolverNode;
102
95
  chorusProcessor: FancyChorus;
103
96
  /**
104
- * The maximum amount of voices allowed at once
97
+ * The maximum number of voices allowed at once
105
98
  * @param value {number}
106
99
  */
107
100
  set voiceCap(value: number);
108
101
  /**
109
- * The maximum amount of voices allowed at once
102
+ * The maximum number of voices allowed at once
110
103
  * @returns {number}
111
104
  */
112
105
  get voiceCap(): number;
@@ -121,7 +114,7 @@ export class Synthetizer {
121
114
  */
122
115
  get currentTime(): number;
123
116
  /**
124
- * @returns {number} the current amount of voices playing
117
+ * @returns {number} the current number of voices playing
125
118
  */
126
119
  get voicesAmount(): number;
127
120
  /**
@@ -171,7 +164,7 @@ export class Synthetizer {
171
164
  rate: number;
172
165
  }): void;
173
166
  /**
174
- * Connects the individual audio outputs to the given audio nodes. In the app it's used by the renderer.
167
+ * Connects the individual audio outputs to the given audio nodes. In the app, it's used by the renderer.
175
168
  * @param audioNodes {AudioNode[]}
176
169
  */
177
170
  connectIndividualOutputs(audioNodes: AudioNode[]): void;
@@ -237,7 +230,7 @@ export class Synthetizer {
237
230
  */
238
231
  pitchWheel(channel: number, MSB: number, LSB: number): void;
239
232
  /**
240
- * Transposes the synthetizer's pitch by given semitones amount (percussion channels do not get affected)
233
+ * Transposes the synthetizer's pitch by given semitones amount (percussion channels don’t get affected)
241
234
  * @param semitones {number} the semitones to transpose by. Can be a floating point number for more precision
242
235
  */
243
236
  transpose(semitones: number): void;
@@ -350,7 +343,8 @@ export type StartRenderingDataConfig = {
350
343
  */
351
344
  snapshot: SynthesizerSnapshot;
352
345
  /**
353
- * - if synth should use one output with 32 channels (2 audio channels for each midi channel). this disables chorus and reverb.
346
+ * - if synth should use one output with 32 channels (2 audio channels for each midi channel).
347
+ * this disabled chorus and reverb.
354
348
  */
355
349
  oneOutput: boolean | undefined;
356
350
  /**
package/LICENSE CHANGED
File without changes
package/README.md CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spessasynth_lib",
3
- "version": "3.24.0",
3
+ "version": "3.24.3",
4
4
  "description": "MIDI and SoundFont2/DLS library with no compromises",
5
5
  "browser": "index.js",
6
6
  "types": "@types/index.d.ts",
File without changes