Add s_zip for 'cat'-ing patterns together step-by-step (#1208)

Fix tactus returned by 'step'
Fix name of toplevel s_extend (was 's_cycles')
This commit is contained in:
Alex McLean 2024-10-30 21:29:43 +01:00 committed by GitHub
parent 9ecad810b1
commit ae335ac40c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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) {
@ -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);
});
@ -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