smplr 0.21.0 → 0.22.0

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
@@ -57,7 +57,7 @@ wav.downloadWav("arpeggio.wav");
57
57
 
58
58
  See demo: https://danigb.github.io/smplr/
59
59
 
60
- `smplr` is approaching 1.0. The 0.21.0 release is the **1.0 candidate** — the documented surface is intended to ship unchanged into 1.0; the formal stability commitment lands when a handful of coordinated sibling tickets are in (see the 0.21.0 [CHANGELOG](https://github.com/danigb/smplr/blob/main/CHANGELOG.md) entry).
60
+ `smplr` is approaching 1.0. The 0.22.0 release lands the final batch of pre-1.0 API work every documented `new X(ctx, opts)` keeps working, and the documented surface is intended to ship unchanged into 1.0. The formal stability commitment lands once the narrow `loader`/`scheduler` public interfaces sibling ticket is in (see [CHANGELOG](https://github.com/danigb/smplr/blob/main/CHANGELOG.md)).
61
61
 
62
62
  > **Upgrading from an earlier 0.x?** No code changes are required — every documented `new X(ctx, opts)` keeps working. New code should drop the `new` (`X(ctx, opts)`) and prefer `await x.ready` over `await x.load`.
63
63
 
@@ -291,14 +291,42 @@ If `loop` is true but `loopStart` or `loopEnd` are not specified, 0 and total du
291
291
 
292
292
  #### Change volume
293
293
 
294
- Instrument `output` attribute represents the main output of the instrument. `output.setVolume` method accepts a number where 0 means no volume, and 127 is max volume without amplification:
294
+ Instrument `output` attribute represents the main output of the instrument. The `output.volume` getter/setter accepts a number where 0 means no volume, and 127 is max volume without amplification:
295
295
 
296
296
  ```js
297
- piano.output.setVolume(80);
297
+ piano.output.volume = 80;
298
+ piano.output.volume; // => 80
298
299
  ```
299
300
 
301
+ `output.setVolume(n)` is kept as a deprecated alias and continues to work.
302
+
300
303
  ⚠️ `volume` is global to the instrument, but `velocity` is specific for each note.
301
304
 
305
+ #### MIDI CC
306
+
307
+ Set and read MIDI Control Change values on the instrument:
308
+
309
+ ```js
310
+ piano.setCC(64, 127); // sustain pedal on
311
+ piano.getCC(64); // => 127
312
+ piano.setCC(64, 0); // sustain pedal off
313
+ ```
314
+
315
+ Unset CCs default to `0` (matches MIDI's "undefined controller defaults to 0" convention).
316
+
317
+ #### Disposing
318
+
319
+ When you're done with an instrument, call `dispose()` to stop all voices, tear down the audio graph, and stop the scheduler. The instance must not be used after this call.
320
+
321
+ ```js
322
+ useEffect(() => {
323
+ const piano = SplendidGrandPiano(context);
324
+ return () => piano.dispose();
325
+ }, []);
326
+ ```
327
+
328
+ `disconnect()` is kept as a deprecated alias and continues to work.
329
+
302
330
  #### Events
303
331
 
304
332
  Two events are supported `onStart` and `onEnded`. Both callbacks will receive as parameter started note.
@@ -345,12 +373,14 @@ const piano = SplendidGrandPiano(context, { volume });
345
373
  piano.output.addEffect("reverb", reverb, 0.2);
346
374
  ```
347
375
 
348
- To change the mix level, use `output.sendEffect(name, mix)`:
376
+ To change the mix level, use `output.setEffectMix(name, mix)`:
349
377
 
350
378
  ```js
351
- piano.output.sendEffect("reverb", 0.5);
379
+ piano.output.setEffectMix("reverb", 0.5);
352
380
  ```
353
381
 
382
+ `output.sendEffect(name, mix)` is kept as a deprecated alias and continues to work.
383
+
354
384
  ### Cache requests
355
385
 
356
386
  The default sample sets are hosted on GitHub Pages, which rate-limits requests per second. That can be a problem, especially in a development environment with hot reload (most React frameworks).
@@ -643,6 +673,22 @@ This will download a WAV file you can attach to your issue or pull request.
643
673
 
644
674
  ## Instruments
645
675
 
676
+ ### Available instruments
677
+
678
+ Each instrument family exposes a synchronous helper that returns the names you can pass to its factory:
679
+
680
+ | Factory | Names helper |
681
+ |---|---|
682
+ | `Soundfont` | `getSoundfontNames(): string[]` |
683
+ | `ElectricPiano` | `getElectricPianoNames(): string[]` |
684
+ | `Mallet` | `getMalletNames(): string[]` |
685
+ | `Mellotron` | `getMellotronNames(): string[]` |
686
+ | `DrumMachine` | `getDrumMachineNames(): string[]` |
687
+ | `Smolken` | `getSmolkenNames(): string[]` |
688
+ | `Versilian` | `getVersilianInstruments(): Promise<string[]>` |
689
+
690
+ `getVersilianInstruments` is async because the catalog is fetched from the network on first call (cached thereafter).
691
+
646
692
  ### Sampler
647
693
 
648
694
  An audio buffer sampler. Pass a `buffers` object with the files to be load:
package/dist/index.d.mts CHANGED
@@ -17,15 +17,20 @@ type OutputChannel = Omit<Channel, "input">;
17
17
  declare class Channel {
18
18
  #private;
19
19
  readonly context: BaseAudioContext;
20
+ /** @deprecated Use `output.volume = n` instead. */
20
21
  readonly setVolume: (vol: number) => void;
21
22
  readonly input: AudioNode;
22
23
  constructor(context: BaseAudioContext, options?: Partial<ChannelConfig>);
24
+ get volume(): number;
25
+ set volume(value: number);
23
26
  get pan(): number;
24
27
  set pan(value: number);
25
28
  addInsert(effect: AudioNode | AudioInsert): void;
26
29
  addEffect(name: string, effect: AudioNode | {
27
30
  input: AudioNode;
28
31
  }, mixValue: number): void;
32
+ setEffectMix(name: string, mix: number): void;
33
+ /** @deprecated Use `setEffectMix(name, mix)` instead. */
29
34
  sendEffect(name: string, mix: number): void;
30
35
  disconnect(): void;
31
36
  }
@@ -110,6 +115,8 @@ type SmplrSamples = {
110
115
  * The top-level smplr.json descriptor. Passed to the Smplr constructor.
111
116
  */
112
117
  type SmplrJson = {
118
+ /** Schema version. Omit for the current format. Reserved for future migrations. */
119
+ smplr?: "1.0";
113
120
  meta?: {
114
121
  name?: string;
115
122
  description?: string;
@@ -287,6 +294,19 @@ interface Smplr {
287
294
  start(event: NoteEvent): StopFn;
288
295
  stop(target?: StopTarget): void;
289
296
  setCC(cc: number, value: number): void;
297
+ /**
298
+ * Read the latest value set via `setCC`. Returns `0` for any CC that has
299
+ * not been set (matches MIDI's "undefined controller defaults to 0" convention).
300
+ */
301
+ getCC(cc: number): number;
302
+ /**
303
+ * Stop all voices, dispose the output channel, and stop the scheduler.
304
+ * The instance must not be used after this call — subsequent `start`/`stop`/
305
+ * `setCC`/`getCC`/`setControlValue`/`loadInstrument` calls throw. Subsequent
306
+ * `dispose()` calls are no-ops.
307
+ */
308
+ dispose(): void;
309
+ /** @deprecated Use `dispose()` instead. */
290
310
  disconnect(): void;
291
311
  }
292
312
  /**
@@ -406,6 +426,8 @@ declare const DrumMachine: InstrumentFactory<Partial<DrumMachineConfig & {
406
426
  velocity?: number;
407
427
  onLoadProgress?: (progress: LoadProgress) => void;
408
428
  }>, DrumMachineExtras>;
429
+ /** Instance type returned by the {@link DrumMachine} factory. */
430
+ type DrumMachine = ReturnType<typeof DrumMachine>;
409
431
  /**
410
432
  * Convert a DrumMachineInstrument to a SmplrJson descriptor.
411
433
  *
@@ -482,22 +504,6 @@ declare function audioBufferToWav16(buffer: AudioBuffer): Blob;
482
504
  */
483
505
  declare function trimSilence(buffer: AudioBuffer): AudioBuffer;
484
506
 
485
- /**
486
- * Given a list of [midi, sampleName] pairs, return one entry per sample with
487
- * a keyRange that covers all MIDI notes closer to that sample than to any
488
- * neighbour. The first sample extends down to 0; the last extends up to 127.
489
- *
490
- * The boundary between two adjacent samples A and B (A < B) is placed at
491
- * `floor((A + B) / 2)`, matching the behaviour of the old `findNearestMidiInLayer`
492
- * which always resolved ties in favour of the lower sample.
493
- */
494
- type SpreadResult = {
495
- keyRange: [number, number];
496
- pitch: number;
497
- sample: string;
498
- };
499
- declare function spreadKeyRanges(samples: [number, string][]): SpreadResult[];
500
-
501
507
  /**
502
508
  * TransportClock
503
509
  *
@@ -715,6 +721,8 @@ declare const ElectricPiano: InstrumentFactory<Partial<{
715
721
  level: (value: number) => void;
716
722
  }>;
717
723
  }>;
724
+ /** Instance type returned by the {@link ElectricPiano} factory. */
725
+ type ElectricPiano = ReturnType<typeof ElectricPiano>;
718
726
 
719
727
  declare function getVersilianInstruments(): Promise<string[]>;
720
728
  type VersilianConfig = {
@@ -739,6 +747,8 @@ declare const Versilian: InstrumentFactory<Partial<VersilianConfig & {
739
747
  velocity?: number;
740
748
  onLoadProgress?: (progress: LoadProgress) => void;
741
749
  }>, {}>;
750
+ /** Instance type returned by the {@link Versilian} factory. */
751
+ type Versilian = ReturnType<typeof Versilian>;
742
752
  /**
743
753
  * Fetch the SFZ for a VCSL instrument and load it into `smplr`. Shared by
744
754
  * the {@link Versilian} and {@link Mallet} factories — not exported from the
@@ -746,14 +756,15 @@ declare const Versilian: InstrumentFactory<Partial<VersilianConfig & {
746
756
  */
747
757
  declare function loadVersilianInstrument(smplr: PluginSmplr, options: VersilianOptions): Promise<void>;
748
758
 
749
- declare function getMalletNames(): MalletName[];
759
+ declare function getMalletNames(): string[];
750
760
  declare const Mallet: InstrumentFactory<Partial<VersilianConfig & {
751
761
  destination?: AudioNode;
752
762
  volume?: number;
753
763
  velocity?: number;
754
764
  onLoadProgress?: (progress: LoadProgress) => void;
755
765
  }>, {}>;
756
- type MalletName = keyof typeof NAME_TO_PATH;
766
+ /** Instance type returned by the {@link Mallet} factory. */
767
+ type Mallet = ReturnType<typeof Mallet>;
757
768
  declare const NAME_TO_PATH: Record<string, string | undefined>;
758
769
 
759
770
  declare function getMellotronNames(): string[];
@@ -775,6 +786,8 @@ declare const Mellotron: InstrumentFactory<Partial<MellotronConfig & {
775
786
  decayTime?: number;
776
787
  onLoadProgress?: (progress: LoadProgress) => void;
777
788
  }>, {}>;
789
+ /** Instance type returned by the {@link Mellotron} factory. */
790
+ type Mellotron = ReturnType<typeof Mellotron>;
778
791
  type MellotronJsonConfig = {
779
792
  instrument: string;
780
793
  variation?: string;
@@ -819,10 +832,6 @@ type SamplerConfig = {
819
832
  volumeToGain: (volume: number) => number;
820
833
  onLoadProgress?: (progress: LoadProgress) => void;
821
834
  };
822
- /**
823
- * A Sampler instrument.
824
- */
825
- declare const Sampler: InstrumentFactory<Partial<SamplerConfig>, {}>;
826
835
  type SamplerJsonOptions = Pick<SamplerConfig, "decayTime" | "lpfCutoffHz" | "detune">;
827
836
  type InternalConvertResult = {
828
837
  json: SmplrJson;
@@ -840,6 +849,12 @@ type InternalConvertResult = {
840
849
  * - String URL values → urlMap (fetched asynchronously by caller).
841
850
  */
842
851
  declare function samplerToSmplrJson(source: Record<string | number, string | AudioBuffer>, options?: Partial<SamplerJsonOptions>): InternalConvertResult;
852
+ /**
853
+ * A Sampler instrument.
854
+ */
855
+ declare const Sampler: InstrumentFactory<Partial<SamplerConfig>, {}>;
856
+ /** Instance type returned by the {@link Sampler} factory. */
857
+ type Sampler = ReturnType<typeof Sampler>;
843
858
 
844
859
  declare function getSmolkenNames(): string[];
845
860
  type SmolkenConfig = {
@@ -858,6 +873,8 @@ declare const Smolken: InstrumentFactory<Partial<SmolkenConfig & {
858
873
  velocity?: number;
859
874
  onLoadProgress?: (progress: LoadProgress) => void;
860
875
  }>, {}>;
876
+ /** Instance type returned by the {@link Smolken} factory. */
877
+ type Smolken = ReturnType<typeof Smolken>;
861
878
 
862
879
  type LoopData = Record<number, [number, number]>;
863
880
 
@@ -884,6 +901,8 @@ declare const Soundfont: InstrumentFactory<Partial<SoundfontConfig & {
884
901
  velocity?: number;
885
902
  onLoadProgress?: (progress: LoadProgress) => void;
886
903
  }>, {}>;
904
+ /** Instance type returned by the {@link Soundfont} factory. */
905
+ type Soundfont = ReturnType<typeof Soundfont>;
887
906
  /**
888
907
  * Convert a list of note names (with optional loop data) to SmplrJson.
889
908
  * Uses spreadKeyRanges so notes between recorded pitches pitch-shift correctly.
@@ -935,6 +954,8 @@ type Soundfont2SamplerExtras = {
935
954
  loadInstrument(instrumentName: string): Promise<void> | undefined;
936
955
  };
937
956
  declare const Soundfont2Sampler: InstrumentFactory<Soundfont2Options, Soundfont2SamplerExtras>;
957
+ /** Instance type returned by the {@link Soundfont2Sampler} factory. */
958
+ type Soundfont2Sampler = ReturnType<typeof Soundfont2Sampler>;
938
959
 
939
960
  /**
940
961
  * Configuration options for SplendidGrandPiano.
@@ -963,6 +984,8 @@ type SplendidGrandPianoConfig = {
963
984
  };
964
985
  };
965
986
  declare const SplendidGrandPiano: InstrumentFactory<Partial<SplendidGrandPianoConfig>, {}>;
987
+ /** Instance type returned by the {@link SplendidGrandPiano} factory. */
988
+ type SplendidGrandPiano = ReturnType<typeof SplendidGrandPiano>;
966
989
  type PianoJsonOptions = Pick<SplendidGrandPianoConfig, "baseUrl" | "detune" | "decayTime" | "notesToLoad" | "formats">;
967
990
  /**
968
991
  * Convert the LAYERS array and user options into a SmplrJson descriptor.
@@ -975,7 +998,6 @@ type PianoJsonOptions = Pick<SplendidGrandPianoConfig, "baseUrl" | "detune" | "d
975
998
  * covers, replacing the old on-the-fly `findNearestMidiInLayer` logic.
976
999
  */
977
1000
  declare function pianoToSmplrJson(options: PianoJsonOptions): SmplrJson;
978
-
979
1001
  declare const LAYERS: ({
980
1002
  name: string;
981
1003
  vel_range: number[];
@@ -988,4 +1010,4 @@ declare const LAYERS: ({
988
1010
  cutoff?: undefined;
989
1011
  })[];
990
1012
 
991
- export { CacheStorage, DrumMachine, type DrumMachineOptions, ElectricPiano, type ElectricPianoOptions, HttpStorage, Instrument, LAYERS, type LoadProgress, Mallet, Mellotron, type MellotronConfig, type MellotronOptions, NAME_TO_PATH, type NoteEvent, type PlaybackParams, type RenderOfflineOptions, RenderResult, Reverb, SampleLoader, Sampler, type SamplerConfig, Scheduler, Sequencer, type SequencerInstrument, type SequencerNote, type SequencerNoteEvent, type SequencerOptions, Smolken, type SmolkenConfig, type SmolkenOptions, type Smplr, type SmplrGroup, type SmplrJson, type SmplrOptions, type SmplrPlugin, type SmplrRegion, type SmplrSamples, Soundfont, type Soundfont2Options, Soundfont2Sampler, type SoundfontOptions, SplendidGrandPiano, type SplendidGrandPianoConfig, type SpreadResult, type StopFn, type StopTarget, type Storage, type StorageResponse, Versilian, type VersilianConfig, type VersilianOptions, type VoiceParams, audioBufferToWav, audioBufferToWav16, drumMachineToSmplrJson, getDrumMachineNames, getElectricPianoNames, getMalletNames, getMellotronNames, getSmolkenNames, getSoundfontKits, getSoundfontNames, getVersilianInstruments, loadVersilianInstrument, mellotronToSmplrJson, pianoToSmplrJson, renderOffline, samplerToSmplrJson, sf2InstrumentToSmplrJson, soundfontToSmplrJson, spreadKeyRanges, trimSilence };
1013
+ export { CacheStorage, DrumMachine, type DrumMachineOptions, ElectricPiano, type ElectricPianoOptions, HttpStorage, Instrument, LAYERS, type LoadProgress, Mallet, Mellotron, type MellotronConfig, type MellotronOptions, NAME_TO_PATH, type NoteEvent, type PlaybackParams, type RenderOfflineOptions, RenderResult, Reverb, SampleLoader, Sampler, type SamplerConfig, Scheduler, Sequencer, type SequencerInstrument, type SequencerNote, type SequencerNoteEvent, type SequencerOptions, Smolken, type SmolkenConfig, type SmolkenOptions, type Smplr, type SmplrGroup, type SmplrJson, type SmplrOptions, type SmplrPlugin, type SmplrRegion, type SmplrSamples, Soundfont, type Soundfont2Options, Soundfont2Sampler, type SoundfontOptions, SplendidGrandPiano, type SplendidGrandPianoConfig, type StopFn, type StopTarget, type Storage, type StorageResponse, Versilian, type VersilianConfig, type VersilianOptions, type VoiceParams, audioBufferToWav, audioBufferToWav16, drumMachineToSmplrJson, getDrumMachineNames, getElectricPianoNames, getMalletNames, getMellotronNames, getSmolkenNames, getSoundfontKits, getSoundfontNames, getVersilianInstruments, loadVersilianInstrument, mellotronToSmplrJson, pianoToSmplrJson, renderOffline, samplerToSmplrJson, sf2InstrumentToSmplrJson, soundfontToSmplrJson, trimSilence };
package/dist/index.d.ts CHANGED
@@ -17,15 +17,20 @@ type OutputChannel = Omit<Channel, "input">;
17
17
  declare class Channel {
18
18
  #private;
19
19
  readonly context: BaseAudioContext;
20
+ /** @deprecated Use `output.volume = n` instead. */
20
21
  readonly setVolume: (vol: number) => void;
21
22
  readonly input: AudioNode;
22
23
  constructor(context: BaseAudioContext, options?: Partial<ChannelConfig>);
24
+ get volume(): number;
25
+ set volume(value: number);
23
26
  get pan(): number;
24
27
  set pan(value: number);
25
28
  addInsert(effect: AudioNode | AudioInsert): void;
26
29
  addEffect(name: string, effect: AudioNode | {
27
30
  input: AudioNode;
28
31
  }, mixValue: number): void;
32
+ setEffectMix(name: string, mix: number): void;
33
+ /** @deprecated Use `setEffectMix(name, mix)` instead. */
29
34
  sendEffect(name: string, mix: number): void;
30
35
  disconnect(): void;
31
36
  }
@@ -110,6 +115,8 @@ type SmplrSamples = {
110
115
  * The top-level smplr.json descriptor. Passed to the Smplr constructor.
111
116
  */
112
117
  type SmplrJson = {
118
+ /** Schema version. Omit for the current format. Reserved for future migrations. */
119
+ smplr?: "1.0";
113
120
  meta?: {
114
121
  name?: string;
115
122
  description?: string;
@@ -287,6 +294,19 @@ interface Smplr {
287
294
  start(event: NoteEvent): StopFn;
288
295
  stop(target?: StopTarget): void;
289
296
  setCC(cc: number, value: number): void;
297
+ /**
298
+ * Read the latest value set via `setCC`. Returns `0` for any CC that has
299
+ * not been set (matches MIDI's "undefined controller defaults to 0" convention).
300
+ */
301
+ getCC(cc: number): number;
302
+ /**
303
+ * Stop all voices, dispose the output channel, and stop the scheduler.
304
+ * The instance must not be used after this call — subsequent `start`/`stop`/
305
+ * `setCC`/`getCC`/`setControlValue`/`loadInstrument` calls throw. Subsequent
306
+ * `dispose()` calls are no-ops.
307
+ */
308
+ dispose(): void;
309
+ /** @deprecated Use `dispose()` instead. */
290
310
  disconnect(): void;
291
311
  }
292
312
  /**
@@ -406,6 +426,8 @@ declare const DrumMachine: InstrumentFactory<Partial<DrumMachineConfig & {
406
426
  velocity?: number;
407
427
  onLoadProgress?: (progress: LoadProgress) => void;
408
428
  }>, DrumMachineExtras>;
429
+ /** Instance type returned by the {@link DrumMachine} factory. */
430
+ type DrumMachine = ReturnType<typeof DrumMachine>;
409
431
  /**
410
432
  * Convert a DrumMachineInstrument to a SmplrJson descriptor.
411
433
  *
@@ -482,22 +504,6 @@ declare function audioBufferToWav16(buffer: AudioBuffer): Blob;
482
504
  */
483
505
  declare function trimSilence(buffer: AudioBuffer): AudioBuffer;
484
506
 
485
- /**
486
- * Given a list of [midi, sampleName] pairs, return one entry per sample with
487
- * a keyRange that covers all MIDI notes closer to that sample than to any
488
- * neighbour. The first sample extends down to 0; the last extends up to 127.
489
- *
490
- * The boundary between two adjacent samples A and B (A < B) is placed at
491
- * `floor((A + B) / 2)`, matching the behaviour of the old `findNearestMidiInLayer`
492
- * which always resolved ties in favour of the lower sample.
493
- */
494
- type SpreadResult = {
495
- keyRange: [number, number];
496
- pitch: number;
497
- sample: string;
498
- };
499
- declare function spreadKeyRanges(samples: [number, string][]): SpreadResult[];
500
-
501
507
  /**
502
508
  * TransportClock
503
509
  *
@@ -715,6 +721,8 @@ declare const ElectricPiano: InstrumentFactory<Partial<{
715
721
  level: (value: number) => void;
716
722
  }>;
717
723
  }>;
724
+ /** Instance type returned by the {@link ElectricPiano} factory. */
725
+ type ElectricPiano = ReturnType<typeof ElectricPiano>;
718
726
 
719
727
  declare function getVersilianInstruments(): Promise<string[]>;
720
728
  type VersilianConfig = {
@@ -739,6 +747,8 @@ declare const Versilian: InstrumentFactory<Partial<VersilianConfig & {
739
747
  velocity?: number;
740
748
  onLoadProgress?: (progress: LoadProgress) => void;
741
749
  }>, {}>;
750
+ /** Instance type returned by the {@link Versilian} factory. */
751
+ type Versilian = ReturnType<typeof Versilian>;
742
752
  /**
743
753
  * Fetch the SFZ for a VCSL instrument and load it into `smplr`. Shared by
744
754
  * the {@link Versilian} and {@link Mallet} factories — not exported from the
@@ -746,14 +756,15 @@ declare const Versilian: InstrumentFactory<Partial<VersilianConfig & {
746
756
  */
747
757
  declare function loadVersilianInstrument(smplr: PluginSmplr, options: VersilianOptions): Promise<void>;
748
758
 
749
- declare function getMalletNames(): MalletName[];
759
+ declare function getMalletNames(): string[];
750
760
  declare const Mallet: InstrumentFactory<Partial<VersilianConfig & {
751
761
  destination?: AudioNode;
752
762
  volume?: number;
753
763
  velocity?: number;
754
764
  onLoadProgress?: (progress: LoadProgress) => void;
755
765
  }>, {}>;
756
- type MalletName = keyof typeof NAME_TO_PATH;
766
+ /** Instance type returned by the {@link Mallet} factory. */
767
+ type Mallet = ReturnType<typeof Mallet>;
757
768
  declare const NAME_TO_PATH: Record<string, string | undefined>;
758
769
 
759
770
  declare function getMellotronNames(): string[];
@@ -775,6 +786,8 @@ declare const Mellotron: InstrumentFactory<Partial<MellotronConfig & {
775
786
  decayTime?: number;
776
787
  onLoadProgress?: (progress: LoadProgress) => void;
777
788
  }>, {}>;
789
+ /** Instance type returned by the {@link Mellotron} factory. */
790
+ type Mellotron = ReturnType<typeof Mellotron>;
778
791
  type MellotronJsonConfig = {
779
792
  instrument: string;
780
793
  variation?: string;
@@ -819,10 +832,6 @@ type SamplerConfig = {
819
832
  volumeToGain: (volume: number) => number;
820
833
  onLoadProgress?: (progress: LoadProgress) => void;
821
834
  };
822
- /**
823
- * A Sampler instrument.
824
- */
825
- declare const Sampler: InstrumentFactory<Partial<SamplerConfig>, {}>;
826
835
  type SamplerJsonOptions = Pick<SamplerConfig, "decayTime" | "lpfCutoffHz" | "detune">;
827
836
  type InternalConvertResult = {
828
837
  json: SmplrJson;
@@ -840,6 +849,12 @@ type InternalConvertResult = {
840
849
  * - String URL values → urlMap (fetched asynchronously by caller).
841
850
  */
842
851
  declare function samplerToSmplrJson(source: Record<string | number, string | AudioBuffer>, options?: Partial<SamplerJsonOptions>): InternalConvertResult;
852
+ /**
853
+ * A Sampler instrument.
854
+ */
855
+ declare const Sampler: InstrumentFactory<Partial<SamplerConfig>, {}>;
856
+ /** Instance type returned by the {@link Sampler} factory. */
857
+ type Sampler = ReturnType<typeof Sampler>;
843
858
 
844
859
  declare function getSmolkenNames(): string[];
845
860
  type SmolkenConfig = {
@@ -858,6 +873,8 @@ declare const Smolken: InstrumentFactory<Partial<SmolkenConfig & {
858
873
  velocity?: number;
859
874
  onLoadProgress?: (progress: LoadProgress) => void;
860
875
  }>, {}>;
876
+ /** Instance type returned by the {@link Smolken} factory. */
877
+ type Smolken = ReturnType<typeof Smolken>;
861
878
 
862
879
  type LoopData = Record<number, [number, number]>;
863
880
 
@@ -884,6 +901,8 @@ declare const Soundfont: InstrumentFactory<Partial<SoundfontConfig & {
884
901
  velocity?: number;
885
902
  onLoadProgress?: (progress: LoadProgress) => void;
886
903
  }>, {}>;
904
+ /** Instance type returned by the {@link Soundfont} factory. */
905
+ type Soundfont = ReturnType<typeof Soundfont>;
887
906
  /**
888
907
  * Convert a list of note names (with optional loop data) to SmplrJson.
889
908
  * Uses spreadKeyRanges so notes between recorded pitches pitch-shift correctly.
@@ -935,6 +954,8 @@ type Soundfont2SamplerExtras = {
935
954
  loadInstrument(instrumentName: string): Promise<void> | undefined;
936
955
  };
937
956
  declare const Soundfont2Sampler: InstrumentFactory<Soundfont2Options, Soundfont2SamplerExtras>;
957
+ /** Instance type returned by the {@link Soundfont2Sampler} factory. */
958
+ type Soundfont2Sampler = ReturnType<typeof Soundfont2Sampler>;
938
959
 
939
960
  /**
940
961
  * Configuration options for SplendidGrandPiano.
@@ -963,6 +984,8 @@ type SplendidGrandPianoConfig = {
963
984
  };
964
985
  };
965
986
  declare const SplendidGrandPiano: InstrumentFactory<Partial<SplendidGrandPianoConfig>, {}>;
987
+ /** Instance type returned by the {@link SplendidGrandPiano} factory. */
988
+ type SplendidGrandPiano = ReturnType<typeof SplendidGrandPiano>;
966
989
  type PianoJsonOptions = Pick<SplendidGrandPianoConfig, "baseUrl" | "detune" | "decayTime" | "notesToLoad" | "formats">;
967
990
  /**
968
991
  * Convert the LAYERS array and user options into a SmplrJson descriptor.
@@ -975,7 +998,6 @@ type PianoJsonOptions = Pick<SplendidGrandPianoConfig, "baseUrl" | "detune" | "d
975
998
  * covers, replacing the old on-the-fly `findNearestMidiInLayer` logic.
976
999
  */
977
1000
  declare function pianoToSmplrJson(options: PianoJsonOptions): SmplrJson;
978
-
979
1001
  declare const LAYERS: ({
980
1002
  name: string;
981
1003
  vel_range: number[];
@@ -988,4 +1010,4 @@ declare const LAYERS: ({
988
1010
  cutoff?: undefined;
989
1011
  })[];
990
1012
 
991
- export { CacheStorage, DrumMachine, type DrumMachineOptions, ElectricPiano, type ElectricPianoOptions, HttpStorage, Instrument, LAYERS, type LoadProgress, Mallet, Mellotron, type MellotronConfig, type MellotronOptions, NAME_TO_PATH, type NoteEvent, type PlaybackParams, type RenderOfflineOptions, RenderResult, Reverb, SampleLoader, Sampler, type SamplerConfig, Scheduler, Sequencer, type SequencerInstrument, type SequencerNote, type SequencerNoteEvent, type SequencerOptions, Smolken, type SmolkenConfig, type SmolkenOptions, type Smplr, type SmplrGroup, type SmplrJson, type SmplrOptions, type SmplrPlugin, type SmplrRegion, type SmplrSamples, Soundfont, type Soundfont2Options, Soundfont2Sampler, type SoundfontOptions, SplendidGrandPiano, type SplendidGrandPianoConfig, type SpreadResult, type StopFn, type StopTarget, type Storage, type StorageResponse, Versilian, type VersilianConfig, type VersilianOptions, type VoiceParams, audioBufferToWav, audioBufferToWav16, drumMachineToSmplrJson, getDrumMachineNames, getElectricPianoNames, getMalletNames, getMellotronNames, getSmolkenNames, getSoundfontKits, getSoundfontNames, getVersilianInstruments, loadVersilianInstrument, mellotronToSmplrJson, pianoToSmplrJson, renderOffline, samplerToSmplrJson, sf2InstrumentToSmplrJson, soundfontToSmplrJson, spreadKeyRanges, trimSilence };
1013
+ export { CacheStorage, DrumMachine, type DrumMachineOptions, ElectricPiano, type ElectricPianoOptions, HttpStorage, Instrument, LAYERS, type LoadProgress, Mallet, Mellotron, type MellotronConfig, type MellotronOptions, NAME_TO_PATH, type NoteEvent, type PlaybackParams, type RenderOfflineOptions, RenderResult, Reverb, SampleLoader, Sampler, type SamplerConfig, Scheduler, Sequencer, type SequencerInstrument, type SequencerNote, type SequencerNoteEvent, type SequencerOptions, Smolken, type SmolkenConfig, type SmolkenOptions, type Smplr, type SmplrGroup, type SmplrJson, type SmplrOptions, type SmplrPlugin, type SmplrRegion, type SmplrSamples, Soundfont, type Soundfont2Options, Soundfont2Sampler, type SoundfontOptions, SplendidGrandPiano, type SplendidGrandPianoConfig, type StopFn, type StopTarget, type Storage, type StorageResponse, Versilian, type VersilianConfig, type VersilianOptions, type VoiceParams, audioBufferToWav, audioBufferToWav16, drumMachineToSmplrJson, getDrumMachineNames, getElectricPianoNames, getMalletNames, getMellotronNames, getSmolkenNames, getSoundfontKits, getSoundfontNames, getVersilianInstruments, loadVersilianInstrument, mellotronToSmplrJson, pianoToSmplrJson, renderOffline, samplerToSmplrJson, sf2InstrumentToSmplrJson, soundfontToSmplrJson, trimSilence };