spessasynth_core 4.2.6 → 4.2.8

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
@@ -624,1785 +624,1797 @@ declare class MIDIPatchTools {
624
624
  static sorter(a: MIDIPatch, b: MIDIPatch): number;
625
625
  }
626
626
 
627
- /**
628
- * Represents a cached voice
629
- */
630
- declare class CachedVoice {
627
+ declare class Generator {
631
628
  /**
632
- * Sample data of this voice.
629
+ * The generator's SF2 type.
633
630
  */
634
- readonly sampleData: Float32Array;
631
+ generatorType: GeneratorType;
635
632
  /**
636
- * The unmodulated (copied to) generators of the voice.
633
+ * The generator's 16-bit value.
637
634
  */
638
- readonly generators: Int16Array;
635
+ generatorValue: number;
639
636
  /**
640
- * The voice's modulators.
637
+ * Constructs a new generator
638
+ * @param type generator type
639
+ * @param value generator value
640
+ * @param validate if the limits should be validated and clamped.
641
641
  */
642
- readonly modulators: Modulator[];
642
+ constructor(type: GeneratorType, value: number, validate?: boolean);
643
+ write(genData: IndexedByteArray): void;
644
+ toString(): string;
645
+ }
646
+
647
+ declare class BasicZone {
643
648
  /**
644
- * Exclusive class number for hi-hats etc.
649
+ * The zone's velocity range.
650
+ * min -1 means that it is a default value
645
651
  */
646
- readonly exclusiveClass: number;
652
+ velRange: GenericRange;
647
653
  /**
648
- * Target key of the voice (can be overridden by generators)
654
+ * The zone's key range.
655
+ * min -1 means that it is a default value.
649
656
  */
650
- readonly targetKey: number;
657
+ keyRange: GenericRange;
651
658
  /**
652
- * Target velocity of the voice (can be overridden by generators)
659
+ * The zone's generators.
653
660
  */
654
- readonly velocity: number;
661
+ generators: Generator[];
655
662
  /**
656
- * MIDI root key of the sample
663
+ * The zone's modulators.
657
664
  */
658
- readonly rootKey: number;
665
+ modulators: Modulator[];
666
+ get hasKeyRange(): boolean;
667
+ get hasVelRange(): boolean;
659
668
  /**
660
- * Start position of the loop
669
+ * The current tuning in cents, taking in both coarse and fine generators.
661
670
  */
662
- readonly loopStart: number;
671
+ get fineTuning(): number;
663
672
  /**
664
- * End position of the loop
673
+ * The current tuning in cents, taking in both coarse and fine generators.
665
674
  */
666
- readonly loopEnd: number;
675
+ set fineTuning(tuningCents: number);
667
676
  /**
668
- * Playback step (rate) for sample pitch correction
677
+ * Adds to a given generator, or its default value.
678
+ * @param type the generator type.
679
+ * @param value the value to add.
680
+ * @param validate if the value should be clamped to allowed limits.
669
681
  */
670
- readonly playbackStep: number;
671
- readonly loopingMode: SampleLoopingMode;
672
- constructor(voiceParams: VoiceParameters, midiNote: number, velocity: number, sampleRate: number);
673
- }
674
-
675
- declare const midiMessageTypes: {
676
- readonly noteOff: 128;
677
- readonly noteOn: 144;
678
- readonly polyPressure: 160;
679
- readonly controllerChange: 176;
680
- readonly programChange: 192;
681
- readonly channelPressure: 208;
682
- readonly pitchWheel: 224;
683
- readonly systemExclusive: 240;
684
- readonly timecode: 241;
685
- readonly songPosition: 242;
686
- readonly songSelect: 243;
687
- readonly tuneRequest: 246;
688
- readonly clock: 248;
689
- readonly start: 250;
690
- readonly continue: 251;
691
- readonly stop: 252;
692
- readonly activeSensing: 254;
693
- readonly reset: 255;
694
- readonly sequenceNumber: 0;
695
- readonly text: 1;
696
- readonly copyright: 2;
697
- readonly trackName: 3;
698
- readonly instrumentName: 4;
699
- readonly lyric: 5;
700
- readonly marker: 6;
701
- readonly cuePoint: 7;
702
- readonly programName: 8;
703
- readonly midiChannelPrefix: 32;
704
- readonly midiPort: 33;
705
- readonly endOfTrack: 47;
706
- readonly setTempo: 81;
707
- readonly smpteOffset: 84;
708
- readonly timeSignature: 88;
709
- readonly keySignature: 89;
710
- readonly sequenceSpecific: 127;
711
- };
712
- type MIDIMessageType = (typeof midiMessageTypes)[keyof typeof midiMessageTypes];
713
- declare const midiControllers: {
714
- readonly bankSelect: 0;
715
- readonly modulationWheel: 1;
716
- readonly breathController: 2;
717
- readonly undefinedCC3: 3;
718
- readonly footController: 4;
719
- readonly portamentoTime: 5;
720
- readonly dataEntryMSB: 6;
721
- readonly mainVolume: 7;
722
- readonly balance: 8;
723
- readonly undefinedCC9: 9;
724
- readonly pan: 10;
725
- readonly expressionController: 11;
726
- readonly effectControl1: 12;
727
- readonly effectControl2: 13;
728
- readonly undefinedCC14: 14;
729
- readonly undefinedCC15: 15;
730
- readonly generalPurposeController1: 16;
731
- readonly generalPurposeController2: 17;
732
- readonly generalPurposeController3: 18;
733
- readonly generalPurposeController4: 19;
734
- readonly undefinedCC20: 20;
735
- readonly undefinedCC21: 21;
736
- readonly undefinedCC22: 22;
737
- readonly undefinedCC23: 23;
738
- readonly undefinedCC24: 24;
739
- readonly undefinedCC25: 25;
740
- readonly undefinedCC26: 26;
741
- readonly undefinedCC27: 27;
742
- readonly undefinedCC28: 28;
743
- readonly undefinedCC29: 29;
744
- readonly undefinedCC30: 30;
745
- readonly undefinedCC31: 31;
746
- readonly bankSelectLSB: 32;
747
- readonly modulationWheelLSB: 33;
748
- readonly breathControllerLSB: 34;
749
- readonly undefinedCC3LSB: 35;
750
- readonly footControllerLSB: 36;
751
- readonly portamentoTimeLSB: 37;
752
- readonly dataEntryLSB: 38;
753
- readonly mainVolumeLSB: 39;
754
- readonly balanceLSB: 40;
755
- readonly undefinedCC9LSB: 41;
756
- readonly panLSB: 42;
757
- readonly expressionControllerLSB: 43;
758
- readonly effectControl1LSB: 44;
759
- readonly effectControl2LSB: 45;
760
- readonly undefinedCC14LSB: 46;
761
- readonly undefinedCC15LSB: 47;
762
- readonly undefinedCC16LSB: 48;
763
- readonly undefinedCC17LSB: 49;
764
- readonly undefinedCC18LSB: 50;
765
- readonly undefinedCC19LSB: 51;
766
- readonly undefinedCC20LSB: 52;
767
- readonly undefinedCC21LSB: 53;
768
- readonly undefinedCC22LSB: 54;
769
- readonly undefinedCC23LSB: 55;
770
- readonly undefinedCC24LSB: 56;
771
- readonly undefinedCC25LSB: 57;
772
- readonly undefinedCC26LSB: 58;
773
- readonly undefinedCC27LSB: 59;
774
- readonly undefinedCC28LSB: 60;
775
- readonly undefinedCC29LSB: 61;
776
- readonly undefinedCC30LSB: 62;
777
- readonly undefinedCC31LSB: 63;
778
- readonly sustainPedal: 64;
779
- readonly portamentoOnOff: 65;
780
- readonly sostenutoPedal: 66;
781
- readonly softPedal: 67;
782
- readonly legatoFootswitch: 68;
783
- readonly hold2Pedal: 69;
784
- readonly soundVariation: 70;
785
- readonly filterResonance: 71;
786
- readonly releaseTime: 72;
787
- readonly attackTime: 73;
788
- readonly brightness: 74;
789
- readonly decayTime: 75;
790
- readonly vibratoRate: 76;
791
- readonly vibratoDepth: 77;
792
- readonly vibratoDelay: 78;
793
- readonly soundController10: 79;
794
- readonly generalPurposeController5: 80;
795
- readonly generalPurposeController6: 81;
796
- readonly generalPurposeController7: 82;
797
- readonly generalPurposeController8: 83;
798
- readonly portamentoControl: 84;
799
- readonly undefinedCC85: 85;
800
- readonly undefinedCC86: 86;
801
- readonly undefinedCC87: 87;
802
- readonly undefinedCC88: 88;
803
- readonly undefinedCC89: 89;
804
- readonly undefinedCC90: 90;
805
- readonly reverbDepth: 91;
806
- readonly tremoloDepth: 92;
807
- readonly chorusDepth: 93;
808
- readonly variationDepth: 94;
809
- readonly phaserDepth: 95;
810
- readonly dataIncrement: 96;
811
- readonly dataDecrement: 97;
812
- readonly nonRegisteredParameterLSB: 98;
813
- readonly nonRegisteredParameterMSB: 99;
814
- readonly registeredParameterLSB: 100;
815
- readonly registeredParameterMSB: 101;
816
- readonly undefinedCC102LSB: 102;
817
- readonly undefinedCC103LSB: 103;
818
- readonly undefinedCC104LSB: 104;
819
- readonly undefinedCC105LSB: 105;
820
- readonly undefinedCC106LSB: 106;
821
- readonly undefinedCC107LSB: 107;
822
- readonly undefinedCC108LSB: 108;
823
- readonly undefinedCC109LSB: 109;
824
- readonly undefinedCC110LSB: 110;
825
- readonly undefinedCC111LSB: 111;
826
- readonly undefinedCC112LSB: 112;
827
- readonly undefinedCC113LSB: 113;
828
- readonly undefinedCC114LSB: 114;
829
- readonly undefinedCC115LSB: 115;
830
- readonly undefinedCC116LSB: 116;
831
- readonly undefinedCC117LSB: 117;
832
- readonly undefinedCC118LSB: 118;
833
- readonly undefinedCC119LSB: 119;
834
- readonly allSoundOff: 120;
835
- readonly resetAllControllers: 121;
836
- readonly localControlOnOff: 122;
837
- readonly allNotesOff: 123;
838
- readonly omniModeOff: 124;
839
- readonly omniModeOn: 125;
840
- readonly monoModeOn: 126;
841
- readonly polyModeOn: 127;
842
- };
843
- type MIDIController = (typeof midiControllers)[keyof typeof midiControllers];
844
-
845
- interface EffectProcessor {
682
+ addToGenerator(type: GeneratorType, value: number, validate?: boolean): void;
846
683
  /**
847
- * 0-127
848
- * This parameter sets the amount of the effect sent to the effect output.
684
+ * Sets a generator to a given value if preset, otherwise adds a new one.
685
+ * @param type the generator type.
686
+ * @param value the value to set. Set to null to remove this generator (set as "unset").
687
+ * @param validate if the value should be clamped to allowed limits.
849
688
  */
850
- level: number;
689
+ setGenerator(type: GeneratorType, value: number | null, validate?: boolean): void;
851
690
  /**
852
- * 0-7
853
- * A low-pass filter can be applied to the sound coming into the effect to cut the high
854
- * frequency range. Higher values will cut more of the high frequencies, resulting in a
855
- * more mellow effect sound.
691
+ * Adds generators to the zone.
692
+ * @param generators the generators to add.
856
693
  */
857
- preLowpass: number;
858
- }
859
- interface ReverbProcessorSnapshot extends EffectProcessor {
694
+ addGenerators(...generators: Generator[]): void;
860
695
  /**
861
- * 0-7.
862
- * If character is not available, it should default to the first one.
863
- *
864
- * This parameter selects the type of reverb. 0–5 are reverb effects, and 6 and 7 are delay
865
- * effects.
696
+ * Adds modulators to the zone.
697
+ * @param modulators the modulators to add.
866
698
  */
867
- character: number;
699
+ addModulators(...modulators: Modulator[]): void;
868
700
  /**
869
- * 0-127
870
- * This parameter sets the time over which the reverberation will continue.
871
- * Higher values result in longer reverberation.
701
+ * Gets a generator value.
702
+ * @param generatorType the generator type.
703
+ * @param notFoundValue if the generator is not found, this value is returned. A default value can be passed here, or null for example,
704
+ * to check if the generator is set.
872
705
  */
873
- time: number;
706
+ getGenerator<K>(generatorType: GeneratorType, notFoundValue: number | K): number | K;
707
+ copyFrom(zone: BasicZone): void;
874
708
  /**
875
- * 0-127
876
- * This parameter is used when the Reverb Character is set to 6 or 7, or the Reverb Type
877
- * is set to Delay or Panning Delay (Rev Character 6, 7). It sets the way in which delays
878
- * repeat. Higher values result in more delay repeats.
709
+ * Filters the generators and prepends the range generators.
879
710
  */
880
- delayFeedback: number;
711
+ getWriteGenerators(bank: BasicSoundBank): Generator[];
712
+ }
713
+
714
+ declare class BasicGlobalZone extends BasicZone {
715
+ }
716
+
717
+ declare class BasicInstrumentZone extends BasicZone {
881
718
  /**
882
- * 0 - 127 (ms)
883
- * This parameter sets the delay time until the reverberant sound is heard.
884
- * Higher values result in a longer pre-delay time, simulating a larger reverberant space.
719
+ * The instrument this zone belongs to.
885
720
  */
886
- preDelayTime: number;
887
- }
888
- interface ReverbProcessor extends ReverbProcessorSnapshot {
721
+ readonly parentInstrument: BasicInstrument;
889
722
  /**
890
- * Process the effect and ADDS it to the output.
891
- * @param input The input buffer to process. It always starts at index 0.
892
- * @param outputLeft The left output buffer.
893
- * @param outputRight The right output buffer.
894
- * @param startIndex The index to start mixing at into the output buffers.
895
- * @param sampleCount The amount of samples to mix.
723
+ * For tracking on the individual zone level, since multiple presets can refer to the same instrument.
896
724
  */
897
- process(input: Float32Array, outputLeft: Float32Array, outputRight: Float32Array, startIndex: number, sampleCount: number): void;
725
+ useCount: number;
898
726
  /**
899
- * Gets a synthesizer from this effect processor instance.
727
+ * Creates a new instrument zone.
728
+ * @param instrument The parent instrument.
729
+ * @param sample The sample to use in this zone.
900
730
  */
901
- getSnapshot(): ReverbProcessorSnapshot;
902
- }
903
- interface ChorusProcessorSnapshot extends EffectProcessor {
731
+ constructor(instrument: BasicInstrument, sample: BasicSample);
904
732
  /**
905
- * 0-127
906
- * This parameter sets the level at which the chorus sound is re-input (fed back) into the
907
- * chorus. By using feedback, a denser chorus sound can be created.
908
- * Higher values result in a greater feedback level.
733
+ * Zone's sample.
909
734
  */
910
- feedback: number;
735
+ private _sample;
911
736
  /**
912
- * 0-127
913
- * This parameter sets the delay time of the chorus effect.
737
+ * Zone's sample.
914
738
  */
915
- delay: number;
739
+ get sample(): BasicSample;
916
740
  /**
917
- * 0-127
918
- * This parameter sets the speed (frequency) at which the chorus sound is modulated.
919
- * Higher values result in faster modulation.
741
+ * Sets a sample for this zone.
742
+ * @param sample the sample to set.
920
743
  */
921
- rate: number;
744
+ set sample(sample: BasicSample);
745
+ getWriteGenerators(bank: BasicSoundBank): Generator[];
746
+ }
747
+
748
+ declare class BasicPresetZone extends BasicZone {
922
749
  /**
923
- * 0-127
924
- * This parameter sets the depth at which the chorus sound is modulated.
925
- * Higher values result in deeper modulation.
750
+ * The preset this zone belongs to.
926
751
  */
927
- depth: number;
752
+ readonly parentPreset: BasicPreset;
928
753
  /**
929
- * 0-127
930
- * This parameter sets the amount of chorus sound that will be sent to the reverb.
931
- * Higher values result in more sound being sent.
754
+ * Creates a new preset zone.
755
+ * @param preset the preset this zone belongs to.
756
+ * @param instrument the instrument to use in this zone.
932
757
  */
933
- sendLevelToReverb: number;
758
+ constructor(preset: BasicPreset, instrument: BasicInstrument);
934
759
  /**
935
- * 0-127
936
- * This parameter sets the amount of chorus sound that will be sent to the delay.
937
- * Higher values result in more sound being sent.
760
+ * Zone's instrument.
938
761
  */
939
- sendLevelToDelay: number;
940
- }
941
- interface ChorusProcessor extends ChorusProcessorSnapshot {
762
+ private _instrument;
942
763
  /**
943
- * Process the effect and ADDS it to the output.
944
- * @param input The input buffer to process. It always starts at index 0.
945
- * @param outputLeft The left output buffer.
946
- * @param outputRight The right output buffer.
947
- * @param outputReverb The mono input for reverb. It always starts at index 0.
948
- * @param outputDelay The mono input for delay. It always starts at index 0.
949
- * @param startIndex The index to start mixing at into the output buffers.
950
- * @param sampleCount The amount of samples to mix.
764
+ * Zone's instrument.
951
765
  */
952
- process(input: Float32Array, outputLeft: Float32Array, outputRight: Float32Array, outputReverb: Float32Array, outputDelay: Float32Array, startIndex: number, sampleCount: number): void;
766
+ get instrument(): BasicInstrument;
953
767
  /**
954
- * Gets a synthesizer from this effect processor instance.
768
+ * Zone's instrument.
955
769
  */
956
- getSnapshot(): ChorusProcessorSnapshot;
770
+ set instrument(instrument: BasicInstrument);
771
+ getWriteGenerators(bank: BasicSoundBank): Generator[];
957
772
  }
958
- interface DelayProcessorSnapshot extends EffectProcessor {
773
+
774
+ /**
775
+ * Returned structure containing extended SF2 chunks.
776
+ */
777
+ interface ExtendedSF2Chunks {
959
778
  /**
960
- * 0-115
961
- * 0.1ms-340ms-1000ms
962
- * The delay effect has three delay times; center, left and
963
- * right (when listening in stereo). Delay Time Center sets the delay time of the delay
964
- * located at the center.
965
- * Refer to SC-8850 Owner's Manual p. 236 for the exact mapping of the values.
779
+ * The PDTA part of the chunk.
966
780
  */
967
- timeCenter: number;
781
+ pdta: IndexedByteArray;
968
782
  /**
969
- * 0-120
970
- * 4% - 500%
971
- * This parameter sets the delay time of the delay located at the left as a percentage of
972
- * the Delay Time Center (up to a max. of 1.0 s).
973
- * The resolution is 100/24(%).
783
+ * The XDTA (https://github.com/spessasus/soundfont-proposals/blob/main/extended_limits.md) part of the chunk.
784
+ */
785
+ xdta: IndexedByteArray;
786
+ }
787
+ /**
788
+ * Write indexes for tracking writing a SoundFont file.
789
+ */
790
+ interface SoundFontWriteIndexes {
791
+ /**
792
+ * Generator start index.
793
+ */
794
+ gen: number;
795
+ /**
796
+ * Modulator start index.
974
797
  */
975
- timeRatioLeft: number;
798
+ mod: number;
976
799
  /**
977
- * 1-120
978
- * 4%-500%
979
- * This parameter sets the delay time of the delay located at the right as a percentage of
980
- * the Delay Time Center (up to a max. of 1.0 s).
981
- * The resolution is 100/24(%).
800
+ * Zone start index.
982
801
  */
983
- timeRatioRight: number;
802
+ bag: number;
984
803
  /**
985
- * 0-127
986
- * This parameter sets the volume of the central delay. Higher values result in a louder
987
- * center delay.
804
+ * Preset/instrument start index.
988
805
  */
989
- levelCenter: number;
806
+ hdr: number;
807
+ }
808
+
809
+ declare class BasicPreset implements MIDIPatchNamed {
990
810
  /**
991
- * 0-127
992
- * This parameter sets the volume of the left delay. Higher values result in a louder left
993
- * delay.
811
+ * The parent soundbank instance
812
+ * Currently used for determining default modulators and XG status
994
813
  */
995
- levelLeft: number;
814
+ readonly parentSoundBank: BasicSoundBank;
996
815
  /**
997
- * 0-127
998
- * This parameter sets the volume of the right delay. Higher values result in a louder
999
- * right delay.
816
+ * The preset's name
1000
817
  */
1001
- levelRight: number;
818
+ name: string;
819
+ program: number;
820
+ bankMSB: number;
821
+ bankLSB: number;
822
+ isGMGSDrum: boolean;
1002
823
  /**
1003
- * 0-127
1004
- * (-64)-63
1005
- * This parameter affects the number of times the delay will repeat. With a value of 0,
1006
- * the delay will not repeat. With higher values there will be more repeats.
1007
- * With negative (-) values, the center delay will be fed back with inverted phase.
1008
- * Negative values are effective with short delay times.
824
+ * The preset's zones
1009
825
  */
1010
- feedback: number;
826
+ zones: BasicPresetZone[];
1011
827
  /**
1012
- * 0-127
1013
- * This parameter sets the amount of delay sound that is sent to the reverb.
1014
- * Higher values result in more sound being sent.
828
+ * Preset's global zone
1015
829
  */
1016
- sendLevelToReverb: number;
1017
- }
1018
- interface DelayProcessor extends DelayProcessorSnapshot {
830
+ readonly globalZone: BasicGlobalZone;
1019
831
  /**
1020
- * Process the effect and ADDS it to the output.
1021
- * @param input The input buffer to process. It always starts at index 0.
1022
- * @param outputLeft The left output buffer.
1023
- * @param outputRight The right output buffer.
1024
- * @param outputReverb The mono input for reverb. It always starts at index 0.
1025
- * @param startIndex The index to start mixing at into the output buffers.
1026
- * @param sampleCount The amount of samples to mix.
832
+ * Unused metadata
1027
833
  */
1028
- process(input: Float32Array, outputLeft: Float32Array, outputRight: Float32Array, outputReverb: Float32Array, startIndex: number, sampleCount: number): void;
834
+ library: number;
1029
835
  /**
1030
- * Gets a synthesizer from this effect processor instance.
836
+ * Unused metadata
1031
837
  */
1032
- getSnapshot(): DelayProcessorSnapshot;
1033
- }
1034
- interface InsertionProcessor {
838
+ genre: number;
1035
839
  /**
1036
- * The EFX type of this processor, stored as MSB << | LSB.
1037
- * For example 0x30, 0x10 is 0x3010
840
+ * Unused metadata
1038
841
  */
1039
- readonly type: number;
842
+ morphology: number;
1040
843
  /**
1041
- * 0-1 (floating point)
1042
- * This parameter sets the amount of insertion sound that will be sent to the reverb.
1043
- * Higher values result in more sound being sent.
844
+ * Creates a new preset representation.
845
+ * @param parentSoundBank the sound bank this preset belongs to.
846
+ * @param globalZone optional, a global zone to use.
1044
847
  */
1045
- sendLevelToReverb: number;
848
+ constructor(parentSoundBank: BasicSoundBank, globalZone?: BasicGlobalZone);
849
+ get isXGDrums(): boolean;
1046
850
  /**
1047
- * 0-1 (floating point)
1048
- * This parameter sets the amount of insertion sound that will be sent to the chorus.
1049
- * Higher values result in more sound being sent.
851
+ * Checks if this preset is a drum preset
1050
852
  */
1051
- sendLevelToChorus: number;
853
+ get isAnyDrums(): boolean;
854
+ private static isInRange;
855
+ private static addUniqueModulators;
856
+ private static subtractRanges;
1052
857
  /**
1053
- * 0-1 (floating point)
1054
- * This parameter sets the amount of insertion sound that will be sent to the delay.
1055
- * Higher values result in more sound being sent.
858
+ * Unlinks everything from this preset.
1056
859
  */
1057
- sendLevelToDelay: number;
860
+ delete(): void;
1058
861
  /**
1059
- * Resets the params to their default values.
1060
- * This does not need to reset send levels.
862
+ * Deletes an instrument zone from this preset.
863
+ * @param index the zone's index to delete.
1061
864
  */
1062
- reset(): void;
865
+ deleteZone(index: number): void;
1063
866
  /**
1064
- * Sets an EFX parameter.
1065
- * @param parameter The parameter number (0x03-0x16).
1066
- * @param value The new value (0-127).
867
+ * Creates a new preset zone and returns it.
868
+ * @param instrument the instrument to use in the zone.
1067
869
  */
1068
- setParameter(parameter: number, value: number): void;
870
+ createZone(instrument: BasicInstrument): BasicPresetZone;
1069
871
  /**
1070
- * Process the effect and ADDS it to the output.
1071
- * @param inputLeft The left input buffer to process. It always starts at index 0.
1072
- * @param inputRight The right input buffer to process. It always starts at index 0.
1073
- * @param outputLeft The left output buffer.
1074
- * @param outputRight The right output buffer.
1075
- * @param outputReverb The mono input for reverb. It always starts at index 0.
1076
- * @param outputChorus The mono input for chorus. It always starts at index 0.
1077
- * @param outputDelay The mono input for delay. It always starts at index 0.
1078
- * @param startIndex The index to start mixing at into the output buffers.
1079
- * @param sampleCount The amount of samples to mix.
872
+ * Preloads (loads and caches synthesis data) for a given key range.
1080
873
  */
1081
- process(inputLeft: Float32Array, inputRight: Float32Array, outputLeft: Float32Array, outputRight: Float32Array, outputReverb: Float32Array, outputChorus: Float32Array, outputDelay: Float32Array, startIndex: number, sampleCount: number): void;
1082
- }
1083
- interface InsertionProcessorSnapshot {
1084
- type: number;
874
+ preload(keyMin: number, keyMax: number): void;
1085
875
  /**
1086
- * 20 parameters for the effect, 255 means "no change" + 3 effect sends (index 20, 21, 22)
876
+ * Checks if the bank and program numbers are the same for the given preset as this one.
877
+ * @param preset The preset to check.
1087
878
  */
1088
- params: Uint8Array;
879
+ matches(preset: MIDIPatch): boolean;
1089
880
  /**
1090
- * A boolean list for channels that have the insertion effect enabled.
881
+ * Returns the voice synthesis data for this preset.
882
+ * @param midiNote the MIDI note number.
883
+ * @param velocity the MIDI velocity.
884
+ * @returns the returned sound data.
1091
885
  */
1092
- channels: boolean[];
1093
- }
1094
- type InsertionProcessorConstructor = new (sampleRate: number, maxBufferSize: number) => InsertionProcessor;
1095
-
1096
- type SynthSystem = "gm" | "gm2" | "gs" | "xg";
1097
- interface NoteOnCallback {
1098
- /** The MIDI note number. */
1099
- midiNote: number;
1100
- /** The MIDI channel number. */
1101
- channel: number;
1102
- /** The velocity of the note. */
1103
- velocity: number;
1104
- }
1105
- interface NoteOffCallback {
1106
- /** The MIDI note number. */
1107
- midiNote: number;
1108
- /** The MIDI channel number. */
1109
- channel: number;
1110
- }
1111
- interface DrumChangeCallback {
1112
- /** The MIDI channel number. */
1113
- channel: number;
1114
- /** Indicates if the channel is a drum channel. */
1115
- isDrumChannel: boolean;
1116
- }
1117
- interface ProgramChangeCallback extends MIDIPatch {
1118
- /** The MIDI channel number. */
1119
- channel: number;
1120
- }
1121
- interface ControllerChangeCallback {
1122
- /** The MIDI channel number. */
1123
- channel: number;
1124
- /** The controller number. */
1125
- controllerNumber: MIDIController;
1126
- /** The value of the controller. */
1127
- controllerValue: number;
1128
- }
1129
- interface MuteChannelCallback {
1130
- /** The MIDI channel number. */
1131
- channel: number;
1132
- /** Indicates if the channel is muted. */
1133
- isMuted: boolean;
1134
- }
1135
- interface PresetListEntry extends MIDIPatchNamed {
886
+ getVoiceParameters(midiNote: number, velocity: number): VoiceParameters[];
1136
887
  /**
1137
- * Indicates if this preset is any kind of drum preset.
888
+ * BankMSB:bankLSB:program:isGMGSDrum
1138
889
  */
1139
- isAnyDrums: boolean;
1140
- }
1141
- /**
1142
- * A list of preset changes, each with a name, bank, and program number.
1143
- */
1144
- type PresetList = PresetListEntry[];
1145
- /**
1146
- * The synthesizer display system exclusive data, EXCLUDING THE F0 BYTE!
1147
- */
1148
- type SynthDisplayCallback = number[];
1149
- interface PitchWheelCallback {
1150
- /** The MIDI channel number. */
1151
- channel: number;
890
+ toMIDIString(): string;
891
+ toString(): string;
1152
892
  /**
1153
- * The unsigned 14-bit value of the pitch: 0 - 16383.
893
+ * Combines preset into an instrument, flattening the preset zones into instrument zones.
894
+ * This is a really complex function that attempts to work around the DLS limitations of only having the instrument layer.
895
+ * @returns The instrument containing the flattened zones. In theory, it should exactly the same as this preset.
1154
896
  */
1155
- pitch: number;
897
+ toFlattenedInstrument(): BasicInstrument;
1156
898
  /**
1157
- * If the pitch wheel was note-specific, this is the MIDI note number that was altered. Set to -1 otherwise.
899
+ * Writes the SF2 header
900
+ * @param phdrData
901
+ * @param index
1158
902
  */
1159
- midiNote: number;
1160
- }
1161
- interface ChannelPressureCallback {
1162
- /** The MIDI channel number. */
1163
- channel: number;
1164
- /** The pressure value. */
1165
- pressure: number;
1166
- }
1167
- interface PolyPressureCallback {
1168
- /** The MIDI channel number. */
1169
- channel: number;
1170
- /** The MIDI note number. */
1171
- midiNote: number;
1172
- /** The pressure value. */
1173
- pressure: number;
903
+ write(phdrData: ExtendedSF2Chunks, index: number): void;
1174
904
  }
905
+
1175
906
  /**
1176
- * The error message for sound bank errors.
907
+ * Represents a single instrument
1177
908
  */
1178
- type SoundBankErrorCallback = Error;
1179
- interface StopAllCallback {
1180
- /**
1181
- * The MIDI channel number.
1182
- */
1183
- channel: number;
909
+ declare class BasicInstrument {
1184
910
  /**
1185
- * If the channel was force stopped. (no release time)
911
+ * The instrument's name
1186
912
  */
1187
- force: boolean;
1188
- }
1189
- type MasterParameterChangeCallback = {
1190
- [P in keyof MasterParameterType]: {
1191
- /**
1192
- * The parameter that was changed.
1193
- */
1194
- parameter: P;
1195
- /**
1196
- * The new value of this parameter.
1197
- */
1198
- value: MasterParameterType[P];
1199
- };
1200
- }[keyof MasterParameterType];
1201
- interface ChannelPropertyChangeCallback {
913
+ name: string;
1202
914
  /**
1203
- * The channel number of the new property.
915
+ * The instrument's zones
1204
916
  */
1205
- channel: number;
917
+ zones: BasicInstrumentZone[];
1206
918
  /**
1207
- * The updated property.
919
+ * Instrument's global zone
1208
920
  */
1209
- property: ChannelProperty;
1210
- }
1211
- type FXType<K> = Exclude<keyof K, "process" | "getSnapshot"> | "macro";
1212
- type EffectChangeCallback = {
921
+ readonly globalZone: BasicGlobalZone;
1213
922
  /**
1214
- * The effect that was changed, "reverb", "chorus", "delay" or "insertion"
923
+ * Instrument's linked presets (the presets that use it)
924
+ * note that duplicates are allowed since one preset can use the same instrument multiple times.
1215
925
  */
1216
- effect: "reverb";
926
+ readonly linkedTo: BasicPreset[];
1217
927
  /**
1218
- * The parameter type or "macro".
928
+ * How many presets is this instrument used by
1219
929
  */
1220
- parameter: FXType<ReverbProcessor>;
930
+ get useCount(): number;
1221
931
  /**
1222
- * The new 7-bit value.
932
+ * Creates a new instrument zone and returns it.
933
+ * @param sample The sample to use in the zone.
1223
934
  */
1224
- value: number;
1225
- } | {
935
+ createZone(sample: BasicSample): BasicInstrumentZone;
1226
936
  /**
1227
- * The effect that was changed, "reverb", "chorus", "delay" or "insertion"
937
+ * Links the instrument ta a given preset
938
+ * @param preset the preset to link to
1228
939
  */
1229
- effect: "chorus";
940
+ linkTo(preset: BasicPreset): void;
1230
941
  /**
1231
- * The parameter type or "macro".
942
+ * Unlinks the instrument from a given preset
943
+ * @param preset the preset to unlink from
1232
944
  */
1233
- parameter: FXType<ChorusProcessor>;
945
+ unlinkFrom(preset: BasicPreset): void;
946
+ deleteUnusedZones(): void;
947
+ delete(): void;
1234
948
  /**
1235
- * The new 7-bit value.
949
+ * Deletes a given instrument zone if it has no uses
950
+ * @param index the index of the zone to delete
951
+ * @param force ignores the use count and deletes forcibly
952
+ * @returns if the zone has been deleted
1236
953
  */
1237
- value: number;
1238
- } | {
954
+ deleteZone(index: number, force?: boolean): boolean;
1239
955
  /**
1240
- * The effect that was changed, "reverb", "chorus", "delay" or "insertion"
956
+ * Globalizes the instrument *in-place.*
957
+ * This means trying to move as many generators and modulators
958
+ * to the global zone as possible to reduce clutter and the count of parameters.
1241
959
  */
1242
- effect: "delay";
960
+ globalize(): void;
961
+ write(instData: ExtendedSF2Chunks, index: number): void;
962
+ }
963
+
964
+ declare class BasicSample {
1243
965
  /**
1244
- * The parameter type or "macro".
966
+ * The sample's name.
1245
967
  */
1246
- parameter: FXType<DelayProcessor>;
968
+ name: string;
1247
969
  /**
1248
- * The new 7-bit value.
970
+ * Sample rate in Hz.
1249
971
  */
1250
- value: number;
1251
- } | {
972
+ sampleRate: number;
1252
973
  /**
1253
- * The effect that was changed, "reverb", "chorus", "delay" or "insertion"
974
+ * Original pitch of the sample as a MIDI note number.
1254
975
  */
1255
- effect: "insertion";
976
+ originalKey: number;
1256
977
  /**
1257
- * The parameter that was changed. This maps to GS address map at addr2 = 0x03.
1258
- * See SC-8850 Manual p.237,
1259
- * for example:
1260
- * - 0x0 - EFX type, the value is 16 bit in this special case. Note that this resets the parameters!
1261
- * - 0x3 - EFX param 1
1262
- * - 0x16 - EFX param 20 (usually level)
1263
- * - 0x17 - EFX send to reverb
1264
- *
1265
- * There are two exceptions:
1266
- * - -1 - the channel has ENABLED the effect.
1267
- * - -2 - the channel has DISABLED the effect.
1268
- * For both of these cases, `value` is the channel number.
978
+ * Pitch correction, in cents. Can be negative.
1269
979
  */
1270
- parameter: number;
980
+ pitchCorrection: number;
1271
981
  /**
1272
- * The new value for the parameter.
982
+ * Linked sample, unused if mono.
1273
983
  */
1274
- value: number;
1275
- };
1276
- interface SynthProcessorEventData {
984
+ linkedSample?: BasicSample;
1277
985
  /**
1278
- * This event fires when a note is played.
986
+ * The type of the sample.
1279
987
  */
1280
- noteOn: NoteOnCallback;
988
+ sampleType: SampleType;
1281
989
  /**
1282
- * This event fires when a note is released.
990
+ * Relative to the start of the sample in sample points.
1283
991
  */
1284
- noteOff: NoteOffCallback;
992
+ loopStart: number;
1285
993
  /**
1286
- * This event fires when a pitch wheel is changed.
994
+ * Relative to the start of the sample in sample points.
1287
995
  */
1288
- pitchWheel: PitchWheelCallback;
996
+ loopEnd: number;
1289
997
  /**
1290
- * This event fires when a controller is changed.
998
+ * Sample's linked instruments (the instruments that use it)
999
+ * note that duplicates are allowed since one instrument can use the same sample multiple times.
1291
1000
  */
1292
- controllerChange: ControllerChangeCallback;
1001
+ linkedTo: BasicInstrument[];
1293
1002
  /**
1294
- * This event fires when a program is changed.
1003
+ * Indicates if the data was overridden, so it cannot be copied back unchanged.
1295
1004
  */
1296
- programChange: ProgramChangeCallback;
1005
+ protected dataOverridden: boolean;
1297
1006
  /**
1298
- * This event fires when a channel pressure is changed.
1007
+ * The compressed sample data if the sample has been compressed.
1299
1008
  */
1300
- channelPressure: ChannelPressureCallback;
1009
+ protected compressedData?: Uint8Array;
1301
1010
  /**
1302
- * This event fires when a polyphonic pressure is changed.
1011
+ * The sample's audio data.
1303
1012
  */
1304
- polyPressure: PolyPressureCallback;
1013
+ protected audioData?: Float32Array;
1305
1014
  /**
1306
- * This event fires when a drum channel is changed.
1015
+ * The basic representation of a sample
1016
+ * @param sampleName The sample's name
1017
+ * @param sampleRate The sample's rate in Hz
1018
+ * @param originalKey The sample's pitch as a MIDI note number
1019
+ * @param pitchCorrection The sample's pitch correction in cents
1020
+ * @param sampleType The sample's type, an enum that can indicate SF3
1021
+ * @param loopStart The sample's loop start relative to the sample start in sample points
1022
+ * @param loopEnd The sample's loop end relative to the sample start in sample points
1307
1023
  */
1308
- drumChange: DrumChangeCallback;
1024
+ constructor(sampleName: string, sampleRate: number, originalKey: number, pitchCorrection: number, sampleType: SampleType, loopStart: number, loopEnd: number);
1309
1025
  /**
1310
- * This event fires when all notes on a channel are stopped.
1026
+ * Indicates if the sample is compressed using vorbis SF3.
1311
1027
  */
1312
- stopAll: StopAllCallback;
1028
+ get isCompressed(): boolean;
1313
1029
  /**
1314
- * This event fires when a new channel is created. There is no data for this event.
1030
+ * If the sample is linked to another sample.
1315
1031
  */
1316
- newChannel: void;
1032
+ get isLinked(): boolean;
1317
1033
  /**
1318
- * This event fires when a channel is muted or unmuted.
1034
+ * The sample's use count
1319
1035
  */
1320
- muteChannel: MuteChannelCallback;
1036
+ get useCount(): number;
1321
1037
  /**
1322
- * This event fires when the preset list is changed.
1038
+ * Get raw data for writing the file, either a compressed bit stream or signed 16-bit little endian PCM data.
1039
+ * @param allowVorbis if vorbis file data is allowed.
1040
+ * @return either s16le or vorbis data.
1323
1041
  */
1324
- presetListChange: PresetList;
1042
+ getRawData(allowVorbis: boolean): Uint8Array;
1325
1043
  /**
1326
- * This event fires when all controllers on all channels are reset. There is no data for this event.
1044
+ * Resamples the audio data to a given sample rate.
1327
1045
  */
1328
- allControllerReset: void;
1046
+ resampleData(newSampleRate: number): void;
1329
1047
  /**
1330
- * This event fires when a sound bank parsing error occurs.
1048
+ * Compresses the audio data
1049
+ * @param encodeVorbis the compression function to use when compressing
1331
1050
  */
1332
- soundBankError: SoundBankErrorCallback;
1051
+ compressSample(encodeVorbis: SampleEncodingFunction): Promise<void>;
1333
1052
  /**
1334
- * This event fires when the synthesizer receives a display message.
1053
+ * Sets the sample type and unlinks if needed.
1054
+ * @param type The type to set it to.
1335
1055
  */
1336
- synthDisplay: SynthDisplayCallback;
1056
+ setSampleType(type: SampleType): void;
1337
1057
  /**
1338
- * This event fires when a master parameter changes.
1058
+ * Unlinks the sample from its stereo link if it has any.
1339
1059
  */
1340
- masterParameterChange: MasterParameterChangeCallback;
1060
+ unlinkSample(): void;
1341
1061
  /**
1342
- * This event fires when a channel property changes.
1062
+ * Links a stereo sample.
1063
+ * @param sample the sample to link to.
1064
+ * @param type either left, right or linked.
1343
1065
  */
1344
- channelPropertyChange: ChannelPropertyChangeCallback;
1066
+ setLinkedSample(sample: BasicSample, type: SampleType): void;
1345
1067
  /**
1346
- * This event fires when an effect processor is modified.
1068
+ * Links the sample to a given instrument
1069
+ * @param instrument the instrument to link to
1347
1070
  */
1348
- effectChange: EffectChangeCallback;
1349
- }
1350
- type SynthProcessorEvent = {
1351
- [K in keyof SynthProcessorEventData]: {
1352
- type: K;
1353
- data: SynthProcessorEventData[K];
1354
- };
1355
- }[keyof SynthProcessorEventData];
1356
- interface SynthMethodOptions {
1071
+ linkTo(instrument: BasicInstrument): void;
1357
1072
  /**
1358
- * The audio context time when the event should execute, in seconds.
1073
+ * Unlinks the sample from a given instrument
1074
+ * @param instrument the instrument to unlink from
1359
1075
  */
1360
- time: number;
1361
- }
1362
- /**
1363
- * Looping mode of the sample.
1364
- * 0 - no loop.
1365
- * 1 - loop.
1366
- * 2 - UNOFFICIAL: polyphone 2.4 added start on release.
1367
- * 3 - loop then play when released.
1368
- */
1369
- type SampleLoopingMode = 0 | 1 | 2 | 3;
1370
- /**
1371
- * A list of voices for a given key:velocity.
1372
- */
1373
- type CachedVoiceList = CachedVoice[];
1374
- interface ChannelProperty {
1076
+ unlinkFrom(instrument: BasicInstrument): void;
1375
1077
  /**
1376
- * The channel's current voice amount.
1078
+ * Get the float32 audio data.
1079
+ * Note that this either decodes the compressed data or passes the ready sampleData.
1080
+ * If neither are set then it will throw an error!
1081
+ * @returns the audio data
1377
1082
  */
1378
- voicesAmount: number;
1083
+ getAudioData(): Float32Array;
1379
1084
  /**
1380
- * The channel's current pitch wheel 0 - 16384.
1085
+ * Replaces the audio data *in-place*.
1086
+ * @param audioData The new audio data as Float32.
1087
+ * @param sampleRate The new sample rate, in Hertz.
1381
1088
  */
1382
- pitchWheel: number;
1089
+ setAudioData(audioData: Float32Array, sampleRate: number): void;
1383
1090
  /**
1384
- * The pitch wheel's range, in semitones.
1091
+ * Replaces the audio with a compressed data sample and flags the sample as compressed
1092
+ * @param data the new compressed data
1385
1093
  */
1386
- pitchWheelRange: number;
1094
+ setCompressedData(data: Uint8Array): void;
1387
1095
  /**
1388
- * Indicates whether the channel is muted.
1096
+ * Encodes s16le sample
1097
+ * @return the encoded data
1389
1098
  */
1390
- isMuted: boolean;
1099
+ protected encodeS16LE(): IndexedByteArray;
1391
1100
  /**
1392
- * Indicates whether the channel is a drum channel.
1101
+ * Decode binary vorbis into a float32 pcm
1393
1102
  */
1394
- isDrum: boolean;
1103
+ protected decodeVorbis(): Float32Array;
1104
+ }
1105
+ declare class EmptySample extends BasicSample {
1395
1106
  /**
1396
- * Indicates whether the channel uses an insertion effect.
1397
- * This means that there will be no separate dry output for processSplit().
1107
+ * A simplified class for creating samples.
1398
1108
  */
1399
- isEFX: boolean;
1109
+ constructor();
1110
+ }
1111
+
1112
+ declare class SoundBankLoader {
1400
1113
  /**
1401
- * The channel's transposition, in semitones.
1114
+ * Loads a sound bank from a file buffer.
1115
+ * @param buffer The binary file buffer to load.
1116
+ * @returns The loaded sound bank, a BasicSoundBank instance.
1402
1117
  */
1403
- transposition: number;
1118
+ static fromArrayBuffer(buffer: ArrayBuffer): BasicSoundBank;
1119
+ private static loadDLS;
1404
1120
  }
1405
- interface SynthProcessorOptions {
1121
+
1122
+ declare class VoiceModulator extends Modulator {
1406
1123
  /**
1407
- * The maximum buffer size the synthesizer can render at once.
1408
- * Attempting to `.process()` more samples than this will result in an error.
1409
- * Defaults to 128.
1124
+ * Indicates if the given modulator is chorus or reverb effects modulator.
1125
+ * This is done to simulate BASSMIDI effects behavior:
1126
+ * - defaults to 1000 transform amount rather than 200
1127
+ * - values can be changed, but anything above 200 is 1000
1128
+ * (except for values above 1000, they are copied directly)
1129
+ * - all values below are multiplied by 5 (200 * 5 = 1000)
1130
+ * - still can be disabled if the soundfont has its own modulator curve
1131
+ * - this fixes the very low amount of reverb by default and doesn't break soundfonts
1410
1132
  */
1411
- maxBufferSize: number;
1133
+ readonly isEffectModulator: boolean;
1412
1134
  /**
1413
- * Indicates if the event system is enabled. This can be changed later.
1135
+ * The default resonant modulator does not affect the filter gain.
1136
+ * Neither XG nor GS responded to cc #74 in that way.
1414
1137
  */
1415
- enableEventSystem: boolean;
1138
+ readonly isDefaultResonantModulator: boolean;
1416
1139
  /**
1417
- * The initial time of the synth, in seconds.
1140
+ * If this is a modulation wheel modulator (for modulation depth range).
1418
1141
  */
1419
- initialTime: number;
1142
+ readonly isModWheelModulator: boolean;
1143
+ private constructor();
1144
+ static fromData(s1: ModulatorSource, s2: ModulatorSource, destination: GeneratorType, amount: number, transformType: ModulatorTransformType): VoiceModulator;
1145
+ static fromModulator(mod: Modulator): VoiceModulator;
1146
+ }
1147
+
1148
+ /**
1149
+ * Represents a cached voice
1150
+ */
1151
+ declare class CachedVoice {
1420
1152
  /**
1421
- * Indicates if the effects are enabled. This can be changed later.
1153
+ * Sample data of this voice.
1422
1154
  */
1423
- enableEffects: boolean;
1155
+ readonly sampleData: Float32Array;
1424
1156
  /**
1425
- * Reverb processor for the synthesizer. Leave undefined to use the default.
1157
+ * The unmodulated (copied to) generators of the voice.
1426
1158
  */
1427
- reverbProcessor?: ReverbProcessor;
1159
+ readonly generators: Int16Array;
1428
1160
  /**
1429
- * Chorus processor for the synthesizer. Leave undefined to use the default.
1161
+ * The voice's modulators.
1430
1162
  */
1431
- chorusProcessor?: ChorusProcessor;
1163
+ readonly modulators: VoiceModulator[];
1432
1164
  /**
1433
- * Delay processor for the synthesizer. Leave undefined to use the default.
1165
+ * Exclusive class number for hi-hats etc.
1434
1166
  */
1435
- delayProcessor?: DelayProcessor;
1436
- }
1437
- /**
1438
- * The master parameters of the synthesizer.
1439
- */
1440
- interface MasterParameterType {
1167
+ readonly exclusiveClass: number;
1441
1168
  /**
1442
- * The master gain, from 0 to any number. 1 is 100% volume.
1169
+ * Target key of the voice (can be overridden by generators)
1443
1170
  */
1444
- masterGain: number;
1171
+ readonly targetKey: number;
1445
1172
  /**
1446
- * The master pan, from -1 (left) to 1 (right). 0 is center.
1173
+ * Target velocity of the voice (can be overridden by generators)
1447
1174
  */
1448
- masterPan: number;
1175
+ readonly velocity: number;
1449
1176
  /**
1450
- * The maximum number of voices that can be played at once.
1451
- *
1452
- * @remarks
1453
- * Increasing this value causes memory allocation for more voices.
1454
- * It is recommended to set it at the beginning, before rendering audio to avoid GC.
1455
- * Decreasing it does not cause memory usage change, so it's fine to use.
1177
+ * MIDI root key of the sample
1456
1178
  */
1457
- voiceCap: number;
1179
+ readonly rootKey: number;
1458
1180
  /**
1459
- * Enabling this parameter will cause a new voice allocation when the voice cap is hit, rather than stealing existing voices.
1460
- *
1461
- * @remarks
1462
- * This is not recommended in real-time environments.
1181
+ * Start position of the loop
1463
1182
  */
1464
- autoAllocateVoices: boolean;
1183
+ readonly loopStart: number;
1465
1184
  /**
1466
- * The interpolation type used for sample playback.
1185
+ * End position of the loop
1467
1186
  */
1468
- interpolationType: InterpolationType;
1187
+ readonly loopEnd: number;
1469
1188
  /**
1470
- * The MIDI system used by the synthesizer for bank selects and system exclusives. (GM, GM2, GS, XG)
1189
+ * Playback step (rate) for sample pitch correction
1471
1190
  */
1472
- midiSystem: SynthSystem;
1191
+ readonly playbackStep: number;
1192
+ readonly loopingMode: SampleLoopingMode;
1193
+ constructor(voiceParams: VoiceParameters, midiNote: number, velocity: number, sampleRate: number);
1194
+ }
1195
+
1196
+ declare const midiMessageTypes: {
1197
+ readonly noteOff: 128;
1198
+ readonly noteOn: 144;
1199
+ readonly polyPressure: 160;
1200
+ readonly controllerChange: 176;
1201
+ readonly programChange: 192;
1202
+ readonly channelPressure: 208;
1203
+ readonly pitchWheel: 224;
1204
+ readonly systemExclusive: 240;
1205
+ readonly timecode: 241;
1206
+ readonly songPosition: 242;
1207
+ readonly songSelect: 243;
1208
+ readonly tuneRequest: 246;
1209
+ readonly clock: 248;
1210
+ readonly start: 250;
1211
+ readonly continue: 251;
1212
+ readonly stop: 252;
1213
+ readonly activeSensing: 254;
1214
+ readonly reset: 255;
1215
+ readonly sequenceNumber: 0;
1216
+ readonly text: 1;
1217
+ readonly copyright: 2;
1218
+ readonly trackName: 3;
1219
+ readonly instrumentName: 4;
1220
+ readonly lyric: 5;
1221
+ readonly marker: 6;
1222
+ readonly cuePoint: 7;
1223
+ readonly programName: 8;
1224
+ readonly midiChannelPrefix: 32;
1225
+ readonly midiPort: 33;
1226
+ readonly endOfTrack: 47;
1227
+ readonly setTempo: 81;
1228
+ readonly smpteOffset: 84;
1229
+ readonly timeSignature: 88;
1230
+ readonly keySignature: 89;
1231
+ readonly sequenceSpecific: 127;
1232
+ };
1233
+ type MIDIMessageType = (typeof midiMessageTypes)[keyof typeof midiMessageTypes];
1234
+ declare const midiControllers: {
1235
+ readonly bankSelect: 0;
1236
+ readonly modulationWheel: 1;
1237
+ readonly breathController: 2;
1238
+ readonly undefinedCC3: 3;
1239
+ readonly footController: 4;
1240
+ readonly portamentoTime: 5;
1241
+ readonly dataEntryMSB: 6;
1242
+ readonly mainVolume: 7;
1243
+ readonly balance: 8;
1244
+ readonly undefinedCC9: 9;
1245
+ readonly pan: 10;
1246
+ readonly expressionController: 11;
1247
+ readonly effectControl1: 12;
1248
+ readonly effectControl2: 13;
1249
+ readonly undefinedCC14: 14;
1250
+ readonly undefinedCC15: 15;
1251
+ readonly generalPurposeController1: 16;
1252
+ readonly generalPurposeController2: 17;
1253
+ readonly generalPurposeController3: 18;
1254
+ readonly generalPurposeController4: 19;
1255
+ readonly undefinedCC20: 20;
1256
+ readonly undefinedCC21: 21;
1257
+ readonly undefinedCC22: 22;
1258
+ readonly undefinedCC23: 23;
1259
+ readonly undefinedCC24: 24;
1260
+ readonly undefinedCC25: 25;
1261
+ readonly undefinedCC26: 26;
1262
+ readonly undefinedCC27: 27;
1263
+ readonly undefinedCC28: 28;
1264
+ readonly undefinedCC29: 29;
1265
+ readonly undefinedCC30: 30;
1266
+ readonly undefinedCC31: 31;
1267
+ readonly bankSelectLSB: 32;
1268
+ readonly modulationWheelLSB: 33;
1269
+ readonly breathControllerLSB: 34;
1270
+ readonly undefinedCC3LSB: 35;
1271
+ readonly footControllerLSB: 36;
1272
+ readonly portamentoTimeLSB: 37;
1273
+ readonly dataEntryLSB: 38;
1274
+ readonly mainVolumeLSB: 39;
1275
+ readonly balanceLSB: 40;
1276
+ readonly undefinedCC9LSB: 41;
1277
+ readonly panLSB: 42;
1278
+ readonly expressionControllerLSB: 43;
1279
+ readonly effectControl1LSB: 44;
1280
+ readonly effectControl2LSB: 45;
1281
+ readonly undefinedCC14LSB: 46;
1282
+ readonly undefinedCC15LSB: 47;
1283
+ readonly undefinedCC16LSB: 48;
1284
+ readonly undefinedCC17LSB: 49;
1285
+ readonly undefinedCC18LSB: 50;
1286
+ readonly undefinedCC19LSB: 51;
1287
+ readonly undefinedCC20LSB: 52;
1288
+ readonly undefinedCC21LSB: 53;
1289
+ readonly undefinedCC22LSB: 54;
1290
+ readonly undefinedCC23LSB: 55;
1291
+ readonly undefinedCC24LSB: 56;
1292
+ readonly undefinedCC25LSB: 57;
1293
+ readonly undefinedCC26LSB: 58;
1294
+ readonly undefinedCC27LSB: 59;
1295
+ readonly undefinedCC28LSB: 60;
1296
+ readonly undefinedCC29LSB: 61;
1297
+ readonly undefinedCC30LSB: 62;
1298
+ readonly undefinedCC31LSB: 63;
1299
+ readonly sustainPedal: 64;
1300
+ readonly portamentoOnOff: 65;
1301
+ readonly sostenutoPedal: 66;
1302
+ readonly softPedal: 67;
1303
+ readonly legatoFootswitch: 68;
1304
+ readonly hold2Pedal: 69;
1305
+ readonly soundVariation: 70;
1306
+ readonly filterResonance: 71;
1307
+ readonly releaseTime: 72;
1308
+ readonly attackTime: 73;
1309
+ readonly brightness: 74;
1310
+ readonly decayTime: 75;
1311
+ readonly vibratoRate: 76;
1312
+ readonly vibratoDepth: 77;
1313
+ readonly vibratoDelay: 78;
1314
+ readonly soundController10: 79;
1315
+ readonly generalPurposeController5: 80;
1316
+ readonly generalPurposeController6: 81;
1317
+ readonly generalPurposeController7: 82;
1318
+ readonly generalPurposeController8: 83;
1319
+ readonly portamentoControl: 84;
1320
+ readonly undefinedCC85: 85;
1321
+ readonly undefinedCC86: 86;
1322
+ readonly undefinedCC87: 87;
1323
+ readonly undefinedCC88: 88;
1324
+ readonly undefinedCC89: 89;
1325
+ readonly undefinedCC90: 90;
1326
+ readonly reverbDepth: 91;
1327
+ readonly tremoloDepth: 92;
1328
+ readonly chorusDepth: 93;
1329
+ readonly variationDepth: 94;
1330
+ readonly phaserDepth: 95;
1331
+ readonly dataIncrement: 96;
1332
+ readonly dataDecrement: 97;
1333
+ readonly nonRegisteredParameterLSB: 98;
1334
+ readonly nonRegisteredParameterMSB: 99;
1335
+ readonly registeredParameterLSB: 100;
1336
+ readonly registeredParameterMSB: 101;
1337
+ readonly undefinedCC102LSB: 102;
1338
+ readonly undefinedCC103LSB: 103;
1339
+ readonly undefinedCC104LSB: 104;
1340
+ readonly undefinedCC105LSB: 105;
1341
+ readonly undefinedCC106LSB: 106;
1342
+ readonly undefinedCC107LSB: 107;
1343
+ readonly undefinedCC108LSB: 108;
1344
+ readonly undefinedCC109LSB: 109;
1345
+ readonly undefinedCC110LSB: 110;
1346
+ readonly undefinedCC111LSB: 111;
1347
+ readonly undefinedCC112LSB: 112;
1348
+ readonly undefinedCC113LSB: 113;
1349
+ readonly undefinedCC114LSB: 114;
1350
+ readonly undefinedCC115LSB: 115;
1351
+ readonly undefinedCC116LSB: 116;
1352
+ readonly undefinedCC117LSB: 117;
1353
+ readonly undefinedCC118LSB: 118;
1354
+ readonly undefinedCC119LSB: 119;
1355
+ readonly allSoundOff: 120;
1356
+ readonly resetAllControllers: 121;
1357
+ readonly localControlOnOff: 122;
1358
+ readonly allNotesOff: 123;
1359
+ readonly omniModeOff: 124;
1360
+ readonly omniModeOn: 125;
1361
+ readonly monoModeOn: 126;
1362
+ readonly polyModeOn: 127;
1363
+ };
1364
+ type MIDIController = (typeof midiControllers)[keyof typeof midiControllers];
1365
+
1366
+ interface EffectProcessor {
1473
1367
  /**
1474
- * Indicates whether the synthesizer is in monophonic retrigger mode.
1475
- * This emulates the behavior of Microsoft GS Wavetable Synth,
1476
- * Where a new note will kill the previous one if it is still playing.
1368
+ * 0-127
1369
+ * This parameter sets the amount of the effect sent to the effect output.
1477
1370
  */
1478
- monophonicRetriggerMode: boolean;
1371
+ level: number;
1479
1372
  /**
1480
- * The reverb gain, from 0 to any number. 1 is 100% reverb.
1373
+ * 0-7
1374
+ * A low-pass filter can be applied to the sound coming into the effect to cut the high
1375
+ * frequency range. Higher values will cut more of the high frequencies, resulting in a
1376
+ * more mellow effect sound.
1481
1377
  */
1482
- reverbGain: number;
1378
+ preLowpass: number;
1379
+ }
1380
+ interface ReverbProcessorSnapshot extends EffectProcessor {
1483
1381
  /**
1484
- * If the synthesizer should prevent editing of the reverb parameters.
1485
- * This effect is modified using MIDI system exclusive messages, so
1486
- * the recommended use case would be setting
1487
- * the reverb parameters then locking it to prevent changes by MIDI files.
1382
+ * 0-7.
1383
+ * If character is not available, it should default to the first one.
1384
+ *
1385
+ * This parameter selects the type of reverb. 0–5 are reverb effects, and 6 and 7 are delay
1386
+ * effects.
1488
1387
  */
1489
- reverbLock: boolean;
1388
+ character: number;
1490
1389
  /**
1491
- * The chorus gain, from 0 to any number. 1 is 100% chorus.
1390
+ * 0-127
1391
+ * This parameter sets the time over which the reverberation will continue.
1392
+ * Higher values result in longer reverberation.
1492
1393
  */
1493
- chorusGain: number;
1394
+ time: number;
1494
1395
  /**
1495
- * If the synthesizer should prevent editing of the chorus parameters.
1496
- * This effect is modified using MIDI system exclusive messages, so
1497
- * the recommended use case would be setting
1498
- * the chorus parameters then locking it to prevent changes by MIDI files.
1396
+ * 0-127
1397
+ * This parameter is used when the Reverb Character is set to 6 or 7, or the Reverb Type
1398
+ * is set to Delay or Panning Delay (Rev Character 6, 7). It sets the way in which delays
1399
+ * repeat. Higher values result in more delay repeats.
1499
1400
  */
1500
- chorusLock: boolean;
1401
+ delayFeedback: number;
1501
1402
  /**
1502
- * The delay gain, from 0 to any number. 1 is 100% delay.
1403
+ * 0 - 127 (ms)
1404
+ * This parameter sets the delay time until the reverberant sound is heard.
1405
+ * Higher values result in a longer pre-delay time, simulating a larger reverberant space.
1503
1406
  */
1504
- delayGain: number;
1407
+ preDelayTime: number;
1408
+ }
1409
+ interface ReverbProcessor extends ReverbProcessorSnapshot {
1505
1410
  /**
1506
- * If the synthesizer should prevent editing of the delay parameters.
1507
- * This effect is modified using MIDI system exclusive messages, so
1508
- * the recommended use case would be setting
1509
- * the delay parameters then locking it to prevent changes by MIDI files.
1411
+ * Process the effect and ADDS it to the output.
1412
+ * @param input The input buffer to process. It always starts at index 0.
1413
+ * @param outputLeft The left output buffer.
1414
+ * @param outputRight The right output buffer.
1415
+ * @param startIndex The index to start mixing at into the output buffers.
1416
+ * @param sampleCount The amount of samples to mix.
1510
1417
  */
1511
- delayLock: boolean;
1418
+ process(input: Float32Array, outputLeft: Float32Array, outputRight: Float32Array, startIndex: number, sampleCount: number): void;
1512
1419
  /**
1513
- * If the synthesizer should prevent changing the insertion effect type and parameters (including enabling/disabling it on channels).
1514
- * This effect is modified using MIDI system exclusive messages, so
1515
- * the recommended use case would be setting
1516
- * the insertion effect type and parameters then locking it to prevent changes by MIDI files.
1420
+ * Gets a synthesizer from this effect processor instance.
1517
1421
  */
1518
- insertionEffectLock: boolean;
1422
+ getSnapshot(): ReverbProcessorSnapshot;
1423
+ }
1424
+ interface ChorusProcessorSnapshot extends EffectProcessor {
1519
1425
  /**
1520
- * If the synthesizer should prevent editing of the drum parameters.
1521
- * These params are modified using MIDI system exclusive messages or NRPN, so
1522
- * the recommended use case would be setting
1523
- * the drum parameters then locking it to prevent changes by MIDI files.
1426
+ * 0-127
1427
+ * This parameter sets the level at which the chorus sound is re-input (fed back) into the
1428
+ * chorus. By using feedback, a denser chorus sound can be created.
1429
+ * Higher values result in a greater feedback level.
1524
1430
  */
1525
- drumLock: boolean;
1431
+ feedback: number;
1526
1432
  /**
1527
- * If the synthesizer should prevent applying the custom vibrato.
1528
- * This effect is modified using NRPN, so
1529
- * the recommended use case would be setting
1530
- * the custom vibrato then locking it to prevent changes by MIDI files.
1433
+ * 0-127
1434
+ * This parameter sets the delay time of the chorus effect.
1531
1435
  */
1532
- customVibratoLock: boolean;
1436
+ delay: number;
1533
1437
  /**
1534
- * If the synthesizer should prevent changing any parameters via NRPN.
1535
- * This includes the custom vibrato parameters.
1438
+ * 0-127
1439
+ * This parameter sets the speed (frequency) at which the chorus sound is modulated.
1440
+ * Higher values result in faster modulation.
1536
1441
  */
1537
- nprnParamLock: boolean;
1442
+ rate: number;
1538
1443
  /**
1539
- * Forces note killing instead of releasing. Improves performance in black MIDIs.
1444
+ * 0-127
1445
+ * This parameter sets the depth at which the chorus sound is modulated.
1446
+ * Higher values result in deeper modulation.
1540
1447
  */
1541
- blackMIDIMode: boolean;
1448
+ depth: number;
1542
1449
  /**
1543
- * The global transposition in semitones. It can be decimal to provide microtonal tuning.
1450
+ * 0-127
1451
+ * This parameter sets the amount of chorus sound that will be sent to the reverb.
1452
+ * Higher values result in more sound being sent.
1544
1453
  */
1545
- transposition: number;
1454
+ sendLevelToReverb: number;
1546
1455
  /**
1547
- * Synthesizer's device ID for system exclusive messages. Set to -1 to accept all.
1456
+ * 0-127
1457
+ * This parameter sets the amount of chorus sound that will be sent to the delay.
1458
+ * Higher values result in more sound being sent.
1548
1459
  */
1549
- deviceID: number;
1460
+ sendLevelToDelay: number;
1550
1461
  }
1551
-
1552
- /**
1553
- * Wavetable_oscillator.ts
1554
- * purpose: plays back raw audio data at an arbitrary playback rate
1555
- */
1556
- declare abstract class WavetableOscillator {
1462
+ interface ChorusProcessor extends ChorusProcessorSnapshot {
1557
1463
  /**
1558
- * Is the loop on?
1464
+ * Process the effect and ADDS it to the output.
1465
+ * @param input The input buffer to process. It always starts at index 0.
1466
+ * @param outputLeft The left output buffer.
1467
+ * @param outputRight The right output buffer.
1468
+ * @param outputReverb The mono input for reverb. It always starts at index 0.
1469
+ * @param outputDelay The mono input for delay. It always starts at index 0.
1470
+ * @param startIndex The index to start mixing at into the output buffers.
1471
+ * @param sampleCount The amount of samples to mix.
1559
1472
  */
1560
- isLooping: boolean;
1473
+ process(input: Float32Array, outputLeft: Float32Array, outputRight: Float32Array, outputReverb: Float32Array, outputDelay: Float32Array, startIndex: number, sampleCount: number): void;
1561
1474
  /**
1562
- * Sample data of the voice.
1475
+ * Gets a synthesizer from this effect processor instance.
1563
1476
  */
1564
- sampleData?: Float32Array;
1477
+ getSnapshot(): ChorusProcessorSnapshot;
1478
+ }
1479
+ interface DelayProcessorSnapshot extends EffectProcessor {
1565
1480
  /**
1566
- * Playback step (rate) for sample pitch correction.
1481
+ * 0-115
1482
+ * 0.1ms-340ms-1000ms
1483
+ * The delay effect has three delay times; center, left and
1484
+ * right (when listening in stereo). Delay Time Center sets the delay time of the delay
1485
+ * located at the center.
1486
+ * Refer to SC-8850 Owner's Manual p. 236 for the exact mapping of the values.
1567
1487
  */
1568
- playbackStep: number;
1488
+ timeCenter: number;
1569
1489
  /**
1570
- * Start position of the loop.
1490
+ * 0-120
1491
+ * 4% - 500%
1492
+ * This parameter sets the delay time of the delay located at the left as a percentage of
1493
+ * the Delay Time Center (up to a max. of 1.0 s).
1494
+ * The resolution is 100/24(%).
1571
1495
  */
1572
- loopStart: number;
1496
+ timeRatioLeft: number;
1573
1497
  /**
1574
- * End position of the loop.
1498
+ * 1-120
1499
+ * 4%-500%
1500
+ * This parameter sets the delay time of the delay located at the right as a percentage of
1501
+ * the Delay Time Center (up to a max. of 1.0 s).
1502
+ * The resolution is 100/24(%).
1575
1503
  */
1576
- loopEnd: number;
1504
+ timeRatioRight: number;
1577
1505
  /**
1578
- * Length of the loop.
1579
- * @private
1506
+ * 0-127
1507
+ * This parameter sets the volume of the central delay. Higher values result in a louder
1508
+ * center delay.
1580
1509
  */
1581
- loopLength: number;
1510
+ levelCenter: number;
1582
1511
  /**
1583
- * End position of the sample.
1512
+ * 0-127
1513
+ * This parameter sets the volume of the left delay. Higher values result in a louder left
1514
+ * delay.
1584
1515
  */
1585
- end: number;
1516
+ levelLeft: number;
1586
1517
  /**
1587
- * The current cursor of the sample.
1518
+ * 0-127
1519
+ * This parameter sets the volume of the right delay. Higher values result in a louder
1520
+ * right delay.
1588
1521
  */
1589
- cursor: number;
1522
+ levelRight: number;
1590
1523
  /**
1591
- * Fills the output buffer with raw sample data using a given interpolation.
1592
- * @param sampleCount The amount of samples to write into the buffer.
1593
- * @param tuningRatio the tuning ratio to apply.
1594
- * @param outputBuffer The output buffer to write to.
1524
+ * 0-127
1525
+ * (-64)-63
1526
+ * This parameter affects the number of times the delay will repeat. With a value of 0,
1527
+ * the delay will not repeat. With higher values there will be more repeats.
1528
+ * With negative (-) values, the center delay will be fed back with inverted phase.
1529
+ * Negative values are effective with short delay times.
1595
1530
  */
1596
- abstract process(sampleCount: number, tuningRatio: number, outputBuffer: Float32Array): boolean;
1597
- }
1598
-
1599
- /**
1600
- * Voice.ts
1601
- * purpose: prepares Voices from sample and generator data
1602
- */
1603
-
1604
- /**
1605
- * Voice represents a single instance of the
1606
- * SoundFont2 synthesis model.
1607
- * That is:
1608
- * A wavetable oscillator (sample)
1609
- * A volume envelope (volEnv)
1610
- * A modulation envelope (modEnv)
1611
- * Generators (generators and modulatedGenerators)
1612
- * Modulators (modulators)
1613
- * And MIDI params such as channel, MIDI note, velocity
1614
- */
1615
- declare class Voice {
1531
+ feedback: number;
1616
1532
  /**
1617
- * All oscillators currently available to the voice.
1533
+ * 0-127
1534
+ * This parameter sets the amount of delay sound that is sent to the reverb.
1535
+ * Higher values result in more sound being sent.
1618
1536
  */
1619
- readonly oscillators: Record<InterpolationType, WavetableOscillator>;
1537
+ sendLevelToReverb: number;
1538
+ }
1539
+ interface DelayProcessor extends DelayProcessorSnapshot {
1620
1540
  /**
1621
- * The oscillator currently used by this voice.
1541
+ * Process the effect and ADDS it to the output.
1542
+ * @param input The input buffer to process. It always starts at index 0.
1543
+ * @param outputLeft The left output buffer.
1544
+ * @param outputRight The right output buffer.
1545
+ * @param outputReverb The mono input for reverb. It always starts at index 0.
1546
+ * @param startIndex The index to start mixing at into the output buffers.
1547
+ * @param sampleCount The amount of samples to mix.
1622
1548
  */
1623
- wavetable: WavetableOscillator;
1549
+ process(input: Float32Array, outputLeft: Float32Array, outputRight: Float32Array, outputReverb: Float32Array, startIndex: number, sampleCount: number): void;
1624
1550
  /**
1625
- * Lowpass filter applied to the voice.
1551
+ * Gets a synthesizer from this effect processor instance.
1626
1552
  */
1627
- readonly filter: LowpassFilter;
1553
+ getSnapshot(): DelayProcessorSnapshot;
1554
+ }
1555
+ interface InsertionProcessor {
1628
1556
  /**
1629
- * The unmodulated (copied to) generators of the voice.
1557
+ * The EFX type of this processor, stored as MSB << | LSB.
1558
+ * For example 0x30, 0x10 is 0x3010
1630
1559
  */
1631
- readonly generators: Int16Array<ArrayBuffer>;
1560
+ readonly type: number;
1632
1561
  /**
1633
- * The generators in real-time, affected by modulators.
1634
- * This is used during rendering.
1562
+ * 0-1 (floating point)
1563
+ * This parameter sets the amount of insertion sound that will be sent to the reverb.
1564
+ * Higher values result in more sound being sent.
1635
1565
  */
1636
- readonly modulatedGenerators: Int16Array<ArrayBuffer>;
1566
+ sendLevelToReverb: number;
1637
1567
  /**
1638
- * The voice's modulators.
1568
+ * 0-1 (floating point)
1569
+ * This parameter sets the amount of insertion sound that will be sent to the chorus.
1570
+ * Higher values result in more sound being sent.
1639
1571
  */
1640
- modulators: Modulator[];
1572
+ sendLevelToChorus: number;
1641
1573
  /**
1642
- * The current values for the respective modulators.
1643
- * If there are more modulators, the array must be resized.
1574
+ * 0-1 (floating point)
1575
+ * This parameter sets the amount of insertion sound that will be sent to the delay.
1576
+ * Higher values result in more sound being sent.
1644
1577
  */
1645
- modulatorValues: Int16Array<ArrayBuffer>;
1578
+ sendLevelToDelay: number;
1646
1579
  /**
1647
- * Modulation envelope.
1580
+ * Resets the params to their default values.
1581
+ * This does not need to reset send levels.
1648
1582
  */
1649
- readonly modEnv: ModulationEnvelope;
1583
+ reset(): void;
1650
1584
  /**
1651
- * Volume envelope.
1585
+ * Sets an EFX parameter.
1586
+ * @param parameter The parameter number (0x03-0x16).
1587
+ * @param value The new value (0-127).
1652
1588
  */
1653
- readonly volEnv: VolumeEnvelope;
1589
+ setParameter(parameter: number, value: number): void;
1654
1590
  /**
1655
- * Resonance offset, it is affected by the default resonant modulator
1591
+ * Process the effect and ADDS it to the output.
1592
+ * @param inputLeft The left input buffer to process. It always starts at index 0.
1593
+ * @param inputRight The right input buffer to process. It always starts at index 0.
1594
+ * @param outputLeft The left output buffer.
1595
+ * @param outputRight The right output buffer.
1596
+ * @param outputReverb The mono input for reverb. It always starts at index 0.
1597
+ * @param outputChorus The mono input for chorus. It always starts at index 0.
1598
+ * @param outputDelay The mono input for delay. It always starts at index 0.
1599
+ * @param startIndex The index to start mixing at into the output buffers.
1600
+ * @param sampleCount The amount of samples to mix.
1656
1601
  */
1657
- resonanceOffset: number;
1602
+ process(inputLeft: Float32Array, inputRight: Float32Array, outputLeft: Float32Array, outputRight: Float32Array, outputReverb: Float32Array, outputChorus: Float32Array, outputDelay: Float32Array, startIndex: number, sampleCount: number): void;
1603
+ }
1604
+ interface InsertionProcessorSnapshot {
1605
+ type: number;
1658
1606
  /**
1659
- * Priority of the voice. Used for stealing.
1607
+ * 20 parameters for the effect, 255 means "no change" + 3 effect sends (index 20, 21, 22)
1660
1608
  */
1661
- priority: number;
1609
+ params: Uint8Array;
1662
1610
  /**
1663
- * If the voice is currently active.
1664
- * If not, it can be used.
1611
+ * A boolean list for channels that have the insertion effect enabled.
1665
1612
  */
1666
- isActive: boolean;
1613
+ channels: boolean[];
1614
+ }
1615
+ type InsertionProcessorConstructor = new (sampleRate: number, maxBufferSize: number) => InsertionProcessor;
1616
+
1617
+ type SynthSystem = "gm" | "gm2" | "gs" | "xg";
1618
+ interface NoteOnCallback {
1619
+ /** The MIDI note number. */
1620
+ midiNote: number;
1621
+ /** The MIDI channel number. */
1622
+ channel: number;
1623
+ /** The velocity of the note. */
1624
+ velocity: number;
1625
+ }
1626
+ interface NoteOffCallback {
1627
+ /** The MIDI note number. */
1628
+ midiNote: number;
1629
+ /** The MIDI channel number. */
1630
+ channel: number;
1631
+ }
1632
+ interface DrumChangeCallback {
1633
+ /** The MIDI channel number. */
1634
+ channel: number;
1635
+ /** Indicates if the channel is a drum channel. */
1636
+ isDrumChannel: boolean;
1637
+ }
1638
+ interface ProgramChangeCallback extends MIDIPatch {
1639
+ /** The MIDI channel number. */
1640
+ channel: number;
1641
+ }
1642
+ interface ControllerChangeCallback {
1643
+ /** The MIDI channel number. */
1644
+ channel: number;
1645
+ /** The controller number. */
1646
+ controllerNumber: MIDIController;
1647
+ /** The value of the controller. */
1648
+ controllerValue: number;
1649
+ }
1650
+ interface MuteChannelCallback {
1651
+ /** The MIDI channel number. */
1652
+ channel: number;
1653
+ /** Indicates if the channel is muted. */
1654
+ isMuted: boolean;
1655
+ }
1656
+ interface PresetListEntry extends MIDIPatchNamed {
1667
1657
  /**
1668
- * Indicates if the voice has rendered at least one buffer.
1669
- * Used for exclusive class to prevent killing voices set on the same note.
1658
+ * Indicates if this preset is any kind of drum preset.
1670
1659
  */
1671
- hasRendered: boolean;
1660
+ isAnyDrums: boolean;
1661
+ }
1662
+ /**
1663
+ * A list of preset changes, each with a name, bank, and program number.
1664
+ */
1665
+ type PresetList = PresetListEntry[];
1666
+ /**
1667
+ * The synthesizer display system exclusive data, EXCLUDING THE F0 BYTE!
1668
+ */
1669
+ type SynthDisplayCallback = number[];
1670
+ interface PitchWheelCallback {
1671
+ /** The MIDI channel number. */
1672
+ channel: number;
1672
1673
  /**
1673
- * Indicates if the voice is in the release phase.
1674
+ * The unsigned 14-bit value of the pitch: 0 - 16383.
1674
1675
  */
1675
- isInRelease: boolean;
1676
+ pitch: number;
1676
1677
  /**
1677
- * Indicates if the voice is currently held by the sustain pedal.
1678
+ * If the pitch wheel was note-specific, this is the MIDI note number that was altered. Set to -1 otherwise.
1678
1679
  */
1679
- isHeld: boolean;
1680
+ midiNote: number;
1681
+ }
1682
+ interface ChannelPressureCallback {
1683
+ /** The MIDI channel number. */
1684
+ channel: number;
1685
+ /** The pressure value. */
1686
+ pressure: number;
1687
+ }
1688
+ interface PolyPressureCallback {
1689
+ /** The MIDI channel number. */
1690
+ channel: number;
1691
+ /** The MIDI note number. */
1692
+ midiNote: number;
1693
+ /** The pressure value. */
1694
+ pressure: number;
1695
+ }
1696
+ /**
1697
+ * The error message for sound bank errors.
1698
+ */
1699
+ type SoundBankErrorCallback = Error;
1700
+ interface StopAllCallback {
1680
1701
  /**
1681
- * MIDI channel number of the voice.
1702
+ * The MIDI channel number.
1682
1703
  */
1683
1704
  channel: number;
1684
1705
  /**
1685
- * Velocity of the note.
1706
+ * If the channel was force stopped. (no release time)
1686
1707
  */
1687
- velocity: number;
1708
+ force: boolean;
1709
+ }
1710
+ type MasterParameterChangeCallback = {
1711
+ [P in keyof MasterParameterType]: {
1712
+ /**
1713
+ * The parameter that was changed.
1714
+ */
1715
+ parameter: P;
1716
+ /**
1717
+ * The new value of this parameter.
1718
+ */
1719
+ value: MasterParameterType[P];
1720
+ };
1721
+ }[keyof MasterParameterType];
1722
+ interface ChannelPropertyChangeCallback {
1688
1723
  /**
1689
- * MIDI note number.
1724
+ * The channel number of the new property.
1690
1725
  */
1691
- midiNote: number;
1726
+ channel: number;
1692
1727
  /**
1693
- * The root key of the voice.
1728
+ * The updated property.
1694
1729
  */
1695
- rootKey: number;
1730
+ property: ChannelProperty;
1731
+ }
1732
+ type FXType<K> = Exclude<keyof K, "process" | "getSnapshot"> | "macro";
1733
+ type EffectChangeCallback = {
1696
1734
  /**
1697
- * Target key for the note.
1735
+ * The effect that was changed, "reverb", "chorus", "delay" or "insertion"
1698
1736
  */
1699
- targetKey: number;
1737
+ effect: "reverb";
1700
1738
  /**
1701
- * The pressure of the voice
1739
+ * The parameter type or "macro".
1702
1740
  */
1703
- pressure: number;
1741
+ parameter: FXType<ReverbProcessor>;
1704
1742
  /**
1705
- * Linear gain of the voice. Used with Key Modifiers.
1743
+ * The new 7-bit value.
1706
1744
  */
1707
- gainModifier: number;
1745
+ value: number;
1746
+ } | {
1708
1747
  /**
1709
- * Looping mode of the sample:
1710
- * 0 - no loop
1711
- * 1 - loop
1712
- * 2 - UNOFFICIAL: polyphone 2.4 added start on release
1713
- * 3 - loop then play when released
1748
+ * The effect that was changed, "reverb", "chorus", "delay" or "insertion"
1714
1749
  */
1715
- loopingMode: SampleLoopingMode;
1750
+ effect: "chorus";
1716
1751
  /**
1717
- * Start time of the voice, absolute.
1752
+ * The parameter type or "macro".
1718
1753
  */
1719
- startTime: number;
1754
+ parameter: FXType<ChorusProcessor>;
1720
1755
  /**
1721
- * Start time of the release phase, absolute.
1756
+ * The new 7-bit value.
1722
1757
  */
1723
- releaseStartTime: number;
1758
+ value: number;
1759
+ } | {
1724
1760
  /**
1725
- * Current tuning in cents.
1761
+ * The effect that was changed, "reverb", "chorus", "delay" or "insertion"
1726
1762
  */
1727
- tuningCents: number;
1763
+ effect: "delay";
1728
1764
  /**
1729
- * Current calculated tuning. (as in ratio)
1765
+ * The parameter type or "macro".
1730
1766
  */
1731
- tuningRatio: number;
1767
+ parameter: FXType<DelayProcessor>;
1732
1768
  /**
1733
- * From -500 to 500. Used for smoothing.
1769
+ * The new 7-bit value.
1734
1770
  */
1735
- currentPan: number;
1771
+ value: number;
1772
+ } | {
1736
1773
  /**
1737
- * If MIDI Tuning Standard is already applied (at note-on time),
1738
- * this will be used to take the values at real-time tuning as "midiNote"
1739
- * property contains the tuned number.
1740
- * see SpessaSynth#29 comment by @paulikaro
1774
+ * The effect that was changed, "reverb", "chorus", "delay" or "insertion"
1741
1775
  */
1742
- realKey: number;
1776
+ effect: "insertion";
1743
1777
  /**
1744
- * Initial key to glide from, MIDI Note number. If -1, the portamento is OFF.
1778
+ * The parameter that was changed. This maps to GS address map at addr2 = 0x03.
1779
+ * See SC-8850 Manual p.237,
1780
+ * for example:
1781
+ * - 0x0 - EFX type, the value is 16 bit in this special case. Note that this resets the parameters!
1782
+ * - 0x3 - EFX param 1
1783
+ * - 0x16 - EFX param 20 (usually level)
1784
+ * - 0x17 - EFX send to reverb
1785
+ *
1786
+ * There are two exceptions:
1787
+ * - -1 - the channel has ENABLED the effect.
1788
+ * - -2 - the channel has DISABLED the effect.
1789
+ * For both of these cases, `value` is the channel number.
1745
1790
  */
1746
- portamentoFromKey: number;
1791
+ parameter: number;
1747
1792
  /**
1748
- * Duration of the linear glide, in seconds.
1793
+ * The new value for the parameter.
1749
1794
  */
1750
- portamentoDuration: number;
1795
+ value: number;
1796
+ };
1797
+ interface SynthProcessorEventData {
1751
1798
  /**
1752
- * From -500 to 500, where zero means disabled (use the channel pan). Used for random pan.
1799
+ * This event fires when a note is played.
1753
1800
  */
1754
- overridePan: number;
1801
+ noteOn: NoteOnCallback;
1755
1802
  /**
1756
- * In cents, used for drum tuning.
1803
+ * This event fires when a note is released.
1757
1804
  */
1758
- pitchOffset: number;
1805
+ noteOff: NoteOffCallback;
1759
1806
  /**
1760
- * Reverb send of the voice, used for drum parts, otherwise 1.
1807
+ * This event fires when a pitch wheel is changed.
1761
1808
  */
1762
- reverbSend: number;
1809
+ pitchWheel: PitchWheelCallback;
1763
1810
  /**
1764
- * Chorus send of the voice, used for drum parts, otherwise 1.
1811
+ * This event fires when a controller is changed.
1765
1812
  */
1766
- chorusSend: number;
1813
+ controllerChange: ControllerChangeCallback;
1767
1814
  /**
1768
- * Delay send of the voice, used for drum parts, otherwise 1.
1815
+ * This event fires when a program is changed.
1769
1816
  */
1770
- delaySend: number;
1817
+ programChange: ProgramChangeCallback;
1771
1818
  /**
1772
- * Exclusive class number for hi-hats etc.
1819
+ * This event fires when a channel pressure is changed.
1773
1820
  */
1774
- exclusiveClass: number;
1821
+ channelPressure: ChannelPressureCallback;
1775
1822
  /**
1776
- * In timecents, where zero means disabled (use the modulatedGenerators table).
1777
- * Used for exclusive notes and killing notes.
1823
+ * This event fires when a polyphonic pressure is changed.
1778
1824
  */
1779
- overrideReleaseVolEnv: number;
1780
- vibLfoPhase: number;
1781
- vibLfoStartTime: number;
1782
- modLfoPhase: number;
1783
- modLfoStartTime: number;
1784
- constructor(sampleRate: number);
1825
+ polyPressure: PolyPressureCallback;
1785
1826
  /**
1786
- * Computes a given modulator
1787
- * @param controllerTable all midi controllers as 14bit values + the non-controller indexes, starting at 128
1788
- * @param pitchWheel the pitch wheel value, as channel determines if it's a per-note or a global value.
1789
- * @param modulatorIndex the modulator to compute
1790
- * @returns the computed value
1827
+ * This event fires when a drum channel is changed.
1791
1828
  */
1792
- computeModulator(this: Voice, controllerTable: Int16Array, pitchWheel: number, modulatorIndex: number): number;
1829
+ drumChange: DrumChangeCallback;
1793
1830
  /**
1794
- * Releases the voice as exclusiveClass.
1831
+ * This event fires when all notes on a channel are stopped.
1795
1832
  */
1796
- exclusiveRelease(currentTime: number, minExclusiveLength?: number): void;
1833
+ stopAll: StopAllCallback;
1797
1834
  /**
1798
- * Stops the voice
1799
- * @param currentTime
1800
- * @param minNoteLength minimum note length in seconds
1835
+ * This event fires when a new channel is created. There is no data for this event.
1801
1836
  */
1802
- releaseVoice(currentTime: number, minNoteLength?: number): void;
1803
- setup(currentTime: number, channel: number, midiNote: number, velocity: number, realKey: number): void;
1804
- }
1805
-
1806
- declare class ModulatorSource {
1837
+ newChannel: void;
1807
1838
  /**
1808
- * If this field is set to false, the controller should be mapped with a minimum value of 0 and a maximum value of 1. This is also
1809
- * called Unipolar. Thus, it behaves similar to the Modulation Wheel controller of the MIDI specification.
1810
- *
1811
- * If this field is set to true, the controller sound be mapped with a minimum value of -1 and a maximum value of 1. This is also
1812
- * called Bipolar. Thus, it behaves similar to the Pitch Wheel controller of the MIDI specification.
1839
+ * This event fires when a channel is muted or unmuted.
1813
1840
  */
1814
- isBipolar: boolean;
1841
+ muteChannel: MuteChannelCallback;
1815
1842
  /**
1816
- * If this field is set true, the direction of the controller should be from the maximum value to the minimum value. So, for
1817
- * example, if the controller source is Key Number, then a Key Number value of 0 corresponds to the maximum possible
1818
- * controller output, and the Key Number value of 127 corresponds to the minimum possible controller input.
1843
+ * This event fires when the preset list is changed.
1819
1844
  */
1820
- isNegative: boolean;
1845
+ presetListChange: PresetList;
1821
1846
  /**
1822
- * The index of the source.
1823
- * It can point to one of the MIDI controllers or one of the predefined sources, depending on the 'isCC' flag.
1847
+ * This event fires when all controllers on all channels are reset. There is no data for this event.
1824
1848
  */
1825
- index: ModulatorSourceIndex;
1849
+ allControllerReset: void;
1826
1850
  /**
1827
- * If this field is set to true, the MIDI Controller Palette is selected. The ‘index’ field value corresponds to one of the 128
1828
- * MIDI Continuous Controller messages as defined in the MIDI specification.
1851
+ * This event fires when a sound bank parsing error occurs.
1829
1852
  */
1830
- isCC: boolean;
1853
+ soundBankError: SoundBankErrorCallback;
1831
1854
  /**
1832
- * This field specifies how the minimum value approaches the maximum value.
1855
+ * This event fires when the synthesizer receives a display message.
1833
1856
  */
1834
- curveType: ModulatorCurveType;
1835
- constructor(index?: ModulatorSourceIndex, curveType?: ModulatorCurveType, isCC?: boolean, isBipolar?: boolean, isNegative?: boolean);
1836
- private get sourceName();
1837
- private get curveTypeName();
1838
- static fromSourceEnum(sourceEnum: number): ModulatorSource;
1857
+ synthDisplay: SynthDisplayCallback;
1839
1858
  /**
1840
- * Copies the modulator source.
1841
- * @param source The source to copy from.
1842
- * @returns the copied source.
1859
+ * This event fires when a master parameter changes.
1843
1860
  */
1844
- static copyFrom(source: ModulatorSource): ModulatorSource;
1845
- toString(): string;
1846
- toSourceEnum(): number;
1847
- isIdentical(source: ModulatorSource): boolean;
1861
+ masterParameterChange: MasterParameterChangeCallback;
1848
1862
  /**
1849
- * Gets the current value from this source.
1850
- * @param midiControllers The MIDI controller + modulator source array.
1851
- * @param pitchWheel the pitch wheel value, as channel determines if it's a per-note or a global value.
1852
- * @param voice The voice to get the data for.
1863
+ * This event fires when a channel property changes.
1853
1864
  */
1854
- getValue(midiControllers: Int16Array, pitchWheel: number, voice: Voice): number;
1855
- }
1856
-
1857
- /**
1858
- * Returned structure containing extended SF2 chunks.
1859
- */
1860
- interface ExtendedSF2Chunks {
1865
+ channelPropertyChange: ChannelPropertyChangeCallback;
1861
1866
  /**
1862
- * The PDTA part of the chunk.
1867
+ * This event fires when an effect processor is modified.
1863
1868
  */
1864
- pdta: IndexedByteArray;
1869
+ effectChange: EffectChangeCallback;
1870
+ }
1871
+ type SynthProcessorEvent = {
1872
+ [K in keyof SynthProcessorEventData]: {
1873
+ type: K;
1874
+ data: SynthProcessorEventData[K];
1875
+ };
1876
+ }[keyof SynthProcessorEventData];
1877
+ interface SynthMethodOptions {
1865
1878
  /**
1866
- * The XDTA (https://github.com/spessasus/soundfont-proposals/blob/main/extended_limits.md) part of the chunk.
1879
+ * The audio context time when the event should execute, in seconds.
1867
1880
  */
1868
- xdta: IndexedByteArray;
1881
+ time: number;
1869
1882
  }
1870
1883
  /**
1871
- * Write indexes for tracking writing a SoundFont file.
1884
+ * Looping mode of the sample.
1885
+ * 0 - no loop.
1886
+ * 1 - loop.
1887
+ * 2 - UNOFFICIAL: polyphone 2.4 added start on release.
1888
+ * 3 - loop then play when released.
1872
1889
  */
1873
- interface SoundFontWriteIndexes {
1874
- /**
1875
- * Generator start index.
1876
- */
1877
- gen: number;
1890
+ type SampleLoopingMode = 0 | 1 | 2 | 3;
1891
+ /**
1892
+ * A list of voices for a given key:velocity.
1893
+ */
1894
+ type CachedVoiceList = CachedVoice[];
1895
+ interface ChannelProperty {
1878
1896
  /**
1879
- * Modulator start index.
1897
+ * The channel's current voice amount.
1880
1898
  */
1881
- mod: number;
1899
+ voicesAmount: number;
1882
1900
  /**
1883
- * Zone start index.
1901
+ * The channel's current pitch wheel 0 - 16384.
1884
1902
  */
1885
- bag: number;
1903
+ pitchWheel: number;
1886
1904
  /**
1887
- * Preset/instrument start index.
1905
+ * The pitch wheel's range, in semitones.
1888
1906
  */
1889
- hdr: number;
1890
- }
1891
-
1892
- declare class Modulator {
1907
+ pitchWheelRange: number;
1893
1908
  /**
1894
- * The generator destination of this modulator.
1909
+ * Indicates whether the channel is muted.
1895
1910
  */
1896
- destination: GeneratorType;
1911
+ isMuted: boolean;
1897
1912
  /**
1898
- * The transform amount for this modulator.
1913
+ * Indicates whether the channel is a drum channel.
1899
1914
  */
1900
- transformAmount: number;
1915
+ isDrum: boolean;
1901
1916
  /**
1902
- * The transform type for this modulator.
1917
+ * Indicates whether the channel uses an insertion effect.
1918
+ * This means that there will be no separate dry output for processSplit().
1903
1919
  */
1904
- transformType: ModulatorTransformType;
1920
+ isEFX: boolean;
1905
1921
  /**
1906
- * Indicates if the given modulator is chorus or reverb effects modulator.
1907
- * This is done to simulate BASSMIDI effects behavior:
1908
- * - defaults to 1000 transform amount rather than 200
1909
- * - values can be changed, but anything above 200 is 1000
1910
- * (except for values above 1000, they are copied directly)
1911
- * - all values below are multiplied by 5 (200 * 5 = 1000)
1912
- * - still can be disabled if the soundfont has its own modulator curve
1913
- * - this fixes the very low amount of reverb by default and doesn't break soundfonts
1922
+ * The channel's transposition, in semitones.
1914
1923
  */
1915
- readonly isEffectModulator: boolean;
1924
+ transposition: number;
1925
+ }
1926
+ interface SynthProcessorOptions {
1916
1927
  /**
1917
- * The default resonant modulator does not affect the filter gain.
1918
- * Neither XG nor GS responded to cc #74 in that way.
1928
+ * The maximum buffer size the synthesizer can render at once.
1929
+ * Attempting to `.process()` more samples than this will result in an error.
1930
+ * Defaults to 128.
1919
1931
  */
1920
- readonly isDefaultResonantModulator: boolean;
1932
+ maxBufferSize: number;
1921
1933
  /**
1922
- * The primary source of this modulator.
1934
+ * Indicates if the event system is enabled. This can be changed later.
1923
1935
  */
1924
- readonly primarySource: ModulatorSource;
1936
+ enableEventSystem: boolean;
1925
1937
  /**
1926
- * The secondary source of this modulator.
1938
+ * The initial time of the synth, in seconds.
1927
1939
  */
1928
- readonly secondarySource: ModulatorSource;
1940
+ initialTime: number;
1929
1941
  /**
1930
- * Creates a new SF2 Modulator
1942
+ * Indicates if the effects are enabled. This can be changed later.
1931
1943
  */
1932
- constructor(primarySource?: ModulatorSource, secondarySource?: ModulatorSource, destination?: GeneratorType, amount?: number, transformType?: ModulatorTransformType, isEffectModulator?: boolean, isDefaultResonantModulator?: boolean);
1933
- private get destinationName();
1944
+ enableEffects: boolean;
1934
1945
  /**
1935
- * Checks if the pair of modulators is identical (in SF2 terms)
1936
- * @param mod1 modulator 1
1937
- * @param mod2 modulator 2
1938
- * @param checkAmount if the amount should be checked too.
1939
- * @returns if they are identical
1946
+ * Reverb processor for the synthesizer. Leave undefined to use the default.
1940
1947
  */
1941
- static isIdentical(mod1: Modulator, mod2: Modulator, checkAmount?: boolean): boolean;
1948
+ reverbProcessor?: ReverbProcessor;
1942
1949
  /**
1943
- * Copies a modulator.
1944
- * @param mod The modulator to copy.
1945
- * @returns The copied modulator.
1950
+ * Chorus processor for the synthesizer. Leave undefined to use the default.
1946
1951
  */
1947
- static copyFrom(mod: Modulator): Modulator;
1948
- toString(): string;
1949
- write(modData: IndexedByteArray, indexes?: SoundFontWriteIndexes): void;
1952
+ chorusProcessor?: ChorusProcessor;
1950
1953
  /**
1951
- * Sums transform and create a NEW modulator
1952
- * @param modulator the modulator to sum with
1953
- * @returns the new modulator
1954
+ * Delay processor for the synthesizer. Leave undefined to use the default.
1954
1955
  */
1955
- sumTransform(modulator: Modulator): Modulator;
1956
+ delayProcessor?: DelayProcessor;
1956
1957
  }
1957
-
1958
- declare class Generator {
1959
- /**
1960
- * The generator's SF2 type.
1961
- */
1962
- generatorType: GeneratorType;
1958
+ /**
1959
+ * The master parameters of the synthesizer.
1960
+ */
1961
+ interface MasterParameterType {
1963
1962
  /**
1964
- * The generator's 16-bit value.
1963
+ * The master gain, from 0 to any number. 1 is 100% volume.
1965
1964
  */
1966
- generatorValue: number;
1965
+ masterGain: number;
1967
1966
  /**
1968
- * Constructs a new generator
1969
- * @param type generator type
1970
- * @param value generator value
1971
- * @param validate if the limits should be validated and clamped.
1967
+ * The master pan, from -1 (left) to 1 (right). 0 is center.
1972
1968
  */
1973
- constructor(type: GeneratorType, value: number, validate?: boolean);
1974
- write(genData: IndexedByteArray): void;
1975
- toString(): string;
1976
- }
1977
-
1978
- declare class BasicZone {
1969
+ masterPan: number;
1979
1970
  /**
1980
- * The zone's velocity range.
1981
- * min -1 means that it is a default value
1971
+ * The maximum number of voices that can be played at once.
1972
+ *
1973
+ * @remarks
1974
+ * Increasing this value causes memory allocation for more voices.
1975
+ * It is recommended to set it at the beginning, before rendering audio to avoid GC.
1976
+ * Decreasing it does not cause memory usage change, so it's fine to use.
1982
1977
  */
1983
- velRange: GenericRange;
1978
+ voiceCap: number;
1984
1979
  /**
1985
- * The zone's key range.
1986
- * min -1 means that it is a default value.
1980
+ * Enabling this parameter will cause a new voice allocation when the voice cap is hit, rather than stealing existing voices.
1981
+ *
1982
+ * @remarks
1983
+ * This is not recommended in real-time environments.
1987
1984
  */
1988
- keyRange: GenericRange;
1985
+ autoAllocateVoices: boolean;
1989
1986
  /**
1990
- * The zone's generators.
1987
+ * The interpolation type used for sample playback.
1991
1988
  */
1992
- generators: Generator[];
1989
+ interpolationType: InterpolationType;
1993
1990
  /**
1994
- * The zone's modulators.
1991
+ * The MIDI system used by the synthesizer for bank selects and system exclusives. (GM, GM2, GS, XG)
1995
1992
  */
1996
- modulators: Modulator[];
1997
- get hasKeyRange(): boolean;
1998
- get hasVelRange(): boolean;
1993
+ midiSystem: SynthSystem;
1999
1994
  /**
2000
- * The current tuning in cents, taking in both coarse and fine generators.
1995
+ * Indicates whether the synthesizer is in monophonic retrigger mode.
1996
+ * This emulates the behavior of Microsoft GS Wavetable Synth,
1997
+ * Where a new note will kill the previous one if it is still playing.
2001
1998
  */
2002
- get fineTuning(): number;
1999
+ monophonicRetriggerMode: boolean;
2003
2000
  /**
2004
- * The current tuning in cents, taking in both coarse and fine generators.
2001
+ * The reverb gain, from 0 to any number. 1 is 100% reverb.
2005
2002
  */
2006
- set fineTuning(tuningCents: number);
2003
+ reverbGain: number;
2007
2004
  /**
2008
- * Adds to a given generator, or its default value.
2009
- * @param type the generator type.
2010
- * @param value the value to add.
2011
- * @param validate if the value should be clamped to allowed limits.
2005
+ * If the synthesizer should prevent editing of the reverb parameters.
2006
+ * This effect is modified using MIDI system exclusive messages, so
2007
+ * the recommended use case would be setting
2008
+ * the reverb parameters then locking it to prevent changes by MIDI files.
2012
2009
  */
2013
- addToGenerator(type: GeneratorType, value: number, validate?: boolean): void;
2010
+ reverbLock: boolean;
2014
2011
  /**
2015
- * Sets a generator to a given value if preset, otherwise adds a new one.
2016
- * @param type the generator type.
2017
- * @param value the value to set. Set to null to remove this generator (set as "unset").
2018
- * @param validate if the value should be clamped to allowed limits.
2012
+ * The chorus gain, from 0 to any number. 1 is 100% chorus.
2019
2013
  */
2020
- setGenerator(type: GeneratorType, value: number | null, validate?: boolean): void;
2014
+ chorusGain: number;
2021
2015
  /**
2022
- * Adds generators to the zone.
2023
- * @param generators the generators to add.
2016
+ * If the synthesizer should prevent editing of the chorus parameters.
2017
+ * This effect is modified using MIDI system exclusive messages, so
2018
+ * the recommended use case would be setting
2019
+ * the chorus parameters then locking it to prevent changes by MIDI files.
2024
2020
  */
2025
- addGenerators(...generators: Generator[]): void;
2021
+ chorusLock: boolean;
2026
2022
  /**
2027
- * Adds modulators to the zone.
2028
- * @param modulators the modulators to add.
2023
+ * The delay gain, from 0 to any number. 1 is 100% delay.
2029
2024
  */
2030
- addModulators(...modulators: Modulator[]): void;
2025
+ delayGain: number;
2031
2026
  /**
2032
- * Gets a generator value.
2033
- * @param generatorType the generator type.
2034
- * @param notFoundValue if the generator is not found, this value is returned. A default value can be passed here, or null for example,
2035
- * to check if the generator is set.
2027
+ * If the synthesizer should prevent editing of the delay parameters.
2028
+ * This effect is modified using MIDI system exclusive messages, so
2029
+ * the recommended use case would be setting
2030
+ * the delay parameters then locking it to prevent changes by MIDI files.
2036
2031
  */
2037
- getGenerator<K>(generatorType: GeneratorType, notFoundValue: number | K): number | K;
2038
- copyFrom(zone: BasicZone): void;
2032
+ delayLock: boolean;
2039
2033
  /**
2040
- * Filters the generators and prepends the range generators.
2034
+ * If the synthesizer should prevent changing the insertion effect type and parameters (including enabling/disabling it on channels).
2035
+ * This effect is modified using MIDI system exclusive messages, so
2036
+ * the recommended use case would be setting
2037
+ * the insertion effect type and parameters then locking it to prevent changes by MIDI files.
2041
2038
  */
2042
- getWriteGenerators(bank: BasicSoundBank): Generator[];
2043
- }
2044
-
2045
- declare class BasicGlobalZone extends BasicZone {
2046
- }
2047
-
2048
- declare class BasicInstrumentZone extends BasicZone {
2039
+ insertionEffectLock: boolean;
2049
2040
  /**
2050
- * The instrument this zone belongs to.
2041
+ * If the synthesizer should prevent editing of the drum parameters.
2042
+ * These params are modified using MIDI system exclusive messages or NRPN, so
2043
+ * the recommended use case would be setting
2044
+ * the drum parameters then locking it to prevent changes by MIDI files.
2051
2045
  */
2052
- readonly parentInstrument: BasicInstrument;
2046
+ drumLock: boolean;
2053
2047
  /**
2054
- * For tracking on the individual zone level, since multiple presets can refer to the same instrument.
2048
+ * If the synthesizer should prevent applying the custom vibrato.
2049
+ * This effect is modified using NRPN, so
2050
+ * the recommended use case would be setting
2051
+ * the custom vibrato then locking it to prevent changes by MIDI files.
2055
2052
  */
2056
- useCount: number;
2053
+ customVibratoLock: boolean;
2057
2054
  /**
2058
- * Creates a new instrument zone.
2059
- * @param instrument The parent instrument.
2060
- * @param sample The sample to use in this zone.
2055
+ * If the synthesizer should prevent changing any parameters via NRPN.
2056
+ * This includes the custom vibrato parameters.
2061
2057
  */
2062
- constructor(instrument: BasicInstrument, sample: BasicSample);
2058
+ nprnParamLock: boolean;
2063
2059
  /**
2064
- * Zone's sample.
2060
+ * Forces note killing instead of releasing. Improves performance in black MIDIs.
2065
2061
  */
2066
- private _sample;
2062
+ blackMIDIMode: boolean;
2067
2063
  /**
2068
- * Zone's sample.
2064
+ * The global transposition in semitones. It can be decimal to provide microtonal tuning.
2069
2065
  */
2070
- get sample(): BasicSample;
2066
+ transposition: number;
2071
2067
  /**
2072
- * Sets a sample for this zone.
2073
- * @param sample the sample to set.
2068
+ * Synthesizer's device ID for system exclusive messages. Set to -1 to accept all.
2074
2069
  */
2075
- set sample(sample: BasicSample);
2076
- getWriteGenerators(bank: BasicSoundBank): Generator[];
2070
+ deviceID: number;
2077
2071
  }
2078
2072
 
2079
- declare class BasicPresetZone extends BasicZone {
2073
+ /**
2074
+ * Wavetable_oscillator.ts
2075
+ * purpose: plays back raw audio data at an arbitrary playback rate
2076
+ */
2077
+ declare abstract class WavetableOscillator {
2080
2078
  /**
2081
- * The preset this zone belongs to.
2079
+ * Is the loop on?
2082
2080
  */
2083
- readonly parentPreset: BasicPreset;
2081
+ isLooping: boolean;
2084
2082
  /**
2085
- * Creates a new preset zone.
2086
- * @param preset the preset this zone belongs to.
2087
- * @param instrument the instrument to use in this zone.
2083
+ * Sample data of the voice.
2088
2084
  */
2089
- constructor(preset: BasicPreset, instrument: BasicInstrument);
2085
+ sampleData?: Float32Array;
2090
2086
  /**
2091
- * Zone's instrument.
2087
+ * Playback step (rate) for sample pitch correction.
2092
2088
  */
2093
- private _instrument;
2089
+ playbackStep: number;
2094
2090
  /**
2095
- * Zone's instrument.
2091
+ * Start position of the loop.
2096
2092
  */
2097
- get instrument(): BasicInstrument;
2093
+ loopStart: number;
2098
2094
  /**
2099
- * Zone's instrument.
2095
+ * End position of the loop.
2100
2096
  */
2101
- set instrument(instrument: BasicInstrument);
2102
- getWriteGenerators(bank: BasicSoundBank): Generator[];
2103
- }
2104
-
2105
- declare class BasicPreset implements MIDIPatchNamed {
2097
+ loopEnd: number;
2106
2098
  /**
2107
- * The parent soundbank instance
2108
- * Currently used for determining default modulators and XG status
2099
+ * Length of the loop.
2100
+ * @private
2109
2101
  */
2110
- readonly parentSoundBank: BasicSoundBank;
2102
+ loopLength: number;
2111
2103
  /**
2112
- * The preset's name
2104
+ * End position of the sample.
2113
2105
  */
2114
- name: string;
2115
- program: number;
2116
- bankMSB: number;
2117
- bankLSB: number;
2118
- isGMGSDrum: boolean;
2106
+ end: number;
2119
2107
  /**
2120
- * The preset's zones
2108
+ * The current cursor of the sample.
2121
2109
  */
2122
- zones: BasicPresetZone[];
2110
+ cursor: number;
2123
2111
  /**
2124
- * Preset's global zone
2112
+ * Fills the output buffer with raw sample data using a given interpolation.
2113
+ * @param sampleCount The amount of samples to write into the buffer.
2114
+ * @param tuningRatio the tuning ratio to apply.
2115
+ * @param outputBuffer The output buffer to write to.
2125
2116
  */
2126
- readonly globalZone: BasicGlobalZone;
2117
+ abstract process(sampleCount: number, tuningRatio: number, outputBuffer: Float32Array): boolean;
2118
+ }
2119
+
2120
+ /**
2121
+ * Voice.ts
2122
+ * purpose: prepares Voices from sample and generator data
2123
+ */
2124
+
2125
+ /**
2126
+ * Voice represents a single instance of the
2127
+ * SoundFont2 synthesis model.
2128
+ * That is:
2129
+ * A wavetable oscillator (sample)
2130
+ * A volume envelope (volEnv)
2131
+ * A modulation envelope (modEnv)
2132
+ * Generators (generators and modulatedGenerators)
2133
+ * Modulators (modulators)
2134
+ * And MIDI params such as channel, MIDI note, velocity
2135
+ */
2136
+ declare class Voice {
2127
2137
  /**
2128
- * Unused metadata
2138
+ * All oscillators currently available to the voice.
2129
2139
  */
2130
- library: number;
2140
+ readonly oscillators: Record<InterpolationType, WavetableOscillator>;
2131
2141
  /**
2132
- * Unused metadata
2142
+ * The oscillator currently used by this voice.
2133
2143
  */
2134
- genre: number;
2144
+ wavetable: WavetableOscillator;
2135
2145
  /**
2136
- * Unused metadata
2146
+ * Lowpass filter applied to the voice.
2137
2147
  */
2138
- morphology: number;
2148
+ readonly filter: LowpassFilter;
2139
2149
  /**
2140
- * Creates a new preset representation.
2141
- * @param parentSoundBank the sound bank this preset belongs to.
2142
- * @param globalZone optional, a global zone to use.
2150
+ * The unmodulated (copied to) generators of the voice.
2143
2151
  */
2144
- constructor(parentSoundBank: BasicSoundBank, globalZone?: BasicGlobalZone);
2145
- get isXGDrums(): boolean;
2152
+ readonly generators: Int16Array<ArrayBuffer>;
2146
2153
  /**
2147
- * Checks if this preset is a drum preset
2154
+ * The generators in real-time, affected by modulators.
2155
+ * This is used during rendering.
2148
2156
  */
2149
- get isAnyDrums(): boolean;
2150
- private static isInRange;
2151
- private static addUniqueModulators;
2152
- private static subtractRanges;
2157
+ readonly modulatedGenerators: Int16Array<ArrayBuffer>;
2153
2158
  /**
2154
- * Unlinks everything from this preset.
2159
+ * The voice's modulators.
2155
2160
  */
2156
- delete(): void;
2161
+ modulators: VoiceModulator[];
2157
2162
  /**
2158
- * Deletes an instrument zone from this preset.
2159
- * @param index the zone's index to delete.
2163
+ * The current values for the respective modulators.
2164
+ * If there are more modulators, the array must be resized.
2160
2165
  */
2161
- deleteZone(index: number): void;
2166
+ modulatorValues: Int16Array<ArrayBuffer>;
2162
2167
  /**
2163
- * Creates a new preset zone and returns it.
2164
- * @param instrument the instrument to use in the zone.
2168
+ * Modulation envelope.
2165
2169
  */
2166
- createZone(instrument: BasicInstrument): BasicPresetZone;
2170
+ readonly modEnv: ModulationEnvelope;
2167
2171
  /**
2168
- * Preloads (loads and caches synthesis data) for a given key range.
2172
+ * Volume envelope.
2169
2173
  */
2170
- preload(keyMin: number, keyMax: number): void;
2174
+ readonly volEnv: VolumeEnvelope;
2171
2175
  /**
2172
- * Checks if the bank and program numbers are the same for the given preset as this one.
2173
- * @param preset The preset to check.
2176
+ * Resonance offset, it is affected by the default resonant modulator
2174
2177
  */
2175
- matches(preset: MIDIPatch): boolean;
2178
+ resonanceOffset: number;
2176
2179
  /**
2177
- * Returns the voice synthesis data for this preset.
2178
- * @param midiNote the MIDI note number.
2179
- * @param velocity the MIDI velocity.
2180
- * @returns the returned sound data.
2180
+ * Priority of the voice. Used for stealing.
2181
2181
  */
2182
- getVoiceParameters(midiNote: number, velocity: number): VoiceParameters[];
2182
+ priority: number;
2183
2183
  /**
2184
- * BankMSB:bankLSB:program:isGMGSDrum
2184
+ * If the voice is currently active.
2185
+ * If not, it can be used.
2185
2186
  */
2186
- toMIDIString(): string;
2187
- toString(): string;
2187
+ isActive: boolean;
2188
2188
  /**
2189
- * Combines preset into an instrument, flattening the preset zones into instrument zones.
2190
- * This is a really complex function that attempts to work around the DLS limitations of only having the instrument layer.
2191
- * @returns The instrument containing the flattened zones. In theory, it should exactly the same as this preset.
2189
+ * Indicates if the voice has rendered at least one buffer.
2190
+ * Used for exclusive class to prevent killing voices set on the same note.
2192
2191
  */
2193
- toFlattenedInstrument(): BasicInstrument;
2192
+ hasRendered: boolean;
2194
2193
  /**
2195
- * Writes the SF2 header
2196
- * @param phdrData
2197
- * @param index
2194
+ * Indicates if the voice is in the release phase.
2198
2195
  */
2199
- write(phdrData: ExtendedSF2Chunks, index: number): void;
2200
- }
2201
-
2202
- /**
2203
- * Represents a single instrument
2204
- */
2205
- declare class BasicInstrument {
2196
+ isInRelease: boolean;
2206
2197
  /**
2207
- * The instrument's name
2198
+ * Indicates if the voice is currently held by the sustain pedal.
2208
2199
  */
2209
- name: string;
2200
+ isHeld: boolean;
2210
2201
  /**
2211
- * The instrument's zones
2202
+ * MIDI channel number of the voice.
2203
+ */
2204
+ channel: number;
2205
+ /**
2206
+ * Velocity of the note.
2207
+ */
2208
+ velocity: number;
2209
+ /**
2210
+ * MIDI note number.
2212
2211
  */
2213
- zones: BasicInstrumentZone[];
2212
+ midiNote: number;
2214
2213
  /**
2215
- * Instrument's global zone
2214
+ * The root key of the voice.
2216
2215
  */
2217
- readonly globalZone: BasicGlobalZone;
2216
+ rootKey: number;
2218
2217
  /**
2219
- * Instrument's linked presets (the presets that use it)
2220
- * note that duplicates are allowed since one preset can use the same instrument multiple times.
2218
+ * Target key for the note.
2221
2219
  */
2222
- readonly linkedTo: BasicPreset[];
2220
+ targetKey: number;
2223
2221
  /**
2224
- * How many presets is this instrument used by
2222
+ * The pressure of the voice
2225
2223
  */
2226
- get useCount(): number;
2224
+ pressure: number;
2227
2225
  /**
2228
- * Creates a new instrument zone and returns it.
2229
- * @param sample The sample to use in the zone.
2226
+ * Linear gain of the voice. Used with Key Modifiers.
2230
2227
  */
2231
- createZone(sample: BasicSample): BasicInstrumentZone;
2228
+ gainModifier: number;
2232
2229
  /**
2233
- * Links the instrument ta a given preset
2234
- * @param preset the preset to link to
2230
+ * Looping mode of the sample:
2231
+ * 0 - no loop
2232
+ * 1 - loop
2233
+ * 2 - UNOFFICIAL: polyphone 2.4 added start on release
2234
+ * 3 - loop then play when released
2235
2235
  */
2236
- linkTo(preset: BasicPreset): void;
2236
+ loopingMode: SampleLoopingMode;
2237
2237
  /**
2238
- * Unlinks the instrument from a given preset
2239
- * @param preset the preset to unlink from
2238
+ * Start time of the voice, absolute.
2240
2239
  */
2241
- unlinkFrom(preset: BasicPreset): void;
2242
- deleteUnusedZones(): void;
2243
- delete(): void;
2240
+ startTime: number;
2244
2241
  /**
2245
- * Deletes a given instrument zone if it has no uses
2246
- * @param index the index of the zone to delete
2247
- * @param force ignores the use count and deletes forcibly
2248
- * @returns if the zone has been deleted
2242
+ * Start time of the release phase, absolute.
2249
2243
  */
2250
- deleteZone(index: number, force?: boolean): boolean;
2244
+ releaseStartTime: number;
2251
2245
  /**
2252
- * Globalizes the instrument *in-place.*
2253
- * This means trying to move as many generators and modulators
2254
- * to the global zone as possible to reduce clutter and the count of parameters.
2246
+ * Current tuning in cents.
2255
2247
  */
2256
- globalize(): void;
2257
- write(instData: ExtendedSF2Chunks, index: number): void;
2258
- }
2259
-
2260
- declare class BasicSample {
2248
+ tuningCents: number;
2261
2249
  /**
2262
- * The sample's name.
2250
+ * Current calculated tuning. (as in ratio)
2263
2251
  */
2264
- name: string;
2252
+ tuningRatio: number;
2265
2253
  /**
2266
- * Sample rate in Hz.
2254
+ * From -500 to 500. Used for smoothing.
2267
2255
  */
2268
- sampleRate: number;
2256
+ currentPan: number;
2269
2257
  /**
2270
- * Original pitch of the sample as a MIDI note number.
2258
+ * If MIDI Tuning Standard is already applied (at note-on time),
2259
+ * this will be used to take the values at real-time tuning as "midiNote"
2260
+ * property contains the tuned number.
2261
+ * see SpessaSynth#29 comment by @paulikaro
2271
2262
  */
2272
- originalKey: number;
2263
+ realKey: number;
2273
2264
  /**
2274
- * Pitch correction, in cents. Can be negative.
2265
+ * Initial key to glide from, MIDI Note number. If -1, the portamento is OFF.
2275
2266
  */
2276
- pitchCorrection: number;
2267
+ portamentoFromKey: number;
2277
2268
  /**
2278
- * Linked sample, unused if mono.
2269
+ * Duration of the linear glide, in seconds.
2279
2270
  */
2280
- linkedSample?: BasicSample;
2271
+ portamentoDuration: number;
2281
2272
  /**
2282
- * The type of the sample.
2273
+ * From -500 to 500, where zero means disabled (use the channel pan). Used for random pan.
2283
2274
  */
2284
- sampleType: SampleType;
2275
+ overridePan: number;
2285
2276
  /**
2286
- * Relative to the start of the sample in sample points.
2277
+ * In cents, used for drum tuning.
2287
2278
  */
2288
- loopStart: number;
2279
+ pitchOffset: number;
2289
2280
  /**
2290
- * Relative to the start of the sample in sample points.
2281
+ * Reverb send of the voice, used for drum parts, otherwise 1.
2291
2282
  */
2292
- loopEnd: number;
2283
+ reverbSend: number;
2293
2284
  /**
2294
- * Sample's linked instruments (the instruments that use it)
2295
- * note that duplicates are allowed since one instrument can use the same sample multiple times.
2285
+ * Chorus send of the voice, used for drum parts, otherwise 1.
2296
2286
  */
2297
- linkedTo: BasicInstrument[];
2287
+ chorusSend: number;
2298
2288
  /**
2299
- * Indicates if the data was overridden, so it cannot be copied back unchanged.
2289
+ * Delay send of the voice, used for drum parts, otherwise 1.
2300
2290
  */
2301
- protected dataOverridden: boolean;
2291
+ delaySend: number;
2302
2292
  /**
2303
- * The compressed sample data if the sample has been compressed.
2293
+ * Exclusive class number for hi-hats etc.
2304
2294
  */
2305
- protected compressedData?: Uint8Array;
2295
+ exclusiveClass: number;
2306
2296
  /**
2307
- * The sample's audio data.
2297
+ * In timecents, where zero means disabled (use the modulatedGenerators table).
2298
+ * Used for exclusive notes and killing notes.
2308
2299
  */
2309
- protected audioData?: Float32Array;
2300
+ overrideReleaseVolEnv: number;
2301
+ vibLfoPhase: number;
2302
+ vibLfoStartTime: number;
2303
+ modLfoPhase: number;
2304
+ modLfoStartTime: number;
2305
+ constructor(sampleRate: number);
2310
2306
  /**
2311
- * The basic representation of a sample
2312
- * @param sampleName The sample's name
2313
- * @param sampleRate The sample's rate in Hz
2314
- * @param originalKey The sample's pitch as a MIDI note number
2315
- * @param pitchCorrection The sample's pitch correction in cents
2316
- * @param sampleType The sample's type, an enum that can indicate SF3
2317
- * @param loopStart The sample's loop start relative to the sample start in sample points
2318
- * @param loopEnd The sample's loop end relative to the sample start in sample points
2307
+ * Releases the voice as exclusiveClass.
2319
2308
  */
2320
- constructor(sampleName: string, sampleRate: number, originalKey: number, pitchCorrection: number, sampleType: SampleType, loopStart: number, loopEnd: number);
2309
+ exclusiveRelease(currentTime: number, minExclusiveLength?: number): void;
2321
2310
  /**
2322
- * Indicates if the sample is compressed using vorbis SF3.
2311
+ * Stops the voice
2312
+ * @param currentTime
2313
+ * @param minNoteLength minimum note length in seconds
2323
2314
  */
2324
- get isCompressed(): boolean;
2315
+ releaseVoice(currentTime: number, minNoteLength?: number): void;
2316
+ setup(currentTime: number, channel: number, midiNote: number, velocity: number, realKey: number): void;
2317
+ }
2318
+
2319
+ declare class ModulatorSource {
2325
2320
  /**
2326
- * If the sample is linked to another sample.
2321
+ * If this field is set to false, the controller should be mapped with a minimum value of 0 and a maximum value of 1. This is also
2322
+ * called Unipolar. Thus, it behaves similar to the Modulation Wheel controller of the MIDI specification.
2323
+ *
2324
+ * If this field is set to true, the controller sound be mapped with a minimum value of -1 and a maximum value of 1. This is also
2325
+ * called Bipolar. Thus, it behaves similar to the Pitch Wheel controller of the MIDI specification.
2327
2326
  */
2328
- get isLinked(): boolean;
2327
+ isBipolar: boolean;
2329
2328
  /**
2330
- * The sample's use count
2329
+ * If this field is set true, the direction of the controller should be from the maximum value to the minimum value. So, for
2330
+ * example, if the controller source is Key Number, then a Key Number value of 0 corresponds to the maximum possible
2331
+ * controller output, and the Key Number value of 127 corresponds to the minimum possible controller input.
2331
2332
  */
2332
- get useCount(): number;
2333
+ isNegative: boolean;
2333
2334
  /**
2334
- * Get raw data for writing the file, either a compressed bit stream or signed 16-bit little endian PCM data.
2335
- * @param allowVorbis if vorbis file data is allowed.
2336
- * @return either s16le or vorbis data.
2335
+ * The index of the source.
2336
+ * It can point to one of the MIDI controllers or one of the predefined sources, depending on the 'isCC' flag.
2337
2337
  */
2338
- getRawData(allowVorbis: boolean): Uint8Array;
2338
+ index: ModulatorSourceIndex;
2339
2339
  /**
2340
- * Resamples the audio data to a given sample rate.
2340
+ * If this field is set to true, the MIDI Controller Palette is selected. The ‘index’ field value corresponds to one of the 128
2341
+ * MIDI Continuous Controller messages as defined in the MIDI specification.
2341
2342
  */
2342
- resampleData(newSampleRate: number): void;
2343
+ isCC: boolean;
2343
2344
  /**
2344
- * Compresses the audio data
2345
- * @param encodeVorbis the compression function to use when compressing
2345
+ * This field specifies how the minimum value approaches the maximum value.
2346
2346
  */
2347
- compressSample(encodeVorbis: SampleEncodingFunction): Promise<void>;
2347
+ curveType: ModulatorCurveType;
2348
+ constructor(index?: ModulatorSourceIndex, curveType?: ModulatorCurveType, isCC?: boolean, isBipolar?: boolean, isNegative?: boolean);
2349
+ private get sourceName();
2350
+ private get curveTypeName();
2351
+ static fromSourceEnum(sourceEnum: number): ModulatorSource;
2348
2352
  /**
2349
- * Sets the sample type and unlinks if needed.
2350
- * @param type The type to set it to.
2353
+ * Copies the modulator source.
2354
+ * @param source The source to copy from.
2355
+ * @returns the copied source.
2351
2356
  */
2352
- setSampleType(type: SampleType): void;
2357
+ static copyFrom(source: ModulatorSource): ModulatorSource;
2358
+ toString(): string;
2359
+ toSourceEnum(): number;
2360
+ isIdentical(source: ModulatorSource): boolean;
2353
2361
  /**
2354
- * Unlinks the sample from its stereo link if it has any.
2362
+ * Gets the current value from this source.
2363
+ * @param midiControllers The MIDI controller + modulator source array.
2364
+ * @param pitchWheel the pitch wheel value, as channel determines if it's a per-note or a global value.
2365
+ * @param voice The voice to get the data for.
2355
2366
  */
2356
- unlinkSample(): void;
2367
+ getValue(midiControllers: Int16Array, pitchWheel: number, voice: Voice): number;
2368
+ }
2369
+
2370
+ declare class Modulator {
2357
2371
  /**
2358
- * Links a stereo sample.
2359
- * @param sample the sample to link to.
2360
- * @param type either left, right or linked.
2372
+ * The generator destination of this modulator.
2361
2373
  */
2362
- setLinkedSample(sample: BasicSample, type: SampleType): void;
2374
+ destination: GeneratorType;
2363
2375
  /**
2364
- * Links the sample to a given instrument
2365
- * @param instrument the instrument to link to
2376
+ * The transform amount for this modulator.
2366
2377
  */
2367
- linkTo(instrument: BasicInstrument): void;
2378
+ transformAmount: number;
2368
2379
  /**
2369
- * Unlinks the sample from a given instrument
2370
- * @param instrument the instrument to unlink from
2380
+ * The transform type for this modulator.
2371
2381
  */
2372
- unlinkFrom(instrument: BasicInstrument): void;
2382
+ transformType: ModulatorTransformType;
2373
2383
  /**
2374
- * Get the float32 audio data.
2375
- * Note that this either decodes the compressed data or passes the ready sampleData.
2376
- * If neither are set then it will throw an error!
2377
- * @returns the audio data
2384
+ * The primary source of this modulator.
2378
2385
  */
2379
- getAudioData(): Float32Array;
2386
+ readonly primarySource: ModulatorSource;
2380
2387
  /**
2381
- * Replaces the audio data *in-place*.
2382
- * @param audioData The new audio data as Float32.
2383
- * @param sampleRate The new sample rate, in Hertz.
2388
+ * The secondary source of this modulator.
2384
2389
  */
2385
- setAudioData(audioData: Float32Array, sampleRate: number): void;
2390
+ readonly secondarySource: ModulatorSource;
2386
2391
  /**
2387
- * Replaces the audio with a compressed data sample and flags the sample as compressed
2388
- * @param data the new compressed data
2392
+ * Creates a new SF2 Modulator
2389
2393
  */
2390
- setCompressedData(data: Uint8Array): void;
2394
+ constructor(primarySource?: ModulatorSource, secondarySource?: ModulatorSource, destination?: GeneratorType, amount?: number, transformType?: ModulatorTransformType);
2395
+ private get destinationName();
2391
2396
  /**
2392
- * Encodes s16le sample
2393
- * @return the encoded data
2397
+ * Checks if the pair of modulators is identical (in SF2 terms)
2398
+ * @param mod1 modulator 1
2399
+ * @param mod2 modulator 2
2400
+ * @param checkAmount if the amount should be checked too.
2401
+ * @returns if they are identical
2394
2402
  */
2395
- protected encodeS16LE(): IndexedByteArray;
2403
+ static isIdentical(mod1: Modulator, mod2: Modulator, checkAmount?: boolean): boolean;
2396
2404
  /**
2397
- * Decode binary vorbis into a float32 pcm
2405
+ * Copies a modulator.
2406
+ * @param mod The modulator to copy.
2407
+ * @returns The copied modulator.
2398
2408
  */
2399
- protected decodeVorbis(): Float32Array;
2400
- }
2401
- declare class EmptySample extends BasicSample {
2409
+ static copyFrom(mod: Modulator): Modulator;
2410
+ toString(): string;
2411
+ write(modData: IndexedByteArray, indexes?: SoundFontWriteIndexes): void;
2402
2412
  /**
2403
- * A simplified class for creating samples.
2413
+ * Sums transform and create a NEW modulator
2414
+ * @param modulator the modulator to sum with
2415
+ * @returns the new modulator
2404
2416
  */
2405
- constructor();
2417
+ sumTransform(modulator: Modulator): Modulator;
2406
2418
  }
2407
2419
 
2408
2420
  /**
@@ -2805,7 +2817,7 @@ declare class DynamicModulatorSystem {
2805
2817
  * The current dynamic modulator list.
2806
2818
  */
2807
2819
  modulatorList: {
2808
- mod: Modulator;
2820
+ mod: VoiceModulator;
2809
2821
  id: string;
2810
2822
  }[];
2811
2823
  active: boolean;
@@ -3488,6 +3500,7 @@ declare class MIDIChannel {
3488
3500
  * A small optimization that disables applying overrides until at least one is set.
3489
3501
  */
3490
3502
  protected generatorOverridesEnabled: boolean;
3503
+ protected readonly computeModulator: (voice: Voice, pitchWheel: number, modulatorIndex: number) => number;
3491
3504
  protected readonly computeModulators: (voice: Voice, sourceUsesCC?: 0 | 1 | -1 | undefined, sourceIndex?: number | undefined) => void;
3492
3505
  /**
3493
3506
  * For tracking voice count changes
@@ -5066,14 +5079,4 @@ declare class SpessaSynthSequencer {
5066
5079
  protected sendMIDIPitchWheel(channel: number, pitch: number): void;
5067
5080
  }
5068
5081
 
5069
- declare class SoundBankLoader {
5070
- /**
5071
- * Loads a sound bank from a file buffer.
5072
- * @param buffer The binary file buffer to load.
5073
- * @returns The loaded sound bank, a BasicSoundBank instance.
5074
- */
5075
- static fromArrayBuffer(buffer: ArrayBuffer): BasicSoundBank;
5076
- private static loadDLS;
5077
- }
5078
-
5079
5082
  export { ALL_CHANNELS_OR_DIFFERENT_ACTION, BasicGlobalZone, BasicInstrument, BasicInstrumentZone, BasicMIDI, BasicPreset, BasicPresetZone, BasicSample, BasicSoundBank, BasicZone, CONTROLLER_TABLE_SIZE, CUSTOM_CONTROLLER_TABLE_SIZE, type CachedVoiceList, type ChannelPressureCallback, type ChannelProperty, type ChannelPropertyChangeCallback, ChannelSnapshot, type ChorusProcessor, type ChorusProcessorSnapshot, type ControllerChangeCallback, type CustomController, DEFAULT_MASTER_PARAMETERS, DEFAULT_PERCUSSION, DEFAULT_WAV_WRITE_OPTIONS, type DLSChunkFourCC, type DLSDestination, type DLSInfoFourCC, type DLSLoop, type DLSLoopType, DLSLoopTypes, type DLSSource, type DLSTransform, type DLSWriteOptions, type DataEntryState, type DelayProcessor, type DelayProcessorSnapshot, type DesiredChannelTranspose, type DesiredControllerChange, type DesiredProgramChange, type DrumChangeCallback, type EffectChangeCallback, EmptySample, type FourCC, GENERATORS_AMOUNT, Generator, type GeneratorType, type GenericBankInfoFourCC, type GenericRIFFFourCC, type GenericRange, IndexedByteArray, type InsertionProcessor, type InsertionProcessorConstructor, type InsertionProcessorSnapshot, type InterpolationType, KeyModifier, MAX_GENERATOR, MIDIBuilder, type MIDIController, type MIDIFormat, type MIDILoop, type MIDILoopType, MIDIMessage, type MIDIMessageType, type MIDIPatch, type MIDIPatchNamed, MIDIPatchTools, MIDITrack, type MasterParameterChangeCallback, type MasterParameterType, Modulator, type ModulatorCurveType, ModulatorSource, type ModulatorSourceEnum, type ModulatorSourceIndex, type ModulatorTransformType, type MuteChannelCallback, NON_CC_INDEX_OFFSET, type NoteOffCallback, type NoteOnCallback, type NoteTime, type PitchWheelCallback, type PolyPressureCallback, type PresetList, type PresetListEntry, type ProgramChangeCallback, type ProgressFunction, type RMIDIWriteOptions, type RMIDInfoData, type RMIDInfoFourCC, type ReverbProcessor, type ReverbProcessorSnapshot, type SF2ChunkFourCC, type SF2InfoFourCC, type SF2VersionTag, type SampleEncodingFunction, type SampleLoopingMode, type SampleType, type SequencerEvent, type SequencerEventData, type SoundBankErrorCallback, type SoundBankInfoData, type SoundBankInfoFourCC, SoundBankLoader, type SoundBankManagerListEntry, type SoundFont2WriteOptions, SpessaSynthCoreUtils, SpessaSynthLogging, SpessaSynthProcessor, SpessaSynthSequencer, type StopAllCallback, type SynthMethodOptions, type SynthProcessorEvent, type SynthProcessorEventData, type SynthProcessorOptions, type SynthSystem, SynthesizerSnapshot, type TempoChange, type VoiceParameters, type WaveMetadata, type WaveWriteOptions, audioToWav, customControllers, customResetArray, dataEntryStates, defaultGeneratorValues, defaultMIDIControllerValues, dlsDestinations, dlsSources, drumReverbResetArray, generatorLimits, generatorTypes, interpolationTypes, midiControllers, midiMessageTypes, modulatorCurveTypes, modulatorSources, modulatorTransformTypes, sampleTypes, setResetValue };