From 52e8d31869d281d3b434578cd87c2813788e8642 Mon Sep 17 00:00:00 2001 From: William Toohey Date: Mon, 3 Jul 2017 14:46:33 +1000 Subject: [PATCH] Minor cleaning and fix #29 --- src/js/HuesCanvas.js | 14 +++++++++----- src/js/HuesCore.js | 8 ++++---- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/js/HuesCanvas.js b/src/js/HuesCanvas.js index 33bfe82..12b37b3 100644 --- a/src/js/HuesCanvas.js +++ b/src/js/HuesCanvas.js @@ -471,7 +471,7 @@ class HuesCanvas { } doBlackout(whiteout) { - if (typeof(whiteout)==='undefined') whiteout = false; + if(typeof(whiteout) === 'undefined') whiteout = false; if(whiteout) { this.blackoutColour = "#FFF"; } else { @@ -489,7 +489,6 @@ class HuesCanvas { } } - // for song changes clearBlackout() { this.blackout = false; this.blackoutTimeout = 0; @@ -500,10 +499,15 @@ class HuesCanvas { } doShortBlackout(beatTime) { - this.doBlackout(); - this.blackoutTimeout = this.audio.currentTime + beatTime / 1.7; // looks better if we go right to black - this.blackoutStart = 0; + this.doInstantBlackout(); + this.blackoutTimeout = this.audio.currentTime + beatTime / 1.7; + } + + doInstantBlackout() { + this.doBlackout(); + // sufficiently negative + this.blackoutStart = -Math.pow(2, 32); } doColourFade(length) { diff --git a/src/js/HuesCore.js b/src/js/HuesCore.js index 8e1d6e8..ad60340 100644 --- a/src/js/HuesCore.js +++ b/src/js/HuesCore.js @@ -97,10 +97,10 @@ class HuesCore { */ frame : [], - /* callback songstarted() + /* callback songstarted(song) * * Called when the song actually begins to play, not just when the - * new song processing begins + * new song processing begins. Song object passed. */ songstarted : [], @@ -524,12 +524,12 @@ class HuesCore { } } this.setInvert(false); - this.renderer.doBlackout(); + this.renderer.doInstantBlackout(); return this.soundManager.playSong(this.currentSong, this.doBuildup) .then(() => { this.resetAudio(); this.fillBuildup(); - this.callEventListeners("songstarted"); + this.callEventListeners("songstarted", this.currentSong); }); }