feat(transactions): update cuelume; bring back improved volume user setting

This commit is contained in:
Herculino Trotta committed 2026-09-13 01:24:37 -03:00
1 parent 82211567d0
commit a2ee0b4ae6
9 files changed
+102 -8

No files matched your search

+8 -1
View File
@@ -1,4 +1,11 @@
import { play } from "cuelume";
window.playSound = play;
// User volume is stored as 0-10 (0 = muted); cuelume expects a 0-1 gain.
// Loudness is perceived logarithmically, so a linear mapping makes adjacent
// steps sound nearly identical. Squaring spreads them out (10 → 0dB, 5 → -12dB, 1 → -40dB).
// Pass `volume` to override the user's saved volume (e.g. to preview a new value).
window.playSound = (name, volume) => {
volume ??= JSON.parse(document.getElementById("volume")?.textContent ?? "10");
play(name, { volume: (volume / 10) ** 2 });
};