smplr 0.23.0 → 0.25.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 +300 -130
- package/dist/index.d.mts +275 -33
- package/dist/index.d.ts +275 -33
- package/dist/index.js +819 -117
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +811 -117
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -35,6 +35,23 @@ declare class Channel {
|
|
|
35
35
|
disconnect(): void;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Wrap a class so it is callable both as `X(...)` (preferred) and as
|
|
40
|
+
* `new X(...)` (kept for compatibility with pre-1.0 examples). Returns
|
|
41
|
+
* a value with both call and construct signatures.
|
|
42
|
+
*
|
|
43
|
+
* Used by the auxiliary exports (`Sequencer`, `Reverb`, `CacheStorage`,
|
|
44
|
+
* `Scheduler`, `SampleLoader`) to match the dual signature already shipped
|
|
45
|
+
* by `InstrumentFactory`. Instrument factories themselves use the richer
|
|
46
|
+
* `Instrument()` builder instead, which owns option-splitting and the
|
|
47
|
+
* ready-promise lifecycle.
|
|
48
|
+
*/
|
|
49
|
+
type Constructable<A extends unknown[], R> = {
|
|
50
|
+
(...args: A): R;
|
|
51
|
+
/** @deprecated Call as a function: `X(...)` instead of `new X(...)`. */
|
|
52
|
+
new (...args: A): R;
|
|
53
|
+
};
|
|
54
|
+
|
|
38
55
|
type StorageResponse = {
|
|
39
56
|
readonly status: number;
|
|
40
57
|
arrayBuffer(): Promise<ArrayBuffer>;
|
|
@@ -45,11 +62,13 @@ type Storage = {
|
|
|
45
62
|
fetch: (url: string) => Promise<StorageResponse>;
|
|
46
63
|
};
|
|
47
64
|
declare const HttpStorage: Storage;
|
|
48
|
-
declare class
|
|
65
|
+
declare class CacheStorageImpl implements Storage {
|
|
49
66
|
#private;
|
|
50
67
|
constructor(name?: string);
|
|
51
68
|
fetch(url: string): Promise<StorageResponse>;
|
|
52
69
|
}
|
|
70
|
+
declare const CacheStorage: Constructable<[name?: string | undefined], CacheStorageImpl>;
|
|
71
|
+
type CacheStorage = ReturnType<typeof CacheStorage>;
|
|
53
72
|
|
|
54
73
|
/**
|
|
55
74
|
* Inheritable playback parameters. Can appear at global defaults, group, or region level.
|
|
@@ -196,7 +215,7 @@ type VoiceParams = {
|
|
|
196
215
|
* or decoded twice. Multiple Smplr instances can share one SampleLoader by
|
|
197
216
|
* passing it via SmplrOptions.loader.
|
|
198
217
|
*/
|
|
199
|
-
declare class
|
|
218
|
+
declare class SampleLoaderImpl {
|
|
200
219
|
#private;
|
|
201
220
|
constructor(context: BaseAudioContext, options?: {
|
|
202
221
|
storage?: Storage;
|
|
@@ -214,6 +233,10 @@ declare class SampleLoader {
|
|
|
214
233
|
onProgress?: (loaded: number, total: number) => void;
|
|
215
234
|
}): Promise<Map<string, AudioBuffer>>;
|
|
216
235
|
}
|
|
236
|
+
declare const SampleLoader: Constructable<[context: BaseAudioContext, options?: {
|
|
237
|
+
storage?: Storage;
|
|
238
|
+
} | undefined], SampleLoaderImpl>;
|
|
239
|
+
type SampleLoader = ReturnType<typeof SampleLoader>;
|
|
217
240
|
|
|
218
241
|
/**
|
|
219
242
|
* Standalone scheduler. Dispatches NoteEvents immediately when they fall within the
|
|
@@ -221,7 +244,7 @@ declare class SampleLoader {
|
|
|
221
244
|
*
|
|
222
245
|
* Multiple Smplr instances can share a single Scheduler for coordinated timing.
|
|
223
246
|
*/
|
|
224
|
-
declare class
|
|
247
|
+
declare class SchedulerImpl {
|
|
225
248
|
#private;
|
|
226
249
|
constructor(context: BaseAudioContext, options?: {
|
|
227
250
|
lookaheadMs?: number;
|
|
@@ -242,6 +265,11 @@ declare class Scheduler {
|
|
|
242
265
|
*/
|
|
243
266
|
stop(): void;
|
|
244
267
|
}
|
|
268
|
+
declare const Scheduler: Constructable<[context: BaseAudioContext, options?: {
|
|
269
|
+
lookaheadMs?: number;
|
|
270
|
+
intervalMs?: number;
|
|
271
|
+
} | undefined], SchedulerImpl>;
|
|
272
|
+
type Scheduler = ReturnType<typeof Scheduler>;
|
|
245
273
|
|
|
246
274
|
type SmplrOptions = {
|
|
247
275
|
/** Custom storage backend for sample fetching (e.g. CacheStorage). */
|
|
@@ -299,6 +327,19 @@ interface Smplr {
|
|
|
299
327
|
* not been set (matches MIDI's "undefined controller defaults to 0" convention).
|
|
300
328
|
*/
|
|
301
329
|
getCC(cc: number): number;
|
|
330
|
+
/**
|
|
331
|
+
* Set the cents detune applied to every future note. Mutates the instrument's
|
|
332
|
+
* playback defaults in place; takes effect on notes scheduled after the call.
|
|
333
|
+
* In-flight notes are unaffected.
|
|
334
|
+
*/
|
|
335
|
+
setDetune(cents: number): void;
|
|
336
|
+
/**
|
|
337
|
+
* Set whether every future note plays its sample reversed. Mutates the
|
|
338
|
+
* instrument's playback defaults in place. The reversed-buffer cache is
|
|
339
|
+
* populated lazily on demand; no cache invalidation is needed in either
|
|
340
|
+
* direction.
|
|
341
|
+
*/
|
|
342
|
+
setReverse(reverse: boolean): void;
|
|
302
343
|
/**
|
|
303
344
|
* Stop all voices, dispose the output channel, and stop the scheduler.
|
|
304
345
|
* The instance must not be used after this call — subsequent `start`/`stop`/
|
|
@@ -437,6 +478,55 @@ type DrumMachine = ReturnType<typeof DrumMachine>;
|
|
|
437
478
|
*/
|
|
438
479
|
declare function drumMachineToPreset(instrument: DrumMachineInstrument): SmplrPreset;
|
|
439
480
|
|
|
481
|
+
declare const DRUM_ABUSE_PACKS: readonly ["vol1", "vol2", "vol3", "vol4", "vol5"];
|
|
482
|
+
type DrumAbusePackId = (typeof DRUM_ABUSE_PACKS)[number];
|
|
483
|
+
declare function getDrumAbuseMachineNames(): string[];
|
|
484
|
+
declare function getDrumAbuseMachinesForPack(pack: DrumAbusePackId): readonly string[];
|
|
485
|
+
declare function getDrumAbusePackNames(): readonly DrumAbusePackId[];
|
|
486
|
+
declare function getDrumAbuseMachinePack(id: string): DrumAbusePackId | undefined;
|
|
487
|
+
/** Build a full sample URL. Exported so external row-level Sampler use
|
|
488
|
+
* (e.g. the sequencer engine) can share the same URL convention. */
|
|
489
|
+
declare function drumAbuseSampleUrl(pack: DrumAbusePackId, urlPath: string, fileNoExt: string, format?: string, baseUrl?: string): string;
|
|
490
|
+
type DrumAbuseSource = {
|
|
491
|
+
kind: "machine";
|
|
492
|
+
machine: string;
|
|
493
|
+
set?: string;
|
|
494
|
+
} | {
|
|
495
|
+
kind: "pack";
|
|
496
|
+
pack: DrumAbusePackId;
|
|
497
|
+
instrument: string;
|
|
498
|
+
};
|
|
499
|
+
type DrumAbuseConfig = {
|
|
500
|
+
source: DrumAbuseSource;
|
|
501
|
+
baseUrl: string;
|
|
502
|
+
storage: Storage;
|
|
503
|
+
};
|
|
504
|
+
type DrumAbuseOptions = Partial<DrumAbuseConfig & {
|
|
505
|
+
destination?: AudioNode;
|
|
506
|
+
volume?: number;
|
|
507
|
+
pan?: number;
|
|
508
|
+
velocity?: number;
|
|
509
|
+
onLoadProgress?: (progress: LoadProgress) => void;
|
|
510
|
+
}>;
|
|
511
|
+
type DrumAbuseExtras = {
|
|
512
|
+
readonly mode: "machine" | "pack";
|
|
513
|
+
getSampleNames(): string[];
|
|
514
|
+
getGroupNames(): string[];
|
|
515
|
+
getSampleNamesForGroup(groupName: string): string[];
|
|
516
|
+
getMachineId(): string | null;
|
|
517
|
+
getSetPath(): string | null;
|
|
518
|
+
getPackId(): DrumAbusePackId;
|
|
519
|
+
start(event: NoteEvent): StopFn;
|
|
520
|
+
};
|
|
521
|
+
declare const DrumAbuse: InstrumentFactory<Partial<DrumAbuseConfig & {
|
|
522
|
+
destination?: AudioNode;
|
|
523
|
+
volume?: number;
|
|
524
|
+
pan?: number;
|
|
525
|
+
velocity?: number;
|
|
526
|
+
onLoadProgress?: (progress: LoadProgress) => void;
|
|
527
|
+
}>, DrumAbuseExtras>;
|
|
528
|
+
type DrumAbuse = ReturnType<typeof DrumAbuse>;
|
|
529
|
+
|
|
440
530
|
/**
|
|
441
531
|
* The result of an offline render. Provides the raw AudioBuffer and
|
|
442
532
|
* lazy WAV encoding / download convenience methods.
|
|
@@ -534,6 +624,19 @@ type SequencerNote = {
|
|
|
534
624
|
velocity?: number;
|
|
535
625
|
/** Probability (0–100) that this note fires on each pass. Default 100 (always). */
|
|
536
626
|
chance?: number;
|
|
627
|
+
/**
|
|
628
|
+
* Expand into N evenly-spaced sub-notes over `duration`. Requires `duration`;
|
|
629
|
+
* silently ignored if `duration` is omitted. Default 1 (no ratchet). When >1,
|
|
630
|
+
* each sub-note's `noteId` is suffixed with `#0`, `#1`, … so individual
|
|
631
|
+
* ratchet voices can be stopped via `stopNote("id#0")`.
|
|
632
|
+
*/
|
|
633
|
+
ratchet?: number;
|
|
634
|
+
/**
|
|
635
|
+
* Multiplicative velocity decay per ratchet step: each step's velocity is
|
|
636
|
+
* scaled by `(1 - decay) ** step_index`. 0 = constant, 1 = silence by last
|
|
637
|
+
* step. Default 0.
|
|
638
|
+
*/
|
|
639
|
+
ratchetVelocityDecay?: number;
|
|
537
640
|
};
|
|
538
641
|
/**
|
|
539
642
|
* Any instrument the Sequencer can drive.
|
|
@@ -558,10 +661,20 @@ type SequencerNoteEvent = {
|
|
|
558
661
|
noteIndex: number;
|
|
559
662
|
note: SequencerNote;
|
|
560
663
|
};
|
|
664
|
+
/**
|
|
665
|
+
* Time signature as a `{ numerator, denominator }` pair (e.g. `{ numerator: 7, denominator: 8 }`
|
|
666
|
+
* for 7/8). The numerator counts beats per bar; the denominator defines the
|
|
667
|
+
* note value of one beat (4 = quarter note, 8 = eighth note, …).
|
|
668
|
+
*/
|
|
669
|
+
type TimeSignature = {
|
|
670
|
+
numerator: number;
|
|
671
|
+
denominator: number;
|
|
672
|
+
};
|
|
561
673
|
type SequencerOptions = {
|
|
562
674
|
bpm?: number;
|
|
563
675
|
ppq?: number;
|
|
564
|
-
|
|
676
|
+
/** Time signature. Accepts `4` (interpreted as 4/4) or `{ numerator, denominator }`. */
|
|
677
|
+
timeSignature?: number | TimeSignature;
|
|
565
678
|
loop?: boolean;
|
|
566
679
|
loopStart?: string | number;
|
|
567
680
|
loopEnd?: string | number;
|
|
@@ -577,35 +690,128 @@ type SequencerOptions = {
|
|
|
577
690
|
/** Emit a "step" event at this interval. Accepts musical notation or ticks: "16n", "8n", ticks, etc. */
|
|
578
691
|
stepSize?: string | number;
|
|
579
692
|
};
|
|
580
|
-
|
|
693
|
+
/**
|
|
694
|
+
* Per-track options accepted by {@link Sequencer.addTrack} and
|
|
695
|
+
* {@link Sequencer.setPatterns}.
|
|
696
|
+
*/
|
|
697
|
+
type AddTrackOptions = {
|
|
698
|
+
/**
|
|
699
|
+
* Stable track id. Required to address this track via
|
|
700
|
+
* {@link Sequencer.setTrackVolume}, {@link Sequencer.muteTrack},
|
|
701
|
+
* {@link Sequencer.soloTrack}, etc.
|
|
702
|
+
*/
|
|
703
|
+
id?: string;
|
|
704
|
+
/** Per-track humanize. Overrides {@link SequencerOptions.humanize} when set. */
|
|
705
|
+
humanize?: {
|
|
706
|
+
timingMs?: number;
|
|
707
|
+
velocity?: number;
|
|
708
|
+
};
|
|
709
|
+
/** Multiplicative velocity scalar in [0, 1+]. Default 1. */
|
|
710
|
+
volume?: number;
|
|
711
|
+
/** When true, this track does not dispatch any notes. Default false. */
|
|
712
|
+
muted?: boolean;
|
|
713
|
+
/**
|
|
714
|
+
* When true, only soloed tracks dispatch notes. If any track in the pattern
|
|
715
|
+
* is soloed, every non-soloed track is silenced. Default false.
|
|
716
|
+
*/
|
|
717
|
+
solo?: boolean;
|
|
718
|
+
};
|
|
719
|
+
/**
|
|
720
|
+
* Public shape for one pattern accepted by {@link Sequencer.setPatterns}.
|
|
721
|
+
*/
|
|
722
|
+
type PatternInput = {
|
|
723
|
+
tracks: Array<{
|
|
724
|
+
instrument: SequencerInstrument;
|
|
725
|
+
notes: SequencerNote[];
|
|
726
|
+
} & AddTrackOptions>;
|
|
727
|
+
/**
|
|
728
|
+
* Pattern length override in ticks or musical time. Defaults to the longest
|
|
729
|
+
* track in this pattern.
|
|
730
|
+
*/
|
|
731
|
+
loopEnd?: string | number;
|
|
732
|
+
};
|
|
733
|
+
declare class SequencerImpl {
|
|
581
734
|
private readonly _context;
|
|
582
735
|
private readonly _clock;
|
|
583
736
|
private readonly _ppq;
|
|
584
737
|
private _timeSignature;
|
|
585
738
|
private _stepTicks;
|
|
586
|
-
|
|
739
|
+
/**
|
|
740
|
+
* Patterns. Always at least one (the implicit default pattern). Replaced
|
|
741
|
+
* atomically by {@link setPatterns}.
|
|
742
|
+
*/
|
|
743
|
+
private _patterns;
|
|
744
|
+
/** Indices into {@link _patterns} defining playback order. */
|
|
745
|
+
private _chainOrder;
|
|
746
|
+
/** Current position within {@link _chainOrder}. */
|
|
747
|
+
private _chainIndex;
|
|
748
|
+
/**
|
|
749
|
+
* True once {@link setPatterns} has been called. After this point,
|
|
750
|
+
* `addTrack` / `removeTrack` / `clearTracks` throw because the chain shape
|
|
751
|
+
* is owned by the patterns array.
|
|
752
|
+
*/
|
|
753
|
+
private _patternsExplicit;
|
|
587
754
|
private _repeatEvents;
|
|
588
755
|
private _listeners;
|
|
589
756
|
private _loop;
|
|
590
757
|
private _loopStartTick;
|
|
591
|
-
/** null = default to _totalTicks */
|
|
592
|
-
private _loopEndOverride;
|
|
593
758
|
private _lookaheadSec;
|
|
594
759
|
private _intervalMs;
|
|
595
760
|
private _humanize;
|
|
596
761
|
private _intervalId;
|
|
597
762
|
/** AudioContext time high-water mark: notes up to here have been scheduled. */
|
|
598
763
|
private _scheduledThrough;
|
|
599
|
-
/** Computed from track notes; the tick where the last note ends. */
|
|
600
|
-
private _totalTicks;
|
|
601
764
|
/** Guards against scheduling the auto-stop setTimeout more than once. */
|
|
602
765
|
private _endScheduled;
|
|
603
766
|
/** Active voices keyed by noteId, so individual notes can be stopped. */
|
|
604
767
|
private _activeVoices;
|
|
605
768
|
constructor(context: BaseAudioContext, options?: SequencerOptions);
|
|
606
|
-
|
|
769
|
+
/**
|
|
770
|
+
* Add a track to the (implicit, default) pattern. Throws after
|
|
771
|
+
* {@link setPatterns} has been called — use {@link setPatterns} to mutate
|
|
772
|
+
* the chain.
|
|
773
|
+
*/
|
|
774
|
+
addTrack(instrument: SequencerInstrument, notes: SequencerNote[], options?: AddTrackOptions): this;
|
|
607
775
|
removeTrack(instrument: SequencerInstrument): this;
|
|
608
776
|
clearTracks(): this;
|
|
777
|
+
/**
|
|
778
|
+
* Replace the sequencer's patterns. Each pattern owns its own tracks and
|
|
779
|
+
* optional `loopEnd`. After this call, `addTrack` / `removeTrack` /
|
|
780
|
+
* `clearTracks` throw — the chain is owned by the patterns array.
|
|
781
|
+
*
|
|
782
|
+
* `chainOrder` is reset to `[0, 1, …, patterns.length - 1]`.
|
|
783
|
+
*/
|
|
784
|
+
setPatterns(patterns: PatternInput[]): this;
|
|
785
|
+
/** Current chain order: indices into the patterns array, in playback order. */
|
|
786
|
+
get chainOrder(): number[];
|
|
787
|
+
/**
|
|
788
|
+
* Set a new chain order. Each entry must be a valid pattern index.
|
|
789
|
+
* Throws if `order` is empty or contains an out-of-range index.
|
|
790
|
+
*/
|
|
791
|
+
set chainOrder(order: number[]);
|
|
792
|
+
/**
|
|
793
|
+
* Set a track's multiplicative volume scalar. Affects every note dispatched
|
|
794
|
+
* by the track from the next flush onwards. No-op if no track has the
|
|
795
|
+
* given id. Search is scoped to the currently-playing pattern.
|
|
796
|
+
*/
|
|
797
|
+
setTrackVolume(id: string, volume: number): this;
|
|
798
|
+
/** Mute a track by id. No-op if no track has the given id. */
|
|
799
|
+
muteTrack(id: string): this;
|
|
800
|
+
/** Unmute a track by id. No-op if no track has the given id. */
|
|
801
|
+
unmuteTrack(id: string): this;
|
|
802
|
+
/** Solo a track by id. While any track is soloed, non-soloed tracks are silenced. */
|
|
803
|
+
soloTrack(id: string): this;
|
|
804
|
+
/** Remove the solo flag from a track. */
|
|
805
|
+
unsoloTrack(id: string): this;
|
|
806
|
+
/**
|
|
807
|
+
* Locate a track by id, scoped to the currently-playing pattern.
|
|
808
|
+
*/
|
|
809
|
+
private _findTrack;
|
|
810
|
+
private _setTrackFlag;
|
|
811
|
+
private _buildTrack;
|
|
812
|
+
private _currentPattern;
|
|
813
|
+
private _assertImplicitPattern;
|
|
814
|
+
private _computePatternTotalTicks;
|
|
609
815
|
get state(): TransportState;
|
|
610
816
|
/**
|
|
611
817
|
* Start playback from `offsetTick`, or resume from pause if no offset given.
|
|
@@ -625,8 +831,8 @@ declare class Sequencer {
|
|
|
625
831
|
togglePlayPause(): this;
|
|
626
832
|
get bpm(): number;
|
|
627
833
|
set bpm(value: number);
|
|
628
|
-
get timeSignature():
|
|
629
|
-
set timeSignature(value: number);
|
|
834
|
+
get timeSignature(): TimeSignature;
|
|
835
|
+
set timeSignature(value: number | TimeSignature);
|
|
630
836
|
/** Current transport position as "bar:beat:tick" (1-indexed). */
|
|
631
837
|
get position(): string;
|
|
632
838
|
/**
|
|
@@ -639,7 +845,10 @@ declare class Sequencer {
|
|
|
639
845
|
/** Loop start in ticks. */
|
|
640
846
|
get loopStart(): number;
|
|
641
847
|
set loopStart(value: string | number);
|
|
642
|
-
/**
|
|
848
|
+
/**
|
|
849
|
+
* Loop end in ticks for the currently-playing pattern. Defaults to the end
|
|
850
|
+
* of the pattern's longest track.
|
|
851
|
+
*/
|
|
643
852
|
get loopEnd(): number;
|
|
644
853
|
set loopEnd(value: string | number);
|
|
645
854
|
/**
|
|
@@ -658,19 +867,20 @@ declare class Sequencer {
|
|
|
658
867
|
/**
|
|
659
868
|
* Listen to a sequencer event.
|
|
660
869
|
*
|
|
661
|
-
* | Event
|
|
662
|
-
*
|
|
663
|
-
* | "statechange"
|
|
664
|
-
* | "start"
|
|
665
|
-
* | "stop"
|
|
666
|
-
* | "pause"
|
|
667
|
-
* | "end"
|
|
668
|
-
* | "loop"
|
|
669
|
-
* | "
|
|
670
|
-
* | "
|
|
671
|
-
* | "
|
|
672
|
-
* | "
|
|
673
|
-
* | "
|
|
870
|
+
* | Event | Args |
|
|
871
|
+
* |-----------------|---------------------------------------------------|
|
|
872
|
+
* | "statechange" | (state: "playing" \| "paused" \| "stopped") |
|
|
873
|
+
* | "start" | |
|
|
874
|
+
* | "stop" | |
|
|
875
|
+
* | "pause" | |
|
|
876
|
+
* | "end" | |
|
|
877
|
+
* | "loop" | |
|
|
878
|
+
* | "patternChange" | (patternIndex: number, time: number) |
|
|
879
|
+
* | "beat" | (beat: number, time: number) |
|
|
880
|
+
* | "bar" | (bar: number, time: number) |
|
|
881
|
+
* | "step" | (stepIndex: number, time: number) |
|
|
882
|
+
* | "noteOn" | (event: SequencerNoteEvent) |
|
|
883
|
+
* | "noteOff" | (event: SequencerNoteEvent) |
|
|
674
884
|
*/
|
|
675
885
|
on(event: string, callback: (...args: any[]) => void): this;
|
|
676
886
|
off(event: string, callback: (...args: any[]) => void): this;
|
|
@@ -683,8 +893,6 @@ declare class Sequencer {
|
|
|
683
893
|
private _emit;
|
|
684
894
|
/** Emit both the specific state event ("start"/"pause"/"stop") and the unified "statechange" event. */
|
|
685
895
|
private _emitStateChange;
|
|
686
|
-
/** Recompute _totalTicks from all track notes (at + duration). */
|
|
687
|
-
private _recomputeTotalTicks;
|
|
688
896
|
/** Format a raw tick count as "bar:beat:tick" (all 1-indexed). */
|
|
689
897
|
private _tickToPosition;
|
|
690
898
|
/**
|
|
@@ -693,6 +901,8 @@ declare class Sequencer {
|
|
|
693
901
|
*/
|
|
694
902
|
private _resetRepeatEvents;
|
|
695
903
|
}
|
|
904
|
+
declare const Sequencer: Constructable<[context: BaseAudioContext, options?: SequencerOptions | undefined], SequencerImpl>;
|
|
905
|
+
type Sequencer = ReturnType<typeof Sequencer>;
|
|
696
906
|
|
|
697
907
|
declare function getElectricPianoNames(): string[];
|
|
698
908
|
type ElectricPianoOptions = Partial<{
|
|
@@ -700,6 +910,8 @@ type ElectricPianoOptions = Partial<{
|
|
|
700
910
|
storage: Storage;
|
|
701
911
|
destination: AudioNode;
|
|
702
912
|
volume: number;
|
|
913
|
+
/** Stereo pan position (-1 = full left, 0 = centre, +1 = full right). */
|
|
914
|
+
pan: number;
|
|
703
915
|
velocity: number;
|
|
704
916
|
onLoadProgress: (progress: LoadProgress) => void;
|
|
705
917
|
/** Audio formats to try, in order of preference. Defaults to ["ogg", "m4a"]. */
|
|
@@ -710,6 +922,8 @@ declare const ElectricPiano: InstrumentFactory<Partial<{
|
|
|
710
922
|
storage: Storage;
|
|
711
923
|
destination: AudioNode;
|
|
712
924
|
volume: number;
|
|
925
|
+
/** Stereo pan position (-1 = full left, 0 = centre, +1 = full right). */
|
|
926
|
+
pan: number;
|
|
713
927
|
velocity: number;
|
|
714
928
|
onLoadProgress: (progress: LoadProgress) => void;
|
|
715
929
|
/** Audio formats to try, in order of preference. Defaults to ["ogg", "m4a"]. */
|
|
@@ -732,6 +946,8 @@ type VersilianConfig = {
|
|
|
732
946
|
type VersilianOptions = Partial<VersilianConfig & {
|
|
733
947
|
destination?: AudioNode;
|
|
734
948
|
volume?: number;
|
|
949
|
+
/** Stereo pan position (-1 = full left, 0 = centre, +1 = full right). */
|
|
950
|
+
pan?: number;
|
|
735
951
|
velocity?: number;
|
|
736
952
|
onLoadProgress?: (progress: LoadProgress) => void;
|
|
737
953
|
}>;
|
|
@@ -744,6 +960,8 @@ type VersilianOptions = Partial<VersilianConfig & {
|
|
|
744
960
|
declare const Versilian: InstrumentFactory<Partial<VersilianConfig & {
|
|
745
961
|
destination?: AudioNode;
|
|
746
962
|
volume?: number;
|
|
963
|
+
/** Stereo pan position (-1 = full left, 0 = centre, +1 = full right). */
|
|
964
|
+
pan?: number;
|
|
747
965
|
velocity?: number;
|
|
748
966
|
onLoadProgress?: (progress: LoadProgress) => void;
|
|
749
967
|
}>, {}>;
|
|
@@ -760,6 +978,7 @@ declare function getMalletNames(): string[];
|
|
|
760
978
|
declare const Mallet: InstrumentFactory<Partial<VersilianConfig & {
|
|
761
979
|
destination?: AudioNode;
|
|
762
980
|
volume?: number;
|
|
981
|
+
pan?: number;
|
|
763
982
|
velocity?: number;
|
|
764
983
|
onLoadProgress?: (progress: LoadProgress) => void;
|
|
765
984
|
}>, {}>;
|
|
@@ -775,6 +994,8 @@ type MellotronConfig = {
|
|
|
775
994
|
type MellotronOptions = Partial<MellotronConfig & {
|
|
776
995
|
destination?: AudioNode;
|
|
777
996
|
volume?: number;
|
|
997
|
+
/** Stereo pan position (-1 = full left, 0 = centre, +1 = full right). */
|
|
998
|
+
pan?: number;
|
|
778
999
|
velocity?: number;
|
|
779
1000
|
decayTime?: number;
|
|
780
1001
|
onLoadProgress?: (progress: LoadProgress) => void;
|
|
@@ -782,6 +1003,8 @@ type MellotronOptions = Partial<MellotronConfig & {
|
|
|
782
1003
|
declare const Mellotron: InstrumentFactory<Partial<MellotronConfig & {
|
|
783
1004
|
destination?: AudioNode;
|
|
784
1005
|
volume?: number;
|
|
1006
|
+
/** Stereo pan position (-1 = full left, 0 = centre, +1 = full right). */
|
|
1007
|
+
pan?: number;
|
|
785
1008
|
velocity?: number;
|
|
786
1009
|
decayTime?: number;
|
|
787
1010
|
onLoadProgress?: (progress: LoadProgress) => void;
|
|
@@ -803,7 +1026,7 @@ type MellotronJsonConfig = {
|
|
|
803
1026
|
declare function mellotronToPreset(sampleNames: string[], config: MellotronJsonConfig): SmplrPreset;
|
|
804
1027
|
|
|
805
1028
|
declare const PARAMS: readonly ["preDelay", "bandwidth", "inputDiffusion1", "inputDiffusion2", "decay", "decayDiffusion1", "decayDiffusion2", "damping", "excursionRate", "excursionDepth", "wet", "dry"];
|
|
806
|
-
declare class
|
|
1029
|
+
declare class ReverbImpl {
|
|
807
1030
|
#private;
|
|
808
1031
|
readonly input: AudioNode;
|
|
809
1032
|
constructor(context: AudioContext);
|
|
@@ -813,6 +1036,8 @@ declare class Reverb {
|
|
|
813
1036
|
ready(): Promise<this>;
|
|
814
1037
|
connect(output: AudioNode): void;
|
|
815
1038
|
}
|
|
1039
|
+
declare const Reverb: Constructable<[context: AudioContext], ReverbImpl>;
|
|
1040
|
+
type Reverb = ReturnType<typeof Reverb>;
|
|
816
1041
|
|
|
817
1042
|
type AudioBuffers = Record<string | number, AudioBuffer | undefined>;
|
|
818
1043
|
/**
|
|
@@ -824,6 +1049,7 @@ type SamplerBase = {
|
|
|
824
1049
|
storage?: Storage;
|
|
825
1050
|
detune?: number;
|
|
826
1051
|
volume?: number;
|
|
1052
|
+
pan?: number;
|
|
827
1053
|
velocity?: number;
|
|
828
1054
|
decayTime?: number;
|
|
829
1055
|
lpfCutoffHz?: number;
|
|
@@ -885,12 +1111,16 @@ type SmolkenConfig = {
|
|
|
885
1111
|
type SmolkenOptions = Partial<SmolkenConfig & {
|
|
886
1112
|
destination?: AudioNode;
|
|
887
1113
|
volume?: number;
|
|
1114
|
+
/** Stereo pan position (-1 = full left, 0 = centre, +1 = full right). */
|
|
1115
|
+
pan?: number;
|
|
888
1116
|
velocity?: number;
|
|
889
1117
|
onLoadProgress?: (progress: LoadProgress) => void;
|
|
890
1118
|
}>;
|
|
891
1119
|
declare const Smolken: InstrumentFactory<Partial<SmolkenConfig & {
|
|
892
1120
|
destination?: AudioNode;
|
|
893
1121
|
volume?: number;
|
|
1122
|
+
/** Stereo pan position (-1 = full left, 0 = centre, +1 = full right). */
|
|
1123
|
+
pan?: number;
|
|
894
1124
|
velocity?: number;
|
|
895
1125
|
onLoadProgress?: (progress: LoadProgress) => void;
|
|
896
1126
|
}>, {}>;
|
|
@@ -913,12 +1143,16 @@ type SoundfontConfig = {
|
|
|
913
1143
|
type SoundfontOptions = Partial<SoundfontConfig & {
|
|
914
1144
|
destination?: AudioNode;
|
|
915
1145
|
volume?: number;
|
|
1146
|
+
/** Stereo pan position (-1 = full left, 0 = centre, +1 = full right). */
|
|
1147
|
+
pan?: number;
|
|
916
1148
|
velocity?: number;
|
|
917
1149
|
onLoadProgress?: (progress: LoadProgress) => void;
|
|
918
1150
|
}>;
|
|
919
1151
|
declare const Soundfont: InstrumentFactory<Partial<SoundfontConfig & {
|
|
920
1152
|
destination?: AudioNode;
|
|
921
1153
|
volume?: number;
|
|
1154
|
+
/** Stereo pan position (-1 = full left, 0 = centre, +1 = full right). */
|
|
1155
|
+
pan?: number;
|
|
922
1156
|
velocity?: number;
|
|
923
1157
|
onLoadProgress?: (progress: LoadProgress) => void;
|
|
924
1158
|
}>, {}>;
|
|
@@ -964,6 +1198,8 @@ type Soundfont2Options = {
|
|
|
964
1198
|
createSoundfont: (data: Uint8Array) => Sf2;
|
|
965
1199
|
destination?: AudioNode;
|
|
966
1200
|
volume?: number;
|
|
1201
|
+
/** Stereo pan position (-1 = full left, 0 = centre, +1 = full right). */
|
|
1202
|
+
pan?: number;
|
|
967
1203
|
velocity?: number;
|
|
968
1204
|
};
|
|
969
1205
|
declare function sf2InstrumentToPreset(sf2Instrument: Sf2Instrument, context: BaseAudioContext): {
|
|
@@ -974,9 +1210,13 @@ type Soundfont2SamplerExtras = {
|
|
|
974
1210
|
readonly instrumentNames: string[];
|
|
975
1211
|
loadInstrument(instrumentName: string): Promise<void> | undefined;
|
|
976
1212
|
};
|
|
1213
|
+
declare const Soundfont2: InstrumentFactory<Soundfont2Options, Soundfont2SamplerExtras>;
|
|
1214
|
+
/** Instance type returned by the {@link Soundfont2} factory. */
|
|
1215
|
+
type Soundfont2 = ReturnType<typeof Soundfont2>;
|
|
1216
|
+
/** @deprecated Use `Soundfont2` instead. */
|
|
977
1217
|
declare const Soundfont2Sampler: InstrumentFactory<Soundfont2Options, Soundfont2SamplerExtras>;
|
|
978
|
-
/**
|
|
979
|
-
type Soundfont2Sampler =
|
|
1218
|
+
/** @deprecated Use `Soundfont2` instead. */
|
|
1219
|
+
type Soundfont2Sampler = Soundfont2;
|
|
980
1220
|
|
|
981
1221
|
/**
|
|
982
1222
|
* Configuration options for SplendidGrandPiano.
|
|
@@ -994,6 +1234,8 @@ type SplendidGrandPianoConfig = {
|
|
|
994
1234
|
destination?: AudioNode;
|
|
995
1235
|
/** Master volume (0–127 MIDI scale). */
|
|
996
1236
|
volume?: number;
|
|
1237
|
+
/** Stereo pan position (-1 = full left, 0 = centre, +1 = full right). */
|
|
1238
|
+
pan?: number;
|
|
997
1239
|
/** Called after each buffer is loaded or served from cache. */
|
|
998
1240
|
onLoadProgress?: (progress: LoadProgress) => void;
|
|
999
1241
|
/** Audio formats to try, in order of preference. Defaults to ["ogg", "m4a"]. */
|
|
@@ -1031,4 +1273,4 @@ declare const LAYERS: ({
|
|
|
1031
1273
|
cutoff?: undefined;
|
|
1032
1274
|
})[];
|
|
1033
1275
|
|
|
1034
|
-
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, type SamplerReloadInput, Scheduler, Sequencer, type SequencerInstrument, type SequencerNote, type SequencerNoteEvent, type SequencerOptions, Smolken, type SmolkenConfig, type SmolkenOptions, type Smplr, type SmplrGroup, type SmplrOptions, type SmplrPlugin, type SmplrPreset, 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, drumMachineToPreset, getDrumMachineNames, getElectricPianoNames, getMalletNames, getMellotronNames, getSmolkenNames, getSoundfontKits, getSoundfontNames, getVersilianInstruments, loadVersilianInstrument, mellotronToPreset, pianoToPreset, renderOffline, samplerToPreset, sf2InstrumentToPreset, soundfontToPreset, trimSilence };
|
|
1276
|
+
export { type AddTrackOptions, CacheStorage, DRUM_ABUSE_PACKS, DrumAbuse, type DrumAbuseConfig, type DrumAbuseExtras, type DrumAbuseOptions, type DrumAbusePackId, type DrumAbuseSource, DrumMachine, type DrumMachineOptions, ElectricPiano, type ElectricPianoOptions, HttpStorage, Instrument, LAYERS, type LoadProgress, Mallet, Mellotron, type MellotronConfig, type MellotronOptions, NAME_TO_PATH, type NoteEvent, type PatternInput, type PlaybackParams, type RenderOfflineOptions, RenderResult, Reverb, SampleLoader, Sampler, type SamplerConfig, type SamplerReloadInput, Scheduler, Sequencer, type SequencerInstrument, type SequencerNote, type SequencerNoteEvent, type SequencerOptions, Smolken, type SmolkenConfig, type SmolkenOptions, type Smplr, type SmplrGroup, type SmplrOptions, type SmplrPlugin, type SmplrPreset, type SmplrRegion, type SmplrSamples, Soundfont, Soundfont2, type Soundfont2Options, Soundfont2Sampler, type SoundfontOptions, SplendidGrandPiano, type SplendidGrandPianoConfig, type StopFn, type StopTarget, type Storage, type StorageResponse, type TimeSignature, Versilian, type VersilianConfig, type VersilianOptions, type VoiceParams, audioBufferToWav, audioBufferToWav16, drumAbuseSampleUrl, drumMachineToPreset, getDrumAbuseMachineNames, getDrumAbuseMachinePack, getDrumAbuseMachinesForPack, getDrumAbusePackNames, getDrumMachineNames, getElectricPianoNames, getMalletNames, getMellotronNames, getSmolkenNames, getSoundfontKits, getSoundfontNames, getVersilianInstruments, loadVersilianInstrument, mellotronToPreset, pianoToPreset, renderOffline, samplerToPreset, sf2InstrumentToPreset, soundfontToPreset, trimSilence };
|