spessasynth_lib 4.2.10 → 4.2.12

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/dist/index.d.ts CHANGED
@@ -1,123 +1,128 @@
1
- import { MIDIPatch, KeyModifier, SoundBankManagerListEntry, SynthProcessorEventData, BasicMIDI, MIDITrack, SequencerEvent, MIDIMessage, SpessaSynthProcessor, SpessaSynthSequencer, SynthProcessorOptions, BasicSoundBank, SoundFont2WriteOptions, DLSWriteOptions, RMIDIWriteOptions, SynthesizerSnapshot, SynthMethodOptions, CustomController, MIDIController, MasterParameterType, SynthProcessorEvent, ChannelProperty, PresetList, WaveWriteOptions } from 'spessasynth_core';
1
+ import { BasicMIDI, BasicSoundBank, ChannelProperty, CustomController, DLSWriteOptions, KeyModifier, MIDIController, MIDIMessage, MIDIPatch, MIDITrack, MasterParameterType, PresetList, RMIDIWriteOptions, SequencerEvent, SoundBankManagerListEntry, SoundFont2WriteOptions, SpessaSynthProcessor, SpessaSynthSequencer, SynthMethodOptions, SynthProcessorEvent, SynthProcessorEventData, SynthProcessorOptions, SynthesizerSnapshot, SynthesizerSnapshot as LibSynthesizerSnapshot, WaveWriteOptions } from "spessasynth_core";
2
2
 
3
+ //#region src/synthesizer/basic/key_modifier_manager.d.ts
3
4
  declare class WorkletKeyModifierManagerWrapper {
4
- private keyModifiers;
5
- private synth;
6
- constructor(synth: BasicSynthesizer);
7
- /**
8
- * Modifies a single key.
9
- * @param channel The channel affected. Usually 0-15.
10
- * @param midiNote The MIDI note to change. 0-127.
11
- * @param options The key's modifiers.
12
- */
13
- addModifier(channel: number, midiNote: number, options: Partial<{
14
- velocity: number;
15
- patch: MIDIPatch;
16
- gain: number;
17
- }>): void;
18
- /**
19
- * Gets a key modifier.
20
- * @param channel The channel affected. Usually 0-15.
21
- * @param midiNote The MIDI note to change. 0-127.
22
- * @returns The key modifier if it exists.
23
- */
24
- getModifier(channel: number, midiNote: number): KeyModifier | undefined;
25
- /**
26
- * Deletes a key modifier.
27
- * @param channel The channel affected. Usually 0-15.
28
- * @param midiNote The MIDI note to change. 0-127.
29
- */
30
- deleteModifier(channel: number, midiNote: number): void;
31
- /**
32
- * Clears ALL Modifiers
33
- */
34
- clearModifiers(): void;
35
- private sendToWorklet;
5
+ private keyModifiers;
6
+ private synth;
7
+ constructor(synth: BasicSynthesizer);
8
+ /**
9
+ * Modifies a single key.
10
+ * @param channel The channel affected. Usually 0-15.
11
+ * @param midiNote The MIDI note to change. 0-127.
12
+ * @param options The key's modifiers.
13
+ */
14
+ addModifier(channel: number, midiNote: number, options: Partial<{
15
+ velocity: number;
16
+ patch: MIDIPatch;
17
+ gain: number;
18
+ }>): void;
19
+ /**
20
+ * Gets a key modifier.
21
+ * @param channel The channel affected. Usually 0-15.
22
+ * @param midiNote The MIDI note to change. 0-127.
23
+ * @returns The key modifier if it exists.
24
+ */
25
+ getModifier(channel: number, midiNote: number): KeyModifier | undefined;
26
+ /**
27
+ * Deletes a key modifier.
28
+ * @param channel The channel affected. Usually 0-15.
29
+ * @param midiNote The MIDI note to change. 0-127.
30
+ */
31
+ deleteModifier(channel: number, midiNote: number): void;
32
+ /**
33
+ * Clears ALL Modifiers
34
+ */
35
+ clearModifiers(): void;
36
+ private sendToWorklet;
36
37
  }
37
-
38
+ //#endregion
39
+ //#region src/synthesizer/basic/sound_bank_manager.d.ts
38
40
  type LibSBKManagerEntry = Omit<SoundBankManagerListEntry, "soundBank">;
39
41
  declare class SoundBankManager {
40
- /**
41
- * All the sound banks, ordered from the most important to the least.
42
- */
43
- soundBankList: LibSBKManagerEntry[];
44
- private synth;
45
- /**
46
- * Creates a new instance of the sound bank manager.
47
- */
48
- constructor(synth: BasicSynthesizer);
49
- /**
50
- * The current sound bank priority order.
51
- * @returns The IDs of the sound banks in the current order.
52
- */
53
- get priorityOrder(): string[];
54
- /**
55
- * Rearranges the sound banks in a given order.
56
- * @param newList The order of sound banks, a list of identifiers, first overwrites second.
57
- */
58
- set priorityOrder(newList: string[]);
59
- /**
60
- * Adds a new sound bank buffer with a given ID.
61
- * @param soundBankBuffer The sound bank's buffer
62
- * @param id The sound bank's unique identifier.
63
- * @param bankOffset The sound bank's bank offset. Default is 0.
64
- */
65
- addSoundBank(soundBankBuffer: ArrayBuffer, id: string, bankOffset?: number): Promise<void>;
66
- /**
67
- * Deletes a sound bank with the given ID.
68
- * @param id The sound bank to delete.
69
- */
70
- deleteSoundBank(id: string): Promise<void>;
71
- private awaitResponse;
72
- private sendToWorklet;
42
+ /**
43
+ * All the sound banks, ordered from the most important to the least.
44
+ */
45
+ soundBankList: LibSBKManagerEntry[];
46
+ private synth;
47
+ /**
48
+ * Creates a new instance of the sound bank manager.
49
+ */
50
+ constructor(synth: BasicSynthesizer);
51
+ /**
52
+ * The current sound bank priority order.
53
+ * @returns The IDs of the sound banks in the current order.
54
+ */
55
+ get priorityOrder(): string[];
56
+ /**
57
+ * Rearranges the sound banks in a given order.
58
+ * @param newList The order of sound banks, a list of identifiers, first overwrites second.
59
+ */
60
+ set priorityOrder(newList: string[]);
61
+ /**
62
+ * Adds a new sound bank buffer with a given ID.
63
+ * @param soundBankBuffer The sound bank's buffer
64
+ * @param id The sound bank's unique identifier.
65
+ * @param bankOffset The sound bank's bank offset. Default is 0.
66
+ */
67
+ addSoundBank(soundBankBuffer: ArrayBuffer, id: string, bankOffset?: number): Promise<void>;
68
+ /**
69
+ * Deletes a sound bank with the given ID.
70
+ * @param id The sound bank to delete.
71
+ */
72
+ deleteSoundBank(id: string): Promise<void>;
73
+ private awaitResponse;
74
+ private sendToWorklet;
73
75
  }
74
-
76
+ //#endregion
77
+ //#region src/synthesizer/basic/synth_event_handler.d.ts
75
78
  type ProcessorEventCallback<T extends keyof SynthProcessorEventData> = (callbackData: SynthProcessorEventData[T]) => unknown;
76
79
  declare class SynthEventHandler {
77
- /**
78
- * The time delay before an event is called.
79
- * Set to 0 to disable it.
80
- */
81
- timeDelay: number;
82
- /**
83
- * The main list of events.
84
- * @private
85
- */
86
- private readonly events;
87
- /**
88
- * Adds a new event listener.
89
- * @param event The event to listen to.
90
- * @param id The unique identifier for the event. It can be used to overwrite existing callback with the same ID.
91
- * @param callback The callback for the event.
92
- */
93
- addEvent<T extends keyof SynthProcessorEventData>(event: T, id: string, callback: ProcessorEventCallback<T>): void;
94
- /**
95
- * Removes an event listener
96
- * @param name The event to remove a listener from.
97
- * @param id The unique identifier for the event to remove.
98
- */
99
- removeEvent<T extends keyof SynthProcessorEventData>(name: T, id: string): void;
100
- /**
101
- * Calls the given event.
102
- * INTERNAL USE ONLY!
103
- * @internal
104
- */
105
- callEventInternal<T extends keyof SynthProcessorEventData>(name: T, eventData: SynthProcessorEventData[T]): void;
80
+ /**
81
+ * The time delay before an event is called.
82
+ * Set to 0 to disable it.
83
+ */
84
+ timeDelay: number;
85
+ /**
86
+ * The main list of events.
87
+ * @private
88
+ */
89
+ private readonly events;
90
+ /**
91
+ * Adds a new event listener.
92
+ * @param event The event to listen to.
93
+ * @param id The unique identifier for the event. It can be used to overwrite existing callback with the same ID.
94
+ * @param callback The callback for the event.
95
+ */
96
+ addEvent<T extends keyof SynthProcessorEventData>(event: T, id: string, callback: ProcessorEventCallback<T>): void;
97
+ /**
98
+ * Removes an event listener
99
+ * @param name The event to remove a listener from.
100
+ * @param id The unique identifier for the event to remove.
101
+ */
102
+ removeEvent<T extends keyof SynthProcessorEventData>(name: T, id: string): void;
103
+ /**
104
+ * Calls the given event.
105
+ * INTERNAL USE ONLY!
106
+ * @internal
107
+ */
108
+ callEventInternal<T extends keyof SynthProcessorEventData>(name: T, eventData: SynthProcessorEventData[T]): void;
106
109
  }
107
-
110
+ //#endregion
111
+ //#region src/sequencer/enums.d.ts
108
112
  declare const songChangeType: {
109
- readonly shuffleOn: 1;
110
- readonly shuffleOff: 2;
111
- readonly index: 3;
113
+ readonly shuffleOn: 1;
114
+ readonly shuffleOff: 2;
115
+ readonly index: 3;
112
116
  };
113
117
  type SongChangeType = (typeof songChangeType)[keyof typeof songChangeType];
114
-
118
+ //#endregion
119
+ //#region src/sequencer/midi_data.d.ts
115
120
  declare class MIDIDataTrack extends MIDITrack {
116
- /**
117
- * THIS DATA WILL BE EMPTY! USE sequencer.getMIDI() TO GET THE ACTUAL DATA!
118
- */
119
- events: never[];
120
- constructor(track: MIDITrack);
121
+ /**
122
+ * THIS DATA WILL BE EMPTY! USE sequencer.getMIDI() TO GET THE ACTUAL DATA!
123
+ */
124
+ events: never[];
125
+ constructor(track: MIDITrack);
121
126
  }
122
127
  /**
123
128
  * A simplified version of the MIDI, accessible at all times from the Sequencer.
@@ -125,73 +130,72 @@ declare class MIDIDataTrack extends MIDITrack {
125
130
  * This class contains all properties that MIDI does, except for tracks and the embedded sound bank.
126
131
  */
127
132
  declare class MIDIData extends BasicMIDI {
128
- tracks: MIDIDataTrack[];
129
- /**
130
- * THIS DATA WILL BE EMPTY! USE sequencer.getMIDI() TO GET THE ACTUAL DATA!
131
- */
132
- embeddedSoundBank: undefined;
133
- /**
134
- * The byte length of the sound bank if it exists.
135
- */
136
- readonly embeddedSoundBankSize?: number;
137
- constructor(mid: BasicMIDI);
133
+ tracks: MIDIDataTrack[];
134
+ /**
135
+ * THIS DATA WILL BE EMPTY! USE sequencer.getMIDI() TO GET THE ACTUAL DATA!
136
+ */
137
+ embeddedSoundBank: undefined;
138
+ /**
139
+ * The byte length of the sound bank if it exists.
140
+ */
141
+ readonly embeddedSoundBankSize?: number;
142
+ constructor(mid: BasicMIDI);
138
143
  }
139
-
144
+ //#endregion
145
+ //#region src/sequencer/types.d.ts
140
146
  interface SequencerOptions {
141
- /**
142
- * If true, the sequencer will skip to the first note.
143
- */
144
- skipToFirstNoteOn: boolean;
145
- /**
146
- * The initial playback rate, defaults to 1.0 (normal speed).
147
- */
148
- initialPlaybackRate: number;
147
+ /**
148
+ * If true, the sequencer will skip to the first note.
149
+ */
150
+ skipToFirstNoteOn: boolean;
151
+ /**
152
+ * The initial playback rate, defaults to 1.0 (normal speed).
153
+ */
154
+ initialPlaybackRate: number;
149
155
  }
