macroInt: fix rounding error when bottom>top

issue #1891
This commit is contained in:
tildearrow 2024-05-21 17:43:10 -05:00
parent 603249573a
commit eb27d61197

View file

@ -143,7 +143,11 @@ void DivMacroStruct::doMacro(DivInstrumentMacro& source, bool released, bool tic
if (!linger) has=false;
break;
}
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;
}
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);
}
}
}
}