Merge pull request '[perf] fix phaser leak of unused biquads' (#1800) from jeromew/strudel:fix-perf10 into main

Reviewed-on: https://codeberg.org/uzu/strudel/pulls/1800
Reviewed-by: Aria <glossing@noreply.codeberg.org>
This commit is contained in:
Aria 2025-12-07 18:53:03 +01:00
commit 9650c8eb50

View file

@ -290,8 +290,8 @@ function getPhaser(time, end, frequency = 1, depth = 0.5, centerFrequency = 1000
const lfo = getLfo(ac, time, end, { frequency, depth: sweep * 2 }); const lfo = getLfo(ac, time, end, { frequency, depth: sweep * 2 });
//filters //filters
const numStages = 2; //num of filters in series const numStages = 1; //num of filters in series
let fOffset = 0; let fOffset = 282; //for backward compat in #1800
const filterChain = []; const filterChain = [];
for (let i = 0; i < numStages; i++) { for (let i = 0; i < numStages; i++) {
const filter = ac.createBiquadFilter(); const filter = ac.createBiquadFilter();
@ -302,12 +302,9 @@ function getPhaser(time, end, frequency = 1, depth = 0.5, centerFrequency = 1000
lfo.connect(filter.detune); lfo.connect(filter.detune);
fOffset += 282; fOffset += 282;
if (i > 0) {
filterChain[i - 1].connect(filter);
}
filterChain.push(filter); filterChain.push(filter);
} }
return { phaser: filterChain[filterChain.length - 1], lfo }; return { filterChain, lfo };
} }
function getFilterType(ftype) { function getFilterType(ftype) {
@ -697,9 +694,9 @@ export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5)
} }
// phaser // phaser
if (phaserrate !== undefined && phaserdepth > 0) { 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); audioNodes.push(lfo);
chain.push(phaser); chain.push(...filterChain);
} }
// last gain // last gain