From 90878c325d4c20ac9fe8d3bb0d21ef692c98fbf2 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 4 Jul 2024 16:33:53 -0500 Subject: [PATCH] macroInt: fix off-by-one when bottom>top issue #1973 issue #1891 --- src/engine/macroInt.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/macroInt.cpp b/src/engine/macroInt.cpp index 97865cc93..52c4b1185 100644 --- a/src/engine/macroInt.cpp +++ b/src/engine/macroInt.cpp @@ -146,8 +146,9 @@ void DivMacroStruct::doMacro(DivInstrumentMacro& source, bool released, bool tic if (ADSR_HIGH>ADSR_LOW) { val=ADSR_LOW+((pos+(ADSR_HIGH-ADSR_LOW)*pos)>>8); } else { - val=ADSR_LOW+(((ADSR_HIGH-ADSR_LOW)*pos-pos)>>8); + val=ADSR_HIGH+(((255-pos)+(ADSR_LOW-ADSR_HIGH)*(255-pos))>>8); } + logV("val: %d",val); } if (type==2) { // LFO lfoPos+=LFO_SPEED;