From 2bdc8b3e06b3996bfbc235e9fc8ad452c7a066e8 Mon Sep 17 00:00:00 2001 From: Christopher Andrews Date: Tue, 21 May 2024 13:55:31 +1000 Subject: [PATCH] Change volume slider to a logarithmic scale (#51) * Change volume slider to a logarithmic scale * Unbreak muting --- htdocs/index.html | 2 +- htdocs/lib/UI.js | 8 +++++++- 2 files changed, 8 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..e2948549 100644 --- a/htdocs/lib/UI.js +++ b/htdocs/lib/UI.js @@ -75,7 +75,13 @@ 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 (x == 0) { + gain = 0; + } + if (audioEngine) audioEngine.setVolume(gain); } };