-
Notifications
You must be signed in to change notification settings - Fork 55
Description
I have a design that measures the balance of 2 channels. Values can be -100 through 100 as channel dominance fluctuates. When I apply a threshold at 90% and the average value for the interval is negative (e.g., -50) the calculation results in a new value of -45, a value greater than the average.
Here's the current calculation in threshold:
to_input = avgsum/interval*smalladapt/100.0f;
My anticipated behavior is that the percentage is determined as the ratio of the max-min range (like the way globals.cpp's size_value method works)
Example of desired behavior:
An average of -50 would be 25% of the -100 through 100 range and a 90% threshold calculation would result in a value of -55.
Desired calculation:
(-50 - -100)/(100 - -100)*0.9 = 0.225 (90% threshold is 0.225 into the max-min range)
-100 + 0.225 * (100 - -100) = -55 (90% of the average of -50 is -55)
I'm currently working around this by adding 100 to the input values so all my values used in the threshold are positive.