From 7cf032d2f69a00abbeaa37d146efad5f0787e826 Mon Sep 17 00:00:00 2001 From: Vance Ingalls Date: Wed, 12 Aug 2026 14:07:55 -0700 Subject: [PATCH] fix(core): dedupe the wet/dry mix math between delayFeedback and chorusLfo Both effect builders set wet.gain to the mix and dry.gain to its complement in identical two-line blocks; fallow kept re-flagging it as a 10-line clone on every unrelated change. Extracted setWetDryMix. --- packages/core/src/audio/audioFxGraph.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/core/src/audio/audioFxGraph.ts b/packages/core/src/audio/audioFxGraph.ts index c463e0467a..1a026e280d 100644 --- a/packages/core/src/audio/audioFxGraph.ts +++ b/packages/core/src/audio/audioFxGraph.ts @@ -69,6 +69,12 @@ type Builder = (ctx: BaseAudioContext, p: HfAudioFxParamValues) => FxNodeHandle; const n = (v: number | string | undefined): number => (typeof v === "number" ? v : Number(v ?? 0)); +/** Linear crossfade: dry falls as wet rises, in lockstep. */ +function setWetDryMix(wet: GainNode, dry: GainNode, mix: number): void { + wet.gain.value = mix; + dry.gain.value = 1 - mix; +} + /** A node that is its own input and output and has nothing to tear down. */ function simple(node: AudioNode, update: (p: HfAudioFxParamValues) => void): FxNodeHandle { return { input: node, output: node, update, dispose: () => node.disconnect() }; @@ -177,8 +183,7 @@ const delayFeedback: Builder = (ctx, p) => { const apply = (v: HfAudioFxParamValues): void => { dl.delayTime.value = Math.min(5, n(v.time) / 1000); fb.gain.value = n(v.feedback); - wet.gain.value = n(v.mix); - dry.gain.value = 1 - n(v.mix); + setWetDryMix(wet, dry, n(v.mix)); }; apply(p); return { @@ -205,8 +210,7 @@ const chorusLfo: Builder = (ctx, p) => { dl.delayTime.value = n(v.delay) / 1000; depth.gain.value = n(v.depth) / 1000; lfo.frequency.value = n(v.speed); - wet.gain.value = n(v.mix); - dry.gain.value = 1 - n(v.mix); + setWetDryMix(wet, dry, n(v.mix)); }; apply(p); return {