private static double CalculateModulator(SourceTypeEnum s, TransformEnum t, DirectionEnum d, PolarityEnum p, int value, int min, int max)
{
double output = 0;
int i;
value = value - min;
max = max - min;
if (d == DirectionEnum.MaxToMin)
value = max - value;
switch (s)
{
case SourceTypeEnum.Linear:
output = value / max;
break;
case SourceTypeEnum.Concave:
i = 127 - value;
output = -(20.0 / 96.0) * Math.Log10((i * i) / (double)(max * max));
break;
case SourceTypeEnum.Convex:
i = value;
output = 1 + (20.0 / 96.0) * Math.Log10((i * i) / (double)(max * max));
break;
case SourceTypeEnum.Switch:
if (value <= (max / 2))
output = 0;
else
output = 1;
break;
}
if (p == PolarityEnum.Bipolar)
output = (output * 2) - 1;
if (t == TransformEnum.AbsoluteValue)
output = Math.Abs(output);
return output;
}