spessasynth_lib 4.0.4 → 4.0.5
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 +122 -107
- package/dist/index.js +32 -20
- package/dist/index.js.map +1 -1
- package/dist/spessasynth_processor.min.js +11 -11
- package/dist/spessasynth_processor.min.js.map +3 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,108 @@
|
|
|
1
|
-
import { BasicMIDI, MIDITrack,
|
|
1
|
+
import { MIDIPatch, KeyModifier, SoundBankManagerListEntry, SynthProcessorEventData, BasicMIDI, MIDITrack, SequencerEvent, MIDIMessage, SpessaSynthProcessor, SpessaSynthSequencer, SynthProcessorOptions, BasicSoundBank, SoundFont2WriteOptions, DLSWriteOptions, RMIDIWriteOptions, SynthesizerSnapshot, SynthMethodOptions, CustomController, MIDIController, MasterParameterType, SynthProcessorEvent, ChannelSnapshot, ChannelProperty, PresetList, WaveWriteOptions } from 'spessasynth_core';
|
|
2
|
+
|
|
3
|
+
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;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type LibSBKManagerEntry = Omit<SoundBankManagerListEntry, "soundBank">;
|
|
39
|
+
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;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
type ProcessorEventCallback<T extends keyof SynthProcessorEventData> = (callbackData: SynthProcessorEventData[T]) => unknown;
|
|
76
|
+
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
|
+
*/
|
|
104
|
+
callEventInternal<T extends keyof SynthProcessorEventData>(name: T, eventData: SynthProcessorEventData[T]): void;
|
|
105
|
+
}
|
|
2
106
|
|
|
3
107
|
declare const songChangeType: {
|
|
4
108
|
readonly shuffleOn: 1;
|
|
@@ -488,110 +592,6 @@ interface ChorusConfig extends BasicEffectConfig {
|
|
|
488
592
|
oscillatorGain: number;
|
|
489
593
|
}
|
|
490
594
|
|
|
491
|
-
declare class WorkletKeyModifierManagerWrapper {
|
|
492
|
-
private keyModifiers;
|
|
493
|
-
private synth;
|
|
494
|
-
constructor(synth: BasicSynthesizer);
|
|
495
|
-
/**
|
|
496
|
-
* Modifies a single key.
|
|
497
|
-
* @param channel The channel affected. Usually 0-15.
|
|
498
|
-
* @param midiNote The MIDI note to change. 0-127.
|
|
499
|
-
* @param options The key's modifiers.
|
|
500
|
-
*/
|
|
501
|
-
addModifier(channel: number, midiNote: number, options: Partial<{
|
|
502
|
-
velocity: number;
|
|
503
|
-
patch: MIDIPatch;
|
|
504
|
-
gain: number;
|
|
505
|
-
}>): void;
|
|
506
|
-
/**
|
|
507
|
-
* Gets a key modifier.
|
|
508
|
-
* @param channel The channel affected. Usually 0-15.
|
|
509
|
-
* @param midiNote The MIDI note to change. 0-127.
|
|
510
|
-
* @returns The key modifier if it exists.
|
|
511
|
-
*/
|
|
512
|
-
getModifier(channel: number, midiNote: number): KeyModifier | undefined;
|
|
513
|
-
/**
|
|
514
|
-
* Deletes a key modifier.
|
|
515
|
-
* @param channel The channel affected. Usually 0-15.
|
|
516
|
-
* @param midiNote The MIDI note to change. 0-127.
|
|
517
|
-
*/
|
|
518
|
-
deleteModifier(channel: number, midiNote: number): void;
|
|
519
|
-
/**
|
|
520
|
-
* Clears ALL Modifiers
|
|
521
|
-
*/
|
|
522
|
-
clearModifiers(): void;
|
|
523
|
-
private sendToWorklet;
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
type LibSBKManagerEntry = Omit<SoundBankManagerListEntry, "soundBank">;
|
|
527
|
-
declare class SoundBankManager {
|
|
528
|
-
/**
|
|
529
|
-
* All the sound banks, ordered from the most important to the least.
|
|
530
|
-
*/
|
|
531
|
-
soundBankList: LibSBKManagerEntry[];
|
|
532
|
-
private synth;
|
|
533
|
-
/**
|
|
534
|
-
* Creates a new instance of the sound bank manager.
|
|
535
|
-
*/
|
|
536
|
-
constructor(synth: BasicSynthesizer);
|
|
537
|
-
/**
|
|
538
|
-
* The current sound bank priority order.
|
|
539
|
-
* @returns The IDs of the sound banks in the current order.
|
|
540
|
-
*/
|
|
541
|
-
get priorityOrder(): string[];
|
|
542
|
-
/**
|
|
543
|
-
* Rearranges the sound banks in a given order.
|
|
544
|
-
* @param newList The order of sound banks, a list of identifiers, first overwrites second.
|
|
545
|
-
*/
|
|
546
|
-
set priorityOrder(newList: string[]);
|
|
547
|
-
/**
|
|
548
|
-
* Adds a new sound bank buffer with a given ID.
|
|
549
|
-
* @param soundBankBuffer The sound bank's buffer
|
|
550
|
-
* @param id The sound bank's unique identifier.
|
|
551
|
-
* @param bankOffset The sound bank's bank offset. Default is 0.
|
|
552
|
-
*/
|
|
553
|
-
addSoundBank(soundBankBuffer: ArrayBuffer, id: string, bankOffset?: number): Promise<void>;
|
|
554
|
-
/**
|
|
555
|
-
* Deletes a sound bank with the given ID.
|
|
556
|
-
* @param id The sound bank to delete.
|
|
557
|
-
*/
|
|
558
|
-
deleteSoundBank(id: string): Promise<void>;
|
|
559
|
-
private awaitResponse;
|
|
560
|
-
private sendToWorklet;
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
type ProcessorEventCallback<T extends keyof SynthProcessorEventData> = (callbackData: SynthProcessorEventData[T]) => unknown;
|
|
564
|
-
declare class SynthEventHandler {
|
|
565
|
-
/**
|
|
566
|
-
* The time delay before an event is called.
|
|
567
|
-
* Set to 0 to disable it.
|
|
568
|
-
*/
|
|
569
|
-
timeDelay: number;
|
|
570
|
-
/**
|
|
571
|
-
* The main list of events.
|
|
572
|
-
* @private
|
|
573
|
-
*/
|
|
574
|
-
private readonly events;
|
|
575
|
-
/**
|
|
576
|
-
* Adds a new event listener.
|
|
577
|
-
* @param event The event to listen to.
|
|
578
|
-
* @param id The unique identifier for the event. It can be used to overwrite existing callback with the same ID.
|
|
579
|
-
* @param callback The callback for the event.
|
|
580
|
-
*/
|
|
581
|
-
addEvent<T extends keyof SynthProcessorEventData>(event: T, id: string, callback: ProcessorEventCallback<T>): void;
|
|
582
|
-
/**
|
|
583
|
-
* Removes an event listener
|
|
584
|
-
* @param name The event to remove a listener from.
|
|
585
|
-
* @param id The unique identifier for the event to remove.
|
|
586
|
-
*/
|
|
587
|
-
removeEvent<T extends keyof SynthProcessorEventData>(name: T, id: string): void;
|
|
588
|
-
/**
|
|
589
|
-
* Calls the given event.
|
|
590
|
-
* INTERNAL USE ONLY!
|
|
591
|
-
*/
|
|
592
|
-
callEventInternal<T extends keyof SynthProcessorEventData>(name: T, eventData: SynthProcessorEventData[T]): void;
|
|
593
|
-
}
|
|
594
|
-
|
|
595
595
|
declare abstract class BasicEffectsProcessor {
|
|
596
596
|
readonly input: AudioNode;
|
|
597
597
|
protected readonly output: AudioNode;
|
|
@@ -664,12 +664,21 @@ declare class ReverbProcessor extends BasicEffectsProcessor {
|
|
|
664
664
|
update(config: Partial<ReverbConfig>): void;
|
|
665
665
|
}
|
|
666
666
|
|
|
667
|
+
/**
|
|
668
|
+
* Extended synthesizer snapshot to contain effects
|
|
669
|
+
*/
|
|
667
670
|
declare class LibSynthesizerSnapshot extends SynthesizerSnapshot {
|
|
671
|
+
/**
|
|
672
|
+
* Chorus configuration of this synthesizer.
|
|
673
|
+
*/
|
|
668
674
|
chorusConfig: ChorusConfig;
|
|
675
|
+
/**
|
|
676
|
+
* Reverb configuration of this synthesizer.
|
|
677
|
+
*/
|
|
669
678
|
reverbConfig: ReverbConfig;
|
|
670
679
|
constructor(channelSnapshots: ChannelSnapshot[], masterParameters: MasterParameterType, keyMappings: (KeyModifier | undefined)[][], chorusConfig?: ChorusConfig, reverbConfig?: ReverbConfig);
|
|
671
680
|
/**
|
|
672
|
-
* Retrieves the
|
|
681
|
+
* Retrieves the SynthesizerSnapshot from the lib snapshot.
|
|
673
682
|
*/
|
|
674
683
|
getCoreSnapshot(): SynthesizerSnapshot;
|
|
675
684
|
}
|
|
@@ -699,6 +708,9 @@ declare abstract class BasicSynthesizer {
|
|
|
699
708
|
* The current preset list.
|
|
700
709
|
*/
|
|
701
710
|
presetList: PresetList;
|
|
711
|
+
/**
|
|
712
|
+
* INTERNAL USE ONLY!
|
|
713
|
+
*/
|
|
702
714
|
sequencerCallbackFunction?: (m: SequencerReturnMessage) => unknown;
|
|
703
715
|
/**
|
|
704
716
|
* Resolves when the synthesizer is ready.
|
|
@@ -714,6 +726,9 @@ declare abstract class BasicSynthesizer {
|
|
|
714
726
|
* Undefined if chorus is disabled.
|
|
715
727
|
*/
|
|
716
728
|
readonly chorusProcessor?: ChorusProcessor;
|
|
729
|
+
/**
|
|
730
|
+
* INTERNAL USE ONLY!
|
|
731
|
+
*/
|
|
717
732
|
readonly post: (data: BasicSynthesizerMessage, transfer?: Transferable[]) => unknown;
|
|
718
733
|
protected readonly worklet: AudioWorkletNode;
|
|
719
734
|
/**
|
|
@@ -1325,4 +1340,4 @@ declare class WebMIDILinkHandler {
|
|
|
1325
1340
|
|
|
1326
1341
|
declare const DEFAULT_SYNTH_CONFIG: SynthConfig;
|
|
1327
1342
|
|
|
1328
|
-
export { ChorusProcessor, DEFAULT_SYNTH_CONFIG, MIDIDeviceHandler, ReverbProcessor, Sequencer, WebMIDILinkHandler, WorkerSynthesizer, WorkerSynthesizerCore, WorkletSynthesizer, audioBufferToWav };
|
|
1343
|
+
export { BasicSynthesizer, ChorusProcessor, DEFAULT_SYNTH_CONFIG, MIDIDeviceHandler, ReverbProcessor, Sequencer, WebMIDILinkHandler, WorkerSynthesizer, WorkerSynthesizerCore, WorkletSynthesizer, audioBufferToWav };
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
// src/synthesizer/audio_effects/effects_config.ts
|
|
2
|
-
var DEFAULT_SYNTH_CONFIG = {
|
|
3
|
-
enableEventSystem: true,
|
|
4
|
-
oneOutput: false,
|
|
5
|
-
audioNodeCreators: void 0,
|
|
6
|
-
initializeChorusProcessor: true,
|
|
7
|
-
initializeReverbProcessor: true
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
// src/synthesizer/worklet/worklet_processor_name.ts
|
|
11
|
-
var WORKLET_PROCESSOR_NAME = "spessasynth-worklet-processor";
|
|
12
|
-
|
|
13
1
|
// src/synthesizer/basic/key_modifier_manager.ts
|
|
14
2
|
import { KeyModifier } from "spessasynth_core";
|
|
15
3
|
|
|
@@ -419,6 +407,7 @@ var ChorusProcessor = class extends BasicEffectsProcessor {
|
|
|
419
407
|
this.deleteNodes();
|
|
420
408
|
}
|
|
421
409
|
deleteNodes() {
|
|
410
|
+
this.input.disconnect();
|
|
422
411
|
for (const node of this.chorusLeft) {
|
|
423
412
|
node.delay.disconnect();
|
|
424
413
|
node.oscillator.disconnect();
|
|
@@ -459,6 +448,15 @@ var ChorusProcessor = class extends BasicEffectsProcessor {
|
|
|
459
448
|
}
|
|
460
449
|
};
|
|
461
450
|
|
|
451
|
+
// src/synthesizer/audio_effects/effects_config.ts
|
|
452
|
+
var DEFAULT_SYNTH_CONFIG = {
|
|
453
|
+
enableEventSystem: true,
|
|
454
|
+
oneOutput: false,
|
|
455
|
+
audioNodeCreators: void 0,
|
|
456
|
+
initializeChorusProcessor: true,
|
|
457
|
+
initializeReverbProcessor: true
|
|
458
|
+
};
|
|
459
|
+
|
|
462
460
|
// src/utils/other.ts
|
|
463
461
|
import { SpessaSynthCoreUtils as SpessaSynthCoreUtils2 } from "spessasynth_core";
|
|
464
462
|
var consoleColors = SpessaSynthCoreUtils2.consoleColors;
|
|
@@ -527,21 +525,28 @@ var ReverbProcessor = class extends BasicEffectsProcessor {
|
|
|
527
525
|
};
|
|
528
526
|
|
|
529
527
|
// src/synthesizer/basic/snapshot.ts
|
|
530
|
-
import {
|
|
531
|
-
SynthesizerSnapshot
|
|
532
|
-
} from "spessasynth_core";
|
|
528
|
+
import { ChannelSnapshot, SynthesizerSnapshot } from "spessasynth_core";
|
|
533
529
|
var LibSynthesizerSnapshot = class extends SynthesizerSnapshot {
|
|
534
|
-
|
|
530
|
+
/**
|
|
531
|
+
* Chorus configuration of this synthesizer.
|
|
532
|
+
*/
|
|
535
533
|
chorusConfig;
|
|
534
|
+
/**
|
|
535
|
+
* Reverb configuration of this synthesizer.
|
|
536
|
+
*/
|
|
536
537
|
reverbConfig;
|
|
537
538
|
constructor(channelSnapshots, masterParameters, keyMappings, chorusConfig = DEFAULT_CHORUS_CONFIG, reverbConfig = DEFAULT_REVERB_CONFIG) {
|
|
538
|
-
super(
|
|
539
|
+
super(
|
|
540
|
+
channelSnapshots.map((c) => ChannelSnapshot.copyFrom(c)),
|
|
541
|
+
masterParameters,
|
|
542
|
+
keyMappings
|
|
543
|
+
);
|
|
539
544
|
this.reverbConfig = { ...reverbConfig };
|
|
540
545
|
this.chorusConfig = { ...chorusConfig };
|
|
541
546
|
}
|
|
542
547
|
// noinspection JSUnusedGlobalSymbols
|
|
543
548
|
/**
|
|
544
|
-
* Retrieves the
|
|
549
|
+
* Retrieves the SynthesizerSnapshot from the lib snapshot.
|
|
545
550
|
*/
|
|
546
551
|
getCoreSnapshot() {
|
|
547
552
|
return new SynthesizerSnapshot(
|
|
@@ -583,7 +588,9 @@ var BasicSynthesizer = class {
|
|
|
583
588
|
* The current preset list.
|
|
584
589
|
*/
|
|
585
590
|
presetList = [];
|
|
586
|
-
|
|
591
|
+
/**
|
|
592
|
+
* INTERNAL USE ONLY!
|
|
593
|
+
*/
|
|
587
594
|
sequencerCallbackFunction;
|
|
588
595
|
/**
|
|
589
596
|
* Resolves when the synthesizer is ready.
|
|
@@ -599,7 +606,9 @@ var BasicSynthesizer = class {
|
|
|
599
606
|
* Undefined if chorus is disabled.
|
|
600
607
|
*/
|
|
601
608
|
chorusProcessor;
|
|
602
|
-
|
|
609
|
+
/**
|
|
610
|
+
* INTERNAL USE ONLY!
|
|
611
|
+
*/
|
|
603
612
|
post;
|
|
604
613
|
worklet;
|
|
605
614
|
/**
|
|
@@ -1261,6 +1270,9 @@ var BasicSynthesizer = class {
|
|
|
1261
1270
|
}
|
|
1262
1271
|
};
|
|
1263
1272
|
|
|
1273
|
+
// src/synthesizer/worklet/worklet_processor_name.ts
|
|
1274
|
+
var WORKLET_PROCESSOR_NAME = "spessasynth-worklet-processor";
|
|
1275
|
+
|
|
1264
1276
|
// src/synthesizer/worklet/worklet_synthesizer.ts
|
|
1265
1277
|
var WorkletSynthesizer = class extends BasicSynthesizer {
|
|
1266
1278
|
/**
|