150
- type SequencerMessage = {
151
- [K in keyof SequencerMessageData]: {
152
- type: K;
153
- data: SequencerMessageData[K];
154
- id: number;
155
- };
156
- }[keyof SequencerMessageData];
156
+ type SequencerMessage = { [K in keyof SequencerMessageData]: {
157
+ type: K;
158
+ data: SequencerMessageData[K];
159
+ id: number;
160
+ } }[keyof SequencerMessageData];
157
161
  interface SequencerMessageData {
158
- loadNewSongList: SuppliedMIDIData[];
159
- pause: null;
160
- play: null;
161
- setTime: number;
162
- changeMIDIMessageSending: boolean;
163
- setPlaybackRate: number;
164
- setLoopCount: number;
165
- changeSong: {
166
- changeType: SongChangeType;
167
- data?: number;
168
- };
169
- getMIDI: null;
170
- setSkipToFirstNote: boolean;
162
+ loadNewSongList: SuppliedMIDIData[];
163
+ pause: null;
164
+ play: null;
165
+ setTime: number;
166
+ changeMIDIMessageSending: boolean;
167
+ setPlaybackRate: number;
168
+ setLoopCount: number;
169
+ changeSong: {
170
+ changeType: SongChangeType;
171
+ data?: number;
172
+ };
173
+ getMIDI: null;
174
+ setSkipToFirstNote: boolean;
171
175
  }
172
176
  type SequencerReturnMessage = (Exclude<SequencerEvent, {
173
- type: "songListChange";
177
+ type: "songListChange";
174
178
  }> & {
175
- id: number;
179
+ id: number;
176
180
  }) | (Extract<SequencerEvent, {
177
- type: "songListChange";
181
+ type: "songListChange";
178
182
  }> & {
179
- data: {
180
- shuffledSongIndexes: number[];
181
- };
182
- id: number;
183
+ data: {
184
+ shuffledSongIndexes: number[];
185
+ };
186
+ id: number;
183
187
  }) | {
184
- type: "getMIDI";
185
- data: BasicMIDI;
186
- id: number;
188
+ type: "getMIDI";
189
+ data: BasicMIDI;
190
+ id: number;
187
191
  } | {
188
- type: "midiError";
189
- data: Error;
190
- id: number;
192
+ type: "midiError";
193
+ data: Error;
194
+ id: number;
191
195
  } | {
192
- type: "sync";
193
- data: number;
194
- id: number;
196
+ type: "sync";
197
+ data: number;
198
+ id: number;
195
199
  };
196
200
  /**
197
201
  * Sequencer.js
@@ -201,982 +205,979 @@ type SequencerReturnMessage = (Exclude<SequencerEvent, {
201
205
  * and only communicates with the worklet sequencer which does the actual playback
202
206
  */
203
207
  type SuppliedMIDIData = BasicMIDI | {
204
- /**
205
- * The binary data of the file.
206
- */
207
- binary: ArrayBuffer;
208
- /**
209
- * The file name of this file as a fallback.
210
- */
211
- fileName?: string;
208
+ /**
209
+ * The binary data of the file.
210
+ */
211
+ binary: ArrayBuffer;
212
+ /**
213
+ * The file name of this file as a fallback.
214
+ */
215
+ fileName?: string;
212
216
  };
213
217
  interface WorkletSequencerEventType {
214
- /**
215
- * New song.
216
- */
217
- songChange: MIDIData;
218
- /**
219
- * New time.
220
- */
221
- timeChange: number;
222
- /**
223
- * No data.
224
- */
225
- songEnded: null;
226
- metaEvent: {
227
- event: MIDIMessage;
228
- trackNumber: number;
229
- };
230
- textEvent: {
231
- /**
232
- * The raw event.
233
- */
234
- event: MIDIMessage;
235
- /**
236
- * If the text is a lyric, the index of the lyric in BasicMIDI's "lyrics" property, otherwise -1.
237
- */
238
- lyricsIndex: number;
239
- };
240
- midiError: Error;
218
+ /**
219
+ * New song.
220
+ */
221
+ songChange: MIDIData;
222
+ /**
223
+ * New time.
224
+ */
225
+ timeChange: number;
226
+ /**
227
+ * No data.
228
+ */
229
+ songEnded: null;
230
+ metaEvent: {
231
+ event: MIDIMessage;
232
+ trackNumber: number;
233
+ };
234
+ textEvent: {
235
+ /**
236
+ * The raw event.
237
+ */
238
+ event: MIDIMessage;
239
+ /**
240
+ * If the text is a lyric, the index of the lyric in BasicMIDI's "lyrics" property, otherwise -1.
241
+ */
242
+ lyricsIndex: number;
243
+ };
244
+ midiError: Error;
241
245
  }
242
-
246
+ //#endregion
247
+ //#region src/synthesizer/basic/basic_synthesizer_core.d.ts
243
248
  type PostMessageSynthCore = (data: BasicSynthesizerReturnMessage, transfer?: Transferable[]) => unknown;
244
249
  /**
245
250
  * The interface for the audio processing code that uses spessasynth_core and runs on a separate thread.
246
251
  */
247
252
  declare abstract class BasicSynthesizerCore {
248
- readonly synthesizer: SpessaSynthProcessor;
249
- readonly sequencers: SpessaSynthSequencer[];
250
- protected readonly post: PostMessageSynthCore;
251
- protected lastSequencerSync: number;
252
- /**
253
- * Indicates if the processor is alive.
254
- * @protected
255
- */
256
- protected alive: boolean;
257
- protected readonly enableEventSystem: boolean;
258
- protected constructor(sampleRate: number, options: Partial<SynthProcessorOptions>, postMessage: PostMessageSynthCore);
259
- protected createNewSequencer(): void;
260
- protected postReady<K extends keyof SynthesizerReturn>(type: K, data: SynthesizerReturn[K], transferable?: Transferable[]): void;
261
- protected postProgress<K extends keyof SynthesizerProgress>(type: K, data: SynthesizerProgress[K]): void;
262
- protected destroy(): void;
263
- protected handleMessage(m: BasicSynthesizerMessage): void;
253
+ readonly synthesizer: SpessaSynthProcessor;
254
+ readonly sequencers: SpessaSynthSequencer[];
255
+ protected readonly post: PostMessageSynthCore;
256
+ protected lastSequencerSync: number;
257
+ /**
258
+ * Indicates if the processor is alive.
259
+ * @protected
260
+ */
261
+ protected alive: boolean;
262
+ protected readonly enableEventSystem: boolean;
263
+ protected constructor(sampleRate: number, options: Partial<SynthProcessorOptions>, postMessage: PostMessageSynthCore);
264
+ protected createNewSequencer(): void;
265
+ protected postReady<K extends keyof SynthesizerReturn>(type: K, data: SynthesizerReturn[K], transferable?: Transferable[]): void;
266
+ protected postProgress<K extends keyof SynthesizerProgress>(type: K, data: SynthesizerProgress[K]): void;
267
+ protected destroy(): void;
268
+ protected handleMessage(m: BasicSynthesizerMessage): void;
264
269
  }
265
-
270
+ //#endregion
271
+ //#region src/synthesizer/worker/worker_synthesizer_core.d.ts
266
272
  declare class WorkerSynthesizerCore extends BasicSynthesizerCore {
267
- /**
268
- * The message port to the playback audio worklet.
269
- */
270
- readonly workletMessagePort: MessagePort;
271
- protected readonly compressionFunction?: WorkerSampleEncodingFunction;
272
- /**
273
- * Creates a new worker synthesizer core: the synthesizer that runs in the worker.
274
- * Most parameters here are provided with the first message that is posted to the worker by the WorkerSynthesizer.
275
- * @param synthesizerConfiguration The data from the first message sent from WorkerSynthesizer.
276
- * Listen for the first event and use its data to initialize this class.
277
- * @param workletMessagePort The first port from the first message sent from WorkerSynthesizer.
278
- * @param mainThreadCallback postMessage function or similar.
279
- * @param compressionFunction Optional function for compressing SF3 banks.
280
- */
281
- constructor(synthesizerConfiguration: {
282
- sampleRate: number;
283
- initialTime: number;
284
- }, workletMessagePort: MessagePort, mainThreadCallback: typeof Worker.prototype.postMessage, compressionFunction?: WorkerSampleEncodingFunction);
285
- /**
286
- * Handles a message received from the main thread.
287
- * @param m The message received.
288
- */
289
- handleMessage(m: BasicSynthesizerMessage): void;
290
- protected getBank(opts: WorkerBankWriteOptions): BasicSoundBank;
291
- protected stopAudioLoop(): void;
292
- protected startAudioLoop(): void;
293
- protected destroy(): void;
294
- protected process(): void;
273
+ /**
274
+ * The message port to the playback audio worklet.
275
+ */
276
+ readonly workletMessagePort: MessagePort;
277
+ protected readonly compressionFunction?: WorkerSampleEncodingFunction;
278
+ /**
279
+ * Creates a new worker synthesizer core: the synthesizer that runs in the worker.
280
+ * Most parameters here are provided with the first message that is posted to the worker by the WorkerSynthesizer.
281
+ * @param synthesizerConfiguration The data from the first message sent from WorkerSynthesizer.
282
+ * Listen for the first event and use its data to initialize this class.
283
+ * @param workletMessagePort The first port from the first message sent from WorkerSynthesizer.
284
+ * @param mainThreadCallback postMessage function or similar.
285
+ * @param compressionFunction Optional function for compressing SF3 banks.
286
+ */
287
+ constructor(synthesizerConfiguration: {
288
+ sampleRate: number;
289
+ initialTime: number;
290
+ }, workletMessagePort: MessagePort, mainThreadCallback: typeof Worker.prototype.postMessage, compressionFunction?: WorkerSampleEncodingFunction);
291
+ /**
292
+ * Handles a message received from the main thread.
293
+ * @param m The message received.
294
+ */
295
+ handleMessage(m: BasicSynthesizerMessage): void;
296
+ protected getBank(opts: WorkerBankWriteOptions): BasicSoundBank;
297
+ protected stopAudioLoop(): void;
298
+ protected startAudioLoop(): void;
299
+ protected destroy(): void;
300
+ protected process(): void;
295
301
  }
296
-
302
+ //#endregion
303
+ //#region src/synthesizer/worker/render_audio_worker.d.ts
297
304
  interface WorkerRenderAudioOptions {
298
- /**
299
- * Extra fadeout time after the song finishes, in seconds.
300
- */
301
- extraTime: number;
302
- /**
303
- * If channels should be rendered separately.
304
- */
305
- separateChannels: boolean;
306
- /**
307
- * The amount of times to loop the song.
308
- */
309
- loopCount: number;
310
- /**
311
- * The function that tracks the rendering progress.
312
- * @param progress mapped 0 to 1.
313
- * @param stage 0 is a dry pass, 1 is adding effects.
314
- */
315
- progressCallback?: (progress: number, stage: number) => unknown;
316
- /**
317
- * If the current parameters of the synthesizer should be preserved.
318
- */
319
- preserveSynthParams: boolean;
320
- /**
321
- * If the effects should be enabled.
322
- */
323
- enableEffects: boolean;
324
- /**
325
- * Which sequencer to render. Defaults to the first one (0).
326
- */
327
- sequencerID: number;
305
+ /**
306
+ * Extra fadeout time after the song finishes, in seconds.
307
+ */
308
+ extraTime: number;
309
+ /**
310
+ * If channels should be rendered separately.
311
+ */
312
+ separateChannels: boolean;
313
+ /**
314
+ * The amount of times to loop the song.
315
+ */
316
+ loopCount: number;
317
+ /**
318
+ * The function that tracks the rendering progress.
319
+ * @param progress mapped 0 to 1.
320
+ * @param stage 0 is a dry pass, 1 is adding effects.
321
+ */
322
+ progressCallback?: (progress: number, stage: number) => unknown;
323
+ /**
324
+ * If the current parameters of the synthesizer should be preserved.
325
+ */
326
+ preserveSynthParams: boolean;
327
+ /**
328
+ * If the effects should be enabled.
329
+ */
330
+ enableEffects: boolean;
331
+ /**
332
+ * Which sequencer to render. Defaults to the first one (0).
333
+ */
334
+ sequencerID: number;
328
335
  }
