From 1e1d5ef442e84dc24ffb3eca7dc9b4873ed611c4 Mon Sep 17 00:00:00 2001 From: "Alexandre G.-Raymond" Date: Sat, 28 Oct 2023 11:47:37 +0200 Subject: [PATCH] Document striate function --- packages/core/pattern.mjs | 8 ++++++++ test/__snapshots__/examples.test.mjs.snap | 17 +++++++++++++++++ website/src/pages/learn/samples.mdx | 4 ++++ 3 files changed, 29 insertions(+) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index 598280bc5..4dcf02e77 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -2217,6 +2217,14 @@ export const chop = register('chop', function (n, pat) { return pat.squeezeBind(func); }); +/** + * Cuts each sample into the given number of parts, triggering progressive portions of each sample at each loop. + * @name striate + * @memberof Pattern + * @returns Pattern + * @example + * s("numbers:0 numbers:1 numbers:2").striate(6).slow(6) + */ export const striate = register('striate', function (n, pat) { const slices = Array.from({ length: n }, (x, i) => i); const slice_objects = slices.map((i) => ({ begin: i / n, end: (i + 1) / n })); diff --git a/test/__snapshots__/examples.test.mjs.snap b/test/__snapshots__/examples.test.mjs.snap index 62c2f0d89..b37af3e98 100644 --- a/test/__snapshots__/examples.test.mjs.snap +++ b/test/__snapshots__/examples.test.mjs.snap @@ -4683,6 +4683,23 @@ exports[`runs examples > example "stack" example index 0 2`] = ` ] `; +exports[`runs examples > example "striate" example index 0 1`] = ` +[ + "[ 0/1 → 1/3 | s:numbers n:0 begin:0 end:0.16666666666666666 ]", + "[ 1/3 → 2/3 | s:numbers n:1 begin:0 end:0.16666666666666666 ]", + "[ 2/3 → 1/1 | s:numbers n:2 begin:0 end:0.16666666666666666 ]", + "[ 1/1 → 4/3 | s:numbers n:0 begin:0.16666666666666666 end:0.3333333333333333 ]", + "[ 4/3 → 5/3 | s:numbers n:1 begin:0.16666666666666666 end:0.3333333333333333 ]", + "[ 5/3 → 2/1 | s:numbers n:2 begin:0.16666666666666666 end:0.3333333333333333 ]", + "[ 2/1 → 7/3 | s:numbers n:0 begin:0.3333333333333333 end:0.5 ]", + "[ 7/3 → 8/3 | s:numbers n:1 begin:0.3333333333333333 end:0.5 ]", + "[ 8/3 → 3/1 | s:numbers n:2 begin:0.3333333333333333 end:0.5 ]", + "[ 3/1 → 10/3 | s:numbers n:0 begin:0.5 end:0.6666666666666666 ]", + "[ 10/3 → 11/3 | s:numbers n:1 begin:0.5 end:0.6666666666666666 ]", + "[ 11/3 → 4/1 | s:numbers n:2 begin:0.5 end:0.6666666666666666 ]", +] +`; + exports[`runs examples > example "struct" example index 0 1`] = ` [ "[ 0/1 → 1/4 | note:c3 ]", diff --git a/website/src/pages/learn/samples.mdx b/website/src/pages/learn/samples.mdx index 658caec73..0496f3c65 100644 --- a/website/src/pages/learn/samples.mdx +++ b/website/src/pages/learn/samples.mdx @@ -348,6 +348,10 @@ Sampler effects are functions that can be used to change the behaviour of sample +### striate + + + ### slice