From 99dbbb41f760765b701f6b0d18719956f1b00e37 Mon Sep 17 00:00:00 2001 From: Recrown Date: Thu, 5 Oct 2017 00:33:10 -0500 Subject: [PATCH] smooth rise of bars --- .../audio/{Mp3AudioData.java => Mp3Manager.java} | 4 ++-- core/src/zero1hd/rhythmbullet/audio/SongList.java | 6 ++++-- .../rhythmbullet/audio/SongListController.java | 13 +++++++++---- .../audio/{WavAudioData.java => WAVManager.java} | 4 ++-- .../audio/visualizer/BasicVisualizer.java | 4 +--- 5 files changed, 18 insertions(+), 13 deletions(-) rename core/src/zero1hd/rhythmbullet/audio/{Mp3AudioData.java => Mp3Manager.java} (94%) rename core/src/zero1hd/rhythmbullet/audio/{WavAudioData.java => WAVManager.java} (92%) diff --git a/core/src/zero1hd/rhythmbullet/audio/Mp3AudioData.java b/core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java similarity index 94% rename from core/src/zero1hd/rhythmbullet/audio/Mp3AudioData.java rename to core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java index c9e122a..4ab8127 100755 --- a/core/src/zero1hd/rhythmbullet/audio/Mp3AudioData.java +++ b/core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java @@ -21,7 +21,7 @@ import javazoom.jl.decoder.Header; import javazoom.jl.decoder.MP3Decoder; import javazoom.jl.decoder.OutputBuffer; -public class Mp3AudioData implements MusicManager { +public class Mp3Manager implements MusicManager { private int readWindowSize = 1024; private int currentReadWindowIndex; @@ -39,7 +39,7 @@ public class Mp3AudioData implements MusicManager { private byte[] workset; private int indexHead = -1; - public Mp3AudioData(FileHandle audioFile) { + public Mp3Manager(FileHandle audioFile) { try { MP3File mp3File = new MP3File(audioFile.file()); sampleCount = MathUtils.round((float) (mp3File.getAudioHeader().getSampleRateAsNumber()*mp3File.getMP3AudioHeader().getPreciseTrackLength())); diff --git a/core/src/zero1hd/rhythmbullet/audio/SongList.java b/core/src/zero1hd/rhythmbullet/audio/SongList.java index dd1c5bc..17f884f 100755 --- a/core/src/zero1hd/rhythmbullet/audio/SongList.java +++ b/core/src/zero1hd/rhythmbullet/audio/SongList.java @@ -27,10 +27,11 @@ public class SongList { } public MusicManager getAudioData(FileHandle file) { + Gdx.app.debug("SongList", "retrieving proper music manager..."); if (file.extension().equalsIgnoreCase("wav")) { - return new WavAudioData(file); + return new WAVManager(file); } else if (file.extension().equalsIgnoreCase("mp3")) { - return new Mp3AudioData(file); + return new Mp3Manager(file); } return null; } @@ -39,6 +40,7 @@ public class SongList { if (index > songList.size) { return null; } + return getAudioData(songList.get(index)); } diff --git a/core/src/zero1hd/rhythmbullet/audio/SongListController.java b/core/src/zero1hd/rhythmbullet/audio/SongListController.java index 98eba3c..115e79c 100755 --- a/core/src/zero1hd/rhythmbullet/audio/SongListController.java +++ b/core/src/zero1hd/rhythmbullet/audio/SongListController.java @@ -30,13 +30,17 @@ public class SongListController implements OnCompletionListener { this.prefs = prefs; listeners = new Array<>(); this.songList = songList; - changeSong(); rand = new Random(); } public void play() { - mdp.play(); - mdp.setVolume(prefs.getFloat("music vol")); + Gdx.app.debug("SongListController", "playing current song."); + if (mdp != null) { + mdp.play(); + mdp.setVolume(prefs.getFloat("music vol")); + } else { + changeSong(); + } } public void setSongByIndex(int index) { @@ -56,6 +60,7 @@ public class SongListController implements OnCompletionListener { @Override public void onCompletion(Music music) { + Gdx.app.debug("SongListController", "Song complete."); if (autoPlay) { if (shuffle) { currentPlaybackID = rand.nextInt(songList.getAmountOfSongs()); @@ -96,7 +101,7 @@ public class SongListController implements OnCompletionListener { if (mdp != null) { mdp.dispose(); } - + Gdx.app.debug("SongListController", "Changing songs..."); this.mdp = songList.getMusicInfoFromIndex(currentPlaybackID); if (mdp == null) { mdp = songList.getAudioData(Gdx.files.internal("music/default.mp3")); diff --git a/core/src/zero1hd/rhythmbullet/audio/WavAudioData.java b/core/src/zero1hd/rhythmbullet/audio/WAVManager.java similarity index 92% rename from core/src/zero1hd/rhythmbullet/audio/WavAudioData.java rename to core/src/zero1hd/rhythmbullet/audio/WAVManager.java index 6d1e560..008089c 100755 --- a/core/src/zero1hd/rhythmbullet/audio/WavAudioData.java +++ b/core/src/zero1hd/rhythmbullet/audio/WAVManager.java @@ -12,7 +12,7 @@ import com.badlogic.gdx.files.FileHandle; import zero1hd.rhythmbullet.audio.wavedecoder.WavDecoder; -public class WavAudioData implements MusicManager { +public class WAVManager implements MusicManager { private int readWindowSize = 1024; private AudioFormat format; private int readIndex; @@ -20,7 +20,7 @@ public class WavAudioData implements MusicManager { private Music playbackMusic; WavDecoder decoder; - public WavAudioData(FileHandle file) { + public WAVManager(FileHandle file) { try { decoder = new WavDecoder(file); } catch (InvalidParameterException | IOException e) { diff --git a/core/src/zero1hd/rhythmbullet/audio/visualizer/BasicVisualizer.java b/core/src/zero1hd/rhythmbullet/audio/visualizer/BasicVisualizer.java index b0a4534..b887a0d 100755 --- a/core/src/zero1hd/rhythmbullet/audio/visualizer/BasicVisualizer.java +++ b/core/src/zero1hd/rhythmbullet/audio/visualizer/BasicVisualizer.java @@ -66,8 +66,6 @@ public class BasicVisualizer extends VisualizerCore { } public void modify(float delta) { - - //Averaging bins together for (int i = 0; i < barCount; i++) { float barHeight = 2; @@ -92,7 +90,7 @@ public class BasicVisualizer extends VisualizerCore { avg /= smoothRange*2; barHeights[i] = avg; - bars[i].setSize(barWidth, bars[i].getHeight() <= barHeights[i] ? barHeights[i] : bars[i].getHeight() - 1.1f*Gdx.graphics.getHeight()*delta); + bars[i].setSize(barWidth, bars[i].getHeight() <= barHeights[i] ? bars[i].getHeight() + 0.5f*barHeights[i] : bars[i].getHeight() - 0.8f*Gdx.graphics.getHeight()*delta); } }