329
-
336
+ //#endregion
337
+ //#region src/synthesizer/types.d.ts
330
338
  interface PassedProcessorParameters {
331
- /**
332
- * If the synthesizer should send events.
333
- */
334
- enableEventSystem: boolean;
335
- /**
336
- * If the synth should use one output with 32 channels (2 audio channels for each midi channel).
337
- */
338
- oneOutput: boolean;
339
+ /**
340
+ * If the synthesizer should send events.
341
+ */
342
+ enableEventSystem: boolean;
343
+ /**
344
+ * If the synth should use one output with 32 channels (2 audio channels for each midi channel).
345
+ */
346
+ oneOutput: boolean;
339
347
  }
340
348
  interface OfflineRenderWorkletData {
341
- /**
342
- * The MIDI to render.
343
- */
344
- midiSequence: BasicMIDI;
345
- /**
346
- * The snapshot to apply.
347
- */
348
- snapshot?: SynthesizerSnapshot;
349
- /**
350
- * The amount times to loop the song.
351
- */
352
- loopCount: number;
353
- /**
354
- * The list of sound banks to render this file with.
355
- */
356
- soundBankList: {
357
- bankOffset: number;
358
- soundBankBuffer: ArrayBuffer;
359
- }[];
360
- /**
361
- * The options to pass to the sequencer.
362
- */
363
- sequencerOptions: Partial<SequencerOptions>;
349
+ /**
350
+ * The MIDI to render.
351
+ */
352
+ midiSequence: BasicMIDI;
353
+ /**
354
+ * The snapshot to apply.
355
+ */
356
+ snapshot?: SynthesizerSnapshot;
357
+ /**
358
+ * The amount times to loop the song.
359
+ */
360
+ loopCount: number;
361
+ /**
362
+ * The list of sound banks to render this file with.
363
+ */
364
+ soundBankList: {
365
+ bankOffset: number;
366
+ soundBankBuffer: ArrayBuffer;
367
+ }[];
368
+ /**
369
+ * The options to pass to the sequencer.
370
+ */
371
+ sequencerOptions: Partial<SequencerOptions>;
364
372
  }
365
373
  interface WorkletSBKManagerData {
366
- addSoundBank: {
367
- soundBankBuffer: ArrayBuffer;
368
- id: string;
369
- bankOffset: number;
370
- };
371
- deleteSoundBank: string;
372
- rearrangeSoundBanks: string[];
374
+ addSoundBank: {
375
+ soundBankBuffer: ArrayBuffer;
376
+ id: string;
377
+ bankOffset: number;
378
+ };
379
+ deleteSoundBank: string;
380
+ rearrangeSoundBanks: string[];
373
381
  }
374
382
  interface WorkletKMManagerData {
375
- addMapping: {
376
- channel: number;
377
- midiNote: number;
378
- mapping: KeyModifier;
379
- };
380
- deleteMapping: {
381
- channel: number;
382
- midiNote: number;
383
- };
384
- clearMappings: null;
383
+ addMapping: {
384
+ channel: number;
385
+ midiNote: number;
386
+ mapping: KeyModifier;
387
+ };
388
+ deleteMapping: {
389
+ channel: number;
390
+ midiNote: number;
391
+ };
392
+ clearMappings: null;
385
393
  }
386
- type BasicSynthesizerMessage = {
387
- [K in keyof BasicSynthesizerMessageData]: {
388
- channelNumber: number;
389
- type: K;
390
- data: BasicSynthesizerMessageData[K];
391
- };
392
- }[keyof BasicSynthesizerMessageData];
394
+ type BasicSynthesizerMessage = { [K in keyof BasicSynthesizerMessageData]: {
395
+ channelNumber: number;
396
+ type: K;
397
+ data: BasicSynthesizerMessageData[K];
398
+ } }[keyof BasicSynthesizerMessageData];
393
399
  interface WorkerBankWriteOptions {
394
- /**
395
- * Trim the sound bank to only include samples used in the current MIDI file.
396
- */
397
- trim: boolean;
398
- /**
399
- * Which sequencer to grab the MIDI from if trimming. Defaults to the first one (0).
400
- */
401
- sequencerID: number;
402
- /**
403
- * The sound bank ID in the sound bank manager to write.
404
- */
405
- bankID: string;
406
- /**
407
- * If the embedded sound bank should be written instead if it exists.
408
- */
409
- writeEmbeddedSoundBank: boolean;
400
+ /**
401
+ * Trim the sound bank to only include samples used in the current MIDI file.
402
+ */
403
+ trim: boolean;
404
+ /**
405
+ * Which sequencer to grab the MIDI from if trimming. Defaults to the first one (0).
406
+ */
407
+ sequencerID: number;
408
+ /**
409
+ * The sound bank ID in the sound bank manager to write.
410
+ */
411
+ bankID: string;
412
+ /**
413
+ * If the embedded sound bank should be written instead if it exists.
414
+ */
415
+ writeEmbeddedSoundBank: boolean;
410
416
  }
411
417
  type WorkerDLSWriteOptions = Omit<DLSWriteOptions, "progressFunction"> & WorkerBankWriteOptions;
412
418
  type WorkerSoundFont2WriteOptions = Omit<SoundFont2WriteOptions, "compressionFunction" | "progressFunction"> & WorkerBankWriteOptions & {
413
- /**
414
- * The compression quality to call your provided compressionFunction with, if compressing.
415
- */
416
- compressionQuality: number;
419
+ /**
420
+ * The compression quality to call your provided compressionFunction with, if compressing.
421
+ */
422
+ compressionQuality: number;
417
423
  };
418
424
  type WorkerSampleEncodingFunction = (audioData: Float32Array, sampleRate: number, quality: number) => Promise<Uint8Array>;
419
425
  type WorkerRMIDIWriteOptions = Omit<RMIDIWriteOptions, "soundBank"> & (({
420
- format: "sf2";
426
+ format: "sf2";
421
427
  } & WorkerSoundFont2WriteOptions) | ({
422
- format: "dls";
428
+ format: "dls";
423
429
  } & WorkerDLSWriteOptions));
424
430
  interface BasicSynthesizerMessageData {
425
- workerInitialization: {
426
- sampleRate: number;
427
- currentTime: number;
428
- };
429
- renderAudio: {
430
- sampleRate: number;
431
- options: WorkerRenderAudioOptions;
432
- };
433
- writeSF2: WorkerSoundFont2WriteOptions;
434
- writeDLS: WorkerDLSWriteOptions;
435
- writeRMIDI: WorkerRMIDIWriteOptions;
436
- startOfflineRender: OfflineRenderWorkletData;
437
- midiMessage: {
438
- messageData: Uint8Array;
439
- channelOffset: number;
440
- options: SynthMethodOptions;
441
- };
442
- ccReset: null;
443
- stopAll: number;
444
- muteChannel: boolean;
445
- addNewChannel: null;
446
- customCcChange: {
447
- ccNumber: CustomController;
448
- ccValue: number;
449
- };
450
- transposeChannel: {
451
- semitones: number;
452
- force: boolean;
453
- };
454
- setDrums: boolean;
455
- lockController: {
456
- controllerNumber: MIDIController | -1;
457
- isLocked: boolean;
458
- };
459
- sequencerSpecific: SequencerMessage;
460
- requestSynthesizerSnapshot: null;
461
- requestNewSequencer: null;
462
- setLogLevel: {
463
- enableInfo: boolean;
464
- enableWarning: boolean;
465
- enableGroup: boolean;
466
- };
467
- setMasterParameter: {
468
- [K in keyof MasterParameterType]: {
469
- type: K;
470
- data: MasterParameterType[K];
471
- };
472
- }[keyof MasterParameterType];
473
- soundBankManager: {
474
- [K in keyof WorkletSBKManagerData]: {
475
- type: K;
476
- data: WorkletSBKManagerData[K];
477
- };
478
- }[keyof WorkletSBKManagerData];
479
- keyModifierManager: {
480
- [K in keyof WorkletKMManagerData]: {
481
- type: K;
482
- data: WorkletKMManagerData[K];
483
- };
484
- }[keyof WorkletKMManagerData];
485
- destroyWorklet: null;
431
+ workerInitialization: {
432
+ sampleRate: number;
433
+ currentTime: number;
434
+ };
435
+ renderAudio: {
436
+ sampleRate: number;
437
+ options: WorkerRenderAudioOptions;
438
+ };
439
+ writeSF2: WorkerSoundFont2WriteOptions;
440
+ writeDLS: WorkerDLSWriteOptions;
441
+ writeRMIDI: WorkerRMIDIWriteOptions;
442
+ startOfflineRender: OfflineRenderWorkletData;
443
+ midiMessage: {
444
+ messageData: Uint8Array;
445
+ channelOffset: number;
446
+ options: SynthMethodOptions;
447
+ };
448
+ ccReset: null;
449
+ stopAll: number;
450
+ muteChannel: boolean;
451
+ addNewChannel: null;
452
+ customCcChange: {
453
+ ccNumber: CustomController;
454
+ ccValue: number;
455
+ };
456
+ transposeChannel: {
457
+ semitones: number;
458
+ force: boolean;
459
+ };
460
+ setDrums: boolean;
461
+ lockController: {
462
+ controllerNumber: MIDIController | -1;
463
+ isLocked: boolean;
464
+ };
465
+ sequencerSpecific: SequencerMessage;
466
+ requestSynthesizerSnapshot: null;
467
+ requestNewSequencer: null;
468
+ setLogLevel: {
469
+ enableInfo: boolean;
470
+ enableWarning: boolean;
471
+ enableGroup: boolean;
472
+ };
473
+ setMasterParameter: { [K in keyof MasterParameterType]: {
474
+ type: K;
475
+ data: MasterParameterType[K];
476
+ } }[keyof MasterParameterType];
477
+ soundBankManager: { [K in keyof WorkletSBKManagerData]: {
478
+ type: K;
479
+ data: WorkletSBKManagerData[K];
480
+ } }[keyof WorkletSBKManagerData];
481
+ keyModifierManager: { [K in keyof WorkletKMManagerData]: {
482
+ type: K;
483
+ data: WorkletKMManagerData[K];
484
+ } }[keyof WorkletKMManagerData];
485
+ destroyWorklet: null;
486
486
  }
487
487
  interface BasicSynthesizerReturnMessageData {
488
- eventCall: SynthProcessorEvent;
489
- sequencerReturn: SequencerReturnMessage;
490
- isFullyInitialized: {
491
- [K in keyof SynthesizerReturn]: {
492
- type: K;
493
- data: SynthesizerReturn[K];
494
- };
495
- }[keyof SynthesizerReturn];
496
- soundBankError: Error;
497
- renderingProgress: {
498
- [K in keyof SynthesizerProgress]: {
499
- type: K;
500
- data: SynthesizerProgress[K];
501
- };
502
- }[keyof SynthesizerProgress];
488
+ eventCall: SynthProcessorEvent;
489
+ sequencerReturn: SequencerReturnMessage;
490
+ isFullyInitialized: { [K in keyof SynthesizerReturn]: {
491
+ type: K;
492
+ data: SynthesizerReturn[K];
493
+ } }[keyof SynthesizerReturn];
494
+ soundBankError: Error;
495
+ renderingProgress: { [K in keyof SynthesizerProgress]: {
496
+ type: K;
497
+ data: SynthesizerProgress[K];
498
+ } }[keyof SynthesizerProgress];
503
499
  }
504
- type BasicSynthesizerReturnMessage = {
505
- [K in keyof BasicSynthesizerReturnMessageData]: {
506
- type: K;
507
- data: BasicSynthesizerReturnMessageData[K];
508
- currentTime: number;
509
- };
510
- }[keyof BasicSynthesizerReturnMessageData];
500
+ type BasicSynthesizerReturnMessage = { [K in keyof BasicSynthesizerReturnMessageData]: {
501
+ type: K;
502
+ data: BasicSynthesizerReturnMessageData[K];
503
+ currentTime: number;
504
+ } }[keyof BasicSynthesizerReturnMessageData];
511
505
  interface SynthesizerProgress {
512
- renderAudio: number;
513
- workerSynthWriteFile: {
514
- sampleName: string;
515
- sampleIndex: number;
516
- sampleCount: number;
517
- };
506
+ renderAudio: number;
507
+ workerSynthWriteFile: {
508
+ sampleName: string;
509
+ sampleIndex: number;
510
+ sampleCount: number;
511
+ };
518
512
  }
