mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-11 21:58:31 +00:00
Merge pull request #741 from daslyfe/bugfix_choose_with
[Bug Fix] chooseWith: prevent pattern from stopping audio when selection is >= 1 or < 0
This commit is contained in:
commit
86997488fb
@ -160,7 +160,11 @@ export const __chooseWith = (pat, xs) => {
|
||||
if (xs.length == 0) {
|
||||
return silence;
|
||||
}
|
||||
return pat.range(0, xs.length).fmap((i) => xs[Math.floor(i)]);
|
||||
|
||||
return pat.range(0, xs.length).fmap((i) => {
|
||||
const key = Math.min(Math.max(Math.floor(i), 0), xs.length - 1);
|
||||
return xs[key];
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Choose from the list of values (or patterns of values) using the given
|
||||
@ -168,6 +172,8 @@ export const __chooseWith = (pat, xs) => {
|
||||
* @param {Pattern} pat
|
||||
* @param {*} xs
|
||||
* @returns {Pattern}
|
||||
* @example
|
||||
* note("c2 g2!2 d2 f1").s(chooseWith(sine.fast(2), ["sawtooth", "triangle", "bd:6"]))
|
||||
*/
|
||||
export const chooseWith = (pat, xs) => {
|
||||
return __chooseWith(pat, xs).outerJoin();
|
||||
|
||||
@ -1071,6 +1071,31 @@ exports[`runs examples > example "chooseCycles" example index 1 1`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "chooseWith" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/5 | note:c2 s:bd n:6 ]",
|
||||
"[ 1/5 → 2/5 | note:g2 s:sawtooth ]",
|
||||
"[ 2/5 → 3/5 | note:g2 s:triangle ]",
|
||||
"[ 3/5 → 4/5 | note:d2 s:bd n:6 ]",
|
||||
"[ 4/5 → 1/1 | note:f1 s:sawtooth ]",
|
||||
"[ 1/1 → 6/5 | note:c2 s:bd n:6 ]",
|
||||
"[ 6/5 → 7/5 | note:g2 s:sawtooth ]",
|
||||
"[ 7/5 → 8/5 | note:g2 s:triangle ]",
|
||||
"[ 8/5 → 9/5 | note:d2 s:bd n:6 ]",
|
||||
"[ 9/5 → 2/1 | note:f1 s:sawtooth ]",
|
||||
"[ 2/1 → 11/5 | note:c2 s:bd n:6 ]",
|
||||
"[ 11/5 → 12/5 | note:g2 s:sawtooth ]",
|
||||
"[ 12/5 → 13/5 | note:g2 s:triangle ]",
|
||||
"[ 13/5 → 14/5 | note:d2 s:bd n:6 ]",
|
||||
"[ 14/5 → 3/1 | note:f1 s:sawtooth ]",
|
||||
"[ 3/1 → 16/5 | note:c2 s:bd n:6 ]",
|
||||
"[ 16/5 → 17/5 | note:g2 s:sawtooth ]",
|
||||
"[ 17/5 → 18/5 | note:g2 s:triangle ]",
|
||||
"[ 18/5 → 19/5 | note:d2 s:bd n:6 ]",
|
||||
"[ 19/5 → 4/1 | note:f1 s:sawtooth ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "chop" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | s:rhodes begin:0.75 end:1 speed:0.25 unit:c ]",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user