test + bugfix for chunkinto

This commit is contained in:
alex 2025-06-27 22:44:15 +01:00
parent 719c70a598
commit ff5b11f5ed
2 changed files with 40 additions and 19 deletions

View file

@ -894,22 +894,6 @@ export class Pattern {
into(pieces, func) {
return this.unjoin(pieces, func).innerJoin();
}
/**
* Like `chunk`, but the function is applied to a looped subcycle of the source pattern.
* @name chunkInto
* @synonym chunkinto
* @memberof Pattern
* @example
* sound("bd sd ht lt bd - cp lt").chunkInto(4, hurry(2))
* .bank("tr909")
*/
chunkInto(n, func) {
return this.into(fastcat(true, ...Array(n - 1).fill(false)).iterback(4), func);
}
chunkinto(n, func) {
return this.chunkInto(n, func);
}
}
//////////////////////////////////////////////////////////////////////
@ -1858,9 +1842,9 @@ export const { fastGap, fastgap } = register(['fastGap', 'fastgap'], function (f
const newWhole = !hap.whole
? undefined
: new TimeSpan(
newPart.begin.sub(begin.sub(hap.whole.begin).div(factor)),
newPart.end.add(hap.whole.end.sub(end).div(factor)),
);
newPart.begin.sub(begin.sub(hap.whole.begin).div(factor)),
newPart.end.add(hap.whole.end.sub(end).div(factor)),
);
return new Hap(newWhole, newPart, hap.value, hap.context);
};
return pat.withQuerySpanMaybe(qf).withHap(ef).splitQueries();
@ -2535,6 +2519,20 @@ export const { fastchunk, fastChunk } = register(
true,
);
/**
* Like `chunk`, but the function is applied to a looped subcycle of the source pattern.
* @name chunkInto
* @synonym chunkinto
* @memberof Pattern
* @example
* sound("bd sd ht lt bd - cp lt").chunkInto(4, hurry(2))
* .bank("tr909")
*/
export const { chunkinto, chunkInto } = register(['chunkinto', 'chunkInto'],
function (n, func, pat) {
return pat.into(fastcat(true, ...Array(n - 1).fill(false)).iterback(n), func);
});
// TODO - redefine elsewhere in terms of mask
export const bypass = register(
'bypass',