From fd73571744e46565e797dc729c43ecf5f8897fae Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Tue, 16 Jan 2024 17:56:38 +0100 Subject: [PATCH] make sure the sustained pitch is the selected note --- packages/superdough/helpers.mjs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/superdough/helpers.mjs b/packages/superdough/helpers.mjs index 7a11d84d..797d6db1 100644 --- a/packages/superdough/helpers.mjs +++ b/packages/superdough/helpers.mjs @@ -153,8 +153,11 @@ export function getPitchEnvelope(param, value, t, holdEnd) { value.psustain, value.prelease, ]); - const cents = value.penv * 100; - getParamADSR(param, pattack, pdecay, psustain, prelease, 0, cents, t, holdEnd, 'linear'); + let panchor = value.panchor ?? psustain; + const cents = value.penv * 100; // penv is in semitones + const min = 0 - cents * panchor; + const max = cents - cents * panchor; + getParamADSR(param, pattack, pdecay, psustain, prelease, min, max, t, holdEnd, 'linear'); } }