From: Chris Fulljames Date: Sat, 22 Aug 2026 13:04:18 +0000 (-0400) Subject: Add audio taper to volume slider X-Git-Url: https://littlesong.place/gitweb/?a=commitdiff_plain;h=HEAD;p=littlesongplace.git Add audio taper to volume slider --- diff --git a/src/littlesongplace/static/player.js b/src/littlesongplace/static/player.js index 9c18b43..d712b5e 100644 --- a/src/littlesongplace/static/player.js +++ b/src/littlesongplace/static/player.js @@ -255,6 +255,22 @@ function resetLove() { updateImageColors(); } +function clamp(x, min, max) { + if (x > max) return max; + if (x < min) return min; + return x; +} + +// Set the playback volume from a slider position +function setVolume(audio, slider) { + // Apply audio taper. Lower a = more extreme curve. + const a = 0.2; + const volExp = a * (Math.pow((1 / a + 1), slider.value) - 1); + const vol = clamp(volExp, 0, 1); + console.log(vol); + audio.volume = vol; +} + // Add event listeners var m_firstLoadPlayer = true; document.addEventListener("DOMContentLoaded", (event) => { @@ -262,7 +278,7 @@ document.addEventListener("DOMContentLoaded", (event) => { // Sync volume with current slider position (may be reset after refresh) var audio = document.getElementById("player-audio"); const slider = document.getElementById("volume-slider"); - audio.volume = slider.value; + setVolume(audio, slider); // The player never gets rebuilt, so we only need to set it up the first time if (!m_firstLoadPlayer) { @@ -329,7 +345,7 @@ document.addEventListener("DOMContentLoaded", (event) => { // Volume document.getElementById("volume-slider").oninput = function(event) { - audio.volume = event.target.value; + setVolume(audio, event.target); } // Show mini player on scroll diff --git a/src/littlesongplace/templates/news.html b/src/littlesongplace/templates/news.html index a1b9f1a..83ac370 100644 --- a/src/littlesongplace/templates/news.html +++ b/src/littlesongplace/templates/news.html @@ -6,11 +6,18 @@

site news

-

2026-08-22 - Private Songs

+

2026-08-22 - Better Volume & Private Songs

-You can now mark songs as private, so they will only be visible to you. This -works basically the same way as it does for playlists. +This update has two parts:

+

2026-03-10 - New Email