From 1c5e6a1ef53a835b6b57bcbccd9f8d7d2bdfe37f Mon Sep 17 00:00:00 2001 From: Stephen Thompson Date: Mon, 21 Nov 2022 11:22:35 +0000 Subject: [PATCH] Issue #1 use modulo operator --- scripts/sounds.js.in | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/sounds.js.in b/scripts/sounds.js.in index 014b5ff..680eab0 100644 --- a/scripts/sounds.js.in +++ b/scripts/sounds.js.in @@ -45,11 +45,10 @@ let playAttempt = setInterval(() => { let x = 0 $("#narration").bind("ended", function(){ x = x + 1 - console.log("Sound array", allsounds) - console.log("Sound array", allsounds[0]) - console.log("Sound array", allsounds[0][1]) + console.log("Sound array", allsounds[x%soundFiles]) + const pick_one = Math.round(Math.random() * (allsounds[x%soundFiles].length-1)) - const file = "sounds/" + String(x%soundFiles).padStart(2, '0') + "_panned.mp3" + const file = allsounds[x][pick_one] console.log("Looking for ", file) narration.src = file narration.pause()