519
513
  interface SynthesizerReturn {
520
- sf3Decoder: null;
521
- soundBankManager: null;
522
- startOfflineRender: null;
523
- synthesizerSnapshot: SynthesizerSnapshot;
524
- renderAudio: {
525
- effects: [Float32Array, Float32Array];
526
- dry: [Float32Array, Float32Array][];
527
- };
528
- workerSynthWriteFile: {
529
- /**
530
- * The binary data of the file.
531
- */
532
- binary: ArrayBuffer;
533
- /**
534
- * The suggested name of the file.
535
- */
536
- fileName: string;
537
- };
538
- }
539
-
540
- interface SynthConfig {
514
+ sf3Decoder: null;
515
+ soundBankManager: null;
516
+ startOfflineRender: null;
517
+ synthesizerSnapshot: SynthesizerSnapshot;
518
+ renderAudio: {
519
+ effects: [Float32Array, Float32Array];
520
+ dry: [Float32Array, Float32Array][];
521
+ };
522
+ workerSynthWriteFile: {
541
523
  /**
542
- * If the synth should use one output with 32 channels (2 audio channels for each midi channel).
543
- */
544
- oneOutput: boolean;
545
- /**
546
- * @deprecated Deprecated parameter, does nothing.
547
- */
548
- initializeChorusProcessor?: boolean;
549
- /**
550
- * @deprecated Deprecated parameter, does nothing.
551
- */
552
- initializeReverbProcessor?: boolean;
553
- /**
554
- * Custom audio node creation functions for Web Audio wrappers, such as standardized-audio-context.
555
- * Pass undefined to use the Web Audio API.
524
+ * The binary data of the file.
556
525
  */
557
- audioNodeCreators?: AudioNodeCreators;
526
+ binary: ArrayBuffer;
558
527
  /**
559
- * If the event system should be enabled. This can only be set once.
528
+ * The suggested name of the file.
560
529
  */
561
- enableEventSystem: boolean;
530
+ fileName: string;
531
+ };
532
+ }
533
+ //#endregion
534
+ //#region src/synthesizer/basic/types.d.ts
535
+ interface SynthConfig {
536
+ /**
537
+ * If the synth should use one output with 32 channels (2 audio channels for each midi channel).
538
+ */
539
+ oneOutput: boolean;
540
+ /**
541
+ * @deprecated Deprecated parameter, does nothing.
542
+ */
543
+ initializeChorusProcessor?: boolean;
544
+ /**
545
+ * @deprecated Deprecated parameter, does nothing.
546
+ */
547
+ initializeReverbProcessor?: boolean;
548
+ /**
549
+ * Custom audio node creation functions for Web Audio wrappers, such as standardized-audio-context.
550
+ * Pass undefined to use the Web Audio API.
551
+ */
552
+ audioNodeCreators?: AudioNodeCreators;
553
+ /**
554
+ * If the event system should be enabled. This can only be set once.
555
+ */
556
+ enableEventSystem: boolean;
562
557
  }
563
558
  interface AudioNodeCreators {
564
- /**
565
- * A custom creator for an AudioWorkletNode.
566
- * @param context
567
- * @param workletName
568
- * @param options
569
- */
570
- worklet: (context: BaseAudioContext, workletName: string, options?: AudioWorkletNodeOptions & {
571
- processorOptions: PassedProcessorParameters;
572
- }) => AudioWorkletNode;
559
+ /**
560
+ * A custom creator for an AudioWorkletNode.
561
+ * @param context
562
+ * @param workletName
563
+ * @param options
564
+ */
565
+ worklet: (context: BaseAudioContext, workletName: string, options?: AudioWorkletNodeOptions & {
566
+ processorOptions: PassedProcessorParameters;
567
+ }) => AudioWorkletNode;
573
568
  }
