smplr 0.25.0 → 0.26.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 +56 -56
- package/dist/index.d.mts +68 -46
- package/dist/index.d.ts +68 -46
- package/dist/index.js +23 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -43
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -386,7 +386,7 @@ function pickPlaybackParams(obj) {
|
|
|
386
386
|
return result;
|
|
387
387
|
}
|
|
388
388
|
function resolveParams(defaults, group, region, midi, velocity, overrides) {
|
|
389
|
-
var _a, _b, _c, _d, _e;
|
|
389
|
+
var _a, _b, _c, _d, _e, _f;
|
|
390
390
|
const merged = __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, PARAM_DEFAULTS), defaults), pickPlaybackParams(group)), pickPlaybackParams(region));
|
|
391
391
|
const pitch = (_b = (_a = region.pitch) != null ? _a : region.key) != null ? _b : midi;
|
|
392
392
|
const semitones = midi - pitch;
|
|
@@ -405,7 +405,7 @@ function resolveParams(defaults, group, region, midi, velocity, overrides) {
|
|
|
405
405
|
loopEnd: merged.loopEnd,
|
|
406
406
|
ampVelCurve: region.ampVelCurve,
|
|
407
407
|
loopAuto: region.loopAuto,
|
|
408
|
-
reverse: overrides == null ? void 0 : overrides.reverse
|
|
408
|
+
reverse: (_f = overrides == null ? void 0 : overrides.reverse) != null ? _f : merged.reverse
|
|
409
409
|
};
|
|
410
410
|
}
|
|
411
411
|
|
|
@@ -583,14 +583,6 @@ var SampleLoaderImpl = class {
|
|
|
583
583
|
__privateSet(this, _context, context);
|
|
584
584
|
__privateSet(this, _storage, (_a = options == null ? void 0 : options.storage) != null ? _a : HttpStorage);
|
|
585
585
|
}
|
|
586
|
-
/**
|
|
587
|
-
* Load all samples referenced in `json`. Returns a Map of sample name →
|
|
588
|
-
* AudioBuffer. Progress is reported via `onProgress` callback or via
|
|
589
|
-
* options object.
|
|
590
|
-
*
|
|
591
|
-
* - `buffers` in options: pre-loaded buffers — skips fetch for these names.
|
|
592
|
-
* - All samples load in parallel. Failed samples are silently omitted.
|
|
593
|
-
*/
|
|
594
586
|
load(json, onProgressOrOptions) {
|
|
595
587
|
return __async(this, null, function* () {
|
|
596
588
|
var _a, _b;
|
|
@@ -710,14 +702,6 @@ var SchedulerImpl = class {
|
|
|
710
702
|
__privateSet(this, _intervalMs, (_b = options == null ? void 0 : options.intervalMs) != null ? _b : INTERVAL_MS_DEFAULT);
|
|
711
703
|
__privateSet(this, _queue, new SortedQueue((a, b) => a.time - b.time));
|
|
712
704
|
}
|
|
713
|
-
/**
|
|
714
|
-
* Schedule a callback for a NoteEvent.
|
|
715
|
-
*
|
|
716
|
-
* - If the event's time falls within the lookahead window (or has no time), the
|
|
717
|
-
* callback is called synchronously and a no-op StopFn is returned.
|
|
718
|
-
* - Otherwise the event is queued, the interval is started if needed, and a StopFn
|
|
719
|
-
* is returned that removes the event from the queue before it is dispatched.
|
|
720
|
-
*/
|
|
721
705
|
schedule(event, callback) {
|
|
722
706
|
var _a;
|
|
723
707
|
const now = __privateGet(this, _context2).currentTime;
|
|
@@ -733,10 +717,6 @@ var SchedulerImpl = class {
|
|
|
733
717
|
__privateGet(this, _queue).removeAll((q) => q === item);
|
|
734
718
|
};
|
|
735
719
|
}
|
|
736
|
-
/**
|
|
737
|
-
* Clear all queued (not-yet-dispatched) events and stop the interval.
|
|
738
|
-
* Does not affect voices that are already playing.
|
|
739
|
-
*/
|
|
740
720
|
stop() {
|
|
741
721
|
__privateGet(this, _queue).clear();
|
|
742
722
|
if (__privateGet(this, _intervalId) !== void 0) {
|
|
@@ -1009,10 +989,12 @@ var SmplrImpl = class {
|
|
|
1009
989
|
__privateSet(this, _voices2, new VoiceManager());
|
|
1010
990
|
this.loader = (_c = options == null ? void 0 : options.loader) != null ? _c : SampleLoader(context, { storage: options == null ? void 0 : options.storage });
|
|
1011
991
|
if (json) {
|
|
1012
|
-
this.ready = this.loader.load(json,
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
992
|
+
this.ready = this.loader.load(json, {
|
|
993
|
+
onProgress: (loaded, total) => {
|
|
994
|
+
var _a2;
|
|
995
|
+
__privateSet(this, _loadProgress, { loaded, total });
|
|
996
|
+
(_a2 = __privateGet(this, _onLoadProgress)) == null ? void 0 : _a2.call(this, { loaded, total });
|
|
997
|
+
}
|
|
1016
998
|
}).then((buffers) => {
|
|
1017
999
|
__privateSet(this, _buffers, buffers);
|
|
1018
1000
|
});
|
|
@@ -2571,6 +2553,7 @@ var SequencerImpl = class {
|
|
|
2571
2553
|
this._clock.stop();
|
|
2572
2554
|
this._stopLoop();
|
|
2573
2555
|
this._endScheduled = false;
|
|
2556
|
+
for (const stopFn of this._activeVoices.values()) stopFn();
|
|
2574
2557
|
this._activeVoices.clear();
|
|
2575
2558
|
this._emitStateChange("stopped");
|
|
2576
2559
|
return this;
|
|
@@ -3208,8 +3191,10 @@ function createTremolo(context, depth) {
|
|
|
3208
3191
|
splitter.disconnect(ampR, 1);
|
|
3209
3192
|
ampL.disconnect(merger, 0, 0);
|
|
3210
3193
|
ampR.disconnect(merger, 0, 1);
|
|
3211
|
-
lfoL.disconnect(
|
|
3212
|
-
|
|
3194
|
+
lfoL.disconnect(lfoLAmp);
|
|
3195
|
+
lfoLAmp.disconnect(ampL.gain);
|
|
3196
|
+
lfoR.disconnect(lfoRAmp);
|
|
3197
|
+
lfoRAmp.disconnect(ampR.gain);
|
|
3213
3198
|
merger.disconnect(output);
|
|
3214
3199
|
};
|
|
3215
3200
|
return { input, output };
|
|
@@ -3280,15 +3265,11 @@ var ElectricPiano = Instrument(
|
|
|
3280
3265
|
|
|
3281
3266
|
// src/versilian.ts
|
|
3282
3267
|
var VCSL_BASE_URL = "https://smpldsnds.github.io/sgossner-vcsl";
|
|
3283
|
-
var
|
|
3268
|
+
var instrumentsPromise;
|
|
3284
3269
|
function getVersilianInstruments() {
|
|
3285
|
-
return
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
(res) => res.json()
|
|
3289
|
-
);
|
|
3290
|
-
return instruments;
|
|
3291
|
-
});
|
|
3270
|
+
return instrumentsPromise != null ? instrumentsPromise : instrumentsPromise = fetch(
|
|
3271
|
+
VCSL_BASE_URL + "/sfz_files.json"
|
|
3272
|
+
).then((res) => res.json());
|
|
3292
3273
|
}
|
|
3293
3274
|
var Versilian = Instrument(
|
|
3294
3275
|
(ctx, options = {}, smplr) => loadVersilianInstrument(smplr, options)
|
|
@@ -3420,7 +3401,7 @@ function mellotronToPreset(sampleNames, config) {
|
|
|
3420
3401
|
for (const sampleName of sampleNames) {
|
|
3421
3402
|
if (config.variation && !sampleName.includes(config.variation)) continue;
|
|
3422
3403
|
const midi = toMidi((_a = sampleName.split(" ")[0]) != null ? _a : "");
|
|
3423
|
-
if (
|
|
3404
|
+
if (midi === void 0) continue;
|
|
3424
3405
|
entries.push([midi, sampleName]);
|
|
3425
3406
|
}
|
|
3426
3407
|
const spread = spreadKeyRanges(entries);
|
|
@@ -3505,7 +3486,7 @@ var ReverbImpl = class {
|
|
|
3505
3486
|
}
|
|
3506
3487
|
getParam(name) {
|
|
3507
3488
|
var _a;
|
|
3508
|
-
return (_a = __privateGet(this, _effect)) == null ? void 0 : _a.parameters.get(
|
|
3489
|
+
return (_a = __privateGet(this, _effect)) == null ? void 0 : _a.parameters.get(name);
|
|
3509
3490
|
}
|
|
3510
3491
|
get isReady() {
|
|
3511
3492
|
return __privateGet(this, _effect) !== void 0;
|
|
@@ -3832,10 +3813,9 @@ function fetchSoundfontLoopData(url, sampleRate = 44100) {
|
|
|
3832
3813
|
const loopData = {};
|
|
3833
3814
|
Object.keys(raw).forEach((key) => {
|
|
3834
3815
|
const midi = toMidi(key);
|
|
3835
|
-
if (midi)
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
}
|
|
3816
|
+
if (midi === void 0) return;
|
|
3817
|
+
const offsets = raw[key];
|
|
3818
|
+
loopData[midi] = [offsets[0] / sampleRate, offsets[1] / sampleRate];
|
|
3839
3819
|
});
|
|
3840
3820
|
return loopData;
|
|
3841
3821
|
} catch (err) {
|
|
@@ -3880,7 +3860,7 @@ function decodeSoundfontFile(context, config) {
|
|
|
3880
3860
|
yield Promise.all(
|
|
3881
3861
|
noteNames.map((noteName) => __async(null, null, function* () {
|
|
3882
3862
|
const midi = toMidi(noteName);
|
|
3883
|
-
if (
|
|
3863
|
+
if (midi === void 0) return;
|
|
3884
3864
|
try {
|
|
3885
3865
|
const audioData = base64ToArrayBuffer(
|
|
3886
3866
|
removeBase64Prefix(json[noteName])
|