From 4fb5c1828d5310cd4be9c47ca4299fb9f3b0c557 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Sat, 13 Jan 2024 01:16:26 +0100 Subject: [PATCH] i have no clue why this works --- packages/superdough/helpers.mjs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/superdough/helpers.mjs b/packages/superdough/helpers.mjs index 846130e8..bee26f38 100644 --- a/packages/superdough/helpers.mjs +++ b/packages/superdough/helpers.mjs @@ -37,13 +37,14 @@ export const getParamADSR = ( min = Math.max(0.0001, min); } const range = max - min; - const peak = min + range; + const peak = max; const sustainVal = min + sustain * range; const duration = end - begin; const envValAtTime = (time) => { if (attack > time) { - return time * getSlope(min, peak, 0, attack) + 0; + let slope = getSlope(min, peak, 0, attack); + return time * slope + (min > peak ? min : 0); } else { return (time - attack) * getSlope(peak, sustainVal, 0, decay) + peak; }