574
-
569
+ //#endregion
570
+ //#region src/synthesizer/basic/basic_synthesizer.d.ts
575
571
  declare abstract class BasicSynthesizer {
576
- /**
577
- * Allows managing the sound bank list.
578
- */
579
- readonly soundBankManager: SoundBankManager;
580
- /**
581
- * Allows managing key modifications.
582
- */
583
- readonly keyModifierManager: WorkletKeyModifierManagerWrapper;
584
- /**
585
- * Allows setting up custom event listeners for the synthesizer.
586
- */
587
- readonly eventHandler: SynthEventHandler;
588
- /**
589
- * Synthesizer's parent AudioContext instance.
590
- */
591
- readonly context: BaseAudioContext;
592
- /**
593
- * Synth's current channel properties.
594
- */
595
- readonly channelProperties: ChannelProperty[];
596
- /**
597
- * The current preset list.
598
- */
599
- presetList: PresetList;
600
- /**
601
- * INTERNAL USE ONLY!
602
- * @internal
603
- * All sequencer callbacks
604
- */
605
- sequencers: ((m: SequencerReturnMessage) => unknown)[];
606
- /**
607
- * Resolves when the synthesizer is ready.
608
- */
609
- readonly isReady: Promise<unknown>;
610
- /**
611
- * Legacy parameter.
612
- * @deprecated
613
- */
614
- readonly reverbProcessor: undefined;
615
- /**
616
- * Legacy parameter.
617
- * @deprecated
618
- */
619
- readonly chorusProcessor: undefined;
620
- /**
621
- * INTERNAL USE ONLY!
622
- * @internal
623
- */
624
- readonly post: (data: BasicSynthesizerMessage, transfer?: Transferable[]) => unknown;
625
- protected readonly worklet: AudioWorkletNode;
626
- /**
627
- * The new channels will have their audio sent to the modulated output by this constant.
628
- * what does that mean?
629
- * e.g., if outputsAmount is 16, then channel's 16 audio data will be sent to channel 0
630
- */
631
- protected readonly _outputsAmount = 16;
632
- /**
633
- * The current amount of MIDI channels the synthesizer has.
634
- */
635
- channelsAmount: number;
636
- protected readonly masterParameters: MasterParameterType;
637
- protected resolveMap: Map<keyof SynthesizerReturn, (data: SynthesizerReturn[keyof SynthesizerReturn]) => unknown>;
638
- protected renderingProgressTracker: Map<keyof SynthesizerProgress, ((args: number) => unknown) | ((args: {
639
- sampleName: string;
640
- sampleIndex: number;
641
- sampleCount: number;
642
- }) => unknown)>;
643
- /**
644
- * Creates a new instance of a synthesizer.
645
- * @param worklet The AudioWorkletNode to use.
646
- * @param postFunction The internal post function.
647
- * @param config Optional configuration for the synthesizer.
648
- */
649
- protected constructor(worklet: AudioWorkletNode, postFunction: (data: BasicSynthesizerMessage, transfer?: Transferable[]) => unknown, config: SynthConfig);
650
- /**
651
- * Current voice amount
652
- */
653
- protected _voicesAmount: number;
654
- /**
655
- * The current number of voices playing.
656
- */
657
- get voicesAmount(): number;
658
- /**
659
- * The audioContext's current time.
660
- */
661
- get currentTime(): number;
662
- /**
663
- * Connects from a given node.
664
- * @param destinationNode The node to connect to.
665
- */
666
- connect(destinationNode: AudioNode): AudioNode;
667
- /**
668
- * Disconnects from a given node.
669
- * @param destinationNode The node to disconnect from.
670
- */
671
- disconnect(destinationNode?: AudioNode): AudioNode | undefined;
672
- /**
673
- * Sets the SpessaSynth's log level in the processor.
674
- * @param enableInfo Enable info (verbose)
675
- * @param enableWarning Enable warnings (unrecognized messages)
676
- * @param enableGroup Enable groups (to group a lot of logs)
677
- */
678
- setLogLevel(enableInfo: boolean, enableWarning: boolean, enableGroup: boolean): void;
679
- /**
680
- * Gets a master parameter from the synthesizer.
681
- * @param type The parameter to get.
682
- * @returns The parameter value.
683
- */
684
- getMasterParameter<K extends keyof MasterParameterType>(type: K): MasterParameterType[K];
685
- /**
686
- * Sets a master parameter to a given value.
687
- * @param type The parameter to set.
688
- * @param value The value to set.
689
- */
690
- setMasterParameter<K extends keyof MasterParameterType>(type: K, value: MasterParameterType[K]): void;
691
- /**
692
- * Gets a complete snapshot of the synthesizer, effects.
693
- */
694
- getSnapshot(): Promise<SynthesizerSnapshot>;
695
- /**
696
- * Adds a new channel to the synthesizer.
697
- */
698
- addNewChannel(): void;
699
- /**
700
- * DEPRECATED, please don't use it!
701
- * @deprecated
702
- */
703
- setVibrato(channel: number, value: {
704
- delay: number;
705
- depth: number;
706
- rate: number;
707
- }): void;
708
- /**
709
- * Connects a given channel output to the given audio node.
710
- * Note that this output is only meant for visualization and may be silent when Insertion Effect for this channel is enabled.
711
- * @param targetNode The node to connect to.
712
- * @param channelNumber The channel number to connect to, will be rolled over if value is greater than 15.
713
- * @returns The target node.
714
- */
715
- connectChannel(targetNode: AudioNode, channelNumber: number): AudioNode;
716
- /**
717
- * Disconnects a given channel output to the given audio node.
718
- * @param targetNode The node to disconnect from.
719
- * @param channelNumber The channel number to connect to, will be rolled over if value is greater than 15.
720
- */
721
- disconnectChannel(targetNode: AudioNode, channelNumber: number): void;
722
- /**
723
- * Connects the individual audio outputs to the given audio nodes.
724
- * Note that these outputs is only meant for visualization and may be silent when Insertion Effect for this channel is enabled.
725
- * @param audioNodes Exactly 16 outputs.
726
- */
727
- connectIndividualOutputs(audioNodes: AudioNode[]): void;
728
- /**
729
- * Disconnects the individual audio outputs from the given audio nodes.
730
- * @param audioNodes Exactly 16 outputs.
731
- */
732
- disconnectIndividualOutputs(audioNodes: AudioNode[]): void;
733
- /**
734
- * Disables the GS NRPN parameters like vibrato or drum key tuning.
735
- * @deprecated Deprecated! Please use master parameters
736
- */
737
- disableGSNPRNParams(): void;
738
- /**
739
- * Sends a raw MIDI message to the synthesizer.
740
- * @param message the midi message, each number is a byte.
741
- * @param channelOffset the channel offset of the message.
742
- * @param eventOptions additional options for this command.
743
- */
744
- sendMessage(message: Iterable<number>, channelOffset?: number, eventOptions?: SynthMethodOptions): void;
745
- /**
746
- * Starts playing a note
747
- * @param channel Usually 0-15: the channel to play the note.
748
- * @param midiNote 0-127 the key number of the note.
749
- * @param velocity 0-127 the velocity of the note (generally controls loudness).
750
- * @param eventOptions Additional options for this command.
751
- */
752
- noteOn(channel: number, midiNote: number, velocity: number, eventOptions?: SynthMethodOptions): void;
753
- /**
754
- * Stops playing a note.
755
- * @param channel Usually 0-15: the channel of the note.
756
- * @param midiNote {number} 0-127 the key number of the note.
757
- * @param eventOptions Additional options for this command.
758
- */
759
- noteOff(channel: number, midiNote: number, eventOptions?: SynthMethodOptions): void;
760
- /**
761
- * Stops all notes.
762
- * @param force If the notes should immediately be stopped, defaults to false.
763
- */
764
- stopAll(force?: boolean): void;
765
- /**
766
- * Changes the given controller
767
- * @param channel Usually 0-15: the channel to change the controller.
768
- * @param controllerNumber 0-127 the MIDI CC number.
769
- * @param controllerValue 0-127 the controller value.
770
- * @param eventOptions Additional options for this command.
771
- */
772
- controllerChange(channel: number, controllerNumber: MIDIController, controllerValue: number, eventOptions?: SynthMethodOptions): void;
773
- /**
774
- * Resets all controllers (for every channel)
775
- */
776
- resetControllers(): void;
777
- /**
778
- * Causes the given midi channel to ignore controller messages for the given controller number.
779
- * @param channel Usually 0-15: the channel to lock.
780
- * @param controllerNumber 0-127 MIDI CC number.
781
- * @param isLocked True if locked, false if unlocked.
782
- * @remarks
783
- * Controller number -1 locks the preset.
784
- */
785
- lockController(channel: number, controllerNumber: MIDIController | -1, isLocked: boolean): void;
786
- /**
787
- * Applies pressure to a given channel.
788
- * @param channel Usually 0-15: the channel to change the controller.
789
- * @param pressure 0-127: the pressure to apply.
790
- * @param eventOptions Additional options for this command.
791
- */
792
- channelPressure(channel: number, pressure: number, eventOptions?: SynthMethodOptions): void;
793
- /**
794
- * Applies pressure to a given note.
795
- * @param channel Usually 0-15: the channel to change the controller.
796
- * @param midiNote 0-127: the MIDI note.
797
- * @param pressure 0-127: the pressure to apply.
798
- * @param eventOptions Additional options for this command.
799
- */
800
- polyPressure(channel: number, midiNote: number, pressure: number, eventOptions?: SynthMethodOptions): void;
801
- /**
802
- * Sets the pitch of the given channel.
803
- * @param channel Usually 0-15: the channel to change pitch.
804
- * @param value The bend of the MIDI pitch wheel message. 0 - 16384
805
- * @param eventOptions Additional options for this command.
806
- */
807
- pitchWheel(channel: number, value: number, eventOptions?: SynthMethodOptions): void;
808
- /**
809
- * Sets the channel's pitch wheel range, in semitones.
810
- * @param channel Usually 0-15: the channel to change.
811
- * @param range The bend range in semitones.
812
- * @param eventOptions Additional options for this command.
813
- */
814
- pitchWheelRange(channel: number, range: number, eventOptions?: SynthMethodOptions): void;
815
- /**
816
- * Changes the program for a given channel
817
- * @param channel Usually 0-15: the channel to change.
818
- * @param programNumber 0-127 the MIDI patch number.
819
- * @param eventOptions Additional options for this command.
820
- */
821
- programChange(channel: number, programNumber: number, eventOptions?: SynthMethodOptions): void;
822
- /**
823
- * Transposes the channel by given number of semitones.
824
- * @param channel The channel number.
825
- * @param semitones The transposition of the channel, it can be a float.
826
- * @param force Defaults to false, if true transposes the channel even if it's a drum channel.
827
- */
828
- transposeChannel(channel: number, semitones: number, force?: boolean): void;
829
- /**
830
- * Mutes or unmutes the given channel.
831
- * @param channel Usually 0-15: the channel to mute.
832
- * @param isMuted Indicates if the channel is muted.
833
- */
834
- muteChannel(channel: number, isMuted: boolean): void;
835
- /**
836
- * Sends a MIDI Sysex message to the synthesizer.
837
- * @param messageData The message's data, excluding the F0 byte, but including the F7 at the end.
838
- * @param channelOffset Channel offset for the system exclusive message, defaults to zero.
839
- * @param eventOptions Additional options for this command.
840
- */
841
- systemExclusive(messageData: number[] | Iterable<number> | Uint8Array, channelOffset?: number, eventOptions?: SynthMethodOptions): void;
842
- /**
843
- * Tune MIDI keys of a given program using the MIDI Tuning Standard.
844
- * @param program 0 - 127 the MIDI program number to use.
845
- * @param tunings The keys and their tunings.
846
- * TargetPitch of -1 sets the tuning for this key to be tuned regularly.
847
- */
848
- tuneKeys(program: number, tunings: {
849
- sourceKey: number;
850
- targetPitch: number;
851
- }[]): void;
852
- /**
853
- * Toggles drums on a given channel.
854
- * @param channel The channel number.
855
- * @param isDrum If the channel should be drums.
856
- */
857
- setDrums(channel: number, isDrum: boolean): void;
858
- /**
859
- * Yes please!
860
- */
861
- reverbateEverythingBecauseWhyNot(): "That's the spirit!";
862
- /**
863
- * INTERNAL USE ONLY!
864
- * @param type INTERNAL USE ONLY!
865
- * @param resolve INTERNAL USE ONLY!
866
- * @internal
867
- */
868
- awaitWorkerResponse<K extends keyof SynthesizerReturn>(type: K, resolve: (data: SynthesizerReturn[K]) => unknown): void;
869
- /**
870
- * INTERNAL USE ONLY!
871
- * @param callback the sequencer callback
872
- * @internal
873
- */
874
- assignNewSequencer(callback: (m: SequencerReturnMessage) => unknown): number;
875
- protected assignProgressTracker<K extends keyof SynthesizerProgress>(type: K, progressFunction: (args: SynthesizerProgress[K]) => unknown): void;
876
- protected revokeProgressTracker<K extends keyof SynthesizerProgress>(type: K): void;
877
- protected _sendInternal(message: Iterable<number>, channelOffset: number, eventOptions: Partial<SynthMethodOptions>): void;
878
- /**
879
- * Handles the messages received from the worklet.
880
- */
881
- protected handleMessage(m: BasicSynthesizerReturnMessage): void;
882
- protected addNewChannelInternal(post: boolean): void;
883
- protected workletResponds<K extends keyof SynthesizerReturn>(type: K, data: SynthesizerReturn[K]): void;
572
+ /**
573
+ * Allows managing the sound bank list.
574
+ */
575
+ readonly soundBankManager: SoundBankManager;
576
+ /**
577
+ * Allows managing key modifications.
578
+ */
579
+ readonly keyModifierManager: WorkletKeyModifierManagerWrapper;
580
+ /**
581
+ * Allows setting up custom event listeners for the synthesizer.
582
+ */
583
+ readonly eventHandler: SynthEventHandler;
584
+ /**
585
+ * Synthesizer's parent AudioContext instance.
586
+ */
587
+ readonly context: BaseAudioContext;
588
+ /**
589
+ * Synth's current channel properties.
590
+ */
591
+ readonly channelProperties: ChannelProperty[];
592
+ /**
593
+ * The current preset list.
594
+ */
595
+ presetList: PresetList;
596
+ /**
597
+ * INTERNAL USE ONLY!
598
+ * @internal
599
+ * All sequencer callbacks
600
+ */
601
+ sequencers: ((m: SequencerReturnMessage) => unknown)[];
602
+ /**
603
+ * Resolves when the synthesizer is ready.
604
+ */
605
+ readonly isReady: Promise<unknown>;
606
+ /**
607
+ * Legacy parameter.
608
+ * @deprecated
609
+ */
610
+ readonly reverbProcessor: undefined;
611
+ /**
612
+ * Legacy parameter.
613
+ * @deprecated
614
+ */
615
+ readonly chorusProcessor: undefined;
616
+ /**
617
+ * INTERNAL USE ONLY!
618
+ * @internal
619
+ */
620
+ readonly post: (data: BasicSynthesizerMessage, transfer?: Transferable[]) => unknown;
621
+ protected readonly worklet: AudioWorkletNode;
622
+ /**
623
+ * The new channels will have their audio sent to the modulated output by this constant.
624
+ * what does that mean?
625
+ * e.g., if outputsAmount is 16, then channel's 16 audio data will be sent to channel 0
626
+ */
627
+ protected readonly _outputsAmount = 16;
628
+ /**
629
+ * The current amount of MIDI channels the synthesizer has.
630
+ */
631
+ channelsAmount: number;
632
+ protected readonly masterParameters: MasterParameterType;
633
+ protected resolveMap: Map<keyof SynthesizerReturn, (data: SynthesizerReturn[keyof SynthesizerReturn]) => unknown>;
634
+ protected renderingProgressTracker: Map<keyof SynthesizerProgress, ((args: number) => unknown) | ((args: {
635
+ sampleName: string;
636
+ sampleIndex: number;
637
+ sampleCount: number;
638
+ }) => unknown)>;
639
+ /**
640
+ * Creates a new instance of a synthesizer.
641
+ * @param worklet The AudioWorkletNode to use.
642
+ * @param postFunction The internal post function.
643
+ * @param config Optional configuration for the synthesizer.
644
+ */
645
+ protected constructor(worklet: AudioWorkletNode, postFunction: (data: BasicSynthesizerMessage, transfer?: Transferable[]) => unknown, config: SynthConfig);
646
+ /**
647
+ * Current voice amount
648
+ */
649
+ protected _voicesAmount: number;
650
+ /**
651
+ * The current number of voices playing.
652
+ */
653
+ get voicesAmount(): number;
654
+ /**
655
+ * The audioContext's current time.
656
+ */
657
+ get currentTime(): number;
658
+ /**
659
+ * Connects from a given node.
660
+ * @param destinationNode The node to connect to.
661
+ */
662
+ connect(destinationNode: AudioNode): AudioNode;
663
+ /**
664
+ * Disconnects from a given node.
665
+ * @param destinationNode The node to disconnect from.
666
+ */
667
+ disconnect(destinationNode?: AudioNode): AudioNode | undefined;
668
+ /**
669
+ * Sets the SpessaSynth's log level in the processor.
670
+ * @param enableInfo Enable info (verbose)
671
+ * @param enableWarning Enable warnings (unrecognized messages)
672
+ * @param enableGroup Enable groups (to group a lot of logs)
673
+ */
674
+ setLogLevel(enableInfo: boolean, enableWarning: boolean, enableGroup: boolean): void;
675
+ /**
676
+ * Gets a master parameter from the synthesizer.
677
+ * @param type The parameter to get.
678
+ * @returns The parameter value.
679
+ */
680
+ getMasterParameter<K extends keyof MasterParameterType>(type: K): MasterParameterType[K];
681
+ /**
682
+ * Sets a master parameter to a given value.
683
+ * @param type The parameter to set.
684
+ * @param value The value to set.
685
+ */
686
+ setMasterParameter<K extends keyof MasterParameterType>(type: K, value: MasterParameterType[K]): void;
687
+ /**
688
+ * Gets a complete snapshot of the synthesizer, effects.
689
+ */
690
+ getSnapshot(): Promise<LibSynthesizerSnapshot>;
691
+ /**
692
+ * Adds a new channel to the synthesizer.
693
+ */
694
+ addNewChannel(): void;
695
+ /**
696
+ * DEPRECATED, please don't use it!
697
+ * @deprecated
698
+ */
699
+ setVibrato(channel: number, value: {
700
+ delay: number;
701
+ depth: number;
702
+ rate: number;
703
+ }): void;
704
+ /**
705
+ * Connects a given channel output to the given audio node.
706
+ * Note that this output is only meant for visualization and may be silent when Insertion Effect for this channel is enabled.
707
+ * @param targetNode The node to connect to.
708
+ * @param channelNumber The channel number to connect to, will be rolled over if value is greater than 15.
709
+ * @returns The target node.
710
+ */
711
+ connectChannel(targetNode: AudioNode, channelNumber: number): AudioNode;
712
+ /**
713
+ * Disconnects a given channel output to the given audio node.
714
+ * @param targetNode The node to disconnect from.
715
+ * @param channelNumber The channel number to connect to, will be rolled over if value is greater than 15.
716
+ */
717
+ disconnectChannel(targetNode: AudioNode, channelNumber: number): void;
718
+ /**
719
+ * Connects the individual audio outputs to the given audio nodes.
720
+ * Note that these outputs is only meant for visualization and may be silent when Insertion Effect for this channel is enabled.
721
+ * @param audioNodes Exactly 16 outputs.
722
+ */
723
+ connectIndividualOutputs(audioNodes: AudioNode[]): void;
724
+ /**
725
+ * Disconnects the individual audio outputs from the given audio nodes.
726
+ * @param audioNodes Exactly 16 outputs.
727
+ */
728
+ disconnectIndividualOutputs(audioNodes: AudioNode[]): void;
729
+ /**
730
+ * Disables the GS NRPN parameters like vibrato or drum key tuning.
731
+ * @deprecated Deprecated! Please use master parameters
732
+ */
733
+ disableGSNPRNParams(): void;
734
+ /**
735
+ * Sends a raw MIDI message to the synthesizer.
736
+ * @param message the midi message, each number is a byte.
737
+ * @param channelOffset the channel offset of the message.
738
+ * @param eventOptions additional options for this command.
739
+ */
740
+ sendMessage(message: Iterable<number>, channelOffset?: number, eventOptions?: SynthMethodOptions): void;
741
+ /**
742
+ * Starts playing a note
743
+ * @param channel Usually 0-15: the channel to play the note.
744
+ * @param midiNote 0-127 the key number of the note.
745
+ * @param velocity 0-127 the velocity of the note (generally controls loudness).
746
+ * @param eventOptions Additional options for this command.
747
+ */
748
+ noteOn(channel: number, midiNote: number, velocity: number, eventOptions?: SynthMethodOptions): void;
749
+ /**
750
+ * Stops playing a note.
751
+ * @param channel Usually 0-15: the channel of the note.
752
+ * @param midiNote {number} 0-127 the key number of the note.
753
+ * @param eventOptions Additional options for this command.
754
+ */
755
+ noteOff(channel: number, midiNote: number, eventOptions?: SynthMethodOptions): void;
756
+ /**
757
+ * Stops all notes.
758
+ * @param force If the notes should immediately be stopped, defaults to false.
759
+ */
760
+ stopAll(force?: boolean): void;
761
+ /**
762
+ * Changes the given controller
763
+ * @param channel Usually 0-15: the channel to change the controller.
764
+ * @param controllerNumber 0-127 the MIDI CC number.
765
+ * @param controllerValue 0-127 the controller value.
766
+ * @param eventOptions Additional options for this command.
767
+ */
768
+ controllerChange(channel: number, controllerNumber: MIDIController, controllerValue: number, eventOptions?: SynthMethodOptions): void;
769
+ /**
770
+ * Resets all controllers (for every channel)
771
+ */
772
+ resetControllers(): void;
773
+ /**
774
+ * Causes the given midi channel to ignore controller messages for the given controller number.
775
+ * @param channel Usually 0-15: the channel to lock.
776
+ * @param controllerNumber 0-127 MIDI CC number.
777
+ * @param isLocked True if locked, false if unlocked.
778
+ * @remarks
779
+ * Controller number -1 locks the preset.
780
+ */
781
+ lockController(channel: number, controllerNumber: MIDIController | -1, isLocked: boolean): void;
782
+ /**
783
+ * Applies pressure to a given channel.
784
+ * @param channel Usually 0-15: the channel to change the controller.
785
+ * @param pressure 0-127: the pressure to apply.
786
+ * @param eventOptions Additional options for this command.
787
+ */
788
+ channelPressure(channel: number, pressure: number, eventOptions?: SynthMethodOptions): void;
789
+ /**
790
+ * Applies pressure to a given note.
791
+ * @param channel Usually 0-15: the channel to change the controller.
792
+ * @param midiNote 0-127: the MIDI note.
793
+ * @param pressure 0-127: the pressure to apply.
794
+ * @param eventOptions Additional options for this command.
795
+ */
796
+ polyPressure(channel: number, midiNote: number, pressure: number, eventOptions?: SynthMethodOptions): void;
797
+ /**
798
+ * Sets the pitch of the given channel.
799
+ * @param channel Usually 0-15: the channel to change pitch.
800
+ * @param value The bend of the MIDI pitch wheel message. 0 - 16384
801
+ * @param eventOptions Additional options for this command.
802
+ */
803
+ pitchWheel(channel: number, value: number, eventOptions?: SynthMethodOptions): void;
804
+ /**
805
+ * Sets the channel's pitch wheel range, in semitones.
806
+ * @param channel Usually 0-15: the channel to change.
807
+ * @param range The bend range in semitones.
808
+ * @param eventOptions Additional options for this command.
809
+ */
810
+ pitchWheelRange(channel: number, range: number, eventOptions?: SynthMethodOptions): void;
811
+ /**
812
+ * Changes the program for a given channel
813
+ * @param channel Usually 0-15: the channel to change.
814
+ * @param programNumber 0-127 the MIDI patch number.
815
+ * @param eventOptions Additional options for this command.
816
+ */
817
+ programChange(channel: number, programNumber: number, eventOptions?: SynthMethodOptions): void;
818
+ /**
819
+ * Transposes the channel by given number of semitones.
820
+ * @param channel The channel number.
821
+ * @param semitones The transposition of the channel, it can be a float.
822
+ * @param force Defaults to false, if true transposes the channel even if it's a drum channel.
823
+ */
824
+ transposeChannel(channel: number, semitones: number, force?: boolean): void;
825
+ /**
826
+ * Mutes or unmutes the given channel.
827
+ * @param channel Usually 0-15: the channel to mute.
828
+ * @param isMuted Indicates if the channel is muted.
829
+ */
830
+ muteChannel(channel: number, isMuted: boolean): void;
831
+ /**
832
+ * Sends a MIDI Sysex message to the synthesizer.
833
+ * @param messageData The message's data, excluding the F0 byte, but including the F7 at the end.
834
+ * @param channelOffset Channel offset for the system exclusive message, defaults to zero.
835
+ * @param eventOptions Additional options for this command.
836
+ */
837
+ systemExclusive(messageData: number[] | Iterable<number> | Uint8Array, channelOffset?: number, eventOptions?: SynthMethodOptions): void;
838
+ /**
839
+ * Tune MIDI keys of a given program using the MIDI Tuning Standard.
840
+ * @param program 0 - 127 the MIDI program number to use.
841
+ * @param tunings The keys and their tunings.
842
+ * TargetPitch of -1 sets the tuning for this key to be tuned regularly.
843
+ */
844
+ tuneKeys(program: number, tunings: {
845
+ sourceKey: number;
846
+ targetPitch: number;
847
+ }[]): void;
848
+ /**
849
+ * Toggles drums on a given channel.
850
+ * @param channel The channel number.
851
+ * @param isDrum If the channel should be drums.
852
+ */
853
+ setDrums(channel: number, isDrum: boolean): void;
854
+ /**
855
+ * Yes please!
856
+ */
857
+ reverbateEverythingBecauseWhyNot(): "That's the spirit!";
858
+ /**
859
+ * INTERNAL USE ONLY!
860
+ * @param type INTERNAL USE ONLY!
861
+ * @param resolve INTERNAL USE ONLY!
862
+ * @internal
863
+ */
864
+ awaitWorkerResponse<K extends keyof SynthesizerReturn>(type: K, resolve: (data: SynthesizerReturn[K]) => unknown): void;
865
+ /**
866
+ * INTERNAL USE ONLY!
867
+ * @param callback the sequencer callback
868
+ * @internal
869
+ */
870
+ assignNewSequencer(callback: (m: SequencerReturnMessage) => unknown): number;
871
+ protected assignProgressTracker<K extends keyof SynthesizerProgress>(type: K, progressFunction: (args: SynthesizerProgress[K]) => unknown): void;
872
+ protected revokeProgressTracker<K extends keyof SynthesizerProgress>(type: K): void;
873
+ protected _sendInternal(message: Iterable<number>, channelOffset: number, eventOptions: Partial<SynthMethodOptions>): void;
874
+ /**
875
+ * Handles the messages received from the worklet.
876
+ */
877
+ protected handleMessage(m: BasicSynthesizerReturnMessage): void;
878
+ protected addNewChannelInternal(post: boolean): void;
879
+ protected workletResponds<K extends keyof SynthesizerReturn>(type: K, data: SynthesizerReturn[K]): void;
884
880
  }
