mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-11-29 20:02:51 +01:00
feat(transactions): update cuelume; bring back improved volume user setting
This commit is contained in:
1 parent
82211567d0
commit
a2ee0b4ae6
9 files changed
+102
-8
No files matched your search
@@ -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 });
|
||||
};
|
||||
Reference in new issue
Block a user