From d066d43b0b014ea1ad335edf308664b823ee623e Mon Sep 17 00:00:00 2001 From: necrashter Date: Mon, 11 Dec 2023 14:06:13 +0300 Subject: [PATCH] Lower music volume to 80% on Web --- web/index.html | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/web/index.html b/web/index.html index 5ffa1eb..7fc01d9 100644 --- a/web/index.html +++ b/web/index.html @@ -47,8 +47,15 @@ // Loop the audio source.loop = true; - // Connect the source to the audio context's destination (output) - source.connect(audioContext.destination); + // Create a gain node to control the volume + const gainNode = audioContext.createGain(); + + // Set the volume to 80% (0.8) + gainNode.gain.value = 0.8; + + // Connect the source to the gain node and the gain node to the audio context's destination + source.connect(gainNode); + gainNode.connect(audioContext.destination); // Start playing the audio source.start(0);