From 316c419b990193328b01adb03d6c4d90d230f73e Mon Sep 17 00:00:00 2001 From: Recrown Date: Sun, 3 Dec 2017 13:39:29 -0600 Subject: [PATCH] fixed previously stated issue --- .../rhythmbullet/audio/Mp3Manager.java | 4 +--- .../audio/analyzer/AudioAnalyzer.java | 3 +-- .../audio/analyzer/PeakDetectionRunnable.java | 8 +++---- .../audio/analyzer/PruneFluxRunnable.java | 2 +- .../SpectralFluxAnalysisRunnable.java | 2 +- .../audio/analyzer/ThresholdCalcRunnable.java | 2 +- .../graphics/ui/pages/AnalysisPage.java | 24 ++++++++----------- 7 files changed, 19 insertions(+), 26 deletions(-) diff --git a/core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java b/core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java index f039ade..8184f2f 100755 --- a/core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java +++ b/core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java @@ -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()); diff --git a/core/src/zero1hd/rhythmbullet/audio/analyzer/AudioAnalyzer.java b/core/src/zero1hd/rhythmbullet/audio/analyzer/AudioAnalyzer.java index d93e5a6..453786d 100755 --- a/core/src/zero1hd/rhythmbullet/audio/analyzer/AudioAnalyzer.java +++ b/core/src/zero1hd/rhythmbullet/audio/analyzer/AudioAnalyzer.java @@ -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; diff --git a/core/src/zero1hd/rhythmbullet/audio/analyzer/PeakDetectionRunnable.java b/core/src/zero1hd/rhythmbullet/audio/analyzer/PeakDetectionRunnable.java index c5f4892..cf2e7f0 100755 --- a/core/src/zero1hd/rhythmbullet/audio/analyzer/PeakDetectionRunnable.java +++ b/core/src/zero1hd/rhythmbullet/audio/analyzer/PeakDetectionRunnable.java @@ -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); diff --git a/core/src/zero1hd/rhythmbullet/audio/analyzer/PruneFluxRunnable.java b/core/src/zero1hd/rhythmbullet/audio/analyzer/PruneFluxRunnable.java index b65ec55..b06ade9 100755 --- a/core/src/zero1hd/rhythmbullet/audio/analyzer/PruneFluxRunnable.java +++ b/core/src/zero1hd/rhythmbullet/audio/analyzer/PruneFluxRunnable.java @@ -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; diff --git a/core/src/zero1hd/rhythmbullet/audio/analyzer/SpectralFluxAnalysisRunnable.java b/core/src/zero1hd/rhythmbullet/audio/analyzer/SpectralFluxAnalysisRunnable.java index 11ee754..9103347 100755 --- a/core/src/zero1hd/rhythmbullet/audio/analyzer/SpectralFluxAnalysisRunnable.java +++ b/core/src/zero1hd/rhythmbullet/audio/analyzer/SpectralFluxAnalysisRunnable.java @@ -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(); diff --git a/core/src/zero1hd/rhythmbullet/audio/analyzer/ThresholdCalcRunnable.java b/core/src/zero1hd/rhythmbullet/audio/analyzer/ThresholdCalcRunnable.java index 181e6a0..613f4c8 100755 --- a/core/src/zero1hd/rhythmbullet/audio/analyzer/ThresholdCalcRunnable.java +++ b/core/src/zero1hd/rhythmbullet/audio/analyzer/ThresholdCalcRunnable.java @@ -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; diff --git a/core/src/zero1hd/rhythmbullet/graphics/ui/pages/AnalysisPage.java b/core/src/zero1hd/rhythmbullet/graphics/ui/pages/AnalysisPage.java index 99557c8..374bc19 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/ui/pages/AnalysisPage.java +++ b/core/src/zero1hd/rhythmbullet/graphics/ui/pages/AnalysisPage.java @@ -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(); + } }