spessasynth_lib 4.2.2 → 4.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +25 -11
- package/dist/index.js +55 -29
- package/dist/index.js.map +1 -1
- package/dist/spessasynth_processor.min.js +2 -2
- package/dist/spessasynth_processor.min.js.map +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -254,6 +254,7 @@ declare abstract class BasicSynthesizerCore {
|
|
|
254
254
|
* @protected
|
|
255
255
|
*/
|
|
256
256
|
protected alive: boolean;
|
|
257
|
+
protected readonly enableEventSystem: boolean;
|
|
257
258
|
protected constructor(sampleRate: number, options: Omit<SynthProcessorOptions, "reverbProcessor" | "chorusProcessor" | "delayProcessor">, postMessage: PostMessageSynthCore);
|
|
258
259
|
protected createNewSequencer(): void;
|
|
259
260
|
protected postReady<K extends keyof SynthesizerReturn>(type: K, data: SynthesizerReturn[K], transferable?: Transferable[]): void;
|
|
@@ -436,7 +437,6 @@ interface BasicSynthesizerMessageData {
|
|
|
436
437
|
midiMessage: {
|
|
437
438
|
messageData: Uint8Array;
|
|
438
439
|
channelOffset: number;
|
|
439
|
-
force: boolean;
|
|
440
440
|
options: SynthMethodOptions;
|
|
441
441
|
};
|
|
442
442
|
ccReset: null;
|
|
@@ -706,12 +706,27 @@ declare abstract class BasicSynthesizer {
|
|
|
706
706
|
rate: number;
|
|
707
707
|
}): void;
|
|
708
708
|
/**
|
|
709
|
-
* Connects
|
|
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.
|
|
710
725
|
* @param audioNodes Exactly 16 outputs.
|
|
711
726
|
*/
|
|
712
727
|
connectIndividualOutputs(audioNodes: AudioNode[]): void;
|
|
713
728
|
/**
|
|
714
|
-
* Disconnects the individual audio outputs
|
|
729
|
+
* Disconnects the individual audio outputs from the given audio nodes.
|
|
715
730
|
* @param audioNodes Exactly 16 outputs.
|
|
716
731
|
*/
|
|
717
732
|
disconnectIndividualOutputs(audioNodes: AudioNode[]): void;
|
|
@@ -739,10 +754,9 @@ declare abstract class BasicSynthesizer {
|
|
|
739
754
|
* Stops playing a note.
|
|
740
755
|
* @param channel Usually 0-15: the channel of the note.
|
|
741
756
|
* @param midiNote {number} 0-127 the key number of the note.
|
|
742
|
-
* @param force Instantly kills the note if true.
|
|
743
757
|
* @param eventOptions Additional options for this command.
|
|
744
758
|
*/
|
|
745
|
-
noteOff(channel: number, midiNote: number,
|
|
759
|
+
noteOff(channel: number, midiNote: number, eventOptions?: SynthMethodOptions): void;
|
|
746
760
|
/**
|
|
747
761
|
* Stops all notes.
|
|
748
762
|
* @param force If the notes should immediately be stopped, defaults to false.
|
|
@@ -753,10 +767,9 @@ declare abstract class BasicSynthesizer {
|
|
|
753
767
|
* @param channel Usually 0-15: the channel to change the controller.
|
|
754
768
|
* @param controllerNumber 0-127 the MIDI CC number.
|
|
755
769
|
* @param controllerValue 0-127 the controller value.
|
|
756
|
-
* @param force Forces the controller-change message, even if it's locked or gm system is set and the cc is bank select.
|
|
757
770
|
* @param eventOptions Additional options for this command.
|
|
758
771
|
*/
|
|
759
|
-
controllerChange(channel: number, controllerNumber: MIDIController, controllerValue: number,
|
|
772
|
+
controllerChange(channel: number, controllerNumber: MIDIController, controllerValue: number, eventOptions?: SynthMethodOptions): void;
|
|
760
773
|
/**
|
|
761
774
|
* Resets all controllers (for every channel)
|
|
762
775
|
*/
|
|
@@ -796,15 +809,16 @@ declare abstract class BasicSynthesizer {
|
|
|
796
809
|
* Sets the channel's pitch wheel range, in semitones.
|
|
797
810
|
* @param channel Usually 0-15: the channel to change.
|
|
798
811
|
* @param range The bend range in semitones.
|
|
812
|
+
* @param eventOptions Additional options for this command.
|
|
799
813
|
*/
|
|
800
|
-
pitchWheelRange(channel: number, range: number): void;
|
|
814
|
+
pitchWheelRange(channel: number, range: number, eventOptions?: SynthMethodOptions): void;
|
|
801
815
|
/**
|
|
802
816
|
* Changes the program for a given channel
|
|
803
817
|
* @param channel Usually 0-15: the channel to change.
|
|
804
818
|
* @param programNumber 0-127 the MIDI patch number.
|
|
805
|
-
*
|
|
819
|
+
* @param eventOptions Additional options for this command.
|
|
806
820
|
*/
|
|
807
|
-
programChange(channel: number, programNumber: number): void;
|
|
821
|
+
programChange(channel: number, programNumber: number, eventOptions?: SynthMethodOptions): void;
|
|
808
822
|
/**
|
|
809
823
|
* Transposes the channel by given number of semitones.
|
|
810
824
|
* @param channel The channel number.
|
|
@@ -860,7 +874,7 @@ declare abstract class BasicSynthesizer {
|
|
|
860
874
|
assignNewSequencer(callback: (m: SequencerReturnMessage) => unknown): number;
|
|
861
875
|
protected assignProgressTracker<K extends keyof SynthesizerProgress>(type: K, progressFunction: (args: SynthesizerProgress[K]) => unknown): void;
|
|
862
876
|
protected revokeProgressTracker<K extends keyof SynthesizerProgress>(type: K): void;
|
|
863
|
-
protected _sendInternal(message: Iterable<number>, channelOffset: number,
|
|
877
|
+
protected _sendInternal(message: Iterable<number>, channelOffset: number, eventOptions: Partial<SynthMethodOptions>): void;
|
|
864
878
|
/**
|
|
865
879
|
* Handles the messages received from the worklet.
|
|
866
880
|
*/
|
package/dist/index.js
CHANGED
|
@@ -557,7 +557,27 @@ var BasicSynthesizer = class {
|
|
|
557
557
|
void value;
|
|
558
558
|
}
|
|
559
559
|
/**
|
|
560
|
-
* Connects
|
|
560
|
+
* Connects a given channel output to the given audio node.
|
|
561
|
+
* Note that this output is only meant for visualization and may be silent when Insertion Effect for this channel is enabled.
|
|
562
|
+
* @param targetNode The node to connect to.
|
|
563
|
+
* @param channelNumber The channel number to connect to, will be rolled over if value is greater than 15.
|
|
564
|
+
* @returns The target node.
|
|
565
|
+
*/
|
|
566
|
+
connectChannel(targetNode, channelNumber) {
|
|
567
|
+
this.worklet.connect(targetNode, channelNumber % 16 + 1);
|
|
568
|
+
return targetNode;
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Disconnects a given channel output to the given audio node.
|
|
572
|
+
* @param targetNode The node to disconnect from.
|
|
573
|
+
* @param channelNumber The channel number to connect to, will be rolled over if value is greater than 15.
|
|
574
|
+
*/
|
|
575
|
+
disconnectChannel(targetNode, channelNumber) {
|
|
576
|
+
this.worklet.disconnect(targetNode, channelNumber % 16 + 1);
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Connects the individual audio outputs to the given audio nodes.
|
|
580
|
+
* Note that these outputs is only meant for visualization and may be silent when Insertion Effect for this channel is enabled.
|
|
561
581
|
* @param audioNodes Exactly 16 outputs.
|
|
562
582
|
*/
|
|
563
583
|
connectIndividualOutputs(audioNodes) {
|
|
@@ -565,12 +585,12 @@ var BasicSynthesizer = class {
|
|
|
565
585
|
throw new Error(`input nodes amount differs from the system's outputs amount!
|
|
566
586
|
Expected ${this._outputsAmount} got ${audioNodes.length}`);
|
|
567
587
|
}
|
|
568
|
-
for (let
|
|
569
|
-
this.
|
|
588
|
+
for (let channel = 0; channel < this._outputsAmount; channel++) {
|
|
589
|
+
this.connectChannel(audioNodes[channel], channel);
|
|
570
590
|
}
|
|
571
591
|
}
|
|
572
592
|
/**
|
|
573
|
-
* Disconnects the individual audio outputs
|
|
593
|
+
* Disconnects the individual audio outputs from the given audio nodes.
|
|
574
594
|
* @param audioNodes Exactly 16 outputs.
|
|
575
595
|
*/
|
|
576
596
|
disconnectIndividualOutputs(audioNodes) {
|
|
@@ -578,8 +598,8 @@ var BasicSynthesizer = class {
|
|
|
578
598
|
throw new Error(`input nodes amount differs from the system's outputs amount!
|
|
579
599
|
Expected ${this._outputsAmount} got ${audioNodes.length}`);
|
|
580
600
|
}
|
|
581
|
-
for (let
|
|
582
|
-
this.
|
|
601
|
+
for (let channel = 0; channel < this._outputsAmount; channel++) {
|
|
602
|
+
this.disconnectChannel(audioNodes[channel], channel);
|
|
583
603
|
}
|
|
584
604
|
}
|
|
585
605
|
// noinspection JSUnusedGlobalSymbols
|
|
@@ -597,7 +617,7 @@ var BasicSynthesizer = class {
|
|
|
597
617
|
* @param eventOptions additional options for this command.
|
|
598
618
|
*/
|
|
599
619
|
sendMessage(message, channelOffset = 0, eventOptions = DEFAULT_SYNTH_METHOD_OPTIONS) {
|
|
600
|
-
this._sendInternal(message, channelOffset,
|
|
620
|
+
this._sendInternal(message, channelOffset, eventOptions);
|
|
601
621
|
}
|
|
602
622
|
/**
|
|
603
623
|
* Starts playing a note
|
|
@@ -621,17 +641,15 @@ var BasicSynthesizer = class {
|
|
|
621
641
|
* Stops playing a note.
|
|
622
642
|
* @param channel Usually 0-15: the channel of the note.
|
|
623
643
|
* @param midiNote {number} 0-127 the key number of the note.
|
|
624
|
-
* @param force Instantly kills the note if true.
|
|
625
644
|
* @param eventOptions Additional options for this command.
|
|
626
645
|
*/
|
|
627
|
-
noteOff(channel, midiNote,
|
|
646
|
+
noteOff(channel, midiNote, eventOptions = DEFAULT_SYNTH_METHOD_OPTIONS) {
|
|
628
647
|
midiNote %= 128;
|
|
629
648
|
const ch = channel % 16;
|
|
630
649
|
const offset = channel - ch;
|
|
631
650
|
this._sendInternal(
|
|
632
651
|
[midiMessageTypes.noteOff | ch, midiNote],
|
|
633
652
|
offset,
|
|
634
|
-
force,
|
|
635
653
|
eventOptions
|
|
636
654
|
);
|
|
637
655
|
}
|
|
@@ -651,10 +669,9 @@ var BasicSynthesizer = class {
|
|
|
651
669
|
* @param channel Usually 0-15: the channel to change the controller.
|
|
652
670
|
* @param controllerNumber 0-127 the MIDI CC number.
|
|
653
671
|
* @param controllerValue 0-127 the controller value.
|
|
654
|
-
* @param force Forces the controller-change message, even if it's locked or gm system is set and the cc is bank select.
|
|
655
672
|
* @param eventOptions Additional options for this command.
|
|
656
673
|
*/
|
|
657
|
-
controllerChange(channel, controllerNumber, controllerValue,
|
|
674
|
+
controllerChange(channel, controllerNumber, controllerValue, eventOptions = DEFAULT_SYNTH_METHOD_OPTIONS) {
|
|
658
675
|
if (controllerNumber > 127 || controllerNumber < 0) {
|
|
659
676
|
throw new Error(`Invalid controller number: ${controllerNumber}`);
|
|
660
677
|
}
|
|
@@ -669,7 +686,6 @@ var BasicSynthesizer = class {
|
|
|
669
686
|
controllerValue
|
|
670
687
|
],
|
|
671
688
|
offset,
|
|
672
|
-
force,
|
|
673
689
|
eventOptions
|
|
674
690
|
);
|
|
675
691
|
}
|
|
@@ -756,44 +772,55 @@ var BasicSynthesizer = class {
|
|
|
756
772
|
* Sets the channel's pitch wheel range, in semitones.
|
|
757
773
|
* @param channel Usually 0-15: the channel to change.
|
|
758
774
|
* @param range The bend range in semitones.
|
|
775
|
+
* @param eventOptions Additional options for this command.
|
|
759
776
|
*/
|
|
760
|
-
pitchWheelRange(channel, range) {
|
|
777
|
+
pitchWheelRange(channel, range, eventOptions = DEFAULT_SYNTH_METHOD_OPTIONS) {
|
|
761
778
|
this.controllerChange(
|
|
762
779
|
channel,
|
|
763
780
|
midiControllers.registeredParameterMSB,
|
|
764
|
-
0
|
|
781
|
+
0,
|
|
782
|
+
eventOptions
|
|
765
783
|
);
|
|
766
784
|
this.controllerChange(
|
|
767
785
|
channel,
|
|
768
786
|
midiControllers.registeredParameterLSB,
|
|
769
|
-
0
|
|
787
|
+
0,
|
|
788
|
+
eventOptions
|
|
770
789
|
);
|
|
771
790
|
this.controllerChange(channel, midiControllers.dataEntryMSB, range);
|
|
772
791
|
this.controllerChange(
|
|
773
792
|
channel,
|
|
774
793
|
midiControllers.registeredParameterMSB,
|
|
775
|
-
127
|
|
794
|
+
127,
|
|
795
|
+
eventOptions
|
|
776
796
|
);
|
|
777
797
|
this.controllerChange(
|
|
778
798
|
channel,
|
|
779
799
|
midiControllers.registeredParameterLSB,
|
|
780
|
-
127
|
|
800
|
+
127,
|
|
801
|
+
eventOptions
|
|
802
|
+
);
|
|
803
|
+
this.controllerChange(
|
|
804
|
+
channel,
|
|
805
|
+
midiControllers.dataEntryMSB,
|
|
806
|
+
0,
|
|
807
|
+
eventOptions
|
|
781
808
|
);
|
|
782
|
-
this.controllerChange(channel, midiControllers.dataEntryMSB, 0);
|
|
783
809
|
}
|
|
784
810
|
/**
|
|
785
811
|
* Changes the program for a given channel
|
|
786
812
|
* @param channel Usually 0-15: the channel to change.
|
|
787
813
|
* @param programNumber 0-127 the MIDI patch number.
|
|
788
|
-
*
|
|
814
|
+
* @param eventOptions Additional options for this command.
|
|
789
815
|
*/
|
|
790
|
-
programChange(channel, programNumber) {
|
|
816
|
+
programChange(channel, programNumber, eventOptions = DEFAULT_SYNTH_METHOD_OPTIONS) {
|
|
791
817
|
const ch = channel % 16;
|
|
792
818
|
const offset = channel - ch;
|
|
793
819
|
programNumber %= 128;
|
|
794
820
|
this.sendMessage(
|
|
795
821
|
[midiMessageTypes.programChange | ch, programNumber],
|
|
796
|
-
offset
|
|
822
|
+
offset,
|
|
823
|
+
eventOptions
|
|
797
824
|
);
|
|
798
825
|
}
|
|
799
826
|
// noinspection JSUnusedGlobalSymbols
|
|
@@ -836,7 +863,6 @@ var BasicSynthesizer = class {
|
|
|
836
863
|
this._sendInternal(
|
|
837
864
|
[midiMessageTypes.systemExclusive, ...Array.from(messageData)],
|
|
838
865
|
channelOffset,
|
|
839
|
-
false,
|
|
840
866
|
eventOptions
|
|
841
867
|
);
|
|
842
868
|
}
|
|
@@ -943,7 +969,7 @@ var BasicSynthesizer = class {
|
|
|
943
969
|
revokeProgressTracker(type) {
|
|
944
970
|
this.renderingProgressTracker.delete(type);
|
|
945
971
|
}
|
|
946
|
-
_sendInternal(message, channelOffset,
|
|
972
|
+
_sendInternal(message, channelOffset, eventOptions) {
|
|
947
973
|
const options = fillWithDefaults(
|
|
948
974
|
eventOptions,
|
|
949
975
|
DEFAULT_SYNTH_METHOD_OPTIONS
|
|
@@ -954,10 +980,8 @@ var BasicSynthesizer = class {
|
|
|
954
980
|
data: {
|
|
955
981
|
messageData: new Uint8Array(message),
|
|
956
982
|
channelOffset,
|
|
957
|
-
force,
|
|
958
983
|
options
|
|
959
984
|
}
|
|
960
|
-
//[new Uint8Array(message), offset, force, opts]
|
|
961
985
|
});
|
|
962
986
|
}
|
|
963
987
|
/**
|
|
@@ -970,7 +994,7 @@ var BasicSynthesizer = class {
|
|
|
970
994
|
break;
|
|
971
995
|
}
|
|
972
996
|
case "sequencerReturn": {
|
|
973
|
-
this.sequencers[m.data.id](m.data);
|
|
997
|
+
this.sequencers[m.data.id]?.(m.data);
|
|
974
998
|
break;
|
|
975
999
|
}
|
|
976
1000
|
case "isFullyInitialized": {
|
|
@@ -1657,8 +1681,10 @@ var BasicSynthesizerCore = class {
|
|
|
1657
1681
|
* @protected
|
|
1658
1682
|
*/
|
|
1659
1683
|
alive = false;
|
|
1684
|
+
enableEventSystem;
|
|
1660
1685
|
constructor(sampleRate, options, postMessage) {
|
|
1661
1686
|
this.synthesizer = new SpessaSynthProcessor2(sampleRate, options);
|
|
1687
|
+
this.enableEventSystem = options.enableEventSystem;
|
|
1662
1688
|
this.post = postMessage;
|
|
1663
1689
|
this.synthesizer.onEventCall = (event) => {
|
|
1664
1690
|
this.post({
|
|
@@ -1673,6 +1699,7 @@ var BasicSynthesizerCore = class {
|
|
|
1673
1699
|
const sequencerID = this.sequencers.length;
|
|
1674
1700
|
this.sequencers.push(sequencer);
|
|
1675
1701
|
sequencer.onEventCall = (e) => {
|
|
1702
|
+
if (!this.enableEventSystem) return;
|
|
1676
1703
|
if (e.type === "songListChange") {
|
|
1677
1704
|
const songs = e.data.newSongList;
|
|
1678
1705
|
const midiDatas = songs.map((s) => {
|
|
@@ -1744,7 +1771,6 @@ var BasicSynthesizerCore = class {
|
|
|
1744
1771
|
this.synthesizer.processMessage(
|
|
1745
1772
|
m.data.messageData,
|
|
1746
1773
|
m.data.channelOffset,
|
|
1747
|
-
m.data.force,
|
|
1748
1774
|
m.data.options
|
|
1749
1775
|
);
|
|
1750
1776
|
break;
|
|
@@ -2270,7 +2296,7 @@ var WorkerSynthesizerCore = class extends BasicSynthesizerCore {
|
|
|
2270
2296
|
this.synthesizer.processSplit(dry, wetL, wetR);
|
|
2271
2297
|
this.workletMessagePort.postMessage(data, [data.buffer]);
|
|
2272
2298
|
const t = this.synthesizer.currentSynthTime;
|
|
2273
|
-
if (t - this.lastSequencerSync > SEQUENCER_SYNC_INTERVAL) {
|
|
2299
|
+
if (this.enableEventSystem && t - this.lastSequencerSync > SEQUENCER_SYNC_INTERVAL) {
|
|
2274
2300
|
for (let id = 0; id < this.sequencers.length; id++) {
|
|
2275
2301
|
this.post({
|
|
2276
2302
|
type: "sequencerReturn",
|