mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-11 21:58:31 +00:00
commit
ac409965d5
@ -979,7 +979,7 @@ function sequence(...xs) {
|
||||
return _sequenceCount(xs)[0];
|
||||
}
|
||||
|
||||
function polymeter(steps = 0, ...args) {
|
||||
function polymeterSteps(steps, ...args) {
|
||||
const seqs = args.map((a) => _sequenceCount(a));
|
||||
if (seqs.length == 0) {
|
||||
return silence;
|
||||
@ -995,15 +995,20 @@ function polymeter(steps = 0, ...args) {
|
||||
if (steps == seq[1]) {
|
||||
pats.push(seq[0]);
|
||||
} else {
|
||||
console.log("aha");
|
||||
pats.push(seq[0]._fast(Fraction(steps).div(Fraction(seq[1]))));
|
||||
}
|
||||
}
|
||||
return stack(pats);
|
||||
return stack(...pats);
|
||||
}
|
||||
|
||||
function polymeter(...args) {
|
||||
return polymeterSteps(0, ...args);
|
||||
}
|
||||
|
||||
// alias
|
||||
function pm(args) {
|
||||
polymeter(args);
|
||||
function pm(...args) {
|
||||
polymeter(...args);
|
||||
}
|
||||
|
||||
function polyrhythm(...xs) {
|
||||
@ -1168,6 +1173,7 @@ export {
|
||||
cat,
|
||||
timeCat,
|
||||
sequence,
|
||||
polymeterSteps,
|
||||
polymeter,
|
||||
pm,
|
||||
polyrhythm,
|
||||
|
||||
@ -13,6 +13,8 @@ import {
|
||||
slowcat,
|
||||
cat,
|
||||
sequence,
|
||||
polymeter,
|
||||
polymeterSteps,
|
||||
polyrhythm,
|
||||
silence,
|
||||
fast,
|
||||
@ -280,6 +282,21 @@ describe('Pattern', function() {
|
||||
)
|
||||
})
|
||||
})
|
||||
describe('polymeter()', () => {
|
||||
it('Can layer up cycles, stepwise', () => {
|
||||
assert.deepStrictEqual(
|
||||
polymeterSteps(3, ["d","e"]).firstCycle(),
|
||||
fastcat(pure("d"),pure("e"),pure("d")).firstCycle()
|
||||
)
|
||||
assert.deepStrictEqual(
|
||||
polymeter(["a","b","c"],["d","e"]).fast(2).firstCycle(),
|
||||
stack(sequence("a","b","c","a","b","c"),
|
||||
sequence("d","e","d","e","d","e")
|
||||
).firstCycle()
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('every()', () => {
|
||||
it('Can apply a function every 3rd time', () => {
|
||||
assert.deepStrictEqual(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user