smplr 0.17.0 → 0.17.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/dist/index.d.mts +18 -226
- package/dist/index.d.ts +18 -226
- package/dist/index.js +469 -536
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +469 -536
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -154,141 +154,6 @@ type LoadProgress = {
|
|
|
154
154
|
total: number;
|
|
155
155
|
};
|
|
156
156
|
|
|
157
|
-
/**
|
|
158
|
-
* Loads and caches AudioBuffers for all samples referenced in a SmplrJson.
|
|
159
|
-
*
|
|
160
|
-
* The cache is keyed by resolved URL, so the same audio file is never fetched
|
|
161
|
-
* or decoded twice. Multiple Smplr instances can share one SampleLoader by
|
|
162
|
-
* passing it via SmplrOptions.loader.
|
|
163
|
-
*/
|
|
164
|
-
declare class SampleLoader {
|
|
165
|
-
#private;
|
|
166
|
-
constructor(context: BaseAudioContext, options?: {
|
|
167
|
-
storage?: Storage;
|
|
168
|
-
});
|
|
169
|
-
/**
|
|
170
|
-
* Load all samples referenced in `json`. Returns a Map of sample name →
|
|
171
|
-
* AudioBuffer. Progress is reported via `onProgress` callback or via
|
|
172
|
-
* options object.
|
|
173
|
-
*
|
|
174
|
-
* - `buffers` in options: pre-loaded buffers — skips fetch for these names.
|
|
175
|
-
* - All samples load in parallel. Failed samples are silently omitted.
|
|
176
|
-
*/
|
|
177
|
-
load(json: SmplrJson, onProgressOrOptions?: ((loaded: number, total: number) => void) | {
|
|
178
|
-
buffers?: Map<string, AudioBuffer>;
|
|
179
|
-
onProgress?: (loaded: number, total: number) => void;
|
|
180
|
-
}): Promise<Map<string, AudioBuffer>>;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Standalone scheduler. Dispatches NoteEvents immediately when they fall within the
|
|
185
|
-
* lookahead window, or queues them for future dispatch via a self-managing interval.
|
|
186
|
-
*
|
|
187
|
-
* Multiple Smplr instances can share a single Scheduler for coordinated timing.
|
|
188
|
-
*/
|
|
189
|
-
declare class Scheduler {
|
|
190
|
-
#private;
|
|
191
|
-
constructor(context: BaseAudioContext, options?: {
|
|
192
|
-
lookaheadMs?: number;
|
|
193
|
-
intervalMs?: number;
|
|
194
|
-
});
|
|
195
|
-
/**
|
|
196
|
-
* Schedule a callback for a NoteEvent.
|
|
197
|
-
*
|
|
198
|
-
* - If the event's time falls within the lookahead window (or has no time), the
|
|
199
|
-
* callback is called synchronously and a no-op StopFn is returned.
|
|
200
|
-
* - Otherwise the event is queued, the interval is started if needed, and a StopFn
|
|
201
|
-
* is returned that removes the event from the queue before it is dispatched.
|
|
202
|
-
*/
|
|
203
|
-
schedule(event: NoteEvent, callback: (event: NoteEvent) => void): StopFn;
|
|
204
|
-
/**
|
|
205
|
-
* Clear all queued (not-yet-dispatched) events and stop the interval.
|
|
206
|
-
* Does not affect voices that are already playing.
|
|
207
|
-
*/
|
|
208
|
-
stop(): void;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
type SmplrOptions = {
|
|
212
|
-
/** Custom storage backend for sample fetching (e.g. CacheStorage). */
|
|
213
|
-
storage?: Storage;
|
|
214
|
-
/** Destination audio node. Defaults to context.destination. */
|
|
215
|
-
destination?: AudioNode;
|
|
216
|
-
/** Master volume (0–127 MIDI scale). Defaults to 100. */
|
|
217
|
-
volume?: number;
|
|
218
|
-
/** Custom volume-to-gain mapping function. Defaults to midiVelToGain. */
|
|
219
|
-
volumeToGain?: (volume: number) => number;
|
|
220
|
-
/** Default note velocity when not specified in NoteEvent (0–127). Defaults to 100. */
|
|
221
|
-
velocity?: number;
|
|
222
|
-
/** Shared SampleLoader instance. If omitted, a private one is created. */
|
|
223
|
-
loader?: SampleLoader;
|
|
224
|
-
/** Shared Scheduler instance. If omitted, a private one is created. */
|
|
225
|
-
scheduler?: Scheduler;
|
|
226
|
-
/** Called after each buffer is loaded (or served from cache). */
|
|
227
|
-
onLoadProgress?: (progress: LoadProgress) => void;
|
|
228
|
-
/** Called when a note is dispatched to the audio engine (slightly before playback). */
|
|
229
|
-
onStart?: (event: NoteEvent) => void;
|
|
230
|
-
/** Called when each voice's audio node ends. */
|
|
231
|
-
onEnded?: (event: NoteEvent) => void;
|
|
232
|
-
};
|
|
233
|
-
/**
|
|
234
|
-
* The main sampler class. Loads samples described by a SmplrJson descriptor,
|
|
235
|
-
* matches notes to regions, and plays them through a Channel.
|
|
236
|
-
*
|
|
237
|
-
* Multiple Smplr instances can share a SampleLoader (shared cache) and/or a
|
|
238
|
-
* Scheduler (coordinated timing) by passing them via SmplrOptions.
|
|
239
|
-
*
|
|
240
|
-
* Pattern A — json provided at construction:
|
|
241
|
-
* `new Smplr(context, json, options?)`
|
|
242
|
-
*
|
|
243
|
-
* Pattern B — json loaded later via loadInstrument():
|
|
244
|
-
* `new Smplr(context, options?)` then `smplr.loadInstrument(json)`
|
|
245
|
-
*/
|
|
246
|
-
declare class Smplr {
|
|
247
|
-
#private;
|
|
248
|
-
/** Resolves with `this` once all sample buffers are loaded. */
|
|
249
|
-
readonly load: Promise<Smplr>;
|
|
250
|
-
/** The AudioContext passed to the constructor. */
|
|
251
|
-
readonly context: AudioContext;
|
|
252
|
-
constructor(context: AudioContext, json: SmplrJson, options?: SmplrOptions);
|
|
253
|
-
constructor(context: AudioContext, options?: SmplrOptions);
|
|
254
|
-
/**
|
|
255
|
-
* Load (or replace) the instrument descriptor. Creates a new RegionMatcher
|
|
256
|
-
* and fetches all sample buffers. Pre-loaded buffers (e.g. base64-decoded)
|
|
257
|
-
* can be passed via the `buffers` parameter — those skip the fetch step.
|
|
258
|
-
*
|
|
259
|
-
* Returns a Promise that resolves when all samples are ready.
|
|
260
|
-
*/
|
|
261
|
-
loadInstrument(json: SmplrJson, buffers?: Map<string, AudioBuffer>): Promise<void>;
|
|
262
|
-
/** Current loading progress snapshot. `total` is known before loading starts. */
|
|
263
|
-
get loadProgress(): LoadProgress;
|
|
264
|
-
/** The output channel — use to add effects, adjust volume, or route audio. */
|
|
265
|
-
get output(): OutputChannel;
|
|
266
|
-
/**
|
|
267
|
-
* Set a MIDI CC value. Affects region matching for groups/regions that have
|
|
268
|
-
* ccRange constraints (e.g. CC64 sustain pedal).
|
|
269
|
-
*/
|
|
270
|
-
setCC(cc: number, value: number): void;
|
|
271
|
-
/**
|
|
272
|
-
* Start playing a note. Returns a StopFn that cancels the note if it hasn't
|
|
273
|
-
* played yet, or stops the resulting voices if it has.
|
|
274
|
-
*/
|
|
275
|
-
start(event: NoteEvent): StopFn;
|
|
276
|
-
/**
|
|
277
|
-
* Stop voices.
|
|
278
|
-
*
|
|
279
|
-
* - No argument → stop all active voices
|
|
280
|
-
* - String or number → stop all voices with that stopId
|
|
281
|
-
* - `{ stopId }` → stop voices with that stopId, optionally at a future time
|
|
282
|
-
* - `{ time }` (no stopId) → stop all voices at a future time
|
|
283
|
-
*/
|
|
284
|
-
stop(target?: StopTarget): void;
|
|
285
|
-
/**
|
|
286
|
-
* Stop all voices, disconnect the output channel, and stop the scheduler.
|
|
287
|
-
* The instance should not be used after this call.
|
|
288
|
-
*/
|
|
289
|
-
disconnect(): void;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
157
|
/**
|
|
293
158
|
* Given a list of [midi, sampleName] pairs, return one entry per sample with
|
|
294
159
|
* a keyRange that covers all MIDI notes closer to that sample than to any
|
|
@@ -353,107 +218,32 @@ declare class DrumMachine {
|
|
|
353
218
|
*/
|
|
354
219
|
declare function drumMachineToSmplrJson(instrument: DrumMachineInstrument): SmplrJson;
|
|
355
220
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
baseUrl?: string;
|
|
360
|
-
websfzUrl: string;
|
|
361
|
-
tags?: string[];
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
type Websfz = {
|
|
365
|
-
global: Record<string, string | number>;
|
|
366
|
-
groups: WebsfzGroup[];
|
|
367
|
-
meta: {
|
|
368
|
-
name?: string;
|
|
369
|
-
description?: string;
|
|
370
|
-
license?: string;
|
|
371
|
-
source?: string;
|
|
372
|
-
baseUrl?: string;
|
|
373
|
-
websfzUrl?: string;
|
|
374
|
-
formats?: string[];
|
|
375
|
-
tags?: string[];
|
|
376
|
-
};
|
|
377
|
-
};
|
|
378
|
-
type WebsfzGroup = {
|
|
379
|
-
group_label?: string;
|
|
380
|
-
group?: number;
|
|
381
|
-
hikey?: number;
|
|
382
|
-
hivel?: number;
|
|
383
|
-
lokey?: number;
|
|
384
|
-
lovel?: number;
|
|
385
|
-
off_by?: number;
|
|
386
|
-
off_mode?: "normal";
|
|
387
|
-
pitch_keycenter?: number;
|
|
388
|
-
regions: WebsfzRegion[];
|
|
389
|
-
seq_length?: number;
|
|
390
|
-
trigger?: "first" | "legato";
|
|
391
|
-
volume?: number;
|
|
392
|
-
amp_velcurve_83?: number;
|
|
393
|
-
locc64?: number;
|
|
394
|
-
hicc64?: number;
|
|
395
|
-
hicc107?: number;
|
|
396
|
-
locc107?: number;
|
|
397
|
-
pan_oncc122?: number;
|
|
398
|
-
tune_oncc123?: number;
|
|
399
|
-
eg06_time1_oncc109?: number;
|
|
400
|
-
ampeg_attack_oncc100?: number;
|
|
401
|
-
};
|
|
402
|
-
type WebsfzRegion = {
|
|
403
|
-
end?: number;
|
|
404
|
-
group?: number;
|
|
405
|
-
hivel?: number;
|
|
406
|
-
lovel?: number;
|
|
407
|
-
hikey?: number;
|
|
408
|
-
key?: number;
|
|
409
|
-
lokey?: number;
|
|
410
|
-
off_by?: number;
|
|
411
|
-
pitch_keycenter?: number;
|
|
412
|
-
region_label?: number;
|
|
413
|
-
sample: string;
|
|
414
|
-
seq_position?: number;
|
|
415
|
-
trigger?: "first" | "legato";
|
|
416
|
-
volume?: number;
|
|
417
|
-
locc64?: number;
|
|
418
|
-
hicc64?: number;
|
|
419
|
-
ampeg_attack_oncc100?: number;
|
|
420
|
-
eg06_time1_oncc109?: number;
|
|
421
|
-
pan_oncc122?: number;
|
|
422
|
-
tune_oncc123?: number;
|
|
423
|
-
};
|
|
424
|
-
|
|
425
|
-
type SfzSamplerConfig = {
|
|
426
|
-
instrument: SfzInstrument | Websfz | string;
|
|
221
|
+
declare function getElectricPianoNames(): string[];
|
|
222
|
+
type ElectricPianoOptions = Partial<{
|
|
223
|
+
instrument: string;
|
|
427
224
|
storage: Storage;
|
|
428
225
|
destination: AudioNode;
|
|
429
226
|
volume: number;
|
|
430
227
|
velocity: number;
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
declare class SfzSampler {
|
|
228
|
+
onLoadProgress: (progress: LoadProgress) => void;
|
|
229
|
+
/** Audio formats to try, in order of preference. Defaults to ["ogg", "m4a"]. */
|
|
230
|
+
formats: string[];
|
|
231
|
+
}>;
|
|
232
|
+
declare class ElectricPiano {
|
|
437
233
|
#private;
|
|
438
234
|
readonly context: AudioContext;
|
|
439
235
|
readonly load: Promise<this>;
|
|
440
|
-
constructor(context: AudioContext, options: Partial<SfzSamplerConfig> & Pick<SfzSamplerConfig, "instrument">);
|
|
441
|
-
get output(): OutputChannel;
|
|
442
|
-
start(sample: NoteEvent | string | number): ReturnType<Smplr["start"]>;
|
|
443
|
-
stop(target?: StopTarget): void;
|
|
444
|
-
setCC(cc: number, value: number): void;
|
|
445
|
-
loaded(): Promise<this>;
|
|
446
|
-
disconnect(): void;
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
declare function getElectricPianoNames(): string[];
|
|
450
|
-
declare class ElectricPiano extends SfzSampler {
|
|
451
236
|
readonly tremolo: Readonly<{
|
|
452
237
|
level: (value: number) => void;
|
|
453
238
|
}>;
|
|
454
|
-
constructor(context: AudioContext, options:
|
|
239
|
+
constructor(context: AudioContext, options: ElectricPianoOptions & {
|
|
455
240
|
instrument: string;
|
|
456
241
|
});
|
|
242
|
+
get output(): OutputChannel;
|
|
243
|
+
get loadProgress(): LoadProgress;
|
|
244
|
+
start(sample: NoteEvent | string | number): StopFn;
|
|
245
|
+
stop(target?: StopTarget): void;
|
|
246
|
+
disconnect(): void;
|
|
457
247
|
}
|
|
458
248
|
|
|
459
249
|
declare function getVersilianInstruments(): Promise<string[]>;
|
|
@@ -725,6 +515,8 @@ type SplendidGrandPianoConfig = {
|
|
|
725
515
|
volume?: number;
|
|
726
516
|
/** Called after each buffer is loaded or served from cache. */
|
|
727
517
|
onLoadProgress?: (progress: LoadProgress) => void;
|
|
518
|
+
/** Audio formats to try, in order of preference. Defaults to ["ogg", "m4a"]. */
|
|
519
|
+
formats?: string[];
|
|
728
520
|
/** Limit which notes are fetched. Useful for reducing initial load time. */
|
|
729
521
|
notesToLoad?: {
|
|
730
522
|
notes: number[];
|
|
@@ -744,7 +536,7 @@ declare class SplendidGrandPiano {
|
|
|
744
536
|
stop(target?: StopTarget): void;
|
|
745
537
|
disconnect(): void;
|
|
746
538
|
}
|
|
747
|
-
type PianoJsonOptions = Pick<SplendidGrandPianoConfig, "baseUrl" | "detune" | "decayTime" | "notesToLoad">;
|
|
539
|
+
type PianoJsonOptions = Pick<SplendidGrandPianoConfig, "baseUrl" | "detune" | "decayTime" | "notesToLoad" | "formats">;
|
|
748
540
|
/**
|
|
749
541
|
* Convert the LAYERS array and user options into a SmplrJson descriptor.
|
|
750
542
|
*
|
|
@@ -769,4 +561,4 @@ declare const LAYERS: ({
|
|
|
769
561
|
cutoff?: undefined;
|
|
770
562
|
})[];
|
|
771
563
|
|
|
772
|
-
export { CacheStorage, DrumMachine, type DrumMachineOptions, ElectricPiano, HttpStorage, LAYERS, Mallet, Mellotron, type MellotronConfig, type MellotronOptions, NAME_TO_PATH, Reverb, Sampler, type SamplerConfig, Smolken, type SmolkenConfig, type SmolkenOptions, Soundfont, type Soundfont2Options, Soundfont2Sampler, type SoundfontOptions, SplendidGrandPiano, type SplendidGrandPianoConfig, type Storage, type StorageResponse, Versilian, type VersilianConfig, type VersilianOptions, drumMachineToSmplrJson, getDrumMachineNames, getElectricPianoNames, getMalletNames, getMellotronNames, getSmolkenNames, getSoundfontKits, getSoundfontNames, getVersilianInstruments, mellotronToSmplrJson, pianoToSmplrJson, samplerToSmplrJson, sf2InstrumentToSmplrJson, soundfontToSmplrJson, spreadKeyRanges };
|
|
564
|
+
export { CacheStorage, DrumMachine, type DrumMachineOptions, ElectricPiano, type ElectricPianoOptions, HttpStorage, LAYERS, Mallet, Mellotron, type MellotronConfig, type MellotronOptions, NAME_TO_PATH, Reverb, Sampler, type SamplerConfig, Smolken, type SmolkenConfig, type SmolkenOptions, Soundfont, type Soundfont2Options, Soundfont2Sampler, type SoundfontOptions, SplendidGrandPiano, type SplendidGrandPianoConfig, type Storage, type StorageResponse, Versilian, type VersilianConfig, type VersilianOptions, drumMachineToSmplrJson, getDrumMachineNames, getElectricPianoNames, getMalletNames, getMellotronNames, getSmolkenNames, getSoundfontKits, getSoundfontNames, getVersilianInstruments, mellotronToSmplrJson, pianoToSmplrJson, samplerToSmplrJson, sf2InstrumentToSmplrJson, soundfontToSmplrJson, spreadKeyRanges };
|
package/dist/index.d.ts
CHANGED
|
@@ -154,141 +154,6 @@ type LoadProgress = {
|
|
|
154
154
|
total: number;
|
|
155
155
|
};
|
|
156
156
|
|
|
157
|
-
/**
|
|
158
|
-
* Loads and caches AudioBuffers for all samples referenced in a SmplrJson.
|
|
159
|
-
*
|
|
160
|
-
* The cache is keyed by resolved URL, so the same audio file is never fetched
|
|
161
|
-
* or decoded twice. Multiple Smplr instances can share one SampleLoader by
|
|
162
|
-
* passing it via SmplrOptions.loader.
|
|
163
|
-
*/
|
|
164
|
-
declare class SampleLoader {
|
|
165
|
-
#private;
|
|
166
|
-
constructor(context: BaseAudioContext, options?: {
|
|
167
|
-
storage?: Storage;
|
|
168
|
-
});
|
|
169
|
-
/**
|
|
170
|
-
* Load all samples referenced in `json`. Returns a Map of sample name →
|
|
171
|
-
* AudioBuffer. Progress is reported via `onProgress` callback or via
|
|
172
|
-
* options object.
|
|
173
|
-
*
|
|
174
|
-
* - `buffers` in options: pre-loaded buffers — skips fetch for these names.
|
|
175
|
-
* - All samples load in parallel. Failed samples are silently omitted.
|
|
176
|
-
*/
|
|
177
|
-
load(json: SmplrJson, onProgressOrOptions?: ((loaded: number, total: number) => void) | {
|
|
178
|
-
buffers?: Map<string, AudioBuffer>;
|
|
179
|
-
onProgress?: (loaded: number, total: number) => void;
|
|
180
|
-
}): Promise<Map<string, AudioBuffer>>;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Standalone scheduler. Dispatches NoteEvents immediately when they fall within the
|
|
185
|
-
* lookahead window, or queues them for future dispatch via a self-managing interval.
|
|
186
|
-
*
|
|
187
|
-
* Multiple Smplr instances can share a single Scheduler for coordinated timing.
|
|
188
|
-
*/
|
|
189
|
-
declare class Scheduler {
|
|
190
|
-
#private;
|
|
191
|
-
constructor(context: BaseAudioContext, options?: {
|
|
192
|
-
lookaheadMs?: number;
|
|
193
|
-
intervalMs?: number;
|
|
194
|
-
});
|
|
195
|
-
/**
|
|
196
|
-
* Schedule a callback for a NoteEvent.
|
|
197
|
-
*
|
|
198
|
-
* - If the event's time falls within the lookahead window (or has no time), the
|
|
199
|
-
* callback is called synchronously and a no-op StopFn is returned.
|
|
200
|
-
* - Otherwise the event is queued, the interval is started if needed, and a StopFn
|
|
201
|
-
* is returned that removes the event from the queue before it is dispatched.
|
|
202
|
-
*/
|
|
203
|
-
schedule(event: NoteEvent, callback: (event: NoteEvent) => void): StopFn;
|
|
204
|
-
/**
|
|
205
|
-
* Clear all queued (not-yet-dispatched) events and stop the interval.
|
|
206
|
-
* Does not affect voices that are already playing.
|
|
207
|
-
*/
|
|
208
|
-
stop(): void;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
type SmplrOptions = {
|
|
212
|
-
/** Custom storage backend for sample fetching (e.g. CacheStorage). */
|
|
213
|
-
storage?: Storage;
|
|
214
|
-
/** Destination audio node. Defaults to context.destination. */
|
|
215
|
-
destination?: AudioNode;
|
|
216
|
-
/** Master volume (0–127 MIDI scale). Defaults to 100. */
|
|
217
|
-
volume?: number;
|
|
218
|
-
/** Custom volume-to-gain mapping function. Defaults to midiVelToGain. */
|
|
219
|
-
volumeToGain?: (volume: number) => number;
|
|
220
|
-
/** Default note velocity when not specified in NoteEvent (0–127). Defaults to 100. */
|
|
221
|
-
velocity?: number;
|
|
222
|
-
/** Shared SampleLoader instance. If omitted, a private one is created. */
|
|
223
|
-
loader?: SampleLoader;
|
|
224
|
-
/** Shared Scheduler instance. If omitted, a private one is created. */
|
|
225
|
-
scheduler?: Scheduler;
|
|
226
|
-
/** Called after each buffer is loaded (or served from cache). */
|
|
227
|
-
onLoadProgress?: (progress: LoadProgress) => void;
|
|
228
|
-
/** Called when a note is dispatched to the audio engine (slightly before playback). */
|
|
229
|
-
onStart?: (event: NoteEvent) => void;
|
|
230
|
-
/** Called when each voice's audio node ends. */
|
|
231
|
-
onEnded?: (event: NoteEvent) => void;
|
|
232
|
-
};
|
|
233
|
-
/**
|
|
234
|
-
* The main sampler class. Loads samples described by a SmplrJson descriptor,
|
|
235
|
-
* matches notes to regions, and plays them through a Channel.
|
|
236
|
-
*
|
|
237
|
-
* Multiple Smplr instances can share a SampleLoader (shared cache) and/or a
|
|
238
|
-
* Scheduler (coordinated timing) by passing them via SmplrOptions.
|
|
239
|
-
*
|
|
240
|
-
* Pattern A — json provided at construction:
|
|
241
|
-
* `new Smplr(context, json, options?)`
|
|
242
|
-
*
|
|
243
|
-
* Pattern B — json loaded later via loadInstrument():
|
|
244
|
-
* `new Smplr(context, options?)` then `smplr.loadInstrument(json)`
|
|
245
|
-
*/
|
|
246
|
-
declare class Smplr {
|
|
247
|
-
#private;
|
|
248
|
-
/** Resolves with `this` once all sample buffers are loaded. */
|
|
249
|
-
readonly load: Promise<Smplr>;
|
|
250
|
-
/** The AudioContext passed to the constructor. */
|
|
251
|
-
readonly context: AudioContext;
|
|
252
|
-
constructor(context: AudioContext, json: SmplrJson, options?: SmplrOptions);
|
|
253
|
-
constructor(context: AudioContext, options?: SmplrOptions);
|
|
254
|
-
/**
|
|
255
|
-
* Load (or replace) the instrument descriptor. Creates a new RegionMatcher
|
|
256
|
-
* and fetches all sample buffers. Pre-loaded buffers (e.g. base64-decoded)
|
|
257
|
-
* can be passed via the `buffers` parameter — those skip the fetch step.
|
|
258
|
-
*
|
|
259
|
-
* Returns a Promise that resolves when all samples are ready.
|
|
260
|
-
*/
|
|
261
|
-
loadInstrument(json: SmplrJson, buffers?: Map<string, AudioBuffer>): Promise<void>;
|
|
262
|
-
/** Current loading progress snapshot. `total` is known before loading starts. */
|
|
263
|
-
get loadProgress(): LoadProgress;
|
|
264
|
-
/** The output channel — use to add effects, adjust volume, or route audio. */
|
|
265
|
-
get output(): OutputChannel;
|
|
266
|
-
/**
|
|
267
|
-
* Set a MIDI CC value. Affects region matching for groups/regions that have
|
|
268
|
-
* ccRange constraints (e.g. CC64 sustain pedal).
|
|
269
|
-
*/
|
|
270
|
-
setCC(cc: number, value: number): void;
|
|
271
|
-
/**
|
|
272
|
-
* Start playing a note. Returns a StopFn that cancels the note if it hasn't
|
|
273
|
-
* played yet, or stops the resulting voices if it has.
|
|
274
|
-
*/
|
|
275
|
-
start(event: NoteEvent): StopFn;
|
|
276
|
-
/**
|
|
277
|
-
* Stop voices.
|
|
278
|
-
*
|
|
279
|
-
* - No argument → stop all active voices
|
|
280
|
-
* - String or number → stop all voices with that stopId
|
|
281
|
-
* - `{ stopId }` → stop voices with that stopId, optionally at a future time
|
|
282
|
-
* - `{ time }` (no stopId) → stop all voices at a future time
|
|
283
|
-
*/
|
|
284
|
-
stop(target?: StopTarget): void;
|
|
285
|
-
/**
|
|
286
|
-
* Stop all voices, disconnect the output channel, and stop the scheduler.
|
|
287
|
-
* The instance should not be used after this call.
|
|
288
|
-
*/
|
|
289
|
-
disconnect(): void;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
157
|
/**
|
|
293
158
|
* Given a list of [midi, sampleName] pairs, return one entry per sample with
|
|
294
159
|
* a keyRange that covers all MIDI notes closer to that sample than to any
|
|
@@ -353,107 +218,32 @@ declare class DrumMachine {
|
|
|
353
218
|
*/
|
|
354
219
|
declare function drumMachineToSmplrJson(instrument: DrumMachineInstrument): SmplrJson;
|
|
355
220
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
baseUrl?: string;
|
|
360
|
-
websfzUrl: string;
|
|
361
|
-
tags?: string[];
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
type Websfz = {
|
|
365
|
-
global: Record<string, string | number>;
|
|
366
|
-
groups: WebsfzGroup[];
|
|
367
|
-
meta: {
|
|
368
|
-
name?: string;
|
|
369
|
-
description?: string;
|
|
370
|
-
license?: string;
|
|
371
|
-
source?: string;
|
|
372
|
-
baseUrl?: string;
|
|
373
|
-
websfzUrl?: string;
|
|
374
|
-
formats?: string[];
|
|
375
|
-
tags?: string[];
|
|
376
|
-
};
|
|
377
|
-
};
|
|
378
|
-
type WebsfzGroup = {
|
|
379
|
-
group_label?: string;
|
|
380
|
-
group?: number;
|
|
381
|
-
hikey?: number;
|
|
382
|
-
hivel?: number;
|
|
383
|
-
lokey?: number;
|
|
384
|
-
lovel?: number;
|
|
385
|
-
off_by?: number;
|
|
386
|
-
off_mode?: "normal";
|
|
387
|
-
pitch_keycenter?: number;
|
|
388
|
-
regions: WebsfzRegion[];
|
|
389
|
-
seq_length?: number;
|
|
390
|
-
trigger?: "first" | "legato";
|
|
391
|
-
volume?: number;
|
|
392
|
-
amp_velcurve_83?: number;
|
|
393
|
-
locc64?: number;
|
|
394
|
-
hicc64?: number;
|
|
395
|
-
hicc107?: number;
|
|
396
|
-
locc107?: number;
|
|
397
|
-
pan_oncc122?: number;
|
|
398
|
-
tune_oncc123?: number;
|
|
399
|
-
eg06_time1_oncc109?: number;
|
|
400
|
-
ampeg_attack_oncc100?: number;
|
|
401
|
-
};
|
|
402
|
-
type WebsfzRegion = {
|
|
403
|
-
end?: number;
|
|
404
|
-
group?: number;
|
|
405
|
-
hivel?: number;
|
|
406
|
-
lovel?: number;
|
|
407
|
-
hikey?: number;
|
|
408
|
-
key?: number;
|
|
409
|
-
lokey?: number;
|
|
410
|
-
off_by?: number;
|
|
411
|
-
pitch_keycenter?: number;
|
|
412
|
-
region_label?: number;
|
|
413
|
-
sample: string;
|
|
414
|
-
seq_position?: number;
|
|
415
|
-
trigger?: "first" | "legato";
|
|
416
|
-
volume?: number;
|
|
417
|
-
locc64?: number;
|
|
418
|
-
hicc64?: number;
|
|
419
|
-
ampeg_attack_oncc100?: number;
|
|
420
|
-
eg06_time1_oncc109?: number;
|
|
421
|
-
pan_oncc122?: number;
|
|
422
|
-
tune_oncc123?: number;
|
|
423
|
-
};
|
|
424
|
-
|
|
425
|
-
type SfzSamplerConfig = {
|
|
426
|
-
instrument: SfzInstrument | Websfz | string;
|
|
221
|
+
declare function getElectricPianoNames(): string[];
|
|
222
|
+
type ElectricPianoOptions = Partial<{
|
|
223
|
+
instrument: string;
|
|
427
224
|
storage: Storage;
|
|
428
225
|
destination: AudioNode;
|
|
429
226
|
volume: number;
|
|
430
227
|
velocity: number;
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
declare class SfzSampler {
|
|
228
|
+
onLoadProgress: (progress: LoadProgress) => void;
|
|
229
|
+
/** Audio formats to try, in order of preference. Defaults to ["ogg", "m4a"]. */
|
|
230
|
+
formats: string[];
|
|
231
|
+
}>;
|
|
232
|
+
declare class ElectricPiano {
|
|
437
233
|
#private;
|
|
438
234
|
readonly context: AudioContext;
|
|
439
235
|
readonly load: Promise<this>;
|
|
440
|
-
constructor(context: AudioContext, options: Partial<SfzSamplerConfig> & Pick<SfzSamplerConfig, "instrument">);
|
|
441
|
-
get output(): OutputChannel;
|
|
442
|
-
start(sample: NoteEvent | string | number): ReturnType<Smplr["start"]>;
|
|
443
|
-
stop(target?: StopTarget): void;
|
|
444
|
-
setCC(cc: number, value: number): void;
|
|
445
|
-
loaded(): Promise<this>;
|
|
446
|
-
disconnect(): void;
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
declare function getElectricPianoNames(): string[];
|
|
450
|
-
declare class ElectricPiano extends SfzSampler {
|
|
451
236
|
readonly tremolo: Readonly<{
|
|
452
237
|
level: (value: number) => void;
|
|
453
238
|
}>;
|
|
454
|
-
constructor(context: AudioContext, options:
|
|
239
|
+
constructor(context: AudioContext, options: ElectricPianoOptions & {
|
|
455
240
|
instrument: string;
|
|
456
241
|
});
|
|
242
|
+
get output(): OutputChannel;
|
|
243
|
+
get loadProgress(): LoadProgress;
|
|
244
|
+
start(sample: NoteEvent | string | number): StopFn;
|
|
245
|
+
stop(target?: StopTarget): void;
|
|
246
|
+
disconnect(): void;
|
|
457
247
|
}
|
|
458
248
|
|
|
459
249
|
declare function getVersilianInstruments(): Promise<string[]>;
|
|
@@ -725,6 +515,8 @@ type SplendidGrandPianoConfig = {
|
|
|
725
515
|
volume?: number;
|
|
726
516
|
/** Called after each buffer is loaded or served from cache. */
|
|
727
517
|
onLoadProgress?: (progress: LoadProgress) => void;
|
|
518
|
+
/** Audio formats to try, in order of preference. Defaults to ["ogg", "m4a"]. */
|
|
519
|
+
formats?: string[];
|
|
728
520
|
/** Limit which notes are fetched. Useful for reducing initial load time. */
|
|
729
521
|
notesToLoad?: {
|
|
730
522
|
notes: number[];
|
|
@@ -744,7 +536,7 @@ declare class SplendidGrandPiano {
|
|
|
744
536
|
stop(target?: StopTarget): void;
|
|
745
537
|
disconnect(): void;
|
|
746
538
|
}
|
|
747
|
-
type PianoJsonOptions = Pick<SplendidGrandPianoConfig, "baseUrl" | "detune" | "decayTime" | "notesToLoad">;
|
|
539
|
+
type PianoJsonOptions = Pick<SplendidGrandPianoConfig, "baseUrl" | "detune" | "decayTime" | "notesToLoad" | "formats">;
|
|
748
540
|
/**
|
|
749
541
|
* Convert the LAYERS array and user options into a SmplrJson descriptor.
|
|
750
542
|
*
|
|
@@ -769,4 +561,4 @@ declare const LAYERS: ({
|
|
|
769
561
|
cutoff?: undefined;
|
|
770
562
|
})[];
|
|
771
563
|
|
|
772
|
-
export { CacheStorage, DrumMachine, type DrumMachineOptions, ElectricPiano, HttpStorage, LAYERS, Mallet, Mellotron, type MellotronConfig, type MellotronOptions, NAME_TO_PATH, Reverb, Sampler, type SamplerConfig, Smolken, type SmolkenConfig, type SmolkenOptions, Soundfont, type Soundfont2Options, Soundfont2Sampler, type SoundfontOptions, SplendidGrandPiano, type SplendidGrandPianoConfig, type Storage, type StorageResponse, Versilian, type VersilianConfig, type VersilianOptions, drumMachineToSmplrJson, getDrumMachineNames, getElectricPianoNames, getMalletNames, getMellotronNames, getSmolkenNames, getSoundfontKits, getSoundfontNames, getVersilianInstruments, mellotronToSmplrJson, pianoToSmplrJson, samplerToSmplrJson, sf2InstrumentToSmplrJson, soundfontToSmplrJson, spreadKeyRanges };
|
|
564
|
+
export { CacheStorage, DrumMachine, type DrumMachineOptions, ElectricPiano, type ElectricPianoOptions, HttpStorage, LAYERS, Mallet, Mellotron, type MellotronConfig, type MellotronOptions, NAME_TO_PATH, Reverb, Sampler, type SamplerConfig, Smolken, type SmolkenConfig, type SmolkenOptions, Soundfont, type Soundfont2Options, Soundfont2Sampler, type SoundfontOptions, SplendidGrandPiano, type SplendidGrandPianoConfig, type Storage, type StorageResponse, Versilian, type VersilianConfig, type VersilianOptions, drumMachineToSmplrJson, getDrumMachineNames, getElectricPianoNames, getMalletNames, getMellotronNames, getSmolkenNames, getSoundfontKits, getSoundfontNames, getVersilianInstruments, mellotronToSmplrJson, pianoToSmplrJson, samplerToSmplrJson, sf2InstrumentToSmplrJson, soundfontToSmplrJson, spreadKeyRanges };
|