diff --git a/core/src/zero1hd/rhythmbullet/audio/Mp3AudioData.java b/core/src/zero1hd/rhythmbullet/audio/Mp3AudioData.java index 89f5856..a97313b 100755 --- a/core/src/zero1hd/rhythmbullet/audio/Mp3AudioData.java +++ b/core/src/zero1hd/rhythmbullet/audio/Mp3AudioData.java @@ -10,6 +10,7 @@ import org.jaudiotagger.tag.TagException; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.audio.Music; import com.badlogic.gdx.files.FileHandle; +import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.utils.GdxRuntimeException; import javazoom.jl.decoder.Bitstream; @@ -39,7 +40,7 @@ public class Mp3AudioData implements AudioData { public Mp3AudioData(FileHandle audioFile) { try { MP3File mp3File = new MP3File(audioFile.file()); - sampleCount = (long) (mp3File.getMP3AudioHeader().getPreciseTrackLength()*mp3File.getMP3AudioHeader().getSampleRateAsNumber()) + 2; //TODO figure out why this is correct since this way of calc was discovered by testing. + sampleCount = MathUtils.round((float) (mp3File.getAudioHeader().getSampleRateAsNumber()*mp3File.getMP3AudioHeader().getPreciseTrackLength())); durationInSeconds = mp3File.getMP3AudioHeader().getNumberOfFrames()/readWindowSize; sampleRate = mp3File.getMP3AudioHeader().getSampleRateAsNumber(); } catch (IOException | TagException | ReadOnlyFileException | InvalidAudioFrameException e) { diff --git a/core/src/zero1hd/rhythmbullet/ui/pages/AnalyzePage.java b/core/src/zero1hd/rhythmbullet/ui/pages/AnalyzePage.java index f8d3d8c..4b89bb5 100755 --- a/core/src/zero1hd/rhythmbullet/ui/pages/AnalyzePage.java +++ b/core/src/zero1hd/rhythmbullet/ui/pages/AnalyzePage.java @@ -34,7 +34,7 @@ public class AnalyzePage extends Page implements MiniListener { AudioData music; RhythmMapAlgorithm mapGenAlgorithm; - private Table songInfo; + private volatile Table songInfo; private volatile Label[] info; Table difficultyTable; @@ -239,12 +239,12 @@ public class AnalyzePage extends Page implements MiniListener { } @Override - public void handle(MiniEvents ID) { + public synchronized void handle(MiniEvents ID) { switch (ID) { case ANALYZER_ITERATED: if (audioAnalyzer.getProgress() == 50) { songInfo.addAction(Actions.moveTo(songInfo.getX(), getHeight()/2f, 0.75f, Interpolation.linear)); - difficultyTable.addAction(Actions.moveTo(songInfo.getX(), songInfo.getY()-difficultyTable.getHeight(),0.8f, Interpolation.linear)); + difficultyTable.addAction(Actions.moveTo(songInfo.getX(), getHeight()/2f-difficultyTable.getHeight()-10,0.8f, Interpolation.linear)); info[2].setText("Awaiting confirmation..."); info[2].addAction(Actions.color(Color.BLACK, 0.75f)); confirmDiffButton.setDisabled(false); diff --git a/core/src/zero1hd/rhythmbullet/ui/stages/GameHUD.java b/core/src/zero1hd/rhythmbullet/ui/stages/GameHUD.java index 82ca85d..4ec306a 100755 --- a/core/src/zero1hd/rhythmbullet/ui/stages/GameHUD.java +++ b/core/src/zero1hd/rhythmbullet/ui/stages/GameHUD.java @@ -120,7 +120,7 @@ public class GameHUD extends Stage { setScore(sm.getScore()); } - try { + if (gpa.getAudioMap() != null && gpa.getAudioMap().getHudType().length > gpa.getAudioMap().getIndex()) { if (gpa.getAudioMap() != null && gpa.getAudioMap().getHudType()[gpa.getAudioMap().getIndex()] != 0) { switch (gpa.getAudioMap().getHudType()[gpa.getAudioMap().getIndex()]) { case 1: @@ -130,9 +130,8 @@ public class GameHUD extends Stage { changeStatusColor(um, 0.2f, original); } } - } catch (ArrayIndexOutOfBoundsException e) { - Gdx.app.debug("GameHUD", "reached end of status data."); } + super.act(delta); }