This commit is contained in:
Jade (Rose) Rowland
2025-11-30 16:44:03 -05:00
parent 7a3e0fd3fe
commit 5a878b7099
+26 -9
View File
@@ -1456,14 +1456,31 @@ export function cat(...pats) {
* @return {Pattern}
* @example
* arrange(
* [4, "<c a f e>(3,8)"],
* [2, "<g a>(5,8)"]
* 4, "<c a f e>(3,8)",
* 2, "<g a>(5,8)"
* ).note()
*/
export function arrange(...sections) {
const total = sections.reduce((sum, [cycles]) => sum + cycles, 0);
sections = sections.map(([cycles, section]) => [cycles, section.fast(cycles)]);
return stepcat(...sections).slow(total);
export function arrange(...input) {
let sects = [];
if (!Array.isArray(input[0])) {
if (input.length % 2 !== 0) {
throw new Error('Arrange needs a length paramter and a pattern')
}
for (let i = 0; i < input.length; i += 2) {
let cycles = input.at(i)
let pattern = input.at(i + 1)
sects.push([cycles, pattern]);
}
} else {
// Handle deprecated arrange input
sects = input;
}
const total = sects.reduce((sum, [cycles]) => sum + cycles, 0);
sects = sects.map(([cycles, section]) => [cycles, section.fast(cycles)]);
return stepcat(...sects).slow(total);
}
/**
@@ -1858,9 +1875,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();