smplr 0.12.1 → 0.12.3

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 CHANGED
@@ -296,16 +296,21 @@ const piano = new SplendidGrandPiano(context, { storage });
296
296
 
297
297
  ### Sampler
298
298
 
299
- An audio buffer sampler.
299
+ An audio buffer sampler. Pass a `buffers` object with the files to be load:
300
300
 
301
301
  ```js
302
302
  import { Sampler } from "smplr";
303
303
 
304
- const samples = {
304
+ const buffers = {
305
305
  kick: "https://danigb.github.io/samples/drum-machines/808-mini/kick.m4a",
306
306
  snare: "https://danigb.github.io/samples/drum-machines/808-mini/snare-1.m4a",
307
307
  };
308
- const sampler = new Sampler(new AudioContext(), { samples });
308
+ const sampler = new Sampler(new AudioContext(), { buffers });
309
+ ```
310
+
311
+ And then use the name of the buffer as note name:
312
+
313
+ ```js
309
314
  sampler.start({ note: "kick" });
310
315
  ```
311
316
 
package/dist/index.d.mts CHANGED
@@ -76,6 +76,9 @@ type SampleStop = {
76
76
  stopId?: string | number;
77
77
  time?: number;
78
78
  };
79
+ /**
80
+ * Configurable options for a sample
81
+ */
79
82
  type SampleOptions = {
80
83
  decayTime?: number;
81
84
  detune?: number;
@@ -87,6 +90,9 @@ type SampleOptions = {
87
90
  loopEnd?: number;
88
91
  gainOffset?: number;
89
92
  };
93
+ /**
94
+ * Start a sample with a specific options
95
+ */
90
96
  type SampleStart = {
91
97
  name?: string;
92
98
  note: string | number;
@@ -97,6 +103,12 @@ type SampleStart = {
97
103
  time?: number;
98
104
  } & SampleOptions;
99
105
  /**
106
+ * Represents a playable region for a sample.
107
+ *
108
+ * It provides constrains to limit which samples are affected,
109
+ * and defaults to apply to the affected samples.
110
+ *
111
+ *
100
112
  * Heavily inspired by SFZ format
101
113
  */
102
114
  type SampleRegion = {
package/dist/index.d.ts CHANGED
@@ -76,6 +76,9 @@ type SampleStop = {
76
76
  stopId?: string | number;
77
77
  time?: number;
78
78
  };
79
+ /**
80
+ * Configurable options for a sample
81
+ */
79
82
  type SampleOptions = {
80
83
  decayTime?: number;
81
84
  detune?: number;
@@ -87,6 +90,9 @@ type SampleOptions = {
87
90
  loopEnd?: number;
88
91
  gainOffset?: number;
89
92
  };
93
+ /**
94
+ * Start a sample with a specific options
95
+ */
90
96
  type SampleStart = {
91
97
  name?: string;
92
98
  note: string | number;
@@ -97,6 +103,12 @@ type SampleStart = {
97
103
  time?: number;
98
104
  } & SampleOptions;
99
105
  /**
106
+ * Represents a playable region for a sample.
107
+ *
108
+ * It provides constrains to limit which samples are affected,
109
+ * and defaults to apply to the affected samples.
110
+ *
111
+ *
100
112
  * Heavily inspired by SFZ format
101
113
  */
102
114
  type SampleRegion = {
package/dist/index.js CHANGED
@@ -1116,7 +1116,7 @@ function findFirstSampleInRegions(group, sample, seqNumber) {
1116
1116
  }
1117
1117
  function findSampleInRegion(midi, seqNum, sample, region, defaults) {
1118
1118
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A;
1119
- const matchMidi = midi >= ((_a = region.midiLow) != null ? _a : 0) && midi <= ((_b = region.midiHigh) != null ? _b : 127);
1119
+ const matchMidi = midi >= ((_a = region.midiLow) != null ? _a : 0) && midi < ((_b = region.midiHigh) != null ? _b : 127) + 1;
1120
1120
  if (!matchMidi)
1121
1121
  return void 0;
1122
1122
  const matchVelocity = sample.velocity === void 0 || sample.velocity >= ((_c = region.velLow) != null ? _c : 0) && sample.velocity <= ((_d = region.velHigh) != null ? _d : 127);