Apply correction curve to the dials

Display the volume levels on the dials with a correction curve that
resembles what the volume knob on the hardware does.
This commit is contained in:
Geoffrey D. Bennett
2023-10-01 00:05:26 +09:30
parent 3fa5803476
commit ea920d6343

View File

@@ -141,7 +141,19 @@ static void dial_measure(GtkWidget *widget,
static inline double calc_valp(double val, double mn, double mx)
{
return (val - mn)/(mx-mn);
if (val <= mn)
return 0.0;
if (val >= mx)
return 1.0;
// convert val from mn..mx to 0..1
val = (val - mn)/(mx-mn);
// 10^(val - 1) converts it to 0.1..1 with a nice curve
val = pow(10, val - 1);
// convert to 0..1 again
return (val - 0.1) / 0.9;
}
static inline double calc_val(double valp, double mn, double mx)