Compare commits

...

8 Commits

2 changed files with 32 additions and 7 deletions
+31 -6
View File
@@ -1456,14 +1456,39 @@ 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) {
if (Array.isArray(input[0])) {
return arrange_deprecated(...input);
}
if (input.length % 2 !== 0) {
throw new Error('Arrange needs a length paramter for each pattern (length, pattern, length, pattern)');
}
let sects = [];
let total = 0;
for (let i = 0; i < input.length; i += 2) {
let cycles = input.at(i);
total += cycles;
let pattern = input.at(i + 1);
sects.push([cycles, pattern.fast(cycles)]);
}
return stepcat(...sects).slow(total);
}
// handle old array syntax ex:
// arrange(
// [4, "<c a f e>(3,8)"],
// [2, "<g a>(5,8)"]
// ).note()
//
function arrange_deprecated(...sects) {
const total = sects.reduce((sum, [cycles]) => sum + cycles, 0);
sects = sects.map(([cycles, pattern]) => [cycles, pattern.fast(cycles)]);
return stepcat(...sects).slow(total);
}
/**
+1 -1
View File
@@ -274,7 +274,7 @@ export async function initAudioOnFirstClick(options) {
}
let controller;
function getSuperdoughAudioController() {
export function getSuperdoughAudioController() {
if (controller == null) {
controller = new SuperdoughAudioController(getAudioContext());
}