From 9aec18b3a0c7cbf86f15b45e0d41cbdf14726fb2 Mon Sep 17 00:00:00 2001 From: Jade Rowland Date: Sun, 3 Dec 2023 18:25:30 -0500 Subject: [PATCH] add 1 to channel selection --- packages/core/controls.mjs | 2 +- packages/superdough/superdough.mjs | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/core/controls.mjs b/packages/core/controls.mjs index 6eca59d8..d979ff23 100644 --- a/packages/core/controls.mjs +++ b/packages/core/controls.mjs @@ -389,7 +389,7 @@ const generic_params = [ * * @param {number | Pattern} channels pattern the output channels * @example - * note("e a d b g").channels("2:3") + * note("e a d b g").channels("3:4") * */ ['channels', 'ch'], diff --git a/packages/superdough/superdough.mjs b/packages/superdough/superdough.mjs index 8449c5c7..1291c192 100644 --- a/packages/superdough/superdough.mjs +++ b/packages/superdough/superdough.mjs @@ -103,8 +103,8 @@ export const connectToDestination = (input, channels = [0, 1]) => { numberOfOutputs: stereoMix.channelCount, }); stereoMix.connect(splitter); - channels.map((ch, i) => { - splitter.connect(channelMerger, i % stereoMix.channelCount, ch); + channels.forEach((ch, i) => { + splitter.connect(channelMerger, i % stereoMix.channelCount, clamp(ch, 0, ctx.destination.channelCount - 1)); }); }; @@ -290,7 +290,7 @@ export const superdough = async (value, deadline, hapDuration) => { bpsustain = 1, bprelease = 0.01, bandq = 1, - channels = [0, 1], + channels = [1, 2], //phaser phaser, phaserdepth = 0.75, @@ -323,7 +323,8 @@ export const superdough = async (value, deadline, hapDuration) => { compressorRelease, } = value; - channels = Array.isArray(channels) ? channels : [channels]; + //music programs/audio gear usually labels channels 0,1 as 1,2 so imitate that behavior + channels = (Array.isArray(channels) ? channels : [channels]).map((ch) => ch - 1); gain *= velocity; // legacy fix for velocity let toDisconnect = []; // audio nodes that will be disconnected when the source has ended