diff --git a/core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java b/core/src/zero1hd/rhythmbullet/audio/Mp3AudioData.java similarity index 84% rename from core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java rename to core/src/zero1hd/rhythmbullet/audio/Mp3AudioData.java index 4078ba7..fb82833 100755 --- a/core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java +++ b/core/src/zero1hd/rhythmbullet/audio/Mp3AudioData.java @@ -23,7 +23,7 @@ import javazoom.jl.decoder.Header; import javazoom.jl.decoder.MP3Decoder; import javazoom.jl.decoder.OutputBuffer; -public class Mp3Manager implements MusicManager { +public class Mp3AudioData implements MusicManager { private int readWindowSize = 1024; private int currentReadWindowIndex; @@ -41,6 +41,7 @@ public class Mp3Manager implements MusicManager { private byte[] workset; private int indexHead = -1; +<<<<<<< HEAD:core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java private ExecutorService exec; private boolean loadComplete; @@ -58,6 +59,17 @@ public class Mp3Manager implements MusicManager { loadComplete = true; }); +======= + public Mp3AudioData(FileHandle audioFile) { + try { + MP3File mp3File = new MP3File(audioFile.file()); + 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) { + e.printStackTrace(); + } +>>>>>>> parent of 23df4f8... smooth rise of bars:core/src/zero1hd/rhythmbullet/audio/Mp3AudioData.java bitstream = new Bitstream(audioFile.read()); decoder = new MP3Decoder(); diff --git a/core/src/zero1hd/rhythmbullet/audio/SongList.java b/core/src/zero1hd/rhythmbullet/audio/SongList.java index 17f884f..dd1c5bc 100755 --- a/core/src/zero1hd/rhythmbullet/audio/SongList.java +++ b/core/src/zero1hd/rhythmbullet/audio/SongList.java @@ -27,11 +27,10 @@ public class SongList { } public MusicManager getAudioData(FileHandle file) { - Gdx.app.debug("SongList", "retrieving proper music manager..."); if (file.extension().equalsIgnoreCase("wav")) { - return new WAVManager(file); + return new WavAudioData(file); } else if (file.extension().equalsIgnoreCase("mp3")) { - return new Mp3Manager(file); + return new Mp3AudioData(file); } return null; } @@ -40,7 +39,6 @@ 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 115e79c..98eba3c 100755 --- a/core/src/zero1hd/rhythmbullet/audio/SongListController.java +++ b/core/src/zero1hd/rhythmbullet/audio/SongListController.java @@ -30,17 +30,13 @@ public class SongListController implements OnCompletionListener { this.prefs = prefs; listeners = new Array<>(); this.songList = songList; + changeSong(); rand = new Random(); } public void play() { - Gdx.app.debug("SongListController", "playing current song."); - if (mdp != null) { - mdp.play(); - mdp.setVolume(prefs.getFloat("music vol")); - } else { - changeSong(); - } + mdp.play(); + mdp.setVolume(prefs.getFloat("music vol")); } public void setSongByIndex(int index) { @@ -60,7 +56,6 @@ 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()); @@ -101,7 +96,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/WAVManager.java b/core/src/zero1hd/rhythmbullet/audio/WavAudioData.java similarity index 87% rename from core/src/zero1hd/rhythmbullet/audio/WAVManager.java rename to core/src/zero1hd/rhythmbullet/audio/WavAudioData.java index dcbcf18..31d91ae 100755 --- a/core/src/zero1hd/rhythmbullet/audio/WAVManager.java +++ b/core/src/zero1hd/rhythmbullet/audio/WavAudioData.java @@ -12,14 +12,19 @@ import com.badlogic.gdx.files.FileHandle; import zero1hd.rhythmbullet.audio.wavedecoder.WavDecoder; -public class WAVManager implements MusicManager { +public class WavAudioData implements MusicManager { private int readWindowSize = 1024; private AudioFormat format; private int readIndex; private int currentReadWindowIndex; private Music playbackMusic; WavDecoder decoder; +<<<<<<< HEAD:core/src/zero1hd/rhythmbullet/audio/WAVManager.java public WAVManager(FileHandle file) { +======= + + public WavAudioData(FileHandle file) { +>>>>>>> parent of 23df4f8... smooth rise of bars:core/src/zero1hd/rhythmbullet/audio/WavAudioData.java 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 9236ef7..fc1b651 100755 --- a/core/src/zero1hd/rhythmbullet/audio/visualizer/BasicVisualizer.java +++ b/core/src/zero1hd/rhythmbullet/audio/visualizer/BasicVisualizer.java @@ -66,6 +66,8 @@ public class BasicVisualizer extends VisualizerCore { } public void modify(float delta) { + + //Averaging bins together for (int i = 0; i < barCount; i++) { float barHeight = 2; @@ -90,7 +92,7 @@ public class BasicVisualizer extends VisualizerCore { avg /= smoothRange*2; barHeights[i] = avg; - 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); + bars[i].setSize(barWidth, bars[i].getHeight() <= barHeights[i] ? barHeights[i] : bars[i].getHeight() - 1.1f*Gdx.graphics.getHeight()*delta); } }