attempt at fixing multi threading issue
This commit is contained in:
parent
569af8adf9
commit
7cdb372de2
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user