Browse Source

Keep position in bounds when getting spectrum

Thomas Dy 11 years ago
parent
commit
9b5c47bedf
1 changed files with 2 additions and 2 deletions
  1. 2 2
      scripts/game.js

+ 2 - 2
scripts/game.js

@@ -386,8 +386,8 @@ var SoundSafari = function(canvas, beatInfo, pSoundManager) {
     if(isNaN(this.shimmerFactor) || this.shimmerFactor < 0) {
       this.shimmerFactor = 0;
     }
-
-    this.spectrum = this.beat.sound.getSpectrum(t%this.beat.info.duration);
+    var pos = t%this.beat.info.duration;
+    if(pos < this.beat.sound.duration) this.spectrum = this.beat.sound.getSpectrum(pos);
   };
 
   var player = {