885
-
881
+ //#endregion
882
+ //#region src/synthesizer/worklet/worklet_synthesizer.d.ts
886
883
  /**
887
884
  * This synthesizer uses an audio worklet node containing the processor.
888
885
  */
889
886
  declare class WorkletSynthesizer extends BasicSynthesizer {
890
- /**
891
- * Creates a new instance of an AudioWorklet-based synthesizer.
892
- * @param context The audio context.
893
- * @param config Optional configuration for the synthesizer.
894
- */
895
- constructor(context: BaseAudioContext, config?: Partial<SynthConfig>);
896
- /**
897
- * Starts an offline audio render.
898
- * @param config The configuration to use.
899
- * @remarks
900
- * Call this method immediately after you've set up the synthesizer.
901
- * Do NOT call any other methods after initializing before this one.
902
- * Chromium seems to ignore worklet messages for OfflineAudioContext.
903
- */
904
- startOfflineRender(config: OfflineRenderWorkletData): Promise<void>;
905
- /**
906
- * Destroys the synthesizer instance.
907
- */
908
- destroy(): void;
887
+ /**
888
+ * Creates a new instance of an AudioWorklet-based synthesizer.
889
+ * @param context The audio context.
890
+ * @param config Optional configuration for the synthesizer.
891
+ */
892
+ constructor(context: BaseAudioContext, config?: Partial<SynthConfig>);
893
+ /**
894
+ * Starts an offline audio render.
895
+ * @param config The configuration to use.
896
+ * @remarks
897
+ * Call this method immediately after you've set up the synthesizer.
898
+ * Do NOT call any other methods after initializing before this one.
899
+ * Chromium seems to ignore worklet messages for OfflineAudioContext.
900
+ */
901
+ startOfflineRender(config: OfflineRenderWorkletData): Promise<void>;
902
+ /**
903
+ * Destroys the synthesizer instance.
904
+ */
905
+ destroy(): void;
909
906
  }
910
-
907
+ //#endregion
908
+ //#region src/synthesizer/worker/worker_synthesizer.d.ts
911
909
  type WorkerSynthWriteOptions<K> = K & {
912
- progressFunction?: (args: SynthesizerProgress["workerSynthWriteFile"]) => unknown;
910
+ progressFunction?: (args: SynthesizerProgress["workerSynthWriteFile"]) => unknown;
913
911
  };
914
912
  /**
915
913
  * This synthesizer uses a Worker containing the processor and an audio worklet node for playback.
916
914
  */
917
915
  declare class WorkerSynthesizer extends BasicSynthesizer {
918
- /**
919
- * Time offset for syncing with the synth
920
- * @private
921
- */
922
- private timeOffset;
923
- /**
924
- * Creates a new instance of a Worker-based synthesizer.
925
- * @param context The audio context.
926
- * @param workerPostMessage The postMessage for the worker containing the synthesizer core.
927
- * @param config Optional configuration for the synthesizer.
928
- */
929
- constructor(context: BaseAudioContext, workerPostMessage: typeof Worker.prototype.postMessage, config?: Partial<SynthConfig>);
930
- get currentTime(): number;
931
- /**
932
- * Registers an audio worklet for the WorkerSynthesizer.
933
- * @param context The context to register the worklet for.
934
- * @param maxQueueSize The maximum amount of 128-sample chunks to store in the worklet. Higher values result in less breakups but higher latency.
935
- */
936
- static registerPlaybackWorklet(context: BaseAudioContext, maxQueueSize?: number): Promise<void>;
937
- /**
938
- * Handles a return message from the Worker.
939
- * @param e The event received from the Worker.
940
- */
941
- handleWorkerMessage(e: BasicSynthesizerReturnMessage): void;
942
- /**
943
- * Writes a DLS file directly in the worker.
944
- * @param options Options for writing the file.
945
- * @returns The file array buffer and its corresponding name.
946
- */
947
- writeDLS(options?: Partial<WorkerSynthWriteOptions<WorkerDLSWriteOptions>>): Promise<SynthesizerReturn["workerSynthWriteFile"]>;
948
- /**
949
- * Writes an SF2/SF3 file directly in the worker.
950
- * @param options Options for writing the file.
951
- * @returns The file array buffer and its corresponding name.
952
- */
953
- writeSF2(options?: Partial<WorkerSynthWriteOptions<WorkerSoundFont2WriteOptions>>): Promise<SynthesizerReturn["workerSynthWriteFile"]>;
954
- /**
955
- * Writes an embedded MIDI (RMIDI) file directly in the worker.
956
- * @param options Options for writing the file.
957
- * @returns The file array buffer.
958
- */
959
- writeRMIDI(options?: Partial<WorkerSynthWriteOptions<WorkerRMIDIWriteOptions>>): Promise<ArrayBuffer>;
960
- /**
961
- * Renders the current song in the connected sequencer to Float32 buffers.
962
- * @param sampleRate The sample rate to use, in Hertz.
963
- * @param renderOptions Extra options for the render.
964
- * @returns A single audioBuffer if separate channels were not enabled, otherwise 16.
965
- * @remarks
966
- * This stops the synthesizer.
967
- */
968
- renderAudio(sampleRate: number, renderOptions?: Partial<WorkerRenderAudioOptions>): Promise<AudioBuffer[]>;
916
+ /**
917
+ * Time offset for syncing with the synth
918
+ * @private
919
+ */
920
+ private timeOffset;
921
+ /**
922
+ * Creates a new instance of a Worker-based synthesizer.
923
+ * @param context The audio context.
924
+ * @param workerPostMessage The postMessage for the worker containing the synthesizer core.
925
+ * @param config Optional configuration for the synthesizer.
926
+ */
927
+ constructor(context: BaseAudioContext, workerPostMessage: typeof Worker.prototype.postMessage, config?: Partial<SynthConfig>);
928
+ get currentTime(): number;
929
+ /**
930
+ * Registers an audio worklet for the WorkerSynthesizer.
931
+ * @param context The context to register the worklet for.
932
+ * @param maxQueueSize The maximum amount of 128-sample chunks to store in the worklet. Higher values result in less breakups but higher latency.
933
+ */
934
+ static registerPlaybackWorklet(context: BaseAudioContext, maxQueueSize?: number): Promise<void>;
935
+ /**
936
+ * Handles a return message from the Worker.
937
+ * @param e The event received from the Worker.
938
+ */
939
+ handleWorkerMessage(e: BasicSynthesizerReturnMessage): void;
940
+ /**
941
+ * Writes a DLS file directly in the worker.
942
+ * @param options Options for writing the file.
943
+ * @returns The file array buffer and its corresponding name.
944
+ */
945
+ writeDLS(options?: Partial<WorkerSynthWriteOptions<WorkerDLSWriteOptions>>): Promise<SynthesizerReturn["workerSynthWriteFile"]>;
946
+ /**
947
+ * Writes an SF2/SF3 file directly in the worker.
948
+ * @param options Options for writing the file.
949
+ * @returns The file array buffer and its corresponding name.
950
+ */
951
+ writeSF2(options?: Partial<WorkerSynthWriteOptions<WorkerSoundFont2WriteOptions>>): Promise<SynthesizerReturn["workerSynthWriteFile"]>;
952
+ /**
953
+ * Writes an embedded MIDI (RMIDI) file directly in the worker.
954
+ * @param options Options for writing the file.
955
+ * @returns The file array buffer.
956
+ */
957
+ writeRMIDI(options?: Partial<WorkerSynthWriteOptions<WorkerRMIDIWriteOptions>>): Promise<ArrayBuffer>;
958
+ /**
959
+ * Renders the current song in the connected sequencer to Float32 buffers.
960
+ * @param sampleRate The sample rate to use, in Hertz.
961
+ * @param renderOptions Extra options for the render.
962
+ * @returns A single audioBuffer if separate channels were not enabled, otherwise 16.
963
+ * @remarks
964
+ * This stops the synthesizer.
965
+ */
966
+ renderAudio(sampleRate: number, renderOptions?: Partial<WorkerRenderAudioOptions>): Promise<AudioBuffer[]>;
969
967
  }
