Merge pull request 'add replicate + use it for ! in mondo' (#1436) from JoStro/strudel:main into main
Reviewed-on: https://codeberg.org/uzu/strudel/pulls/1436
This commit is contained in:
commit
c727534d29
3 changed files with 47 additions and 2 deletions
|
|
@ -2998,6 +2998,24 @@ export const extend = stepRegister('extend', function (factor, pat) {
|
||||||
return pat.fast(factor).expand(factor);
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* *Experimental*
|
* *Experimental*
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import {
|
||||||
slow,
|
slow,
|
||||||
seq,
|
seq,
|
||||||
stepcat,
|
stepcat,
|
||||||
extend,
|
replicate,
|
||||||
expand,
|
expand,
|
||||||
pace,
|
pace,
|
||||||
chooseIn,
|
chooseIn,
|
||||||
|
|
@ -36,7 +36,7 @@ lib.square = (...args) => stepcat(...args).setSteps(1);
|
||||||
lib.angle = (...args) => stepcat(...args).pace(1);
|
lib.angle = (...args) => stepcat(...args).pace(1);
|
||||||
lib['*'] = fast;
|
lib['*'] = fast;
|
||||||
lib['/'] = slow;
|
lib['/'] = slow;
|
||||||
lib['!'] = extend;
|
lib['!'] = replicate;
|
||||||
lib['@'] = expand;
|
lib['@'] = expand;
|
||||||
lib['%'] = pace;
|
lib['%'] = pace;
|
||||||
lib['?'] = degradeBy; // todo: default 0.5 not working..
|
lib['?'] = degradeBy; // todo: default 0.5 not working..
|
||||||
|
|
|
||||||
|
|
@ -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`] = `
|
exports[`runs examples > example "reset" example index 0 1`] = `
|
||||||
[
|
[
|
||||||
"[ 0/1 → 1/8 | s:hh ]",
|
"[ 0/1 → 1/8 | s:hh ]",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue