From f5ae50c3cee2dd4b53476518b2765d8c58ddcaa6 Mon Sep 17 00:00:00 2001 From: JoStro Date: Tue, 1 Jul 2025 22:02:54 +0100 Subject: [PATCH 1/4] Modify `extend` to better match behavior of `!` operator --- packages/core/pattern.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index cbaf8a8a2..abe613d19 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -2928,7 +2928,7 @@ export const drop = stepRegister('drop', function (i, pat) { * ).pace(8) */ export const extend = stepRegister('extend', function (factor, pat) { - return pat.fast(factor).expand(factor); + return pat.repeatCycles(factor).fast(factor).expand(factor); }); /** From c2a5562bad41bea5192e089b040ddc7156f51580 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Mon, 20 Oct 2025 21:24:13 +0200 Subject: [PATCH 2/4] add new flavour under replicate --- packages/core/pattern.mjs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index fdf27e9fc..f5b0c676e 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -2995,6 +2995,24 @@ export const drop = stepRegister('drop', function (i, pat) { * ).pace(8) */ export const extend = stepRegister('extend', function (factor, pat) { + return pat.fast(factor).expand(factor); +}); + +/** + * *Experimental* + * + * `replicate` is similar to `fast` in that it increases its density, but it also increases the step count + * accordingly. So `stepcat("a b".replicate(2), "c d")` would be the same as `"a b a b c d"`, whereas + * `stepcat("a b".fast(2), "c d")` would be the same as `"[a b] [a b] c d"`. + * + * TODO: find out how this function differs from extend + * @example + * stepcat( + * sound("bd bd - cp").replicate(2), + * sound("bd - sd -") + * ).pace(8) + */ +export const replicate = stepRegister('replicate', function (factor, pat) { return pat.repeatCycles(factor).fast(factor).expand(factor); }); From 188f0e90984b61bf0275b40da7af6edbb9f77aec Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Mon, 20 Oct 2025 21:35:28 +0200 Subject: [PATCH 3/4] snapshot --- test/__snapshots__/examples.test.mjs.snap | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/__snapshots__/examples.test.mjs.snap b/test/__snapshots__/examples.test.mjs.snap index 937d42797..d7e13d4d9 100644 --- a/test/__snapshots__/examples.test.mjs.snap +++ b/test/__snapshots__/examples.test.mjs.snap @@ -8307,6 +8307,33 @@ exports[`runs examples > example "repeatCycles" example index 0 1`] = ` ] `; +exports[`runs examples > example "replicate" example index 0 1`] = ` +[ + "[ 0/1 → 1/8 | s:bd ]", + "[ 1/8 → 1/4 | s:bd ]", + "[ 3/8 → 1/2 | s:cp ]", + "[ 1/2 → 5/8 | s:bd ]", + "[ 5/8 → 3/4 | s:bd ]", + "[ 7/8 → 1/1 | s:cp ]", + "[ 1/1 → 9/8 | s:bd ]", + "[ 5/4 → 11/8 | s:sd ]", + "[ 3/2 → 13/8 | s:bd ]", + "[ 13/8 → 7/4 | s:bd ]", + "[ 15/8 → 2/1 | s:cp ]", + "[ 2/1 → 17/8 | s:bd ]", + "[ 17/8 → 9/4 | s:bd ]", + "[ 19/8 → 5/2 | s:cp ]", + "[ 5/2 → 21/8 | s:bd ]", + "[ 11/4 → 23/8 | s:sd ]", + "[ 3/1 → 25/8 | s:bd ]", + "[ 25/8 → 13/4 | s:bd ]", + "[ 27/8 → 7/2 | s:cp ]", + "[ 7/2 → 29/8 | s:bd ]", + "[ 29/8 → 15/4 | s:bd ]", + "[ 31/8 → 4/1 | s:cp ]", +] +`; + exports[`runs examples > example "reset" example index 0 1`] = ` [ "[ 0/1 → 1/8 | s:hh ]", From 20e5fdedfbce14cb0ce8fd84ccdf0cf35da3875c Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Mon, 20 Oct 2025 21:38:43 +0200 Subject: [PATCH 4/4] fix: use replicate for ! in mondo --- packages/mondough/mondough.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mondough/mondough.mjs b/packages/mondough/mondough.mjs index b7ee83787..e2c6dc9ad 100644 --- a/packages/mondough/mondough.mjs +++ b/packages/mondough/mondough.mjs @@ -5,7 +5,7 @@ import { slow, seq, stepcat, - extend, + replicate, expand, pace, chooseIn, @@ -36,7 +36,7 @@ lib.square = (...args) => stepcat(...args).setSteps(1); lib.angle = (...args) => stepcat(...args).pace(1); lib['*'] = fast; lib['/'] = slow; -lib['!'] = extend; +lib['!'] = replicate; lib['@'] = expand; lib['%'] = pace; lib['?'] = degradeBy; // todo: default 0.5 not working..