spessasynth_lib 3.24.3 → 3.24.4
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.
- package/package.json +1 -2
- package/sequencer/worklet_sequencer/worklet_sequencer.js +6 -0
- package/synthetizer/worklet_processor.min.js +6 -6
- package/@types/external_midi/midi_handler.d.ts +0 -39
- package/@types/external_midi/web_midi_link.d.ts +0 -12
- package/@types/externals/stbvorbis_sync/stbvorbis_sync.min.d.ts +0 -1
- package/@types/index.d.ts +0 -44
- package/@types/midi_parser/basic_midi.d.ts +0 -36
- package/@types/midi_parser/midi_builder.d.ts +0 -68
- package/@types/midi_parser/midi_data.d.ts +0 -46
- package/@types/midi_parser/midi_editor.d.ts +0 -89
- package/@types/midi_parser/midi_loader.d.ts +0 -30
- package/@types/midi_parser/midi_message.d.ts +0 -155
- package/@types/midi_parser/midi_sequence.d.ts +0 -135
- package/@types/midi_parser/midi_writer.d.ts +0 -6
- package/@types/midi_parser/rmidi_writer.d.ts +0 -85
- package/@types/midi_parser/used_keys_loaded.d.ts +0 -10
- package/@types/sequencer/sequencer.d.ts +0 -277
- package/@types/sequencer/worklet_sequencer/sequencer_message.d.ts +0 -31
- package/@types/soundfont/basic_soundfont/basic_instrument.d.ts +0 -29
- package/@types/soundfont/basic_soundfont/basic_preset.d.ts +0 -86
- package/@types/soundfont/basic_soundfont/basic_sample.d.ts +0 -88
- package/@types/soundfont/basic_soundfont/basic_soundfont.d.ts +0 -102
- package/@types/soundfont/basic_soundfont/basic_zone.d.ts +0 -58
- package/@types/soundfont/basic_soundfont/basic_zones.d.ts +0 -22
- package/@types/soundfont/basic_soundfont/generator.d.ts +0 -102
- package/@types/soundfont/basic_soundfont/modulator.d.ts +0 -92
- package/@types/soundfont/basic_soundfont/riff_chunk.d.ts +0 -45
- package/@types/soundfont/basic_soundfont/write_dls/art2.d.ts +0 -6
- package/@types/soundfont/basic_soundfont/write_dls/articulator.d.ts +0 -28
- package/@types/soundfont/basic_soundfont/write_dls/combine_zones.d.ts +0 -8
- package/@types/soundfont/basic_soundfont/write_dls/ins.d.ts +0 -7
- package/@types/soundfont/basic_soundfont/write_dls/lins.d.ts +0 -5
- package/@types/soundfont/basic_soundfont/write_dls/modulator_converter.d.ts +0 -11
- package/@types/soundfont/basic_soundfont/write_dls/rgn2.d.ts +0 -8
- package/@types/soundfont/basic_soundfont/write_dls/wave.d.ts +0 -6
- package/@types/soundfont/basic_soundfont/write_dls/write_dls.d.ts +0 -6
- package/@types/soundfont/basic_soundfont/write_dls/wsmp.d.ts +0 -12
- package/@types/soundfont/basic_soundfont/write_dls/wvpl.d.ts +0 -8
- package/@types/soundfont/basic_soundfont/write_sf2/ibag.d.ts +0 -6
- package/@types/soundfont/basic_soundfont/write_sf2/igen.d.ts +0 -6
- package/@types/soundfont/basic_soundfont/write_sf2/imod.d.ts +0 -6
- package/@types/soundfont/basic_soundfont/write_sf2/inst.d.ts +0 -6
- package/@types/soundfont/basic_soundfont/write_sf2/pbag.d.ts +0 -6
- package/@types/soundfont/basic_soundfont/write_sf2/pgen.d.ts +0 -6
- package/@types/soundfont/basic_soundfont/write_sf2/phdr.d.ts +0 -6
- package/@types/soundfont/basic_soundfont/write_sf2/pmod.d.ts +0 -6
- package/@types/soundfont/basic_soundfont/write_sf2/sdta.d.ts +0 -11
- package/@types/soundfont/basic_soundfont/write_sf2/shdr.d.ts +0 -8
- package/@types/soundfont/basic_soundfont/write_sf2/soundfont_trimmer.d.ts +0 -6
- package/@types/soundfont/basic_soundfont/write_sf2/write.d.ts +0 -21
- package/@types/soundfont/dls/articulator_converter.d.ts +0 -19
- package/@types/soundfont/dls/dls_destinations.d.ts +0 -29
- package/@types/soundfont/dls/dls_preset.d.ts +0 -13
- package/@types/soundfont/dls/dls_sample.d.ts +0 -19
- package/@types/soundfont/dls/dls_soundfont.d.ts +0 -31
- package/@types/soundfont/dls/dls_sources.d.ts +0 -27
- package/@types/soundfont/dls/dls_zone.d.ts +0 -23
- package/@types/soundfont/dls/read_articulation.d.ts +0 -12
- package/@types/soundfont/dls/read_instrument.d.ts +0 -5
- package/@types/soundfont/dls/read_instrument_list.d.ts +0 -5
- package/@types/soundfont/dls/read_lart.d.ts +0 -7
- package/@types/soundfont/dls/read_region.d.ts +0 -7
- package/@types/soundfont/dls/read_samples.d.ts +0 -5
- package/@types/soundfont/load_soundfont.d.ts +0 -6
- package/@types/soundfont/read_sf2/generators.d.ts +0 -16
- package/@types/soundfont/read_sf2/instruments.d.ts +0 -29
- package/@types/soundfont/read_sf2/modulators.d.ts +0 -15
- package/@types/soundfont/read_sf2/presets.d.ts +0 -30
- package/@types/soundfont/read_sf2/samples.d.ts +0 -55
- package/@types/soundfont/read_sf2/soundfont.d.ts +0 -28
- package/@types/soundfont/read_sf2/zones.d.ts +0 -99
- package/@types/synthetizer/audio_effects/effects_config.d.ts +0 -41
- package/@types/synthetizer/audio_effects/fancy_chorus.d.ts +0 -97
- package/@types/synthetizer/audio_effects/reverb.d.ts +0 -7
- package/@types/synthetizer/key_modifier_manager.d.ts +0 -56
- package/@types/synthetizer/synth_event_handler.d.ts +0 -263
- package/@types/synthetizer/synth_soundfont_manager.d.ts +0 -52
- package/@types/synthetizer/synthetizer.d.ts +0 -358
- package/@types/synthetizer/worklet_system/message_protocol/worklet_message.d.ts +0 -98
- package/@types/synthetizer/worklet_system/worklet_methods/worklet_key_modifier.d.ts +0 -77
- package/@types/synthetizer/worklet_system/worklet_methods/worklet_soundfont_manager/sfman_message.d.ts +0 -7
- package/@types/synthetizer/worklet_system/worklet_utilities/controller_tables.d.ts +0 -23
- package/@types/synthetizer/worklet_system/worklet_utilities/worklet_processor_channel.d.ts +0 -155
- package/@types/synthetizer/worklet_url.d.ts +0 -5
- package/@types/utils/buffer_to_wav.d.ts +0 -31
- package/@types/utils/byte_functions/big_endian.d.ts +0 -13
- package/@types/utils/byte_functions/little_endian.d.ts +0 -35
- package/@types/utils/byte_functions/string.d.ts +0 -27
- package/@types/utils/byte_functions/variable_length_quantity.d.ts +0 -12
- package/@types/utils/indexed_array.d.ts +0 -21
- package/@types/utils/loggin.d.ts +0 -26
- package/@types/utils/other.d.ts +0 -37
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* synth_event_handler.js
|
|
3
|
-
* purpose: manages the synthesizer's event system, calling assinged functions when synthesizer requests dispatching the event
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @typedef {Object} NoteOnCallback
|
|
7
|
-
* @property {number} midiNote - The MIDI note number.
|
|
8
|
-
* @property {number} channel - The MIDI channel number.
|
|
9
|
-
* @property {number} velocity - The velocity of the note.
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* @typedef {Object} NoteOffCallback
|
|
13
|
-
* @property {number} midiNote - The MIDI note number.
|
|
14
|
-
* @property {number} channel - The MIDI channel number.
|
|
15
|
-
*/
|
|
16
|
-
/**
|
|
17
|
-
* @typedef {Object} DrumChangeCallback
|
|
18
|
-
* @property {number} channel - The MIDI channel number.
|
|
19
|
-
* @property {boolean} isDrumChannel - Indicates if the channel is a drum channel.
|
|
20
|
-
*/
|
|
21
|
-
/**
|
|
22
|
-
* @typedef {Object} ProgramChangeCallback
|
|
23
|
-
* @property {number} channel - The MIDI channel number.
|
|
24
|
-
* @property {number} program - The program number.
|
|
25
|
-
* @property {number} bank - The bank number.
|
|
26
|
-
* @property {boolean} userCalled - Indicates if the change was user-initiated.
|
|
27
|
-
*/
|
|
28
|
-
/**
|
|
29
|
-
* @typedef {Object} ControllerChangeCallback
|
|
30
|
-
* @property {number} channel - The MIDI channel number.
|
|
31
|
-
* @property {number} controllerNumber - The controller number.
|
|
32
|
-
* @property {number} controllerValue - The value of the controller.
|
|
33
|
-
*/
|
|
34
|
-
/**
|
|
35
|
-
* @typedef {Object} MuteChannelCallback
|
|
36
|
-
* @property {number} channel - The MIDI channel number.
|
|
37
|
-
* @property {boolean} isMuted - Indicates if the channel is muted.
|
|
38
|
-
*/
|
|
39
|
-
/**
|
|
40
|
-
* @typedef {Object} PresetListChangeCallbackSingle
|
|
41
|
-
* @property {string} presetName - The name of the preset.
|
|
42
|
-
* @property {number} bank - The bank number.
|
|
43
|
-
* @property {number} program - The program number.
|
|
44
|
-
*/
|
|
45
|
-
/**
|
|
46
|
-
* @typedef {PresetListChangeCallbackSingle[]} PresetListChangeCallback - A list of preset objects.
|
|
47
|
-
*/
|
|
48
|
-
/**
|
|
49
|
-
* @typedef {Object} SynthDisplayCallback
|
|
50
|
-
* @property {Uint8Array} displayData - The data to display.
|
|
51
|
-
* @property {SynthDisplayType} displayType - The type of display.
|
|
52
|
-
*/
|
|
53
|
-
/**
|
|
54
|
-
* @typedef {Object} PitchWheelCallback
|
|
55
|
-
* @property {number} channel - The MIDI channel number.
|
|
56
|
-
* @property {number} MSB - The most significant byte of the pitch wheel value.
|
|
57
|
-
* @property {number} LSB - The least significant byte of the pitch wheel value.
|
|
58
|
-
*/
|
|
59
|
-
/**
|
|
60
|
-
* @typedef {Object} ChannelPressureCallback
|
|
61
|
-
* @property {number} channel - The MIDI channel number.
|
|
62
|
-
* @property {number} pressure - The pressure value.
|
|
63
|
-
*/
|
|
64
|
-
/**
|
|
65
|
-
* @typedef {Error} SoundfontErrorCallback - The error message for soundfont errors.
|
|
66
|
-
*/
|
|
67
|
-
/**
|
|
68
|
-
* @typedef {
|
|
69
|
-
* NoteOnCallback |
|
|
70
|
-
* NoteOffCallback |
|
|
71
|
-
* DrumChangeCallback |
|
|
72
|
-
* ProgramChangeCallback |
|
|
73
|
-
* ControllerChangeCallback |
|
|
74
|
-
* MuteChannelCallback |
|
|
75
|
-
* PresetListChangeCallback |
|
|
76
|
-
* PitchWheelCallback |
|
|
77
|
-
* SoundfontErrorCallback |
|
|
78
|
-
* ChannelPressureCallback |
|
|
79
|
-
* SynthDisplayCallback |
|
|
80
|
-
* undefined
|
|
81
|
-
* } EventCallbackData
|
|
82
|
-
*/
|
|
83
|
-
/**
|
|
84
|
-
* @typedef {
|
|
85
|
-
* "noteon"|
|
|
86
|
-
* "noteoff"|
|
|
87
|
-
* "pitchwheel"|
|
|
88
|
-
* "controllerchange"|
|
|
89
|
-
* "programchange"|
|
|
90
|
-
* "channelpressure"|
|
|
91
|
-
* "polypressure" |
|
|
92
|
-
* "drumchange"|
|
|
93
|
-
* "stopall"|
|
|
94
|
-
* "newchannel"|
|
|
95
|
-
* "mutechannel"|
|
|
96
|
-
* "presetlistchange"|
|
|
97
|
-
* "allcontrollerreset"|
|
|
98
|
-
* "soundfonterror"|
|
|
99
|
-
* "synthdisplay"} EventTypes
|
|
100
|
-
*/
|
|
101
|
-
export class EventHandler {
|
|
102
|
-
/**
|
|
103
|
-
* The main list of events
|
|
104
|
-
* @type {Object<EventTypes, Object<string, function(EventCallbackData)>>}
|
|
105
|
-
*/
|
|
106
|
-
events: any;
|
|
107
|
-
/**
|
|
108
|
-
* Set to 0 to disabled, otherwise in seconds
|
|
109
|
-
* @type {number}
|
|
110
|
-
*/
|
|
111
|
-
timeDelay: number;
|
|
112
|
-
/**
|
|
113
|
-
* Adds a new event listener
|
|
114
|
-
* @param name {EventTypes}
|
|
115
|
-
* @param id {string} the unique identifier for the event (to delete it
|
|
116
|
-
* @param callback {function(EventCallbackData)}
|
|
117
|
-
*/
|
|
118
|
-
addEvent(name: EventTypes, id: string, callback: (arg0: EventCallbackData) => any): void;
|
|
119
|
-
/**
|
|
120
|
-
* Removes an event listener
|
|
121
|
-
* @param name {EventTypes}
|
|
122
|
-
* @param id {string}
|
|
123
|
-
*/
|
|
124
|
-
removeEvent(name: EventTypes, id: string): void;
|
|
125
|
-
/**
|
|
126
|
-
* Calls the given event
|
|
127
|
-
* @param name {EventTypes}
|
|
128
|
-
* @param eventData {EventCallbackData}
|
|
129
|
-
*/
|
|
130
|
-
callEvent(name: EventTypes, eventData: EventCallbackData): void;
|
|
131
|
-
}
|
|
132
|
-
export type NoteOnCallback = {
|
|
133
|
-
/**
|
|
134
|
-
* - The MIDI note number.
|
|
135
|
-
*/
|
|
136
|
-
midiNote: number;
|
|
137
|
-
/**
|
|
138
|
-
* - The MIDI channel number.
|
|
139
|
-
*/
|
|
140
|
-
channel: number;
|
|
141
|
-
/**
|
|
142
|
-
* - The velocity of the note.
|
|
143
|
-
*/
|
|
144
|
-
velocity: number;
|
|
145
|
-
};
|
|
146
|
-
export type NoteOffCallback = {
|
|
147
|
-
/**
|
|
148
|
-
* - The MIDI note number.
|
|
149
|
-
*/
|
|
150
|
-
midiNote: number;
|
|
151
|
-
/**
|
|
152
|
-
* - The MIDI channel number.
|
|
153
|
-
*/
|
|
154
|
-
channel: number;
|
|
155
|
-
};
|
|
156
|
-
export type DrumChangeCallback = {
|
|
157
|
-
/**
|
|
158
|
-
* - The MIDI channel number.
|
|
159
|
-
*/
|
|
160
|
-
channel: number;
|
|
161
|
-
/**
|
|
162
|
-
* - Indicates if the channel is a drum channel.
|
|
163
|
-
*/
|
|
164
|
-
isDrumChannel: boolean;
|
|
165
|
-
};
|
|
166
|
-
export type ProgramChangeCallback = {
|
|
167
|
-
/**
|
|
168
|
-
* - The MIDI channel number.
|
|
169
|
-
*/
|
|
170
|
-
channel: number;
|
|
171
|
-
/**
|
|
172
|
-
* - The program number.
|
|
173
|
-
*/
|
|
174
|
-
program: number;
|
|
175
|
-
/**
|
|
176
|
-
* - The bank number.
|
|
177
|
-
*/
|
|
178
|
-
bank: number;
|
|
179
|
-
/**
|
|
180
|
-
* - Indicates if the change was user-initiated.
|
|
181
|
-
*/
|
|
182
|
-
userCalled: boolean;
|
|
183
|
-
};
|
|
184
|
-
export type ControllerChangeCallback = {
|
|
185
|
-
/**
|
|
186
|
-
* - The MIDI channel number.
|
|
187
|
-
*/
|
|
188
|
-
channel: number;
|
|
189
|
-
/**
|
|
190
|
-
* - The controller number.
|
|
191
|
-
*/
|
|
192
|
-
controllerNumber: number;
|
|
193
|
-
/**
|
|
194
|
-
* - The value of the controller.
|
|
195
|
-
*/
|
|
196
|
-
controllerValue: number;
|
|
197
|
-
};
|
|
198
|
-
export type MuteChannelCallback = {
|
|
199
|
-
/**
|
|
200
|
-
* - The MIDI channel number.
|
|
201
|
-
*/
|
|
202
|
-
channel: number;
|
|
203
|
-
/**
|
|
204
|
-
* - Indicates if the channel is muted.
|
|
205
|
-
*/
|
|
206
|
-
isMuted: boolean;
|
|
207
|
-
};
|
|
208
|
-
export type PresetListChangeCallbackSingle = {
|
|
209
|
-
/**
|
|
210
|
-
* - The name of the preset.
|
|
211
|
-
*/
|
|
212
|
-
presetName: string;
|
|
213
|
-
/**
|
|
214
|
-
* - The bank number.
|
|
215
|
-
*/
|
|
216
|
-
bank: number;
|
|
217
|
-
/**
|
|
218
|
-
* - The program number.
|
|
219
|
-
*/
|
|
220
|
-
program: number;
|
|
221
|
-
};
|
|
222
|
-
/**
|
|
223
|
-
* - A list of preset objects.
|
|
224
|
-
*/
|
|
225
|
-
export type PresetListChangeCallback = PresetListChangeCallbackSingle[];
|
|
226
|
-
export type SynthDisplayCallback = {
|
|
227
|
-
/**
|
|
228
|
-
* - The data to display.
|
|
229
|
-
*/
|
|
230
|
-
displayData: Uint8Array;
|
|
231
|
-
/**
|
|
232
|
-
* - The type of display.
|
|
233
|
-
*/
|
|
234
|
-
displayType: SynthDisplayType;
|
|
235
|
-
};
|
|
236
|
-
export type PitchWheelCallback = {
|
|
237
|
-
/**
|
|
238
|
-
* - The MIDI channel number.
|
|
239
|
-
*/
|
|
240
|
-
channel: number;
|
|
241
|
-
/**
|
|
242
|
-
* - The most significant byte of the pitch wheel value.
|
|
243
|
-
*/
|
|
244
|
-
MSB: number;
|
|
245
|
-
/**
|
|
246
|
-
* - The least significant byte of the pitch wheel value.
|
|
247
|
-
*/
|
|
248
|
-
LSB: number;
|
|
249
|
-
};
|
|
250
|
-
export type ChannelPressureCallback = {
|
|
251
|
-
/**
|
|
252
|
-
* - The MIDI channel number.
|
|
253
|
-
*/
|
|
254
|
-
channel: number;
|
|
255
|
-
/**
|
|
256
|
-
* - The pressure value.
|
|
257
|
-
*/
|
|
258
|
-
pressure: number;
|
|
259
|
-
};
|
|
260
|
-
/**
|
|
261
|
-
* - The error message for soundfont errors.
|
|
262
|
-
*/
|
|
263
|
-
export type SoundfontErrorCallback = Error;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
export class SoundfontManager {
|
|
2
|
-
/**
|
|
3
|
-
* Creates a new instance of the soundfont manager
|
|
4
|
-
* @param synth {Synthetizer}
|
|
5
|
-
*/
|
|
6
|
-
constructor(synth: Synthetizer);
|
|
7
|
-
/**
|
|
8
|
-
* The current list of soundfonts, in order from the most important to the least.
|
|
9
|
-
* @type {{
|
|
10
|
-
* id: string,
|
|
11
|
-
* bankOffset: number
|
|
12
|
-
* }[]}
|
|
13
|
-
*/
|
|
14
|
-
soundfontList: {
|
|
15
|
-
id: string;
|
|
16
|
-
bankOffset: number;
|
|
17
|
-
}[];
|
|
18
|
-
/**
|
|
19
|
-
* @type {MessagePort}
|
|
20
|
-
* @private
|
|
21
|
-
*/
|
|
22
|
-
private _port;
|
|
23
|
-
synth: Synthetizer;
|
|
24
|
-
/**
|
|
25
|
-
* @private
|
|
26
|
-
* @param type {WorkletSoundfontManagerMessageType}
|
|
27
|
-
* @param data {any}
|
|
28
|
-
*/
|
|
29
|
-
private _sendToWorklet;
|
|
30
|
-
/**
|
|
31
|
-
* Adds a new soundfont buffer with a given ID
|
|
32
|
-
* @param soundfontBuffer {ArrayBuffer} - the soundfont's buffer
|
|
33
|
-
* @param id {string} - the soundfont's unique identifier
|
|
34
|
-
* @param bankOffset {number} - the soundfont's bank offset. Default is 0
|
|
35
|
-
*/
|
|
36
|
-
addNewSoundFont(soundfontBuffer: ArrayBuffer, id: string, bankOffset?: number): Promise<void>;
|
|
37
|
-
/**
|
|
38
|
-
* Deletes a soundfont with the given ID
|
|
39
|
-
* @param id {string} - the soundfont to delete
|
|
40
|
-
*/
|
|
41
|
-
deleteSoundFont(id: string): void;
|
|
42
|
-
/**
|
|
43
|
-
* Rearranges the soundfonts in a given order
|
|
44
|
-
* @param newList {string[]} the order of soundfonts, a list of identifiers, first overwrites second
|
|
45
|
-
*/
|
|
46
|
-
rearrangeSoundFonts(newList: string[]): void;
|
|
47
|
-
/**
|
|
48
|
-
* DELETES ALL SOUNDFONTS!! and creates a new one with id "main"
|
|
49
|
-
* @param newBuffer {ArrayBuffer}
|
|
50
|
-
*/
|
|
51
|
-
reloadManager(newBuffer: ArrayBuffer): Promise<void>;
|
|
52
|
-
}
|
|
@@ -1,358 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* synthesizer.js
|
|
3
|
-
* purpose: responds to midi messages and called functions, managing the channels and passing the messages to them
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @typedef {Object} StartRenderingDataConfig
|
|
7
|
-
* @property {BasicMIDI} parsedMIDI - the MIDI to render
|
|
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).
|
|
10
|
-
* this disabled chorus and reverb.
|
|
11
|
-
* @property {number|undefined} loopCount - the times to loop the song
|
|
12
|
-
*/
|
|
13
|
-
export const WORKLET_PROCESSOR_NAME: "spessasynth-worklet-system";
|
|
14
|
-
export const VOICE_CAP: 350;
|
|
15
|
-
export const DEFAULT_PERCUSSION: 9;
|
|
16
|
-
export const MIDI_CHANNEL_COUNT: 16;
|
|
17
|
-
export const DEFAULT_SYNTH_MODE: "gs";
|
|
18
|
-
export class Synthetizer {
|
|
19
|
-
/**
|
|
20
|
-
* Creates a new instance of the SpessaSynth synthesizer
|
|
21
|
-
* @param targetNode {AudioNode}
|
|
22
|
-
* @param soundFontBuffer {ArrayBuffer} the soundfont file array buffer
|
|
23
|
-
* @param enableEventSystem {boolean} enables the event system. Defaults to true
|
|
24
|
-
* @param startRenderingData {StartRenderingDataConfig} if set, starts playing this immediately and restores the values
|
|
25
|
-
* @param synthConfig {SynthConfig} optional configuration for the synthesizer.
|
|
26
|
-
*/
|
|
27
|
-
constructor(targetNode: AudioNode, soundFontBuffer: ArrayBuffer, enableEventSystem?: boolean, startRenderingData?: StartRenderingDataConfig, synthConfig?: SynthConfig);
|
|
28
|
-
context: BaseAudioContext;
|
|
29
|
-
targetNode: AudioNode;
|
|
30
|
-
/**
|
|
31
|
-
* Allows setting up custom event listeners for the synthesizer
|
|
32
|
-
* @type {EventHandler}
|
|
33
|
-
*/
|
|
34
|
-
eventHandler: EventHandler;
|
|
35
|
-
_voiceCap: number;
|
|
36
|
-
_destroyed: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* the new channels will have their audio sent to the moduled output by this constant.
|
|
39
|
-
* what does that mean? e.g., if outputsAmount is 16, then channel's 16 audio data will be sent to channel 0
|
|
40
|
-
* @type {number}
|
|
41
|
-
* @private
|
|
42
|
-
*/
|
|
43
|
-
private _outputsAmount;
|
|
44
|
-
/**
|
|
45
|
-
* the number of midi channels
|
|
46
|
-
* @type {number}
|
|
47
|
-
*/
|
|
48
|
-
channelsAmount: number;
|
|
49
|
-
/**
|
|
50
|
-
* @type {function}
|
|
51
|
-
*/
|
|
52
|
-
resolveWhenReady: Function;
|
|
53
|
-
/**
|
|
54
|
-
* Indicates if the synth is fully ready
|
|
55
|
-
* @type {Promise<void>}
|
|
56
|
-
*/
|
|
57
|
-
isReady: Promise<void>;
|
|
58
|
-
/**
|
|
59
|
-
* individual channel voices amount
|
|
60
|
-
* @type {ChannelProperty[]}
|
|
61
|
-
*/
|
|
62
|
-
channelProperties: ChannelProperty[];
|
|
63
|
-
_voicesAmount: number;
|
|
64
|
-
/**
|
|
65
|
-
* For Black MIDI's - forces release time to 50ms
|
|
66
|
-
* @type {boolean}
|
|
67
|
-
*/
|
|
68
|
-
_highPerformanceMode: boolean;
|
|
69
|
-
/**
|
|
70
|
-
* @type {SynthConfig}
|
|
71
|
-
*/
|
|
72
|
-
effectsConfig: SynthConfig;
|
|
73
|
-
worklet: any;
|
|
74
|
-
/**
|
|
75
|
-
* The synth's soundfont manager
|
|
76
|
-
* @type {SoundfontManager}
|
|
77
|
-
*/
|
|
78
|
-
soundfontManager: SoundfontManager;
|
|
79
|
-
/**
|
|
80
|
-
* The synth's key modifier manager
|
|
81
|
-
* @type {KeyModifierManager}
|
|
82
|
-
*/
|
|
83
|
-
keyModifierManager: KeyModifierManager;
|
|
84
|
-
/**
|
|
85
|
-
* @type {function(SynthesizerSnapshot)}
|
|
86
|
-
* @private
|
|
87
|
-
*/
|
|
88
|
-
private _snapshotCallback;
|
|
89
|
-
/**
|
|
90
|
-
* for the worklet sequencer's messages
|
|
91
|
-
* @type {function(WorkletSequencerReturnMessageType, any)}
|
|
92
|
-
*/
|
|
93
|
-
sequencerCallbackFunction: (arg0: WorkletSequencerReturnMessageType, arg1: any) => any;
|
|
94
|
-
reverbProcessor: ConvolverNode;
|
|
95
|
-
chorusProcessor: FancyChorus;
|
|
96
|
-
/**
|
|
97
|
-
* The maximum number of voices allowed at once
|
|
98
|
-
* @param value {number}
|
|
99
|
-
*/
|
|
100
|
-
set voiceCap(value: number);
|
|
101
|
-
/**
|
|
102
|
-
* The maximum number of voices allowed at once
|
|
103
|
-
* @returns {number}
|
|
104
|
-
*/
|
|
105
|
-
get voiceCap(): number;
|
|
106
|
-
/**
|
|
107
|
-
* For Black MIDI's - forces release time to 50ms
|
|
108
|
-
* @param {boolean} value
|
|
109
|
-
*/
|
|
110
|
-
set highPerformanceMode(value: boolean);
|
|
111
|
-
get highPerformanceMode(): boolean;
|
|
112
|
-
/**
|
|
113
|
-
* @returns {number} the audioContext's current time
|
|
114
|
-
*/
|
|
115
|
-
get currentTime(): number;
|
|
116
|
-
/**
|
|
117
|
-
* @returns {number} the current number of voices playing
|
|
118
|
-
*/
|
|
119
|
-
get voicesAmount(): number;
|
|
120
|
-
/**
|
|
121
|
-
* Sets the SpessaSynth's log level
|
|
122
|
-
* @param enableInfo {boolean} - enable info (verbose)
|
|
123
|
-
* @param enableWarning {boolean} - enable warnings (unrecognized messages)
|
|
124
|
-
* @param enableGroup {boolean} - enable groups (recomended)
|
|
125
|
-
* @param enableTable {boolean} - enable table (debug message)
|
|
126
|
-
*/
|
|
127
|
-
setLogLevel(enableInfo: boolean, enableWarning: boolean, enableGroup: boolean, enableTable: boolean): void;
|
|
128
|
-
/**
|
|
129
|
-
* @param type {masterParameterType}
|
|
130
|
-
* @param data {any}
|
|
131
|
-
* @private
|
|
132
|
-
*/
|
|
133
|
-
private _setMasterParam;
|
|
134
|
-
/**
|
|
135
|
-
* Sets the interpolation type for the synthesizer:
|
|
136
|
-
* 0 - linear
|
|
137
|
-
* 1 - nearest neighbor
|
|
138
|
-
* @param type {interpolationTypes}
|
|
139
|
-
*/
|
|
140
|
-
setInterpolationType(type: interpolationTypes): void;
|
|
141
|
-
/**
|
|
142
|
-
* Handles the messages received from the worklet
|
|
143
|
-
* @param message {WorkletReturnMessage}
|
|
144
|
-
* @private
|
|
145
|
-
*/
|
|
146
|
-
private handleMessage;
|
|
147
|
-
/**
|
|
148
|
-
* Gets a complete snapshot of the synthesizer, including controllers
|
|
149
|
-
* @returns {Promise<SynthesizerSnapshot>}
|
|
150
|
-
*/
|
|
151
|
-
getSynthesizerSnapshot(): Promise<SynthesizerSnapshot>;
|
|
152
|
-
/**
|
|
153
|
-
* Adds a new channel to the synthesizer
|
|
154
|
-
* @param postMessage {boolean} leave at true, set to false only at initialization
|
|
155
|
-
*/
|
|
156
|
-
addNewChannel(postMessage?: boolean): void;
|
|
157
|
-
/**
|
|
158
|
-
* @param channel {number}
|
|
159
|
-
* @param value {{delay: number, depth: number, rate: number}}
|
|
160
|
-
*/
|
|
161
|
-
setVibrato(channel: number, value: {
|
|
162
|
-
delay: number;
|
|
163
|
-
depth: number;
|
|
164
|
-
rate: number;
|
|
165
|
-
}): void;
|
|
166
|
-
/**
|
|
167
|
-
* Connects the individual audio outputs to the given audio nodes. In the app, it's used by the renderer.
|
|
168
|
-
* @param audioNodes {AudioNode[]}
|
|
169
|
-
*/
|
|
170
|
-
connectIndividualOutputs(audioNodes: AudioNode[]): void;
|
|
171
|
-
disableGSNRPparams(): void;
|
|
172
|
-
/**
|
|
173
|
-
* A message for debugging
|
|
174
|
-
*/
|
|
175
|
-
debugMessage(): void;
|
|
176
|
-
/**
|
|
177
|
-
* Starts playing a note
|
|
178
|
-
* @param channel {number} usually 0-15: the channel to play the note
|
|
179
|
-
* @param midiNote {number} 0-127 the key number of the note
|
|
180
|
-
* @param velocity {number} 0-127 the velocity of the note (generally controls loudness)
|
|
181
|
-
* @param enableDebugging {boolean} set to true to log technical details to console
|
|
182
|
-
*/
|
|
183
|
-
noteOn(channel: number, midiNote: number, velocity: number, enableDebugging?: boolean): void;
|
|
184
|
-
/**
|
|
185
|
-
* Stops playing a note
|
|
186
|
-
* @param channel {number} usually 0-15: the channel of the note
|
|
187
|
-
* @param midiNote {number} 0-127 the key number of the note
|
|
188
|
-
* @param force {boolean} instantly kills the note if true
|
|
189
|
-
*/
|
|
190
|
-
noteOff(channel: number, midiNote: number, force?: boolean): void;
|
|
191
|
-
/**
|
|
192
|
-
* Stops all notes
|
|
193
|
-
* @param force {boolean} if we should instantly kill the note, defaults to false
|
|
194
|
-
*/
|
|
195
|
-
stopAll(force?: boolean): void;
|
|
196
|
-
/**
|
|
197
|
-
* Changes the given controller
|
|
198
|
-
* @param channel {number} usually 0-15: the channel to change the controller
|
|
199
|
-
* @param controllerNumber {number} 0-127 the MIDI CC number
|
|
200
|
-
* @param controllerValue {number} 0-127 the controller value
|
|
201
|
-
* @param force {boolean} forces the controller change, even if it's locked or gm system is set and the cc is bank select
|
|
202
|
-
*/
|
|
203
|
-
controllerChange(channel: number, controllerNumber: number, controllerValue: number, force?: boolean): void;
|
|
204
|
-
/**
|
|
205
|
-
* Resets all controllers (for every channel)
|
|
206
|
-
*/
|
|
207
|
-
resetControllers(): void;
|
|
208
|
-
/**
|
|
209
|
-
* Applies pressure to a given channel
|
|
210
|
-
* @param channel {number} usually 0-15: the channel to change the controller
|
|
211
|
-
* @param pressure {number} 0-127: the pressure to apply
|
|
212
|
-
*/
|
|
213
|
-
channelPressure(channel: number, pressure: number): void;
|
|
214
|
-
/**
|
|
215
|
-
* Applies pressure to a given note
|
|
216
|
-
* @param channel {number} usually 0-15: the channel to change the controller
|
|
217
|
-
* @param midiNote {number} 0-127: the MIDI note
|
|
218
|
-
* @param pressure {number} 0-127: the pressure to apply
|
|
219
|
-
*/
|
|
220
|
-
polyPressure(channel: number, midiNote: number, pressure: number): void;
|
|
221
|
-
/**
|
|
222
|
-
* @param data {WorkletMessage}
|
|
223
|
-
*/
|
|
224
|
-
post(data: WorkletMessage): void;
|
|
225
|
-
/**
|
|
226
|
-
* Sets the pitch of the given channel
|
|
227
|
-
* @param channel {number} usually 0-15: the channel to change pitch
|
|
228
|
-
* @param MSB {number} SECOND byte of the MIDI pitchWheel message
|
|
229
|
-
* @param LSB {number} FIRST byte of the MIDI pitchWheel message
|
|
230
|
-
*/
|
|
231
|
-
pitchWheel(channel: number, MSB: number, LSB: number): void;
|
|
232
|
-
/**
|
|
233
|
-
* Transposes the synthetizer's pitch by given semitones amount (percussion channels don’t get affected)
|
|
234
|
-
* @param semitones {number} the semitones to transpose by. Can be a floating point number for more precision
|
|
235
|
-
*/
|
|
236
|
-
transpose(semitones: number): void;
|
|
237
|
-
/**
|
|
238
|
-
* Transposes the channel by given amount of semitones
|
|
239
|
-
* @param channel {number} the channel number
|
|
240
|
-
* @param semitones {number} the transposition of the channel, can be a float
|
|
241
|
-
* @param force {boolean} defaults to false, if true transposes the channel even if it's a drum channel
|
|
242
|
-
*/
|
|
243
|
-
transposeChannel(channel: number, semitones: number, force?: boolean): void;
|
|
244
|
-
/**
|
|
245
|
-
* Sets the main volume
|
|
246
|
-
* @param volume {number} 0-1 the volume
|
|
247
|
-
*/
|
|
248
|
-
setMainVolume(volume: number): void;
|
|
249
|
-
/**
|
|
250
|
-
* Sets the master stereo panning
|
|
251
|
-
* @param pan {number} -1 to 1, the pan (-1 is left, 0 is midde, 1 is right)
|
|
252
|
-
*/
|
|
253
|
-
setMasterPan(pan: number): void;
|
|
254
|
-
/**
|
|
255
|
-
* Sets the channel's pitch bend range, in semitones
|
|
256
|
-
* @param channel {number} usually 0-15: the channel to change
|
|
257
|
-
* @param pitchBendRangeSemitones {number} the bend range in semitones
|
|
258
|
-
*/
|
|
259
|
-
setPitchBendRange(channel: number, pitchBendRangeSemitones: number): void;
|
|
260
|
-
/**
|
|
261
|
-
* Changes the patch for a given channel
|
|
262
|
-
* @param channel {number} usually 0-15: the channel to change
|
|
263
|
-
* @param programNumber {number} 0-127 the MIDI patch number
|
|
264
|
-
* @param userChange {boolean} indicates if the program change has been called by user. defaults to false
|
|
265
|
-
*/
|
|
266
|
-
programChange(channel: number, programNumber: number, userChange?: boolean): void;
|
|
267
|
-
/**
|
|
268
|
-
* Overrides velocity on a given channel
|
|
269
|
-
* @param channel {number} usually 0-15: the channel to change
|
|
270
|
-
* @param velocity {number} 1-127, the velocity to use.
|
|
271
|
-
* 0 Disables this functionality
|
|
272
|
-
*/
|
|
273
|
-
velocityOverride(channel: number, velocity: number): void;
|
|
274
|
-
/**
|
|
275
|
-
* Causes the given midi channel to ignore controller messages for the given controller number
|
|
276
|
-
* @param channel {number} usually 0-15: the channel to lock
|
|
277
|
-
* @param controllerNumber {number} 0-127 MIDI CC number NOTE: -1 locks the preset
|
|
278
|
-
* @param isLocked {boolean} true if locked, false if unlocked
|
|
279
|
-
*/
|
|
280
|
-
lockController(channel: number, controllerNumber: number, isLocked: boolean): void;
|
|
281
|
-
/**
|
|
282
|
-
* Mutes or unmutes the given channel
|
|
283
|
-
* @param channel {number} usually 0-15: the channel to lock
|
|
284
|
-
* @param isMuted {boolean} indicates if the channel is muted
|
|
285
|
-
*/
|
|
286
|
-
muteChannel(channel: number, isMuted: boolean): void;
|
|
287
|
-
/**
|
|
288
|
-
* Reloads the sounfont.
|
|
289
|
-
* THIS IS DEPRECATED!
|
|
290
|
-
* USE soundfontManager INSTEAD
|
|
291
|
-
* @param soundFontBuffer {ArrayBuffer} the new soundfont file array buffer
|
|
292
|
-
* @return {Promise<void>}
|
|
293
|
-
* @deprecated Use the soundfontManager property
|
|
294
|
-
*/
|
|
295
|
-
reloadSoundFont(soundFontBuffer: ArrayBuffer): Promise<void>;
|
|
296
|
-
/**
|
|
297
|
-
* Sends a MIDI Sysex message to the synthesizer
|
|
298
|
-
* @param messageData {number[]|ArrayLike|Uint8Array} the message's data
|
|
299
|
-
* (excluding the F0 byte, but including the F7 at the end)
|
|
300
|
-
*/
|
|
301
|
-
systemExclusive(messageData: number[] | ArrayLike<any> | Uint8Array): void;
|
|
302
|
-
/**
|
|
303
|
-
* Toggles drums on a given channel
|
|
304
|
-
* @param channel {number}
|
|
305
|
-
* @param isDrum {boolean}
|
|
306
|
-
*/
|
|
307
|
-
setDrums(channel: number, isDrum: boolean): void;
|
|
308
|
-
/**
|
|
309
|
-
* sends a raw MIDI message to the synthesizer
|
|
310
|
-
* @param message {number[]|Uint8Array} the midi message, each number is a byte
|
|
311
|
-
* @param channelOffset {number} the channel offset of the message
|
|
312
|
-
*/
|
|
313
|
-
sendMessage(message: number[] | Uint8Array, channelOffset?: number): void;
|
|
314
|
-
/**
|
|
315
|
-
* Updates the reverb processor with a new impulse response
|
|
316
|
-
* @param buffer {AudioBuffer} the new reverb impulse response
|
|
317
|
-
*/
|
|
318
|
-
setReverbResponse(buffer: AudioBuffer): void;
|
|
319
|
-
/**
|
|
320
|
-
* Updates the chorus processor parameters
|
|
321
|
-
* @param config {ChorusConfig} the new chorus
|
|
322
|
-
*/
|
|
323
|
-
setChorusConfig(config: ChorusConfig): void;
|
|
324
|
-
/**
|
|
325
|
-
* Changes the effects gain
|
|
326
|
-
* @param reverbGain {number} the reverb gain, 0-1
|
|
327
|
-
* @param chorusGain {number} the chorus gain, 0-1
|
|
328
|
-
*/
|
|
329
|
-
setEffectsGain(reverbGain: number, chorusGain: number): void;
|
|
330
|
-
/**
|
|
331
|
-
* Destroys the synthesizer instance
|
|
332
|
-
*/
|
|
333
|
-
destroy(): void;
|
|
334
|
-
reverbateEverythingBecauseWhyNot(): string;
|
|
335
|
-
}
|
|
336
|
-
export type StartRenderingDataConfig = {
|
|
337
|
-
/**
|
|
338
|
-
* - the MIDI to render
|
|
339
|
-
*/
|
|
340
|
-
parsedMIDI: BasicMIDI;
|
|
341
|
-
/**
|
|
342
|
-
* - the snapshot to apply
|
|
343
|
-
*/
|
|
344
|
-
snapshot: SynthesizerSnapshot;
|
|
345
|
-
/**
|
|
346
|
-
* - if synth should use one output with 32 channels (2 audio channels for each midi channel).
|
|
347
|
-
* this disabled chorus and reverb.
|
|
348
|
-
*/
|
|
349
|
-
oneOutput: boolean | undefined;
|
|
350
|
-
/**
|
|
351
|
-
* - the times to loop the song
|
|
352
|
-
*/
|
|
353
|
-
loopCount: number | undefined;
|
|
354
|
-
};
|
|
355
|
-
import { EventHandler } from "./synth_event_handler.js";
|
|
356
|
-
import { SoundfontManager } from "./synth_soundfont_manager.js";
|
|
357
|
-
import { KeyModifierManager } from "./key_modifier_manager.js";
|
|
358
|
-
import { FancyChorus } from "./audio_effects/fancy_chorus.js";
|