Merge pull request '[perf] fix connect-leak in fm modulation' (#1758) from jeromew/strudel:fix-perf6 into main

Reviewed-on: https://codeberg.org/uzu/strudel/pulls/1758
This commit is contained in:
froos
2025-11-23 22:23:24 +01:00
+7 -2
View File
@@ -362,9 +362,9 @@ const mod = (freq, range = 1, type = 'sine') => {
}
osc.start();
const g = new GainNode(ctx, { gain: range });
const g = gainNode(range);
osc.connect(g); // -range, range
return { node: g, stop: (t) => osc.stop(t) };
return { node: g, stop: (t) => osc.stop(t), osc: osc };
};
const fm = (frequencyparam, harmonicityRatio, modulationIndex, wave = 'sine') => {
const carrfreq = frequencyparam.value;
@@ -416,6 +416,11 @@ export function applyFM(param, value, begin) {
modulator.connect(envGain);
envGain.connect(param);
}
fmmod.osc.onended = () => {
envGain.disconnect();
modulator.disconnect();
fmmod.osc.disconnect();
};
}
return { stop };
}