diff --git a/core/src/zero1hd/rhythmbullet/audio/MusicList.java b/core/src/zero1hd/rhythmbullet/audio/MusicList.java index cbcdc8e..ca1bb99 100755 --- a/core/src/zero1hd/rhythmbullet/audio/MusicList.java +++ b/core/src/zero1hd/rhythmbullet/audio/MusicList.java @@ -19,17 +19,27 @@ public class MusicList extends Observable { fhac = new FileHandleAlphabeticalComparator(); } + private Array recursiveMusicFileList(FileHandle fileHandle) { + Array musicFiles = new Array<>(); + FileHandle[] files = fileHandle.list(); + for (int i = 0; i < files.length; i++) { + if (files[i].isDirectory()) { + musicFiles.addAll(recursiveMusicFileList(files[i])); + } else { + if (files[i].extension().equalsIgnoreCase("wav") || files[i].extension().equalsIgnoreCase("mp3")) { + musicFiles.add(files[i]); + } + } + } + return musicFiles; + } + public void refresh() { searched = true; musicList.clear(); Gdx.app.debug("SongController", "Searching path: " + searchPath); if (Gdx.files.absolute(searchPath).exists() && Gdx.files.absolute(searchPath).isDirectory()) { - musicList.addAll(Gdx.files.absolute(searchPath).list((dir, name) -> { - if (name.endsWith("mp3") || name.endsWith("wav")) { - return true; - } - return false; - })); + musicList.addAll(recursiveMusicFileList(Gdx.files.absolute(searchPath))); } if (!Gdx.files.external("RhythmBullet/Alan Walker - Spectre.mp3").exists()) { Gdx.files.internal("music/Alan Walker - Spectre.mp3").copyTo(Gdx.files.external("RhythmBullet/Alan Walker - Spectre.mp3")); @@ -80,4 +90,5 @@ public class MusicList extends Observable { public boolean isSearched() { return searched; } + } diff --git a/core/src/zero1hd/rhythmbullet/audio/analyzer/AudioAnalyzer.java b/core/src/zero1hd/rhythmbullet/audio/analyzer/AudioAnalyzer.java index 453786d..1fdb9a2 100755 --- a/core/src/zero1hd/rhythmbullet/audio/analyzer/AudioAnalyzer.java +++ b/core/src/zero1hd/rhythmbullet/audio/analyzer/AudioAnalyzer.java @@ -15,12 +15,16 @@ public class AudioAnalyzer implements Disposable { private PruneFluxRunnable pfr; private PeakDetectionRunnable pdr; + private MusicManager musicManager; + public AudioAnalyzer(MusicManager musicManager) { exec = Executors.newSingleThreadExecutor(); sfar = new SpectralFluxAnalysisRunnable(musicManager); tcr = new ThresholdCalcRunnable(sfar); pfr = new PruneFluxRunnable(tcr); pdr = new PeakDetectionRunnable(pfr, sfar.getPUID()); + + this.musicManager = musicManager; } public void start() { @@ -40,10 +44,15 @@ public class AudioAnalyzer implements Disposable { @Override public void dispose() { stop(); + musicManager.dispose(); exec.shutdown(); } public boolean isDone() { - return (sfar.isDone() && tcr.isDone() && pfr.isDone() && pdr.isDone()); + if ((sfar.isDone() && tcr.isDone() && pfr.isDone() && pdr.isDone())) { + dispose(); + return true; + } + return false; } } diff --git a/core/src/zero1hd/rhythmbullet/graphics/ui/components/Visualizer.java b/core/src/zero1hd/rhythmbullet/graphics/ui/components/Visualizer.java index b3e0969..dd16922 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/ui/components/Visualizer.java +++ b/core/src/zero1hd/rhythmbullet/graphics/ui/components/Visualizer.java @@ -34,7 +34,7 @@ public class Visualizer extends Widget { } vis.modify(delta); - setVisualizerPosProp(); + updateVisualizerProperties(); if (updatePositioning) { vis.updatePositionInfo(); vis.setxPos((getWidth() - vis.getActualWidth())/2f); @@ -61,7 +61,7 @@ public class Visualizer extends Widget { super.setColor(r, g, b, a); } - public void setVisualizerPosProp() { + public void updateVisualizerProperties() { vis.setHeight(getHeight()); vis.setWidth(getWidth()); vis.setxPos(getX()); @@ -75,7 +75,7 @@ public class Visualizer extends Widget { } public void updateVisualPosition() { - setVisualizerPosProp(); + updateVisualizerProperties(); vis.updatePositionInfo(); vis.setxPos(((vis.getWidth() - vis.getActualWidth())/2f)); Gdx.app.debug("Visualizer", "currently offseting visualizer by (px): " + vis.getxPos()); diff --git a/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MusicSelectionPage.java b/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MusicSelectionPage.java index 2b8bea3..923afd4 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MusicSelectionPage.java +++ b/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MusicSelectionPage.java @@ -187,6 +187,7 @@ public class MusicSelectionPage extends Page implements Observer { selectables.clear(); musicInfoTable.clear(); musicSubInfo.clear(); + extraInfoDone = false; for (int i = 0; i < selectables.size; i++) { selectables.get(i).dispose(); @@ -326,7 +327,5 @@ public class MusicSelectionPage extends Page implements Observer { ratedDifficulty.setText("Rated Difficulty: " + difficulty); albumCover.setDrawable((new TextureRegionDrawable(new TextureRegion(currentlySelected.getAudioInfo().getAlbumCover())))); - - } }