Skip to content

Commit

Permalink
Apply correction curve to the dials
Browse files Browse the repository at this point in the history
Display the volume levels on the dials with a correction curve that
resembles what the volume knob on the hardware does.
  • Loading branch information
geoffreybennett committed Oct 8, 2023
1 parent 3fa5803 commit ea920d6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/gtkdial.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ea920d6

Please sign in to comment.