From 178f1d7d42879c3a9fd44b54645b87083c81f761 Mon Sep 17 00:00:00 2001 From: scisneromam Date: Tue, 8 Aug 2023 14:42:18 +0200 Subject: [PATCH 1/2] feat: Volume control Adds Volume as a query param Adds !bongovolume mod command to set Volume Volume can range between 0.0 and 1.0 --- src/bongocat.js | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/bongocat.js b/src/bongocat.js index 5875649..ec5b76f 100644 --- a/src/bongocat.js +++ b/src/bongocat.js @@ -46,6 +46,7 @@ var stackMode = false; var defaultNotation = "bongo"; var currentSong = null; +var volume = 1.0; window.maxNotesPerBatch = 5; @@ -63,9 +64,13 @@ notations["bongo+"] = parseSongBongo; // ====================================================== // // =================== helper methods =================== // // ====================================================== // -function setBPM(targetBPM, username) +function setVolume(volumeParam) { + volume = Math.min(1.0, Math.max(0, Number(volumeParam))); +} +function setBPM(targetBPM, username) +{ targetBPM = Number(targetBPM); if (isNaN(targetBPM)) { @@ -116,6 +121,7 @@ function playSound(cmd, cBpm) setInstrument(audio.dataset.instrument); audio.currentTime = 0; + audio.volume = volume; audio.play(); } @@ -364,7 +370,7 @@ function skipSong(args) return; } - console.log(`${args.tags.username} cleared the current song ${currentSong}`) + console.log(`${args.tags.username} cleared the current song ${currentSong}`); for (let id of currentSong.timeoutIDs) { @@ -376,6 +382,17 @@ function skipSong(args) commands["!bongoskip"] = skipSong; +function setVolumeCommand(args) +{ + if (!isSuperUser(args.tags)) + { + return; + } + setVolume(args.arg); +} + +commands["!bongovolume"] = setVolumeCommand; + // ====================================================== // // ==================== user commands =================== // // ====================================================== // @@ -507,6 +524,12 @@ if (params.get("stackMode")) stackMode = true; } +let volumeParam = params.get("volume"); +if (volumeParam && !isNaN(Number(volumeParam))) +{ + setVolume(volumeParam); +} + // ====================================================== // // ======================== tmijs ======================= // // ====================================================== // From 1e3df8eb3ec004eaf6e65d368078a5f3221f8c0c Mon Sep 17 00:00:00 2001 From: scisneromam Date: Tue, 8 Aug 2023 14:42:48 +0200 Subject: [PATCH 2/2] fix: Dedications are no longer shown when empty --- src/bongocat.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bongocat.js b/src/bongocat.js index ec5b76f..dc63957 100644 --- a/src/bongocat.js +++ b/src/bongocat.js @@ -145,14 +145,17 @@ function introAnimation(song) }); document.getElementById("dedications").innerHTML = "This song is dedicated to " + song.dedications.join(", "); + document.getElementById("dedications").style.visibility = "visible"; } else { document.getElementById("dedications").innerHTML = ""; + document.getElementById("dedications").style.visibility = "hidden"; } document.getElementById("bongocat").style.left = "0px"; playing = true; } + function outroAnimation() { document.getElementById("bongocat").style.left = "-1920px"; @@ -163,6 +166,7 @@ function outroAnimation() currentSong = null; }, 1000); } + function setInstrument(instrument) { var c = document.getElementById("instruments").children; @@ -175,12 +179,14 @@ function setInstrument(instrument) newInstrument.style.visibility = "visible"; } + function setPaw(paw, cBpm) { var currentPaw = document.getElementById(paw); currentPaw.style.backgroundPosition = "top right"; window.setTimeout(releasePaw, cBpm / 2, paw); } + function releasePaw(paw) {