970
-
968
+ //#endregion
969
+ //#region src/sequencer/seq_event_handler.d.ts
971
970
  type SequencerEventCallback<T extends keyof WorkletSequencerEventType> = (callbackData: WorkletSequencerEventType[T]) => unknown;
972
971
  declare class SeqEventHandler {
973
- /**
974
- * The time delay before an event is called.
975
- * Set to 0 to disable it.
976
- */
977
- timeDelay: number;
978
- private readonly events;
979
- /**
980
- * Adds a new event listener.
981
- * @param event The event to listen to.
982
- * @param id The unique identifier for the event. It can be used to overwrite existing callback with the same ID.
983
- * @param callback The callback for the event.
984
- */
985
- addEvent<T extends keyof WorkletSequencerEventType>(event: T, id: string, callback: SequencerEventCallback<T>): void;
986
- /**
987
- * Removes an event listener
988
- * @param name The event to remove a listener from.
989
- * @param id The unique identifier for the event to remove.
990
- */
991
- removeEvent<T extends keyof WorkletSequencerEventType>(name: T, id: string): void;
992
- /**
993
- * Calls the given event.
994
- * Internal use only.
995
- * @internal
996
- */
997
- callEventInternal<T extends keyof WorkletSequencerEventType>(name: T, eventData: WorkletSequencerEventType[T]): void;
972
+ /**
973
+ * The time delay before an event is called.
974
+ * Set to 0 to disable it.
975
+ */
976
+ timeDelay: number;
977
+ private readonly events;
978
+ /**
979
+ * Adds a new event listener.
980
+ * @param event The event to listen to.
981
+ * @param id The unique identifier for the event. It can be used to overwrite existing callback with the same ID.
982
+ * @param callback The callback for the event.
983
+ */
984
+ addEvent<T extends keyof WorkletSequencerEventType>(event: T, id: string, callback: SequencerEventCallback<T>): void;
985
+ /**
986
+ * Removes an event listener
987
+ * @param name The event to remove a listener from.
988
+ * @param id The unique identifier for the event to remove.
989
+ */
990
+ removeEvent<T extends keyof WorkletSequencerEventType>(name: T, id: string): void;
991
+ /**
992
+ * Calls the given event.
993
+ * Internal use only.
994
+ * @internal
995
+ */
996
+ callEventInternal<T extends keyof WorkletSequencerEventType>(name: T, eventData: WorkletSequencerEventType[T]): void;
998
997
  }
999
-
998
+ //#endregion
999
+ //#region src/sequencer/sequencer.d.ts
1000
1000
  declare class Sequencer {
1001
- /**
1002
- * The current MIDI data for all songs, like the midiData property.
1003
- */
1004
- songListData: MIDIData[];
1005
- /**
1006
- * Allows setting up custom event listeners for the sequencer.
1007
- */
1008
- eventHandler: SeqEventHandler;
1009
- /**
1010
- * Indicates whether the sequencer has finished playing a sequence.
1011
- */
1012
- isFinished: boolean;
1013
- /**
1014
- * The synthesizer attached to this sequencer.
1015
- */
1016
- readonly synth: BasicSynthesizer;
1017
- /**
1018
- * The current MIDI data, with the exclusion of the embedded sound bank and event data.
1019
- */
1020
- midiData?: MIDIData;
1021
- /**
1022
- * The MIDI port to play to.
1023
- */
1024
- private midiOut?;
1025
- private isLoading;
1026
- /**
1027
- * Indicates if the sequencer is paused.
1028
- * Paused if a number, undefined if playing.
1029
- */
1030
- private pausedTime?;
1031
- private getMIDICallback?;
1032
- private highResTimeOffset;
1033
- /**
1034
- * Absolute playback startTime, bases on the synth's time.
1035
- */
1036
- private absoluteStartTime;
1037
- /**
1038
- * For sending the messages to the correct SpessaSynthSequencer in core
1039
- */
1040
- private readonly sequencerID;
1041
- /**
1042
- * Creates a new MIDI sequencer for playing back MIDI files.
1043
- * @param synth synth to send events to.
1044
- * @param options the sequencer's options.
1045
- */
1046
- constructor(synth: BasicSynthesizer, options?: Partial<SequencerOptions>);
1047
- private _shuffledSongIndexes;
1048
- /**
1049
- * The shuffled song indexes.
1050
- * This is used when shuffleMode is enabled.
1051
- */
1052
- get shuffledSongIndexes(): number[];
1053
- private _songIndex;
1054
- /**
1055
- * The current song number in the playlist.
1056
- * If shuffle Mode is enabled, this is the index of the shuffled song list.
1057
- */
1058
- get songIndex(): number;
1059
- /**
1060
- * The current song number in the playlist.
1061
- * If shuffle Mode is enabled, this is the index of the shuffled song list.
1062
- */
1063
- set songIndex(value: number);
1064
- private _currentTempo;
1065
- /**
1066
- * Current song's tempo in BPM.
1067
- */
1068
- get currentTempo(): number;
1069
- /**
1070
- * The current sequence's length, in seconds.
1071
- */
1072
- get duration(): number;
1073
- private _songsAmount;
1074
- get songsAmount(): number;
1075
- private _skipToFirstNoteOn;
1076
- /**
1077
- * Indicates if the sequencer should skip to first note on.
1078
- */
1079
- get skipToFirstNoteOn(): boolean;
1080
- /**
1081
- * Indicates if the sequencer should skip to first note on.
1082
- */
1083
- set skipToFirstNoteOn(val: boolean);
1084
- /**
1085
- * Internal loop count marker (-1 is infinite).
1086
- */
1087
- private _loopCount;
1088
- /**
1089
- * The current remaining number of loops. -1 means infinite looping.
1090
- */
1091
- get loopCount(): number;
1092
- /**
1093
- * The current remaining number of loops. -1 means infinite looping.
1094
- */
1095
- set loopCount(val: number);
1096
- /**
1097
- * Controls the playback's rate.
1098
- */
1099
- private _playbackRate;
1100
- /**
1101
- * Controls the playback's rate.
1102
- */
1103
- get playbackRate(): number;
1104
- /**
1105
- * Controls the playback's rate.
1106
- */
1107
- set playbackRate(value: number);
1108
- private _shuffleSongs;
1109
- /**
1110
- * Controls if the sequencer should shuffle the songs in the song list.
1111
- * If true, the sequencer will play the songs in a random order.
1112
- *
1113
- * Songs are shuffled on a `loadNewSongList` call.
1114
- */
1115
- get shuffleSongs(): boolean;
1116
- /**
1117
- * Controls if the sequencer should shuffle the songs in the song list.
1118
- * If true, the sequencer will play the songs in a random order.
1119
- *
1120
- * Songs are shuffled on a `loadNewSongList` call.
1121
- */
1122
- set shuffleSongs(value: boolean);
1123
- /**
1124
- * Current playback time, in seconds.
1125
- */
1126
- get currentTime(): number;
1127
- /**
1128
- * Current playback time, in seconds.
1129
- */
1130
- set currentTime(time: number);
1131
- /**
1132
- * A smoothed version of currentTime.
1133
- * Use for visualization as it's not affected by the audioContext stutter.
1134
- */
1135
- get currentHighResolutionTime(): number;
1136
- /**
1137
- * True if paused, false if playing or stopped.
1138
- */
1139
- get paused(): boolean;
1140
- /**
1141
- * Gets the current MIDI File.
1142
- */
1143
- getMIDI(): Promise<BasicMIDI>;
1144
- /**
1145
- * Loads a new song list.
1146
- * @param midiBuffers The MIDI files to play.
1147
- */
1148
- loadNewSongList(midiBuffers: SuppliedMIDIData[]): void;
1149
- /**
1150
- * Connects a given output to the sequencer.
1151
- * @param output The output to connect. Pass undefined to use the connected synthesizer.
1152
- */
1153
- connectMIDIOutput(output?: {
1154
- send: (data: number[]) => unknown;
1155
- }): void;
1156
- /**
1157
- * Pauses the playback.
1158
- */
1159
- pause(): void;
1160
- /**
1161
- * Starts or resumes the playback.
1162
- */
1163
- play(): void;
1164
- private handleMessage;
1165
- private callEventInternal;
1166
- private resetMIDIOutput;
1167
- private recalculateStartTime;
1168
- private sendMessage;
1001
+ /**
1002
+ * The current MIDI data for all songs, like the midiData property.
1003
+ */
1004
+ songListData: MIDIData[];
1005
+ /**
1006
+ * Allows setting up custom event listeners for the sequencer.
1007
+ */
1008
+ eventHandler: SeqEventHandler;
1009
+ /**
1010
+ * Indicates whether the sequencer has finished playing a sequence.
1011
+ */
1012
+ isFinished: boolean;
1013
+ /**
1014
+ * The synthesizer attached to this sequencer.
1015
+ */
1016
+ readonly synth: BasicSynthesizer;
1017
+ /**
1018
+ * The current MIDI data, with the exclusion of the embedded sound bank and event data.
1019
+ */
1020
+ midiData?: MIDIData;
1021
+ /**
1022
+ * The MIDI port to play to.
1023
+ */
1024
+ private midiOut?;
1025
+ private isLoading;
1026
+ /**
1027
+ * Indicates if the sequencer is paused.
1028
+ * Paused if a number, undefined if playing.
1029
+ */
1030
+ private pausedTime?;
1031
+ private getMIDICallback?;
1032
+ private highResTimeOffset;
1033
+ /**
1034
+ * Absolute playback startTime, bases on the synth's time.
1035
+ */
1036
+ private absoluteStartTime;
1037
+ /**
1038
+ * For sending the messages to the correct SpessaSynthSequencer in core
1039
+ */
1040
+ private readonly sequencerID;
1041
+ /**
1042
+ * Creates a new MIDI sequencer for playing back MIDI files.
1043
+ * @param synth synth to send events to.
1044
+ * @param options the sequencer's options.
1045
+ */
1046
+ constructor(synth: BasicSynthesizer, options?: Partial<SequencerOptions>);
1047
+ private _shuffledSongIndexes;
1048
+ /**
1049
+ * The shuffled song indexes.
1050
+ * This is used when shuffleMode is enabled.
1051
+ */
1052
+ get shuffledSongIndexes(): number[];
1053
+ private _songIndex;
1054
+ /**
1055
+ * The current song number in the playlist.
1056
+ * If shuffle Mode is enabled, this is the index of the shuffled song list.
1057
+ */
1058
+ get songIndex(): number;
1059
+ /**
1060
+ * The current song number in the playlist.
1061
+ * If shuffle Mode is enabled, this is the index of the shuffled song list.
1062
+ */
1063
+ set songIndex(value: number);
1064
+ private _currentTempo;
1065
+ /**
1066
+ * Current song's tempo in BPM.
1067
+ */
1068
+ get currentTempo(): number;
1069
+ /**
1070
+ * The current sequence's length, in seconds.
1071
+ */
1072
+ get duration(): number;
1073
+ private _songsAmount;
1074
+ get songsAmount(): number;
1075
+ private _skipToFirstNoteOn;
1076
+ /**
1077
+ * Indicates if the sequencer should skip to first note on.
1078
+ */
1079
+ get skipToFirstNoteOn(): boolean;
1080
+ /**
1081
+ * Indicates if the sequencer should skip to first note on.
1082
+ */
1083
+ set skipToFirstNoteOn(val: boolean);
1084
+ /**
1085
+ * Internal loop count marker (-1 is infinite).
1086
+ */
1087
+ private _loopCount;
1088
+ /**
1089
+ * The current remaining number of loops. -1 means infinite looping.
1090
+ */
1091
+ get loopCount(): number;
1092
+ /**
1093
+ * The current remaining number of loops. -1 means infinite looping.
1094
+ */
1095
+ set loopCount(val: number);
1096
+ /**
1097
+ * Controls the playback's rate.
1098
+ */
1099
+ private _playbackRate;
1100
+ /**
1101
+ * Controls the playback's rate.
1102
+ */
1103
+ get playbackRate(): number;
1104
+ /**
1105
+ * Controls the playback's rate.
1106
+ */
1107
+ set playbackRate(value: number);
1108
+ private _shuffleSongs;
1109
+ /**
1110
+ * Controls if the sequencer should shuffle the songs in the song list.
1111
+ * If true, the sequencer will play the songs in a random order.
1112
+ *
1113
+ * Songs are shuffled on a `loadNewSongList` call.
1114
+ */
1115
+ get shuffleSongs(): boolean;
1116
+ /**
1117
+ * Controls if the sequencer should shuffle the songs in the song list.
1118
+ * If true, the sequencer will play the songs in a random order.
1119
+ *
1120
+ * Songs are shuffled on a `loadNewSongList` call.
1121
+ */
1122
+ set shuffleSongs(value: boolean);
1123
+ /**
1124
+ * Current playback time, in seconds.
1125
+ */
1126
+ get currentTime(): number;
1127
+ /**
1128
+ * Current playback time, in seconds.
1129
+ */
1130
+ set currentTime(time: number);
1131
+ /**
1132
+ * A smoothed version of currentTime.
1133
+ * Use for visualization as it's not affected by the audioContext stutter.
1134
+ */
1135
+ get currentHighResolutionTime(): number;
1136
+ /**
1137
+ * True if paused, false if playing or stopped.
1138
+ */
1139
+ get paused(): boolean;
1140
+ /**
1141
+ * Gets the current MIDI File.
1142
+ */
1143
+ getMIDI(): Promise<BasicMIDI>;
1144
+ /**
1145
+ * Loads a new song list.
1146
+ * @param midiBuffers The MIDI files to play.
1147
+ */
1148
+ loadNewSongList(midiBuffers: SuppliedMIDIData[]): void;
1149
+ /**
1150
+ * Connects a given output to the sequencer.
1151
+ * @param output The output to connect. Pass undefined to use the connected synthesizer.
1152
+ */
1153
+ connectMIDIOutput(output?: {
1154
+ send: (data: number[]) => unknown;
1155
+ }): void;
1156
+ /**
1157
+ * Pauses the playback.
1158
+ */
1159
+ pause(): void;
1160
+ /**
1161
+ * Starts or resumes the playback.
1162
+ */
1163
+ play(): void;
1164
+ private handleMessage;
1165
+ private callEventInternal;
1166
+ private resetMIDIOutput;
1167
+ private recalculateStartTime;
1168
+ private sendMessage;
1169
1169
  }
