diff --git a/src/engine/macroInt.cpp b/src/engine/macroInt.cpp index 621eab424..97865cc93 100644 --- a/src/engine/macroInt.cpp +++ b/src/engine/macroInt.cpp @@ -143,7 +143,11 @@ void DivMacroStruct::doMacro(DivInstrumentMacro& source, bool released, bool tic if (!linger) has=false; break; } - val=ADSR_LOW+((pos+(ADSR_HIGH-ADSR_LOW)*pos)>>8); + 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); + } } if (type==2) { // LFO lfoPos+=LFO_SPEED; @@ -161,7 +165,11 @@ void DivMacroStruct::doMacro(DivInstrumentMacro& source, bool released, bool tic lfoOut=(lfoPos&512)?255:0; break; } - val=ADSR_LOW+((lfoOut+(ADSR_HIGH-ADSR_LOW)*lfoOut)>>8); + if (ADSR_HIGH>ADSR_LOW) { + val=ADSR_LOW+((lfoOut+(ADSR_HIGH-ADSR_LOW)*lfoOut)>>8); + } else { + val=ADSR_LOW+(((ADSR_HIGH-ADSR_LOW)*lfoOut-lfoOut)>>8); + } } } }