Skip to content

Commit

Permalink
Add s_zip for 'cat'-ing patterns together step-by-step (#1208)
Browse files Browse the repository at this point in the history
Fix tactus returned by 'step'
Fix name of toplevel s_extend (was 's_cycles')
  • Loading branch information
yaxu authored Oct 30, 2024
1 parent 9ecad81 commit ae335ac
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/core/pattern.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2593,7 +2593,7 @@ export const steps = register('steps', function (targetTactus, pat) {
// avoid divide by zero..
return nothing;
}
return pat.fast(Fraction(targetTactus).div(pat.tactus));
return pat._fast(Fraction(targetTactus).div(pat.tactus)).setTactus(targetTactus);
});

export function _polymeterListSteps(steps, ...args) {
Expand Down Expand Up @@ -2801,7 +2801,7 @@ export const s_sub = stepRegister('s_sub', function (i, pat) {
return pat.s_add(pat.tactus.sub(i));
});

export const s_cycles = stepRegister('s_extend', function (factor, pat) {
export const s_extend = stepRegister('s_extend', function (factor, pat) {
return pat.fast(factor).s_expand(factor);
});

Expand Down Expand Up @@ -2882,6 +2882,13 @@ export const s_tour = function (pat, ...many) {
return pat.s_tour(...many);
};

const s_zip = function (...pats) {
pats = pats.filter((pat) => pat.hasTactus);
const zipped = slowcat(...pats.map((pat) => pat._slow(pat.tactus)));
// Should maybe use lcm or gcd for tactus?
return zipped._fast(pats[0].tactus).setTactus(pats[0].tactus);
};

//////////////////////////////////////////////////////////////////////
// Control-related functions, i.e. ones that manipulate patterns of
// objects
Expand Down

0 comments on commit ae335ac

Please sign in to comment.