spessasynth_lib 4.1.5 → 4.2.1

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/README.md CHANGED
@@ -45,7 +45,6 @@ It allows you to:
45
45
  - **[Detailed documentation:](https://spessasus.github.io/spessasynth_lib/)** _With [examples!](https://spessasus.github.io/spessasynth_lib/getting-started/#examples)_
46
46
  - **Easy to Use:** _Basic setup is just [two lines of code!](https://spessasus.github.io/spessasynth_lib/getting-started/#minimal-setup)_
47
47
  - **No external dependencies:** _Just spessasynth_core!_
48
- - **Reverb and chorus support:** [customizable](https://spessasus.github.io/spessasynth_lib/synthesizer/#effects-configuration-object) and can be used standalone!
49
48
  - **Export audio files** using [OfflineAudioContext](https://developer.mozilla.org/en-US/docs/Web/API/OfflineAudioContext)!
50
49
  - **AudioWorklet synthesizer:**
51
50
  - Runs in a **separate thread** for maximum performance!
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { MIDIPatch, KeyModifier, SoundBankManagerListEntry, SynthProcessorEventData, BasicMIDI, MIDITrack, SequencerEvent, MIDIMessage, SpessaSynthProcessor, SpessaSynthSequencer, SynthProcessorOptions, BasicSoundBank, SoundFont2WriteOptions, DLSWriteOptions, RMIDIWriteOptions, SynthesizerSnapshot, SynthMethodOptions, CustomController, MIDIController, MasterParameterType, SynthProcessorEvent, ChannelSnapshot, ChannelProperty, PresetList, WaveWriteOptions } from 'spessasynth_core';
1
+ import { MIDIPatch, KeyModifier, SoundBankManagerListEntry, SynthProcessorEventData, BasicMIDI, MIDITrack, SequencerEvent, MIDIMessage, SpessaSynthProcessor, SpessaSynthSequencer, SynthProcessorOptions, BasicSoundBank, SoundFont2WriteOptions, DLSWriteOptions, RMIDIWriteOptions, SynthesizerSnapshot, SynthMethodOptions, CustomController, MIDIController, MasterParameterType, SynthProcessorEvent, ChannelProperty, PresetList, WaveWriteOptions } from 'spessasynth_core';
2
2
 
3
3
  declare class WorkletKeyModifierManagerWrapper {
4
4
  private keyModifiers;
@@ -169,7 +169,16 @@ interface SequencerMessageData {
169
169
  getMIDI: null;
170
170
  setSkipToFirstNote: boolean;
171
171
  }
172
- type SequencerReturnMessage = (SequencerEvent & {
172
+ type SequencerReturnMessage = (Exclude<SequencerEvent, {
173
+ type: "songListChange";
174
+ }> & {
175
+ id: number;
176
+ }) | (Extract<SequencerEvent, {
177
+ type: "songListChange";
178
+ }> & {
179
+ data: {
180
+ shuffledSongIndexes: number[];
181
+ };
173
182
  id: number;
174
183
  }) | {
175
184
  type: "getMIDI";
@@ -245,7 +254,7 @@ declare abstract class BasicSynthesizerCore {
245
254
  * @protected
246
255
  */
247
256
  protected alive: boolean;
248
- protected constructor(sampleRate: number, options: SynthProcessorOptions, postMessage: PostMessageSynthCore);
257
+ protected constructor(sampleRate: number, options: Omit<SynthProcessorOptions, "reverbProcessor" | "chorusProcessor" | "delayProcessor">, postMessage: PostMessageSynthCore);
249
258
  protected createNewSequencer(): void;
250
259
  protected postReady<K extends keyof SynthesizerReturn>(type: K, data: SynthesizerReturn[K], transferable?: Transferable[]): void;
251
260
  protected postProgress<K extends keyof SynthesizerProgress>(type: K, data: SynthesizerProgress[K]): void;
@@ -431,11 +440,6 @@ interface BasicSynthesizerMessageData {
431
440
  options: SynthMethodOptions;
432
441
  };
433
442
  ccReset: null;
434
- setChannelVibrato: {
435
- rate: number;
436
- depth: number;
437
- delay: number;
438
- };
439
443
  stopAll: number;
440
444
  muteChannel: boolean;
441
445
  addNewChannel: null;
@@ -518,8 +522,7 @@ interface SynthesizerReturn {
518
522
  startOfflineRender: null;
519
523
  synthesizerSnapshot: SynthesizerSnapshot;
520
524
  renderAudio: {
521
- reverb: [Float32Array, Float32Array];
522
- chorus: [Float32Array, Float32Array];
525
+ effects: [Float32Array, Float32Array];
523
526
  dry: [Float32Array, Float32Array][];
524
527
  };
525
528
  workerSynthWriteFile: {
@@ -540,17 +543,13 @@ interface SynthConfig {
540
543
  */
541
544
  oneOutput: boolean;
542
545
  /**
543
- * If the chorus processor should be initialized during creation.
544
- * Note that setting this to false will not allow it to be used later.
545
- * If you want to enable it at some point, set this to true and set the chorus gain to 0.
546
+ * @deprecated Deprecated parameter, does nothing.
546
547
  */
547
- initializeChorusProcessor: boolean;
548
+ initializeChorusProcessor?: boolean;
548
549
  /**
549
- * If the reverb processor should be initialized during creation.
550
- * Note that setting this to false will not allow it to be used later.
551
- * If you want to enable it at some point, set this to true and set the reverb gain to 0.
550
+ * @deprecated Deprecated parameter, does nothing.
552
551
  */
553
- initializeReverbProcessor: boolean;
552
+ initializeReverbProcessor?: boolean;
554
553
  /**
555
554
  * Custom audio node creation functions for Web Audio wrappers, such as standardized-audio-context.
556
555
  * Pass undefined to use the Web Audio API.
@@ -561,9 +560,6 @@ interface SynthConfig {
561
560
  */
562
561
  enableEventSystem: boolean;
563
562
  }
564
- interface BasicEffectConfig {
565
- null?: null;
566
- }
567
563
  interface AudioNodeCreators {
568
564
  /**
569
565
  * A custom creator for an AudioWorkletNode.
@@ -575,133 +571,6 @@ interface AudioNodeCreators {
575
571
  processorOptions: PassedProcessorParameters;
576
572
  }) => AudioWorkletNode;
577
573
  }
578
- interface ReverbConfig extends BasicEffectConfig {
579
- /**
580
- * The impulse response for the reverb. Pass undefined to use default one.
581
- */
582
- impulseResponse?: AudioBuffer;
583
- }
584
- interface ChorusConfig extends BasicEffectConfig {
585
- /**
586
- * The amount of delay nodes (for each channel) and the corresponding oscillators.
587
- */
588
- nodesAmount: number;
589
- /**
590
- * The initial delay, in seconds.
591
- */
592
- defaultDelay: number;
593
- /**
594
- * The difference between delays in the delay nodes.
595
- */
596
- delayVariation: number;
597
- /**
598
- * The difference of delays between two channels (added to the right channel).
599
- */
600
- stereoDifference: number;
601
- /**
602
- * The initial delay time oscillator frequency, in Hz.
603
- */
604
- oscillatorFrequency: number;
605
- /**
606
- * The difference between frequencies of oscillators, in Hz.
607
- */
608
- oscillatorFrequencyVariation: number;
609
- /**
610
- * How much will oscillator alter the delay in delay nodes, in seconds.
611
- */
612
- oscillatorGain: number;
613
- }
614
-
615
- declare abstract class BasicEffectsProcessor {
616
- readonly input: AudioNode;
617
- protected readonly output: AudioNode;
618
- protected constructor(input: AudioNode, output: AudioNode);
619
- abstract get config(): BasicEffectConfig;
620
- abstract update(config: BasicEffectConfig): void;
621
- /**
622
- * Connects the processor to a given node.
623
- * @param destinationNode The node to connect to.
624
- */
625
- connect(destinationNode: AudioNode): AudioNode;
626
- /**
627
- * Disconnects the processor from a given node.
628
- * @param destinationNode The node to disconnect from.
629
- */
630
- disconnect(destinationNode?: AudioNode): void;
631
- /**
632
- * Disconnects the effect processor.
633
- */
634
- delete(): void;
635
- }
636
-
637
- /**
638
- * Fancy_chorus.js
639
- * purpose: creates a simple chorus effect node
640
- */
641
-
642
- declare class ChorusProcessor extends BasicEffectsProcessor {
643
- private readonly chorusLeft;
644
- private readonly chorusRight;
645
- /**
646
- * Creates a fancy chorus effect.
647
- * @param context The audio context.
648
- * @param config The configuration for the chorus.
649
- */
650
- constructor(context: BaseAudioContext, config?: Partial<ChorusConfig>);
651
- private _config;
652
- get config(): ChorusConfig;
653
- /**
654
- * Updates the chorus with a given config.
655
- * @param chorusConfig The config to use.
656
- */
657
- update(chorusConfig: Partial<ChorusConfig>): void;
658
- /**
659
- * Disconnects and deletes the chorus effect.
660
- */
661
- delete(): void;
662
- private deleteNodes;
663
- private createChorusNode;
664
- }
665
-
666
- declare class ReverbProcessor extends BasicEffectsProcessor {
667
- /**
668
- * Indicates that the reverb is ready.
669
- */
670
- readonly isReady: Promise<AudioBuffer>;
671
- private conv;
672
- /**
673
- * Creates a new reverb processor.
674
- * @param context The context to use.
675
- * @param config The reverb configuration.
676
- */
677
- constructor(context: BaseAudioContext, config?: Partial<ReverbConfig>);
678
- private _config;
679
- get config(): ReverbConfig;
680
- /**
681
- * Updates the reverb with a given config.
682
- * @param config The config to use.
683
- */
684
- update(config: Partial<ReverbConfig>): void;
685
- }
686
-
687
- /**
688
- * Extended synthesizer snapshot to contain effects
689
- */
690
- declare class LibSynthesizerSnapshot extends SynthesizerSnapshot {
691
- /**
692
- * Chorus configuration of this synthesizer.
693
- */
694
- chorusConfig: ChorusConfig;
695
- /**
696
- * Reverb configuration of this synthesizer.
697
- */
698
- reverbConfig: ReverbConfig;
699
- constructor(channelSnapshots: ChannelSnapshot[], masterParameters: MasterParameterType, keyMappings: (KeyModifier | undefined)[][], chorusConfig?: ChorusConfig, reverbConfig?: ReverbConfig);
700
- /**
701
- * Retrieves the SynthesizerSnapshot from the lib snapshot.
702
- */
703
- getCoreSnapshot(): SynthesizerSnapshot;
704
- }
705
574
 
706
575
  declare abstract class BasicSynthesizer {
707
576
  /**
@@ -739,15 +608,15 @@ declare abstract class BasicSynthesizer {
739
608
  */
740
609
  readonly isReady: Promise<unknown>;
741
610
  /**
742
- * Synthesizer's reverb processor.
743
- * Undefined if reverb is disabled.
611
+ * Legacy parameter.
612
+ * @deprecated
744
613
  */
745
- readonly reverbProcessor?: ReverbProcessor;
614
+ readonly reverbProcessor: undefined;
746
615
  /**
747
- * Synthesizer's chorus processor.
748
- * Undefined if chorus is disabled.
616
+ * Legacy parameter.
617
+ * @deprecated
749
618
  */
750
- readonly chorusProcessor?: ChorusProcessor;
619
+ readonly chorusProcessor: undefined;
751
620
  /**
752
621
  * INTERNAL USE ONLY!
753
622
  * @internal
@@ -822,15 +691,14 @@ declare abstract class BasicSynthesizer {
822
691
  /**
823
692
  * Gets a complete snapshot of the synthesizer, effects.
824
693
  */
825
- getSnapshot(): Promise<LibSynthesizerSnapshot>;
694
+ getSnapshot(): Promise<SynthesizerSnapshot>;
826
695
  /**
827
696
  * Adds a new channel to the synthesizer.
828
697
  */
829
698
  addNewChannel(): void;
830
699
  /**
831
- * Sets custom vibrato for the channel.
832
- * @param channel The channel number.
833
- * @param value The vibrato parameters.
700
+ * DEPRECATED, please don't use it!
701
+ * @deprecated
834
702
  */
835
703
  setVibrato(channel: number, value: {
836
704
  delay: number;
@@ -849,6 +717,7 @@ declare abstract class BasicSynthesizer {
849
717
  disconnectIndividualOutputs(audioNodes: AudioNode[]): void;
850
718
  /**
851
719
  * Disables the GS NRPN parameters like vibrato or drum key tuning.
720
+ * @deprecated Deprecated! Please use master parameters
852
721
  */
853
722
  disableGSNPRNParams(): void;
854
723
  /**
@@ -1115,10 +984,6 @@ declare class SeqEventHandler {
1115
984
  }
1116
985
 
1117
986
  declare class Sequencer {
1118
- /**
1119
- * The current MIDI data, with the exclusion of the embedded sound bank and event data.
1120
- */
1121
- midiData?: MIDIData;
1122
987
  /**
1123
988
  * The current MIDI data for all songs, like the midiData property.
1124
989
  */
@@ -1135,6 +1000,10 @@ declare class Sequencer {
1135
1000
  * The synthesizer attached to this sequencer.
1136
1001
  */
1137
1002
  readonly synth: BasicSynthesizer;
1003
+ /**
1004
+ * The current MIDI data, with the exclusion of the embedded sound bank and event data.
1005
+ */
1006
+ midiData?: MIDIData;
1138
1007
  /**
1139
1008
  * The MIDI port to play to.
1140
1009
  */
@@ -1161,13 +1030,21 @@ declare class Sequencer {
1161
1030
  * @param options the sequencer's options.
1162
1031
  */
1163
1032
  constructor(synth: BasicSynthesizer, options?: Partial<SequencerOptions>);
1033
+ private _shuffledSongIndexes;
1034
+ /**
1035
+ * The shuffled song indexes.
1036
+ * This is used when shuffleMode is enabled.
1037
+ */
1038
+ get shuffledSongIndexes(): number[];
1164
1039
  private _songIndex;
1165
1040
  /**
1166
1041
  * The current song number in the playlist.
1042
+ * If shuffle Mode is enabled, this is the index of the shuffled song list.
1167
1043
  */
1168
1044
  get songIndex(): number;
1169
1045
  /**
1170
1046
  * The current song number in the playlist.
1047
+ * If shuffle Mode is enabled, this is the index of the shuffled song list.
1171
1048
  */
1172
1049
  set songIndex(value: number);
1173
1050
  private _currentTempo;
@@ -1216,11 +1093,17 @@ declare class Sequencer {
1216
1093
  set playbackRate(value: number);
1217
1094
  private _shuffleSongs;
1218
1095
  /**
1219
- * Indicates if the song order is random.
1096
+ * Controls if the sequencer should shuffle the songs in the song list.
1097
+ * If true, the sequencer will play the songs in a random order.
1098
+ *
1099
+ * Songs are shuffled on a `loadNewSongList` call.
1220
1100
  */
1221
1101
  get shuffleSongs(): boolean;
1222
1102
  /**
1223
- * Indicates if the song order is random.
1103
+ * Controls if the sequencer should shuffle the songs in the song list.
1104
+ * If true, the sequencer will play the songs in a random order.
1105
+ *
1106
+ * Songs are shuffled on a `loadNewSongList` call.
1224
1107
  */
1225
1108
  set shuffleSongs(value: boolean);
1226
1109
  /**
@@ -1377,4 +1260,4 @@ declare class WebMIDILinkHandler {
1377
1260
 
1378
1261
  declare const DEFAULT_SYNTH_CONFIG: SynthConfig;
1379
1262
 
1380
- export { BasicSynthesizer, ChorusProcessor, DEFAULT_SYNTH_CONFIG, MIDIDeviceHandler, ReverbProcessor, Sequencer, WebMIDILinkHandler, WorkerSynthesizer, WorkerSynthesizerCore, WorkletSynthesizer, audioBufferToWav };
1263
+ export { BasicSynthesizer, DEFAULT_SYNTH_CONFIG, MIDIDeviceHandler, Sequencer, WebMIDILinkHandler, WorkerSynthesizer, WorkerSynthesizerCore, WorkletSynthesizer, audioBufferToWav };