From b65cc2128feabf0a5909e652fe59058303aadbf1 Mon Sep 17 00:00:00 2001 From: jeromew Date: Sat, 29 Nov 2025 14:47:03 +0000 Subject: [PATCH 1/2] [perf] fix phaser leak of unused biquads --- packages/superdough/superdough.mjs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/superdough/superdough.mjs b/packages/superdough/superdough.mjs index 6f610d514..514c492cf 100644 --- a/packages/superdough/superdough.mjs +++ b/packages/superdough/superdough.mjs @@ -290,7 +290,7 @@ function getPhaser(time, end, frequency = 1, depth = 0.5, centerFrequency = 1000 const lfo = getLfo(ac, time, end, { frequency, depth: sweep * 2 }); //filters - const numStages = 2; //num of filters in series + const numStages = 1; //num of filters in series let fOffset = 0; const filterChain = []; for (let i = 0; i < numStages; i++) { @@ -302,12 +302,9 @@ function getPhaser(time, end, frequency = 1, depth = 0.5, centerFrequency = 1000 lfo.connect(filter.detune); fOffset += 282; - if (i > 0) { - filterChain[i - 1].connect(filter); - } filterChain.push(filter); } - return { phaser: filterChain[filterChain.length - 1], lfo }; + return { phaser: filterChain, lfo }; } function getFilterType(ftype) { @@ -699,7 +696,7 @@ export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5) if (phaserrate !== undefined && phaserdepth > 0) { const { phaser, lfo } = getPhaser(t, endWithRelease, phaserrate, phaserdepth, phasercenter, phasersweep); audioNodes.push(lfo); - chain.push(phaser); + Array.prototype.push.apply(chain, phaser); } // last gain From 0b711e879c767ab1c4bfba7af0c655d28da70f8c Mon Sep 17 00:00:00 2001 From: jeromew Date: Thu, 4 Dec 2025 08:23:36 +0000 Subject: [PATCH 2/2] Improve naming & backward compat --- packages/superdough/superdough.mjs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/superdough/superdough.mjs b/packages/superdough/superdough.mjs index 514c492cf..191665498 100644 --- a/packages/superdough/superdough.mjs +++ b/packages/superdough/superdough.mjs @@ -291,7 +291,7 @@ function getPhaser(time, end, frequency = 1, depth = 0.5, centerFrequency = 1000 //filters const numStages = 1; //num of filters in series - let fOffset = 0; + let fOffset = 282; //for backward compat in #1800 const filterChain = []; for (let i = 0; i < numStages; i++) { const filter = ac.createBiquadFilter(); @@ -304,7 +304,7 @@ function getPhaser(time, end, frequency = 1, depth = 0.5, centerFrequency = 1000 fOffset += 282; filterChain.push(filter); } - return { phaser: filterChain, lfo }; + return { filterChain, lfo }; } function getFilterType(ftype) { @@ -694,9 +694,9 @@ export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5) } // phaser if (phaserrate !== undefined && phaserdepth > 0) { - const { phaser, lfo } = getPhaser(t, endWithRelease, phaserrate, phaserdepth, phasercenter, phasersweep); + const { filterChain, lfo } = getPhaser(t, endWithRelease, phaserrate, phaserdepth, phasercenter, phasersweep); audioNodes.push(lfo); - Array.prototype.push.apply(chain, phaser); + chain.push(...filterChain); } // last gain