diff --git a/CHANGELOG.md b/CHANGELOG.md index 45f0026..547bdfc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # smplr +## 0.16.x + +#### DrumMachine sample groups + +DrumMachines group different samples with same prefix under the same group. For example `tom-1.ogg` and `tom-2.ogg` forms the `tom` group: + +```js +const drums = new DrumMachine(context, { instrument: "TR-808" }); +drum.getSampleNames(); // => ['kick-1', 'kick-2', 'snare-1', 'snare-2', ...] +drum.getGroupNames(); // => ['kick', 'snare'] +drum.getSampleNamesForGroup('kick') => // => ['kick-1', 'kick-2'] +``` + +**Deprecations:** + +- `drum.sampleNames` is deprecated in favour of `drum.getSampleNames()` or `drum.getGroupNames()` +- `drum.getVariations` is now called `drum.getSampleNamesForGroup` + ## 0.15.x #### Disable scheduler with `disableScheduler` option diff --git a/README.md b/README.md index 4de5e87..7343d5b 100644 --- a/README.md +++ b/README.md @@ -467,11 +467,14 @@ const context = new AudioContext(); const drums = new DrumMachine(context, { instrument: "TR-808" }); drums.start({ note: "kick" }); -// Drum samples could have variations: -const now = context.currentTime; -drums.getVariations("kick").forEach((variation, index) => { - drums.start({ note: variation, time: now + index }); -}); +// Drum samples are grouped and can have sample variations: +drums.getSampleNames(); // => ['kick-1', 'kick-2', 'snare-1', 'snare-2', ...] +drums.getGroupNames(); // => ['kick', 'snare'] +drums.getSampleNamesForGroup("kick") => // => ['kick-1', 'kick-2'] + +// You can trigger samples by group name or specific sample +drums.start("kick"); // Play the first sample of the group +drums.start("kick-1"); // Play this specific sample ``` ### Smolken double bass diff --git a/package.json b/package.json index e69321c..d4cc849 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "smplr", - "version": "0.15.1", + "version": "0.16.0", "homepage": "https://github.com/danigb/smplr#readme", "description": "A Sampled collection of instruments", "main": "dist/index.js", diff --git a/site/src/DrumMachineExample.tsx b/site/src/DrumMachineExample.tsx index 0d44962..17fa1d5 100644 --- a/site/src/DrumMachineExample.tsx +++ b/site/src/DrumMachineExample.tsx @@ -90,29 +90,29 @@ export function DrumMachineExample({ className }: { className?: string }) { />