This commit is contained in:
Felix Roos 2023-12-12 21:46:52 +01:00
parent b0bbd58f66
commit f38d1c272e

View File

@ -22,18 +22,12 @@ export const getEnvelope = (attack, decay, sustain, release, velocity, begin) =>
node: gainNode,
stop: (t) => {
// to make sure the release won't begin before sustain is reached
//phase = Math.max(t, phase + 0.001);
phase = Math.max(t, phase);
// see https://github.com/tidalcycles/strudel/issues/522
//if (typeof gainNode.gain.cancelAndHoldAtTime === 'function') {
// gainNode.gain.cancelAndHoldAtTime(t); // this seems to release instantly....
// see https://discord.com/channels/779427371270275082/937365093082079272/1086053607360712735
//} else {
// firefox: this will glitch when the sustain has not been reached yet at the time of release
gainNode.gain.setValueAtTime(sustainLevel, phase);
//}
gainNode.gain.linearRampToValueAtTime(0, phase + release); // release
return phase + release;
phase += release;
gainNode.gain.linearRampToValueAtTime(0, phase); // release
return phase;
},
};
};