1170
-
1170
+ //#endregion
1171
+ //#region src/utils/buffer_to_wav.d.ts
1171
1172
  interface ExtraWaveOptions extends WaveWriteOptions {
1172
- /**
1173
- * The channel offset in the AudioBuffer. Defaults to 0.
1174
- */
1175
- channelOffset: number;
1176
- /**
1177
- * The amount of channels from the AudioBuffer to write. Defaults to all.
1178
- */
1179
- channelCount: number;
1173
+ /**
1174
+ * The channel offset in the AudioBuffer. Defaults to 0.
1175
+ */
1176
+ channelOffset: number;
1177
+ /**
1178
+ * The amount of channels from the AudioBuffer to write. Defaults to all.
1179
+ */
1180
+ channelCount: number;
1180
1181
  }
1181
1182
  /**
1182
1183
  * Converts an audio buffer into a wave file.
@@ -1185,93 +1186,97 @@ interface ExtraWaveOptions extends WaveWriteOptions {
1185
1186
  * @returns The binary file.
1186
1187
  */
1187
1188
  declare function audioBufferToWav(audioBuffer: AudioBuffer, options?: Partial<ExtraWaveOptions>): Blob;
1188
-
1189
+ //#endregion
1190
+ //#region src/external_midi/midi_handler.d.ts
1189
1191
  /**
1190
1192
  * Midi_handler.js
1191
1193
  * purpose: handles the connection between MIDI devices and synthesizer/sequencer via Web MIDI API
1192
1194
  */
1193
1195
  declare class LibMIDIPort {
1194
- readonly port: MIDIPort;
1195
- protected constructor(port: MIDIPort);
1196
- /**
1197
- *
1198
- */
1199
- get id(): string;
1200
- /**
1201
- *
1202
- */
1203
- get name(): string | null;
1204
- /**
1205
- *
1206
- */
1207
- get manufacturer(): string | null;
1208
- /**
1209
- *
1210
- */
1211
- get version(): string | null;
1196
+ readonly port: MIDIPort;
1197
+ protected constructor(port: MIDIPort);
1198
+ /**
1199
+ *
1200
+ */
1201
+ get id(): string;
1202
+ /**
1203
+ *
1204
+ */
1205
+ get name(): string | null;
1206
+ /**
1207
+ *
1208
+ */
1209
+ get manufacturer(): string | null;
1210
+ /**
1211
+ *
1212
+ */
1213
+ get version(): string | null;
1212
1214
  }
1213
1215
  declare class LibMIDIInput extends LibMIDIPort {
1214
- private readonly connectedSynths;
1215
- constructor(input: MIDIInput);
1216
- /**
1217
- * Connects the input to a given synth, listening for all incoming events.
1218
- * @param synth The synth to connect to.
1219
- */
1220
- connect(synth: BasicSynthesizer): void;
1221
- /**
1222
- * Disconnects the input from a given synth.
1223
- * @param synth The synth to disconnect from.
1224
- */
1225
- disconnect(synth: BasicSynthesizer): void;
1216
+ private readonly connectedSynths;
1217
+ constructor(input: MIDIInput);
1218
+ /**
1219
+ * Connects the input to a given synth, listening for all incoming events.
1220
+ * @param synth The synth to connect to.
1221
+ */
1222
+ connect(synth: BasicSynthesizer): void;
1223
+ /**
1224
+ * Disconnects the input from a given synth.
1225
+ * @param synth The synth to disconnect from.
1226
+ */
1227
+ disconnect(synth: BasicSynthesizer): void;
1226
1228
  }
1227
1229
  declare class LibMIDIOutput extends LibMIDIPort {
1228
- readonly port: MIDIOutput;
1229
- constructor(output: MIDIOutput);
1230
- /**
1231
- * Connects a given sequencer to the output, playing back the MIDI file to it.
1232
- * @param seq The sequencer to connect.
1233
- */
1234
- connect(seq: Sequencer): void;
1235
- /**
1236
- * Disconnects sequencer from the output, making it play to the attached Synthesizer instead.
1237
- * @param seq The sequencer to disconnect.
1238
- */
1239
- disconnect(seq: Sequencer): void;
1230
+ readonly port: MIDIOutput;
1231
+ constructor(output: MIDIOutput);
1232
+ /**
1233
+ * Connects a given sequencer to the output, playing back the MIDI file to it.
1234
+ * @param seq The sequencer to connect.
1235
+ */
1236
+ connect(seq: Sequencer): void;
1237
+ /**
1238
+ * Disconnects sequencer from the output, making it play to the attached Synthesizer instead.
1239
+ * @param seq The sequencer to disconnect.
1240
+ */
1241
+ disconnect(seq: Sequencer): void;
1240
1242
  }
1241
1243
  /**
1242
1244
  * A class for handling physical MIDI devices.
1243
1245
  */
1244
1246
  declare class MIDIDeviceHandler {
1245
- /**
1246
- * The available MIDI inputs. ID maps to the input.
1247
- */
1248
- readonly inputs: Map<string, LibMIDIInput>;
1249
- /**
1250
- * The available MIDI outputs. ID maps to the output.
1251
- */
1252
- readonly outputs: Map<string, LibMIDIOutput>;
1253
- private constructor();
1254
- /**
1255
- * Attempts to initialize the MIDI Device Handler.
1256
- * @returns The handler.
1257
- * @throws An error if the MIDI Devices fail to initialize.
1258
- */
1259
- static createMIDIDeviceHandler(): Promise<MIDIDeviceHandler>;
1247
+ /**
1248
+ * The available MIDI inputs. ID maps to the input.
1249
+ */
1250
+ readonly inputs: Map<string, LibMIDIInput>;
1251
+ /**
1252
+ * The available MIDI outputs. ID maps to the output.
1253
+ */
1254
+ readonly outputs: Map<string, LibMIDIOutput>;
1255
+ private constructor();
1256
+ /**
1257
+ * Attempts to initialize the MIDI Device Handler.
1258
+ * @returns The handler.
1259
+ * @throws An error if the MIDI Devices fail to initialize.
1260
+ */
1261
+ static createMIDIDeviceHandler(): Promise<MIDIDeviceHandler>;
1260
1262
  }
1261
-
1263
+ //#endregion
1264
+ //#region src/external_midi/web_midi_link.d.ts
1262
1265
  /**
1263
1266
  * Web_midi_link.js
1264
1267
  * purpose: handles the web midi link connection to the synthesizer
1265
1268
  * https://www.g200kg.com/en/docs/webmidilink/
1266
1269
  */
1267
1270
  declare class WebMIDILinkHandler {
1268
- /**
1269
- * Initializes support for Web MIDI Link (https://www.g200kg.com/en/docs/webmidilink/)
1270
- * @param synth The synthesizer to enable support with.
1271
- */
1272
- constructor(synth: BasicSynthesizer);
1271
+ /**
1272
+ * Initializes support for Web MIDI Link (https://www.g200kg.com/en/docs/webmidilink/)
1273
+ * @param synth The synthesizer to enable support with.
1274
+ */
1275
+ constructor(synth: BasicSynthesizer);
1273
1276
  }
1274
-
1277
+ //#endregion
1278
+ //#region src/synthesizer/basic/synth_config.d.ts
1275
1279
  declare const DEFAULT_SYNTH_CONFIG: SynthConfig;
1276
-
1277
- export { BasicSynthesizer, DEFAULT_SYNTH_CONFIG, MIDIDeviceHandler, Sequencer, WebMIDILinkHandler, WorkerSynthesizer, WorkerSynthesizerCore, WorkletSynthesizer, audioBufferToWav };
1280
+ //#endregion
1281
+ export { type BasicSynthesizer, DEFAULT_SYNTH_CONFIG, MIDIDeviceHandler, Sequencer, WebMIDILinkHandler, WorkerSynthesizer, WorkerSynthesizerCore, WorkletSynthesizer, audioBufferToWav };
1282
+ //# sourceMappingURL=index.d.ts.map