small accuracy improvement

(int)currentResult is a truncation, so we need to add 0.5 for proper rounding.
also changed inefficient "constrain" into faster max(min( ...))
This commit is contained in:
Frank
2024-05-08 21:04:07 +02:00
parent e08ae84a83
commit 5a377103b5

View File

@@ -940,7 +940,7 @@ static void postProcessFFTResults(bool noiseGateOpen, int numberOfChannels) // p
if (post_gain < 1.0f) post_gain = ((post_gain -1.0f) * 0.8f) +1.0f; if (post_gain < 1.0f) post_gain = ((post_gain -1.0f) * 0.8f) +1.0f;
currentResult *= post_gain; currentResult *= post_gain;
} }
fftResult[i] = constrain((int)currentResult, 0, 255); fftResult[i] = max(min((int)(currentResult+0.5f), 255), 0); // +0.5 for proper rounding
} }
} }
//////////////////// ////////////////////