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:
@@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
////////////////////
|
////////////////////
|
||||||
|
|||||||
Reference in New Issue
Block a user