fix: exp envelope allow 0 without blowup

This commit is contained in:
Felix Roos 2023-08-31 04:35:35 +02:00
parent 26d7a32f11
commit 876f97e9a2

View File

@ -40,6 +40,8 @@ export const getEnvelope = (attack, decay, sustain, release, velocity, begin) =>
};
export const getExpEnvelope = (attack, decay, sustain, release, velocity, begin) => {
sustain = Math.max(0.001, sustain);
velocity = Math.max(0.001, velocity);
const gainNode = getAudioContext().createGain();
gainNode.gain.setValueAtTime(0.0001, begin);
gainNode.gain.exponentialRampToValueAtTime(velocity, begin + attack);