smplr 0.20.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 +168 -80
- package/dist/index.d.mts +205 -179
- package/dist/index.d.ts +205 -179
- package/dist/index.js +373 -503
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +371 -501
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -8
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;
|
|
@@ -260,80 +267,129 @@ type SmplrOptions = {
|
|
|
260
267
|
/** Called when each voice's audio node ends. */
|
|
261
268
|
onEnded?: (event: NoteEvent) => void;
|
|
262
269
|
};
|
|
270
|
+
|
|
263
271
|
/**
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
* Multiple Smplr instances can share a SampleLoader (shared cache) and/or a
|
|
268
|
-
* Scheduler (coordinated timing) by passing them via SmplrOptions.
|
|
269
|
-
*
|
|
270
|
-
* Pattern A — json provided at construction:
|
|
271
|
-
* `new Smplr(context, json, options?)`
|
|
272
|
+
* Public Smplr interface — the type plugin authors, helper functions, and
|
|
273
|
+
* users program against. Mirrors the surface of the underlying SmplrImpl
|
|
274
|
+
* class, minus internal helpers.
|
|
272
275
|
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
276
|
+
* `loadInstrument` is intentionally *not* on this interface — it's the
|
|
277
|
+
* plugin-side API, exposed via {@link PluginSmplr} to plugin bodies only.
|
|
275
278
|
*/
|
|
276
|
-
|
|
277
|
-
#private;
|
|
278
|
-
/** Resolves with `this` once all sample buffers are loaded. */
|
|
279
|
-
readonly load: Promise<Smplr>;
|
|
280
|
-
/** The AudioContext (or OfflineAudioContext) passed to the constructor. */
|
|
279
|
+
interface Smplr {
|
|
281
280
|
readonly context: BaseAudioContext;
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Load (or replace) the instrument descriptor. Creates a new RegionMatcher
|
|
286
|
-
* and fetches all sample buffers. Pre-loaded buffers (e.g. base64-decoded)
|
|
287
|
-
* can be passed via the `buffers` parameter — those skip the fetch step.
|
|
288
|
-
*
|
|
289
|
-
* Returns a Promise that resolves when all samples are ready.
|
|
290
|
-
*/
|
|
291
|
-
loadInstrument(json: SmplrJson, buffers?: Map<string, AudioBuffer>): Promise<void>;
|
|
292
|
-
/** Current loading progress snapshot. `total` is known before loading starts. */
|
|
293
|
-
get loadProgress(): LoadProgress;
|
|
294
|
-
/** The output channel — use to add effects, adjust volume, or route audio. */
|
|
295
|
-
get output(): OutputChannel;
|
|
281
|
+
/** Resolves when the instrument is ready to play. Preferred over `load`. */
|
|
282
|
+
readonly ready: Promise<void>;
|
|
296
283
|
/**
|
|
297
|
-
*
|
|
298
|
-
*
|
|
284
|
+
* @deprecated Use `ready` instead. Returns a Promise that resolves to the
|
|
285
|
+
* instrument for compatibility with `const x = await new X(ctx).load`.
|
|
299
286
|
*/
|
|
287
|
+
readonly load: Promise<Smplr>;
|
|
288
|
+
readonly output: OutputChannel;
|
|
289
|
+
/** Shared with other instruments via SmplrOptions.loader. */
|
|
290
|
+
readonly loader: SampleLoader;
|
|
291
|
+
/** Shared with other instruments via SmplrOptions.scheduler. */
|
|
292
|
+
readonly scheduler: Scheduler;
|
|
293
|
+
readonly loadProgress: LoadProgress;
|
|
294
|
+
start(event: NoteEvent): StopFn;
|
|
295
|
+
stop(target?: StopTarget): void;
|
|
300
296
|
setCC(cc: number, value: number): void;
|
|
301
297
|
/**
|
|
302
|
-
*
|
|
303
|
-
*
|
|
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).
|
|
304
300
|
*/
|
|
305
|
-
|
|
301
|
+
getCC(cc: number): number;
|
|
306
302
|
/**
|
|
307
|
-
* Stop voices.
|
|
308
|
-
*
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
* - `{ stopId }` → stop voices with that stopId, optionally at a future time
|
|
312
|
-
* - `{ time }` (no stopId) → stop all voices at a future time
|
|
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.
|
|
313
307
|
*/
|
|
314
|
-
|
|
308
|
+
dispose(): void;
|
|
309
|
+
/** @deprecated Use `dispose()` instead. */
|
|
310
|
+
disconnect(): void;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Plugin-facing widening of {@link Smplr} that exposes `loadInstrument` —
|
|
314
|
+
* the primary plugin → smplr API for wiring an async-loaded JSON.
|
|
315
|
+
*
|
|
316
|
+
* This interface is *not* exported from the package barrel. Plugin authors
|
|
317
|
+
* receive it as the third argument to their {@link SmplrPlugin}.
|
|
318
|
+
*/
|
|
319
|
+
interface PluginSmplr extends Smplr {
|
|
315
320
|
/**
|
|
316
|
-
*
|
|
317
|
-
*
|
|
321
|
+
* Replace the current instrument JSON and re-fetch buffers. Pre-decoded
|
|
322
|
+
* buffers (e.g. base64-decoded from a soundfont) can be passed via the
|
|
323
|
+
* `buffers` parameter.
|
|
324
|
+
*
|
|
325
|
+
* Resolves when all samples are ready.
|
|
318
326
|
*/
|
|
319
|
-
|
|
327
|
+
loadInstrument(json: SmplrJson, buffers?: Map<string, AudioBuffer>): Promise<void>;
|
|
320
328
|
}
|
|
321
|
-
|
|
322
329
|
/**
|
|
323
|
-
*
|
|
324
|
-
* a keyRange that covers all MIDI notes closer to that sample than to any
|
|
325
|
-
* neighbour. The first sample extends down to 0; the last extends up to 127.
|
|
330
|
+
* Permitted return shapes for an {@link SmplrPlugin}:
|
|
326
331
|
*
|
|
327
|
-
*
|
|
328
|
-
* `
|
|
329
|
-
*
|
|
332
|
+
* - `void` — sync plugin, no async load, no extras
|
|
333
|
+
* - `Promise<void>` — async load, no extras
|
|
334
|
+
* - `{ extras: E; ready: Promise<void> }` — sync extras + async load
|
|
335
|
+
* - `{ ready: Promise<void> }` — async load, no extras (explicit form)
|
|
336
|
+
*
|
|
337
|
+
* Extras keys are merged onto the smplr instance via `Object.assign` and
|
|
338
|
+
* may shadow base {@link Smplr} methods (e.g. DrumMachine overrides `start`
|
|
339
|
+
* to inject `stopId: sample.note`). For sync extras with no async load,
|
|
340
|
+
* use `{ extras, ready: Promise.resolve() }`.
|
|
330
341
|
*/
|
|
331
|
-
type
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
342
|
+
type SmplrPluginResult<E extends object> = void | Promise<void> | {
|
|
343
|
+
extras: E;
|
|
344
|
+
ready: Promise<void>;
|
|
345
|
+
} | {
|
|
346
|
+
ready: Promise<void>;
|
|
347
|
+
};
|
|
348
|
+
/**
|
|
349
|
+
* Plugin signature. Receives the audio context, the user options (with
|
|
350
|
+
* SmplrOptions keys already stripped by the {@link Instrument} builder),
|
|
351
|
+
* and a {@link PluginSmplr} the plugin can wire up.
|
|
352
|
+
*/
|
|
353
|
+
type SmplrPlugin<O, E extends object = {}> = (ctx: BaseAudioContext, options: O, smplr: PluginSmplr) => SmplrPluginResult<E>;
|
|
354
|
+
/**
|
|
355
|
+
* The dual call/construct factory produced by {@link Instrument}. Callable
|
|
356
|
+
* without `new` (preferred) or with `new` (kept for compatibility with
|
|
357
|
+
* pre-1.0 examples).
|
|
358
|
+
*/
|
|
359
|
+
/**
|
|
360
|
+
* The full instance type produced by an {@link InstrumentFactory} — a Smplr
|
|
361
|
+
* with its plugin extras, plus a `load` Promise refined to resolve back to
|
|
362
|
+
* the same intersection (so `await x.load` preserves the extras shape).
|
|
363
|
+
*/
|
|
364
|
+
type InstrumentInstance<E extends object = {}> = Smplr & E & {
|
|
365
|
+
readonly load: Promise<Smplr & E>;
|
|
366
|
+
};
|
|
367
|
+
type InstrumentFactory<O, E extends object = {}> = {
|
|
368
|
+
(ctx: BaseAudioContext, options?: O & Partial<SmplrOptions>): InstrumentInstance<E>;
|
|
369
|
+
/**
|
|
370
|
+
* @deprecated Call as a function: `MyInstrument(ctx, opts)` instead of
|
|
371
|
+
* `new MyInstrument(...)`. Kept for compatibility with pre-1.0 examples.
|
|
372
|
+
*/
|
|
373
|
+
new (ctx: BaseAudioContext, options?: O & Partial<SmplrOptions>): InstrumentInstance<E>;
|
|
335
374
|
};
|
|
336
|
-
|
|
375
|
+
/**
|
|
376
|
+
* Builder for smplr instruments. Wraps a plugin function into a dual
|
|
377
|
+
* call/construct factory that produces ready-to-play {@link Smplr} instances
|
|
378
|
+
* augmented with plugin extras.
|
|
379
|
+
*
|
|
380
|
+
* ```ts
|
|
381
|
+
* type MyOptions = { instrument: string };
|
|
382
|
+
*
|
|
383
|
+
* export const MyInstrument = Instrument<MyOptions>((ctx, options, smplr) => {
|
|
384
|
+
* return smplr.loadInstrument(fetchJson(options.instrument));
|
|
385
|
+
* });
|
|
386
|
+
*
|
|
387
|
+
* const inst = MyInstrument(ctx, { instrument: "piano", volume: 80 });
|
|
388
|
+
* await inst.ready;
|
|
389
|
+
* inst.start("C4");
|
|
390
|
+
* ```
|
|
391
|
+
*/
|
|
392
|
+
declare function Instrument<O, E extends object = {}>(plugin: SmplrPlugin<O, E>): InstrumentFactory<O, E>;
|
|
337
393
|
|
|
338
394
|
type DrumMachineInstrument = {
|
|
339
395
|
baseUrl: string;
|
|
@@ -357,24 +413,21 @@ type DrumMachineOptions = Partial<DrumMachineConfig & {
|
|
|
357
413
|
velocity?: number;
|
|
358
414
|
onLoadProgress?: (progress: LoadProgress) => void;
|
|
359
415
|
}>;
|
|
360
|
-
|
|
361
|
-
#private;
|
|
362
|
-
readonly load: Promise<this>;
|
|
363
|
-
readonly output: OutputChannel;
|
|
364
|
-
constructor(context: AudioContext, options?: DrumMachineOptions);
|
|
416
|
+
type DrumMachineExtras = {
|
|
365
417
|
getSampleNames(): string[];
|
|
366
418
|
getGroupNames(): string[];
|
|
367
419
|
getSampleNamesForGroup(groupName: string): string[];
|
|
368
|
-
start(
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
}
|
|
420
|
+
start(event: NoteEvent): StopFn;
|
|
421
|
+
};
|
|
422
|
+
declare const DrumMachine: InstrumentFactory<Partial<DrumMachineConfig & {
|
|
423
|
+
destination?: AudioNode;
|
|
424
|
+
volume?: number;
|
|
425
|
+
pan?: number;
|
|
426
|
+
velocity?: number;
|
|
427
|
+
onLoadProgress?: (progress: LoadProgress) => void;
|
|
428
|
+
}>, DrumMachineExtras>;
|
|
429
|
+
/** Instance type returned by the {@link DrumMachine} factory. */
|
|
430
|
+
type DrumMachine = ReturnType<typeof DrumMachine>;
|
|
378
431
|
/**
|
|
379
432
|
* Convert a DrumMachineInstrument to a SmplrJson descriptor.
|
|
380
433
|
*
|
|
@@ -652,22 +705,24 @@ type ElectricPianoOptions = Partial<{
|
|
|
652
705
|
/** Audio formats to try, in order of preference. Defaults to ["ogg", "m4a"]. */
|
|
653
706
|
formats: string[];
|
|
654
707
|
}>;
|
|
655
|
-
declare
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
708
|
+
declare const ElectricPiano: InstrumentFactory<Partial<{
|
|
709
|
+
instrument: string;
|
|
710
|
+
storage: Storage;
|
|
711
|
+
destination: AudioNode;
|
|
712
|
+
volume: number;
|
|
713
|
+
velocity: number;
|
|
714
|
+
onLoadProgress: (progress: LoadProgress) => void;
|
|
715
|
+
/** Audio formats to try, in order of preference. Defaults to ["ogg", "m4a"]. */
|
|
716
|
+
formats: string[];
|
|
717
|
+
}> & {
|
|
718
|
+
instrument: string;
|
|
719
|
+
}, {
|
|
720
|
+
tremolo: Readonly<{
|
|
660
721
|
level: (value: number) => void;
|
|
661
722
|
}>;
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
get output(): OutputChannel;
|
|
666
|
-
get loadProgress(): LoadProgress;
|
|
667
|
-
start(sample: NoteEvent | string | number): StopFn;
|
|
668
|
-
stop(target?: StopTarget): void;
|
|
669
|
-
disconnect(): void;
|
|
670
|
-
}
|
|
723
|
+
}>;
|
|
724
|
+
/** Instance type returned by the {@link ElectricPiano} factory. */
|
|
725
|
+
type ElectricPiano = ReturnType<typeof ElectricPiano>;
|
|
671
726
|
|
|
672
727
|
declare function getVersilianInstruments(): Promise<string[]>;
|
|
673
728
|
type VersilianConfig = {
|
|
@@ -686,23 +741,30 @@ type VersilianOptions = Partial<VersilianConfig & {
|
|
|
686
741
|
* The Versilian Community Sample Library is an open CC0 general-purpose sample
|
|
687
742
|
* library created by Versilian Studios LLC.
|
|
688
743
|
*/
|
|
689
|
-
declare
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
}
|
|
744
|
+
declare const Versilian: InstrumentFactory<Partial<VersilianConfig & {
|
|
745
|
+
destination?: AudioNode;
|
|
746
|
+
volume?: number;
|
|
747
|
+
velocity?: number;
|
|
748
|
+
onLoadProgress?: (progress: LoadProgress) => void;
|
|
749
|
+
}>, {}>;
|
|
750
|
+
/** Instance type returned by the {@link Versilian} factory. */
|
|
751
|
+
type Versilian = ReturnType<typeof Versilian>;
|
|
752
|
+
/**
|
|
753
|
+
* Fetch the SFZ for a VCSL instrument and load it into `smplr`. Shared by
|
|
754
|
+
* the {@link Versilian} and {@link Mallet} factories — not exported from the
|
|
755
|
+
* package barrel.
|
|
756
|
+
*/
|
|
757
|
+
declare function loadVersilianInstrument(smplr: PluginSmplr, options: VersilianOptions): Promise<void>;
|
|
700
758
|
|
|
701
|
-
declare function getMalletNames():
|
|
702
|
-
declare
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
759
|
+
declare function getMalletNames(): string[];
|
|
760
|
+
declare const Mallet: InstrumentFactory<Partial<VersilianConfig & {
|
|
761
|
+
destination?: AudioNode;
|
|
762
|
+
volume?: number;
|
|
763
|
+
velocity?: number;
|
|
764
|
+
onLoadProgress?: (progress: LoadProgress) => void;
|
|
765
|
+
}>, {}>;
|
|
766
|
+
/** Instance type returned by the {@link Mallet} factory. */
|
|
767
|
+
type Mallet = ReturnType<typeof Mallet>;
|
|
706
768
|
declare const NAME_TO_PATH: Record<string, string | undefined>;
|
|
707
769
|
|
|
708
770
|
declare function getMellotronNames(): string[];
|
|
@@ -717,17 +779,15 @@ type MellotronOptions = Partial<MellotronConfig & {
|
|
|
717
779
|
decayTime?: number;
|
|
718
780
|
onLoadProgress?: (progress: LoadProgress) => void;
|
|
719
781
|
}>;
|
|
720
|
-
declare
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
disconnect(): void;
|
|
730
|
-
}
|
|
782
|
+
declare const Mellotron: InstrumentFactory<Partial<MellotronConfig & {
|
|
783
|
+
destination?: AudioNode;
|
|
784
|
+
volume?: number;
|
|
785
|
+
velocity?: number;
|
|
786
|
+
decayTime?: number;
|
|
787
|
+
onLoadProgress?: (progress: LoadProgress) => void;
|
|
788
|
+
}>, {}>;
|
|
789
|
+
/** Instance type returned by the {@link Mellotron} factory. */
|
|
790
|
+
type Mellotron = ReturnType<typeof Mellotron>;
|
|
731
791
|
type MellotronJsonConfig = {
|
|
732
792
|
instrument: string;
|
|
733
793
|
variation?: string;
|
|
@@ -772,20 +832,6 @@ type SamplerConfig = {
|
|
|
772
832
|
volumeToGain: (volume: number) => number;
|
|
773
833
|
onLoadProgress?: (progress: LoadProgress) => void;
|
|
774
834
|
};
|
|
775
|
-
/**
|
|
776
|
-
* A Sampler instrument
|
|
777
|
-
*/
|
|
778
|
-
declare class Sampler {
|
|
779
|
-
#private;
|
|
780
|
-
readonly context: AudioContext;
|
|
781
|
-
readonly load: Promise<this>;
|
|
782
|
-
constructor(context: AudioContext, options?: Partial<SamplerConfig>);
|
|
783
|
-
loaded(): Promise<this>;
|
|
784
|
-
get output(): OutputChannel;
|
|
785
|
-
start(sample: NoteEvent | string | number): StopFn;
|
|
786
|
-
stop(sample?: StopTarget | string | number): void;
|
|
787
|
-
disconnect(): void;
|
|
788
|
-
}
|
|
789
835
|
type SamplerJsonOptions = Pick<SamplerConfig, "decayTime" | "lpfCutoffHz" | "detune">;
|
|
790
836
|
type InternalConvertResult = {
|
|
791
837
|
json: SmplrJson;
|
|
@@ -803,6 +849,12 @@ type InternalConvertResult = {
|
|
|
803
849
|
* - String URL values → urlMap (fetched asynchronously by caller).
|
|
804
850
|
*/
|
|
805
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>;
|
|
806
858
|
|
|
807
859
|
declare function getSmolkenNames(): string[];
|
|
808
860
|
type SmolkenConfig = {
|
|
@@ -815,17 +867,14 @@ type SmolkenOptions = Partial<SmolkenConfig & {
|
|
|
815
867
|
velocity?: number;
|
|
816
868
|
onLoadProgress?: (progress: LoadProgress) => void;
|
|
817
869
|
}>;
|
|
818
|
-
declare
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
stop(target?: StopTarget): void;
|
|
827
|
-
disconnect(): void;
|
|
828
|
-
}
|
|
870
|
+
declare const Smolken: InstrumentFactory<Partial<SmolkenConfig & {
|
|
871
|
+
destination?: AudioNode;
|
|
872
|
+
volume?: number;
|
|
873
|
+
velocity?: number;
|
|
874
|
+
onLoadProgress?: (progress: LoadProgress) => void;
|
|
875
|
+
}>, {}>;
|
|
876
|
+
/** Instance type returned by the {@link Smolken} factory. */
|
|
877
|
+
type Smolken = ReturnType<typeof Smolken>;
|
|
829
878
|
|
|
830
879
|
type LoopData = Record<number, [number, number]>;
|
|
831
880
|
|
|
@@ -846,19 +895,14 @@ type SoundfontOptions = Partial<SoundfontConfig & {
|
|
|
846
895
|
velocity?: number;
|
|
847
896
|
onLoadProgress?: (progress: LoadProgress) => void;
|
|
848
897
|
}>;
|
|
849
|
-
declare
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
loaded(): Promise<this>;
|
|
858
|
-
disconnect(): void;
|
|
859
|
-
start(sample: NoteEvent | string | number): StopFn;
|
|
860
|
-
stop(sample?: StopTarget | string | number): void;
|
|
861
|
-
}
|
|
898
|
+
declare const Soundfont: InstrumentFactory<Partial<SoundfontConfig & {
|
|
899
|
+
destination?: AudioNode;
|
|
900
|
+
volume?: number;
|
|
901
|
+
velocity?: number;
|
|
902
|
+
onLoadProgress?: (progress: LoadProgress) => void;
|
|
903
|
+
}>, {}>;
|
|
904
|
+
/** Instance type returned by the {@link Soundfont} factory. */
|
|
905
|
+
type Soundfont = ReturnType<typeof Soundfont>;
|
|
862
906
|
/**
|
|
863
907
|
* Convert a list of note names (with optional loop data) to SmplrJson.
|
|
864
908
|
* Uses spreadKeyRanges so notes between recorded pitches pitch-shift correctly.
|
|
@@ -901,24 +945,17 @@ type Soundfont2Options = {
|
|
|
901
945
|
volume?: number;
|
|
902
946
|
velocity?: number;
|
|
903
947
|
};
|
|
904
|
-
declare function sf2InstrumentToSmplrJson(sf2Instrument: Sf2Instrument, context:
|
|
948
|
+
declare function sf2InstrumentToSmplrJson(sf2Instrument: Sf2Instrument, context: BaseAudioContext): {
|
|
905
949
|
json: SmplrJson;
|
|
906
950
|
buffers: Map<string, AudioBuffer>;
|
|
907
951
|
};
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
readonly context: AudioContext;
|
|
911
|
-
readonly options: Soundfont2Options;
|
|
912
|
-
soundfont: Sf2 | undefined;
|
|
913
|
-
readonly load: Promise<this>;
|
|
914
|
-
constructor(context: AudioContext, options: Soundfont2Options);
|
|
915
|
-
get instrumentNames(): string[];
|
|
916
|
-
get output(): OutputChannel;
|
|
952
|
+
type Soundfont2SamplerExtras = {
|
|
953
|
+
readonly instrumentNames: string[];
|
|
917
954
|
loadInstrument(instrumentName: string): Promise<void> | undefined;
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
955
|
+
};
|
|
956
|
+
declare const Soundfont2Sampler: InstrumentFactory<Soundfont2Options, Soundfont2SamplerExtras>;
|
|
957
|
+
/** Instance type returned by the {@link Soundfont2Sampler} factory. */
|
|
958
|
+
type Soundfont2Sampler = ReturnType<typeof Soundfont2Sampler>;
|
|
922
959
|
|
|
923
960
|
/**
|
|
924
961
|
* Configuration options for SplendidGrandPiano.
|
|
@@ -946,19 +983,9 @@ type SplendidGrandPianoConfig = {
|
|
|
946
983
|
velocityRange: [number, number];
|
|
947
984
|
};
|
|
948
985
|
};
|
|
949
|
-
declare
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
readonly load: Promise<this>;
|
|
953
|
-
constructor(context: AudioContext, options?: Partial<SplendidGrandPianoConfig>);
|
|
954
|
-
get output(): OutputChannel;
|
|
955
|
-
get loadProgress(): LoadProgress;
|
|
956
|
-
/** @deprecated Use `load` instead. */
|
|
957
|
-
loaded(): Promise<this>;
|
|
958
|
-
start(event: NoteEvent): StopFn;
|
|
959
|
-
stop(target?: StopTarget): void;
|
|
960
|
-
disconnect(): void;
|
|
961
|
-
}
|
|
986
|
+
declare const SplendidGrandPiano: InstrumentFactory<Partial<SplendidGrandPianoConfig>, {}>;
|
|
987
|
+
/** Instance type returned by the {@link SplendidGrandPiano} factory. */
|
|
988
|
+
type SplendidGrandPiano = ReturnType<typeof SplendidGrandPiano>;
|
|
962
989
|
type PianoJsonOptions = Pick<SplendidGrandPianoConfig, "baseUrl" | "detune" | "decayTime" | "notesToLoad" | "formats">;
|
|
963
990
|
/**
|
|
964
991
|
* Convert the LAYERS array and user options into a SmplrJson descriptor.
|
|
@@ -971,7 +998,6 @@ type PianoJsonOptions = Pick<SplendidGrandPianoConfig, "baseUrl" | "detune" | "d
|
|
|
971
998
|
* covers, replacing the old on-the-fly `findNearestMidiInLayer` logic.
|
|
972
999
|
*/
|
|
973
1000
|
declare function pianoToSmplrJson(options: PianoJsonOptions): SmplrJson;
|
|
974
|
-
|
|
975
1001
|
declare const LAYERS: ({
|
|
976
1002
|
name: string;
|
|
977
1003
|
vel_range: number[];
|
|
@@ -984,4 +1010,4 @@ declare const LAYERS: ({
|
|
|
984
1010
|
cutoff?: undefined;
|
|
985
1011
|
})[];
|
|
986
1012
|
|
|
987
|
-
export { CacheStorage, DrumMachine, type DrumMachineOptions, ElectricPiano, type ElectricPianoOptions, HttpStorage, 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, Smplr, type SmplrGroup, type SmplrJson, type SmplrOptions, type SmplrRegion, type SmplrSamples, Soundfont, type Soundfont2Options, Soundfont2Sampler, type SoundfontOptions, SplendidGrandPiano, type SplendidGrandPianoConfig, type
|
|
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 };
|