From a7e53b877c5bb52050550f2b7f208c33c30fbdf9 Mon Sep 17 00:00:00 2001 From: William Toohey Date: Mon, 8 Feb 2016 17:45:58 +1000 Subject: [PATCH] Fix #6 --- src/js/HuesCore.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/js/HuesCore.js b/src/js/HuesCore.js index e0a0c2d..0db3d99 100644 --- a/src/js/HuesCore.js +++ b/src/js/HuesCore.js @@ -298,6 +298,11 @@ HuesCore.prototype.animationLoop = function() { HuesCore.prototype.recalcBeatIndex = function() { this.beatIndex = Math.floor(this.soundManager.currentTime() / this.getBeatLength()); + // beatIndex is NaN, abort + if(this.beatIndex != this.beatIndex) { + this.setInvert(false); + return; + } // We should sync up to how many inverts there are let build = this.currentSong.buildupRhythm; @@ -311,7 +316,7 @@ HuesCore.prototype.recalcBeatIndex = function() { if((rhythm.match(/i|I/g)||[]).length % 2) { return; } - mapSoFar = build + rhythm.slice(0, this.beatIndex); + mapSoFar = (build ? build : "") + rhythm.slice(0, this.beatIndex); } // If there's an odd amount of inverts thus far, invert our display let invertCount = (mapSoFar.match(/i|I/g)||[]).length;