fixed previously stated issue

This commit is contained in:
Harrison Deng 2017-12-03 13:39:29 -06:00
parent 7d0f3a365d
commit 316c419b99
7 changed files with 19 additions and 26 deletions

View File

@ -58,7 +58,7 @@ public class Mp3Manager implements MusicManager {
lock.lock();
try {
MP3File mp3File = new MP3File(audioFile.file());
sampleCount = MathUtils.round(Float.valueOf(String.valueOf((mp3File.getAudioHeader().getSampleRateAsNumber()*mp3File.getMP3AudioHeader().getPreciseTrackLength()))));
sampleCount = MathUtils.round(Float.valueOf((float) (mp3File.getAudioHeader().getSampleRateAsNumber()*mp3File.getMP3AudioHeader().getPreciseTrackLength())));
sampleRate = mp3File.getMP3AudioHeader().getSampleRateAsNumber();
durationInSeconds = mp3File.getMP3AudioHeader().getPreciseTrackLength();
@ -66,8 +66,6 @@ public class Mp3Manager implements MusicManager {
e.printStackTrace();
}
lock.unlock();
});
bitstream = new Bitstream(audioFile.read());

View File

@ -1,6 +1,5 @@
package zero1hd.rhythmbullet.audio.analyzer;
import java.util.Observable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -8,7 +7,7 @@ import com.badlogic.gdx.utils.Disposable;
import zero1hd.rhythmbullet.audio.MusicManager;
public class AudioAnalyzer extends Observable implements Disposable {
public class AudioAnalyzer implements Disposable {
private ExecutorService exec;
private SpectralFluxAnalysisRunnable sfar;

View File

@ -7,7 +7,7 @@ import zero1hd.rhythmbullet.audio.AudioDataPackage;
import zero1hd.rhythmbullet.audio.MusicManager;
public class PeakDetectionRunnable implements Runnable {
boolean work, done;
boolean work = true, done;
private FloatArray bassPrunned;
private FloatArray mPrunned;
private FloatArray umPrunned;
@ -35,7 +35,7 @@ public class PeakDetectionRunnable implements Runnable {
@Override
public void run() {
int lastID = 0;
int lastBeatID = 0;
float bassBeats = 0;
float mBeats = 0;
float umBeats = 0;
@ -62,7 +62,7 @@ public class PeakDetectionRunnable implements Runnable {
if (bassPeaks.get(i) == 0) {
avgSPB ++;
} else {
lastID = i;
lastBeatID = i;
}
} else if (bassPeaks.get(i) != 0) {
avgSPB = 0;
@ -87,7 +87,7 @@ public class PeakDetectionRunnable implements Runnable {
secondsPerWindow = musicManager.getReadWindowSize()/musicManager.getSampleRate();
//then we minus one from the beats so it actually works out
avgSPB -= bassPrunned.size-lastID;
avgSPB -= bassPrunned.size-lastBeatID;
avgSPB *= secondsPerWindow;
avgSPB /= bassBeats;
Gdx.app.debug("Audio Analyzer", "Avg SPB: " + avgSPB);

View File

@ -6,7 +6,7 @@ import com.badlogic.gdx.utils.FloatArray;
import zero1hd.rhythmbullet.audio.MusicManager;
public class PruneFluxRunnable implements Runnable {
boolean work;
boolean work = true;
private boolean done;
private FloatArray bassSpectralFlux;
private FloatArray mSpectralFlux;

View File

@ -7,7 +7,7 @@ import edu.emory.mathcs.jtransforms.fft.FloatFFT_1D;
import zero1hd.rhythmbullet.audio.MusicManager;
public class SpectralFluxAnalysisRunnable implements Runnable {
boolean work;
boolean work = true;
private boolean done;
private FloatArray bassSpectralFlux = new FloatArray();

View File

@ -6,7 +6,7 @@ import com.badlogic.gdx.utils.FloatArray;
import zero1hd.rhythmbullet.audio.MusicManager;
public class ThresholdCalcRunnable implements Runnable {
boolean work;
boolean work = true;
private boolean done;
private MusicManager musicManager;

View File

@ -1,8 +1,5 @@
package zero1hd.rhythmbullet.graphics.ui.pages;
import java.util.Observable;
import java.util.Observer;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.Actor;
@ -16,9 +13,9 @@ import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import zero1hd.rhythmbullet.audio.MusicManager;
import zero1hd.rhythmbullet.audio.analyzer.AudioAnalyzer;
public class AnalysisPage extends Page implements Observer {
public class AnalysisPage extends Page {
private boolean confirmed;
private volatile AudioAnalyzer aa;
private AudioAnalyzer aa;
private Table table;
private Label difficultyModLabel, healthModLabel, speedModLabel;
private Slider difficultyModifierSlider, healthModifierSlider, speedModifierSlider;
@ -81,24 +78,17 @@ public class AnalysisPage extends Page implements Observer {
}
});
table.add(confirmButton);
table.row().colspan(3).fillX();
table.add(confirmButton).colspan(3).fillX();
table.row();
progressLabel = new Label("Loading... ", skin);
table.add(progressLabel).colspan(2).left().spaceTop(20f);
}
public void processSong(MusicManager mm) {
aa = new AudioAnalyzer(mm);
aa.addObserver(this);
aa.start();
}
@Override
public void update(Observable arg0, Object arg1) {
if (arg0 == aa) {
}
}
@Override
public void act(float delta) {
if (aa != null && aa.isDone() && confirmed) {
@ -106,4 +96,10 @@ public class AnalysisPage extends Page implements Observer {
}
super.act(delta);
}
@Override
public void dispose() {
aa.dispose();
super.dispose();
}
}