Skip to content

Commit

Permalink
Merge pull request #766 from ilesinge/document_striate
Browse files Browse the repository at this point in the history
Document striate function
  • Loading branch information
felixroos authored Oct 28, 2023
2 parents 248757a + 1e1d5ef commit 6c23309
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/core/pattern.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
Expand Down
17 changes: 17 additions & 0 deletions test/__snapshots__/examples.test.mjs.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]",
Expand Down
4 changes: 4 additions & 0 deletions website/src/pages/learn/samples.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ Sampler effects are functions that can be used to change the behaviour of sample

<JsDoc client:idle name="Pattern.chop" h={0} />

### striate

<JsDoc client:idle name="Pattern.striate" h={0} />

### slice

<JsDoc client:idle name="Pattern.slice" h={0} />
Expand Down

0 comments on commit 6c23309

Please sign in to comment.