fix: apply square curve to volume slider so low positions are genuinely quiet

This commit is contained in:
Honey committed 2026-05-09 17:12:37 +02:00
1 parent e2c28926b2
commit 7dd22d9639
2 files changed
+4 -2

No files matched your search

+1 -1
View File
@@ -56,7 +56,7 @@ export function syncNowPlaying() {
const volSlider = document.getElementById('np-vol-slider'); const volSlider = document.getElementById('np-vol-slider');
if(shuffleBtn) shuffleBtn.classList.toggle('active', S.shuffle); if(shuffleBtn) shuffleBtn.classList.toggle('active', S.shuffle);
if(repeatBtn) repeatBtn.classList.toggle('active', S.repeat !== false); if(repeatBtn) repeatBtn.classList.toggle('active', S.repeat !== false);
if(volSlider) volSlider.value = Math.round(S.audio.volume * 100); if(volSlider) volSlider.value = Math.round(Math.sqrt(S.audio.volume) * 100);
const playing = !S.audio.paused; const playing = !S.audio.paused;
const npIcon = document.getElementById('np-play-icon'); const npIcon = document.getElementById('np-play-icon');
if(npIcon) npIcon.innerHTML = playing if(npIcon) npIcon.innerHTML = playing
+3 -1
View File
@@ -637,7 +637,9 @@ function _initBarScrub(bar, fill, onMove) {
} }
export function setVolume(v) { export function setVolume(v) {
const vol = v / 100; // Square curve: slider 50 → actual 0.25, slider 30 → actual 0.09
// Matches how ears perceive loudness (logarithmic) so low values feel genuinely quiet.
const vol = Math.pow(v / 100, 2);
S.audio.volume = vol; S.audio.volume = vol;
S.previewAudio.volume = vol; S.previewAudio.volume = vol;
const absAudio = document.getElementById('abs-audio'); const absAudio = document.getElementById('abs-audio');