Use setvalueattime to pin values and prevent bleed

This commit is contained in:
Aria 2025-12-04 22:50:28 -06:00
parent d50af71ba1
commit 4c99f4866b
3 changed files with 16 additions and 13 deletions

View file

@ -238,10 +238,11 @@ export async function onTriggerSynth(t, value, onended, tables, cps, frameLen) {
};
const factory = () => new AudioWorkletNode(ac, 'wavetable-oscillator-processor', { outputChannelCount: [2] });
const source = getNodeFromPool('wavetable', factory);
const now = ac.currentTime;
Object.entries(params).forEach(([key, value]) => {
if (value !== undefined) {
source.parameters.get(key).value = value;
}
const param = source.parameters.get(key);
const target = value !== undefined ? value : param.defaultValue;
param.setValueAtTime(target, now);
});
source.port.postMessage({ type: 'initialize', payload });
source.port.onmessage = (e) => {