From a194180130e83bf330a56794376bab594af7fcb4 Mon Sep 17 00:00:00 2001 From: "Alexandre G.-Raymond" Date: Sun, 21 Apr 2024 11:03:55 +0200 Subject: [PATCH] Fix wchooseCycles not picking the whole pattern (#1061) --- packages/core/signal.mjs | 4 +- test/__snapshots__/examples.test.mjs.snap | 59 +++++++++++++++++++++-- 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/packages/core/signal.mjs b/packages/core/signal.mjs index 7c931affa..375c4f674 100644 --- a/packages/core/signal.mjs +++ b/packages/core/signal.mjs @@ -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; diff --git a/test/__snapshots__/examples.test.mjs.snap b/test/__snapshots__/examples.test.mjs.snap index 1d2af9dec..94c390b62 100644 --- a/test/__snapshots__/examples.test.mjs.snap +++ b/test/__snapshots__/examples.test.mjs.snap @@ -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 ]", @@ -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 ]", @@ -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 ]",