From 2be9d73943a37fe7d079405607f275c2de4ba04c Mon Sep 17 00:00:00 2001 From: Christopher Andrews Date: Sun, 19 May 2024 09:49:43 +1000 Subject: [PATCH] Change volume slider to a logarithmic scale --- htdocs/index.html | 2 +- htdocs/lib/UI.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/index.html b/htdocs/index.html index 075818ee..e7cbafe7 100644 --- a/htdocs/index.html +++ b/htdocs/index.html @@ -225,7 +225,7 @@ - +
diff --git a/htdocs/lib/UI.js b/htdocs/lib/UI.js index 15c903cc..f734d01c 100644 --- a/htdocs/lib/UI.js +++ b/htdocs/lib/UI.js @@ -75,7 +75,10 @@ UI.setVolume = function(x) { this.volume = x; LS.save('volume', x); $('#openwebrx-panel-volume').val(x) - if (audioEngine) audioEngine.setVolume(x / 100); + //Map 0-150 to -60 to 0db gain + xdb = (x / 2.5) - 60; + gain = Math.pow(10, xdb / 20); + if (audioEngine) audioEngine.setVolume(gain); } };