Skip to content

Commit

Permalink
Fix wchooseCycles not picking the whole pattern (#1061)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilesinge authored Apr 21, 2024
1 parent 64cc8ca commit a194180
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/core/signal.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,10 @@ export const wchoose = (...pairs) => wchooseWith(rand, ...pairs);
* @returns {Pattern}
* @example
* wchooseCycles(["bd",10], ["hh",1], ["sd",1]).s().fast(8)
* @example
* wchooseCycles(["bd bd bd",5], ["hh hh hh",3], ["sd sd sd",1]).fast(4).s()
*/
export const wchooseCycles = (...pairs) => _wchooseWith(rand, ...pairs).innerJoin();
export const wchooseCycles = (...pairs) => _wchooseWith(rand.segment(1), ...pairs).innerJoin();

export const wrandcat = wchooseCycles;

Expand Down
59 changes: 56 additions & 3 deletions test/__snapshots__/examples.test.mjs.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7985,12 +7985,12 @@ exports[`runs examples > example "wchooseCycles" example index 0 1`] = `
"[ 3/8 → 1/2 | s:bd ]",
"[ 1/2 → 5/8 | s:bd ]",
"[ 5/8 → 3/4 | s:bd ]",
"[ 3/4 → 7/8 | s:bd ]",
"[ 3/4 → 7/8 | s:sd ]",
"[ 7/8 → 1/1 | s:bd ]",
"[ 1/1 → 9/8 | s:bd ]",
"[ 9/8 → 5/4 | s:bd ]",
"[ 5/4 → 11/8 | s:bd ]",
"[ 11/8 → 3/2 | s:bd ]",
"[ 11/8 → 3/2 | s:sd ]",
"[ 3/2 → 13/8 | s:bd ]",
"[ 13/8 → 7/4 | s:bd ]",
"[ 7/4 → 15/8 | s:bd ]",
Expand All @@ -8001,7 +8001,7 @@ exports[`runs examples > example "wchooseCycles" example index 0 1`] = `
"[ 19/8 → 5/2 | s:bd ]",
"[ 5/2 → 21/8 | s:bd ]",
"[ 21/8 → 11/4 | s:bd ]",
"[ 11/4 → 23/8 | s:bd ]",
"[ 11/4 → 23/8 | s:hh ]",
"[ 23/8 → 3/1 | s:bd ]",
"[ 3/1 → 25/8 | s:bd ]",
"[ 25/8 → 13/4 | s:bd ]",
Expand All @@ -8014,6 +8014,59 @@ exports[`runs examples > example "wchooseCycles" example index 0 1`] = `
]
`;

exports[`runs examples > example "wchooseCycles" example index 1 1`] = `
[
"[ 0/1 → 1/12 | s:bd ]",
"[ 1/12 → 1/6 | s:bd ]",
"[ 1/6 → 1/4 | s:bd ]",
"[ 1/4 → 1/3 | s:hh ]",
"[ 1/3 → 5/12 | s:hh ]",
"[ 5/12 → 1/2 | s:hh ]",
"[ 1/2 → 7/12 | s:bd ]",
"[ 7/12 → 2/3 | s:bd ]",
"[ 2/3 → 3/4 | s:bd ]",
"[ 3/4 → 5/6 | s:bd ]",
"[ 5/6 → 11/12 | s:bd ]",
"[ 11/12 → 1/1 | s:bd ]",
"[ 1/1 → 13/12 | s:bd ]",
"[ 13/12 → 7/6 | s:bd ]",
"[ 7/6 → 5/4 | s:bd ]",
"[ 5/4 → 4/3 | s:bd ]",
"[ 4/3 → 17/12 | s:bd ]",
"[ 17/12 → 3/2 | s:bd ]",
"[ 3/2 → 19/12 | s:sd ]",
"[ 19/12 → 5/3 | s:sd ]",
"[ 5/3 → 7/4 | s:sd ]",
"[ 7/4 → 11/6 | s:bd ]",
"[ 11/6 → 23/12 | s:bd ]",
"[ 23/12 → 2/1 | s:bd ]",
"[ 2/1 → 25/12 | s:hh ]",
"[ 25/12 → 13/6 | s:hh ]",
"[ 13/6 → 9/4 | s:hh ]",
"[ 9/4 → 7/3 | s:hh ]",
"[ 7/3 → 29/12 | s:hh ]",
"[ 29/12 → 5/2 | s:hh ]",
"[ 5/2 → 31/12 | s:hh ]",
"[ 31/12 → 8/3 | s:hh ]",
"[ 8/3 → 11/4 | s:hh ]",
"[ 11/4 → 17/6 | s:sd ]",
"[ 17/6 → 35/12 | s:sd ]",
"[ 35/12 → 3/1 | s:sd ]",
"[ 3/1 → 37/12 | s:bd ]",
"[ 37/12 → 19/6 | s:bd ]",
"[ 19/6 → 13/4 | s:bd ]",
"[ 13/4 → 10/3 | s:bd ]",
"[ 10/3 → 41/12 | s:bd ]",
"[ 41/12 → 7/2 | s:bd ]",
"[ 7/2 → 43/12 | s:hh ]",
"[ 43/12 → 11/3 | s:hh ]",
"[ 11/3 → 15/4 | s:hh ]",
"[ 15/4 → 23/6 | s:bd ]",
"[ 23/6 → 47/12 | s:bd ]",
"[ 47/12 → 4/1 | s:bd ]",
]
`;

exports[`runs examples > example "when" example index 0 1`] = `
[
"[ 0/1 → 1/3 | note:c3 ]",
Expand Down

0 comments on commit a194180

Please sign in to comment.