smplr 0.12.3 → 0.13.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/dist/index.d.mts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +15 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -236,9 +236,18 @@ type QueuedPlayerConfig = {
|
|
|
236
236
|
|
|
237
237
|
type DefaultPlayerConfig = ChannelConfig & SamplerConfig & QueuedPlayerConfig;
|
|
238
238
|
|
|
239
|
+
type DrumMachineInstrument = {
|
|
240
|
+
baseUrl: string;
|
|
241
|
+
name: string;
|
|
242
|
+
samples: string[];
|
|
243
|
+
sampleNames: string[];
|
|
244
|
+
nameToSample: Record<string, string | undefined>;
|
|
245
|
+
sampleNameVariations: Record<string, string[]>;
|
|
246
|
+
};
|
|
247
|
+
|
|
239
248
|
declare function getDrumMachineNames(): string[];
|
|
240
249
|
type DrumMachineConfig = {
|
|
241
|
-
instrument: string;
|
|
250
|
+
instrument: string | DrumMachineInstrument;
|
|
242
251
|
url: string;
|
|
243
252
|
storage: Storage;
|
|
244
253
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -236,9 +236,18 @@ type QueuedPlayerConfig = {
|
|
|
236
236
|
|
|
237
237
|
type DefaultPlayerConfig = ChannelConfig & SamplerConfig & QueuedPlayerConfig;
|
|
238
238
|
|
|
239
|
+
type DrumMachineInstrument = {
|
|
240
|
+
baseUrl: string;
|
|
241
|
+
name: string;
|
|
242
|
+
samples: string[];
|
|
243
|
+
sampleNames: string[];
|
|
244
|
+
nameToSample: Record<string, string | undefined>;
|
|
245
|
+
sampleNameVariations: Record<string, string[]>;
|
|
246
|
+
};
|
|
247
|
+
|
|
239
248
|
declare function getDrumMachineNames(): string[];
|
|
240
249
|
type DrumMachineConfig = {
|
|
241
|
-
instrument: string;
|
|
250
|
+
instrument: string | DrumMachineInstrument;
|
|
242
251
|
url: string;
|
|
243
252
|
storage: Storage;
|
|
244
253
|
};
|
package/dist/index.js
CHANGED
|
@@ -679,6 +679,9 @@ saveResponse_fn = function(request, response) {
|
|
|
679
679
|
};
|
|
680
680
|
|
|
681
681
|
// src/drum-machine/dm-instrument.ts
|
|
682
|
+
function isDrumMachineInstrument(instrument) {
|
|
683
|
+
return typeof instrument === "object" && typeof instrument.baseUrl === "string" && typeof instrument.name === "string" && Array.isArray(instrument.samples) && Array.isArray(instrument.sampleNames) && typeof instrument.nameToSample === "object" && typeof instrument.sampleNameVariations === "object";
|
|
684
|
+
}
|
|
682
685
|
var EMPTY_INSTRUMENT = {
|
|
683
686
|
baseUrl: "",
|
|
684
687
|
name: "",
|
|
@@ -718,11 +721,11 @@ function getDrumMachineNames() {
|
|
|
718
721
|
return Object.keys(INSTRUMENTS);
|
|
719
722
|
}
|
|
720
723
|
var INSTRUMENTS = {
|
|
721
|
-
"TR-808": "https://
|
|
722
|
-
"Casio-RZ1": "https://
|
|
723
|
-
"LM-2": "https://
|
|
724
|
-
"MFB-512": "https://
|
|
725
|
-
"Roland CR-8000": "https://
|
|
724
|
+
"TR-808": "https://smpldsnds.github.io/drum-machines/TR-808/dm.json",
|
|
725
|
+
"Casio-RZ1": "https://smpldsnds.github.io/drum-machines/Casio-RZ1/dm.json",
|
|
726
|
+
"LM-2": "https://smpldsnds.github.io/drum-machines/LM-2/dm.json",
|
|
727
|
+
"MFB-512": "https://smpldsnds.github.io/drum-machines/MFB-512/dm.json",
|
|
728
|
+
"Roland CR-8000": "https://smpldsnds.github.io/drum-machines/Roland-CR-8000/dm.json"
|
|
726
729
|
};
|
|
727
730
|
function getConfig2(options) {
|
|
728
731
|
var _a, _b, _c;
|
|
@@ -731,9 +734,13 @@ function getConfig2(options) {
|
|
|
731
734
|
storage: (_b = options == null ? void 0 : options.storage) != null ? _b : HttpStorage,
|
|
732
735
|
url: (_c = options == null ? void 0 : options.url) != null ? _c : ""
|
|
733
736
|
};
|
|
734
|
-
|
|
735
|
-
|
|
737
|
+
if (typeof config.instrument === "string") {
|
|
738
|
+
config.url || (config.url = INSTRUMENTS[config.instrument]);
|
|
739
|
+
if (!config.url)
|
|
740
|
+
throw new Error("Invalid instrument: " + config.instrument);
|
|
741
|
+
} else if (!isDrumMachineInstrument(config.instrument)) {
|
|
736
742
|
throw new Error("Invalid instrument: " + config.instrument);
|
|
743
|
+
}
|
|
737
744
|
return config;
|
|
738
745
|
}
|
|
739
746
|
var _instrument;
|
|
@@ -741,7 +748,7 @@ var DrumMachine = class {
|
|
|
741
748
|
constructor(context, options) {
|
|
742
749
|
__privateAdd(this, _instrument, EMPTY_INSTRUMENT);
|
|
743
750
|
const config = getConfig2(options);
|
|
744
|
-
const instrument = fetchDrumMachineInstrument(config.url, config.storage);
|
|
751
|
+
const instrument = isDrumMachineInstrument(config.instrument) ? Promise.resolve(config.instrument) : fetchDrumMachineInstrument(config.url, config.storage);
|
|
745
752
|
this.player = new DefaultPlayer(context, options);
|
|
746
753
|
this.output = this.player.output;
|
|
747
754
|
this.load = drumMachineLoader(
|