diff --git a/packages/core/src/audio/audioFxGraph.ts b/packages/core/src/audio/audioFxGraph.ts index 09f3c91a7a..f4bc818ddf 100644 --- a/packages/core/src/audio/audioFxGraph.ts +++ b/packages/core/src/audio/audioFxGraph.ts @@ -94,6 +94,12 @@ function mixTargets(wet: AudioParam, dry: AudioParam): FxParamTarget[] { return [{ param: wet }, { param: dry, map: (v) => 1 - v }]; } +/** 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, @@ -243,8 +249,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 { @@ -276,8 +281,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 {