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:
commit
22f1512697
1 changed files with 7 additions and 2 deletions
|
|
@ -362,9 +362,9 @@ const mod = (freq, range = 1, type = 'sine') => {
|
||||||
}
|
}
|
||||||
|
|
||||||
osc.start();
|
osc.start();
|
||||||
const g = new GainNode(ctx, { gain: range });
|
const g = gainNode(range);
|
||||||
osc.connect(g); // -range, 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 fm = (frequencyparam, harmonicityRatio, modulationIndex, wave = 'sine') => {
|
||||||
const carrfreq = frequencyparam.value;
|
const carrfreq = frequencyparam.value;
|
||||||
|
|
@ -416,6 +416,11 @@ export function applyFM(param, value, begin) {
|
||||||
modulator.connect(envGain);
|
modulator.connect(envGain);
|
||||||
envGain.connect(param);
|
envGain.connect(param);
|
||||||
}
|
}
|
||||||
|
fmmod.osc.onended = () => {
|
||||||
|
envGain.disconnect();
|
||||||
|
modulator.disconnect();
|
||||||
|
fmmod.osc.disconnect();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return { stop };
|
return { stop };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue