diff --git a/android/assets/1280x720/title.png b/android/assets/1280x720/title.png index 4518a31..9be0ad6 100755 Binary files a/android/assets/1280x720/title.png and b/android/assets/1280x720/title.png differ diff --git a/android/assets/1280x800/title.png b/android/assets/1280x800/title.png index 1831d2d..ca71aa0 100755 Binary files a/android/assets/1280x800/title.png and b/android/assets/1280x800/title.png differ diff --git a/android/assets/1366x768/title.png b/android/assets/1366x768/title.png index 867f5de..cd4caf7 100755 Binary files a/android/assets/1366x768/title.png and b/android/assets/1366x768/title.png differ diff --git a/android/assets/1920x1080/title.png b/android/assets/1920x1080/title.png index 2cd73ba..7885f48 100755 Binary files a/android/assets/1920x1080/title.png and b/android/assets/1920x1080/title.png differ diff --git a/android/assets/1920x1200/title.png b/android/assets/1920x1200/title.png index 5eb9541..1ada752 100755 Binary files a/android/assets/1920x1200/title.png and b/android/assets/1920x1200/title.png differ diff --git a/android/assets/2560x1440/title.png b/android/assets/2560x1440/title.png index 285514e..dc1274a 100755 Binary files a/android/assets/2560x1440/title.png and b/android/assets/2560x1440/title.png differ diff --git a/android/assets/3840x2160/title.png b/android/assets/3840x2160/title.png index f232203..998f2d9 100755 Binary files a/android/assets/3840x2160/title.png and b/android/assets/3840x2160/title.png differ diff --git a/android/assets/800x480/title.png b/android/assets/800x480/title.png index 6fa8509..740ae0e 100755 Binary files a/android/assets/800x480/title.png and b/android/assets/800x480/title.png differ diff --git a/core/src/zero1hd/rhythmbullet/RhythmBullet.java b/core/src/zero1hd/rhythmbullet/RhythmBullet.java index 0b240ed..ee8e669 100755 --- a/core/src/zero1hd/rhythmbullet/RhythmBullet.java +++ b/core/src/zero1hd/rhythmbullet/RhythmBullet.java @@ -217,8 +217,8 @@ public class RhythmBullet extends Game { } public void defineSkinStyles() { - getDefaultSkin().add("default", Color.BLACK); - getDefaultSkin().add("inverse", Color.WHITE); + getDefaultSkin().add("default", Color.WHITE); + getDefaultSkin().add("inverse", Color.BLACK); TextButtonStyle defaultTextButton = new TextButtonStyle(); defaultTextButton.up = getDefaultSkin().getDrawable("default-round"); diff --git a/core/src/zero1hd/rhythmbullet/audio/AudioAnalyzer.java b/core/src/zero1hd/rhythmbullet/audio/AudioAnalyzer.java index 93d4b06..112e93f 100755 --- a/core/src/zero1hd/rhythmbullet/audio/AudioAnalyzer.java +++ b/core/src/zero1hd/rhythmbullet/audio/AudioAnalyzer.java @@ -12,7 +12,7 @@ import zero1hd.rhythmbullet.util.MiniSender; public class AudioAnalyzer { private boolean containsData; - private CoreMusicInfo musicInfo; + private MusicDataPack musicInfo; float[] audioPCM; float[] spectrum; @@ -56,7 +56,7 @@ public class AudioAnalyzer { private float secondsPerWindow; private AudioDataPackage pack; - public AudioAnalyzer(CoreMusicInfo audiofile) { + public AudioAnalyzer(MusicDataPack audiofile) { sender = new MiniSender(); analysisAlgorithm = () -> { diff --git a/core/src/zero1hd/rhythmbullet/audio/AudioDataPackage.java b/core/src/zero1hd/rhythmbullet/audio/AudioDataPackage.java index 98470ff..e8887fb 100755 --- a/core/src/zero1hd/rhythmbullet/audio/AudioDataPackage.java +++ b/core/src/zero1hd/rhythmbullet/audio/AudioDataPackage.java @@ -9,7 +9,7 @@ public class AudioDataPackage { private FloatArray mPeaks; private FloatArray umPeaks; - private CoreMusicInfo musicInfo; + private MusicDataPack musicInfo; private float bassMaxVal, bassAvg; private float mMaxVal, mAvg; @@ -64,7 +64,7 @@ public class AudioDataPackage { this.uMAvg = uMAvg; } - public void setMusicInfo(CoreMusicInfo musicInfo) { + public void setMusicInfo(MusicDataPack musicInfo) { if (this.musicInfo != null) { throw new InvalidParameterException("There is already music information in this package."); } @@ -108,7 +108,7 @@ public class AudioDataPackage { } } - public CoreMusicInfo getMusicInfo() { + public MusicDataPack getMusicInfo() { if (musicInfo == null) { throw new NullPointerException("Music info hasn't been baked in..."); } diff --git a/core/src/zero1hd/rhythmbullet/audio/Mp3AudioData.java b/core/src/zero1hd/rhythmbullet/audio/Mp3AudioData.java index f929d9e..b13c3b6 100755 --- a/core/src/zero1hd/rhythmbullet/audio/Mp3AudioData.java +++ b/core/src/zero1hd/rhythmbullet/audio/Mp3AudioData.java @@ -20,7 +20,7 @@ import javazoom.jl.decoder.Header; import javazoom.jl.decoder.MP3Decoder; import javazoom.jl.decoder.OutputBuffer; -public class Mp3AudioData implements CoreMusicInfo { +public class Mp3AudioData implements MusicDataPack { private int readWindowSize = 1024; private int currentReadWindowIndex; diff --git a/core/src/zero1hd/rhythmbullet/audio/CoreMusicInfo.java b/core/src/zero1hd/rhythmbullet/audio/MusicDataPack.java similarity index 92% rename from core/src/zero1hd/rhythmbullet/audio/CoreMusicInfo.java rename to core/src/zero1hd/rhythmbullet/audio/MusicDataPack.java index 48095b3..304f480 100755 --- a/core/src/zero1hd/rhythmbullet/audio/CoreMusicInfo.java +++ b/core/src/zero1hd/rhythmbullet/audio/MusicDataPack.java @@ -4,7 +4,7 @@ package zero1hd.rhythmbullet.audio; import com.badlogic.gdx.audio.Music; import com.badlogic.gdx.utils.Disposable; -public interface CoreMusicInfo extends Disposable { +public interface MusicDataPack extends Disposable { /** * sets a integer variable to the current window of audio data the playback is at. * Useful for efficiency because we compute once for that frame then get the values everytime it is required instead of calculating every time we get the index. diff --git a/core/src/zero1hd/rhythmbullet/audio/SongController.java b/core/src/zero1hd/rhythmbullet/audio/SongController.java new file mode 100755 index 0000000..6ece7d5 --- /dev/null +++ b/core/src/zero1hd/rhythmbullet/audio/SongController.java @@ -0,0 +1,123 @@ +package zero1hd.rhythmbullet.audio; + +import java.security.InvalidParameterException; +import java.util.Random; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.audio.Music; +import com.badlogic.gdx.audio.Music.OnCompletionListener; +import com.badlogic.gdx.utils.Array; + +import zero1hd.rhythmbullet.events.OnDifferentSongListener; + +public class SongController implements OnCompletionListener { + private SongList songList; + private MusicDataPack mdp; + private int currentPlaybackID; + private boolean autoPlay; + private boolean shuffle; + private Random rand; + + private Array listeners; + + public SongController(SongList songList) { + if (songList == null) throw new NullPointerException("song list is null..."); + if (!songList.isSearched()) throw new InvalidParameterException("Song list has to be searched already."); + listeners = new Array<>(); + this.songList = songList; + updateSong(); + rand = new Random(); + } + + public void play() { + mdp.getPlaybackMusic().play(); + } + + public void setSongByIndex(int index) { + this.currentPlaybackID = index; + updateSong(); + } + + public void skip() { + currentPlaybackID++; + updateSong(); + } + + public void previous() { + currentPlaybackID--; + updateSong(); + } + + @Override + public void onCompletion(Music music) { + if (autoPlay) { + if (shuffle) { + currentPlaybackID = rand.nextInt(songList.getAmountOfSongs()); + } else { + currentPlaybackID++; + if (currentPlaybackID > songList.getAmountOfSongs()) { + currentPlaybackID = 0; + } + } + updateSong(); + play(); + } + } + + public void shuffle() { + currentPlaybackID = rand.nextInt(songList.getAmountOfSongs()); + updateSong(); + } + + public void setAutoPlay(boolean autoPlay) { + this.autoPlay = autoPlay; + } + + public void setShuffle(boolean shuffle) { + this.shuffle = shuffle; + shuffle(); + } + + public boolean isShuffle() { + return shuffle; + } + + public boolean isAutoPlay() { + return autoPlay; + } + + private void updateSong() { + if (mdp != null) { + mdp.dispose(); + } + + this.mdp = songList.getMusicInfoFromIndex(currentPlaybackID); + if (mdp == null) { + mdp = songList.getAudioData(Gdx.files.internal("music/default.mp3")); + } + mdp.getPlaybackMusic().setOnCompletionListener(this); + sendEvent(); + } + + public SongList getSongList() { + return songList; + } + + private void sendEvent() { + for (int i = 0; i < listeners.size; i++) { + listeners.get(i).onDifferentSong(mdp); + } + } + + public void addOnDifferentSongListener(OnDifferentSongListener listener) { + listeners.add(listener); + } + + public void removeListener(OnDifferentSongListener listener) { + listeners.removeValue(listener, true); + } + + public MusicDataPack getCurrentSong() { + return mdp; + } +} diff --git a/core/src/zero1hd/rhythmbullet/audio/SongList.java b/core/src/zero1hd/rhythmbullet/audio/SongList.java index 2a0aa74..db6c1ec 100755 --- a/core/src/zero1hd/rhythmbullet/audio/SongList.java +++ b/core/src/zero1hd/rhythmbullet/audio/SongList.java @@ -7,12 +7,13 @@ import com.badlogic.gdx.utils.Array; public class SongList { private Array songList; private String searchPath; - + private boolean searched; public SongList() { songList = new Array<>(); } public void refresh() { + searched = true; songList.addAll(Gdx.files.absolute(searchPath).list((dir, name) -> { if (name.endsWith("mp3") || name.endsWith("wav")) { return true; @@ -25,7 +26,7 @@ public class SongList { this.searchPath = searchPath; } - public CoreMusicInfo getAudioData(FileHandle file) { + public MusicDataPack getAudioData(FileHandle file) { if (file.extension().equalsIgnoreCase("wav")) { return new WavAudioData(file); } else if (file.extension().equalsIgnoreCase("mp3")) { @@ -34,15 +35,30 @@ public class SongList { return null; } - public CoreMusicInfo getMusicInfoFromIndex(int index) { + public MusicDataPack getMusicInfoFromIndex(int index) { + if (index > songList.size) { + return null; + } return getAudioData(songList.get(index)); } + public int getAmountOfSongs() { + return songList.size; + } + + public FileHandle getSongFileHandleFromIndex(int index) { + if (!searched) Gdx.app.debug("SongList", "Warning, this list hasn't even searched yet..."); + if (index > songList.size) { + return null; + } + return songList.get(index); + } + public Array getSongList() { return songList; } - public int getAmountOfSongs() { - return songList.size; + public boolean isSearched() { + return searched; } } diff --git a/core/src/zero1hd/rhythmbullet/audio/WavAudioData.java b/core/src/zero1hd/rhythmbullet/audio/WavAudioData.java index e7bb089..528b4ca 100755 --- a/core/src/zero1hd/rhythmbullet/audio/WavAudioData.java +++ b/core/src/zero1hd/rhythmbullet/audio/WavAudioData.java @@ -11,7 +11,7 @@ import com.badlogic.gdx.files.FileHandle; import zero1hd.rhythmbullet.audio.wavedecoder.WavDecoder; -public class WavAudioData implements CoreMusicInfo { +public class WavAudioData implements MusicDataPack { private int readWindowSize = 1024; private AudioFormat format; private int readIndex; diff --git a/core/src/zero1hd/rhythmbullet/audio/map/GamePlayMap.java b/core/src/zero1hd/rhythmbullet/audio/map/GamePlayMap.java index c125cba..80e532f 100755 --- a/core/src/zero1hd/rhythmbullet/audio/map/GamePlayMap.java +++ b/core/src/zero1hd/rhythmbullet/audio/map/GamePlayMap.java @@ -1,13 +1,13 @@ package zero1hd.rhythmbullet.audio.map; -import zero1hd.rhythmbullet.audio.CoreMusicInfo; +import zero1hd.rhythmbullet.audio.MusicDataPack; import zero1hd.rhythmbullet.entity.Entity; import zero1hd.rhythmbullet.entity.EntityFrame; import zero1hd.rhythmbullet.entity.coordinator.Coordinator; import zero1hd.rhythmbullet.entity.coordinator.CoordinatorFrame; public class GamePlayMap { - private CoreMusicInfo musicData; + private MusicDataPack musicData; private MapWindowData[] spawnList; private boolean building; private int index; @@ -17,7 +17,7 @@ public class GamePlayMap { * GamePlayMap is what the game area will use to generate entities and judge current audio data * @param audioData audio data */ - public GamePlayMap(CoreMusicInfo audioData, int totalWindows) { + public GamePlayMap(MusicDataPack audioData, int totalWindows) { this.musicData = audioData; spawnList = new MapWindowData[totalWindows]; hudType = new byte[totalWindows]; @@ -68,7 +68,7 @@ public class GamePlayMap { index = spawnList.length-1; } - public CoreMusicInfo getMusicData() { + public MusicDataPack getMusicData() { return musicData; } diff --git a/core/src/zero1hd/rhythmbullet/audio/visualizer/HorizontalVisualizer.java b/core/src/zero1hd/rhythmbullet/audio/visualizer/HorizontalVisualizer.java index 4a6b753..73d96c5 100755 --- a/core/src/zero1hd/rhythmbullet/audio/visualizer/HorizontalVisualizer.java +++ b/core/src/zero1hd/rhythmbullet/audio/visualizer/HorizontalVisualizer.java @@ -6,8 +6,9 @@ import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.Pixmap.Format; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.Batch; +import com.badlogic.gdx.math.MathUtils; -import zero1hd.rhythmbullet.audio.CoreMusicInfo; +import zero1hd.rhythmbullet.audio.MusicDataPack; public class HorizontalVisualizer extends VisualizerCore { private Pixmap pixmap; @@ -24,31 +25,34 @@ public class HorizontalVisualizer extends VisualizerCore { pixmap.fill(); bar = new Texture(pixmap); pixmap.dispose(); - barCount = 64; - + barCount = 70; barWidth = width/barCount; + spaceBetweenBars = 10; + barWidth -= spaceBetweenBars; } @Override public void render(Batch batch, float parentAlpha) { if (cmi != null) { for (int i = 0; i < barCount; i++) { - int currentBinAvg = 0; - for (int j = i; j < binsPerBar; j++) { - currentBinAvg += audioPCM[j]; + float currentBinAvg = 0; + for (int j = 0; j < binsPerBar+4; j++) { + currentBinAvg += audioPCM[j+i*binsPerBar]; } currentBinAvg /= binsPerBar; - - batch.draw(bar, xPos + i*(barWidth+spaceBetweenBars), yPos, barWidth, currentBinAvg*height); +// currentBinAvg = (int) audioPCM[i]; + batch.draw(bar, xPos + i*(barWidth+spaceBetweenBars), yPos, barWidth, currentBinAvg*2 +1); } } super.render(batch, parentAlpha); } @Override - public void setCmi(CoreMusicInfo cmi) { - binsPerBar = audioPCM.length/barCount; - super.setCmi(cmi); + public void setMDP(MusicDataPack mdp) { + super.setMDP(mdp); + float validBins = (5000/((mdp.getSampleRate()/2)/((audioPCM.length/2)+1))); + Gdx.app.debug("Visualizer", "valid frequency bins " + validBins); + binsPerBar = MathUtils.round((validBins/barCount)); } @Override diff --git a/core/src/zero1hd/rhythmbullet/audio/visualizer/VisualizerCore.java b/core/src/zero1hd/rhythmbullet/audio/visualizer/VisualizerCore.java index dc54dd2..9c98041 100755 --- a/core/src/zero1hd/rhythmbullet/audio/visualizer/VisualizerCore.java +++ b/core/src/zero1hd/rhythmbullet/audio/visualizer/VisualizerCore.java @@ -1,14 +1,13 @@ package zero1hd.rhythmbullet.audio.visualizer; -import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.utils.Disposable; import edu.emory.mathcs.jtransforms.fft.FloatFFT_1D; -import zero1hd.rhythmbullet.audio.CoreMusicInfo; +import zero1hd.rhythmbullet.audio.MusicDataPack; public class VisualizerCore implements Disposable { - protected CoreMusicInfo cmi; + protected MusicDataPack cmi; private FloatFFT_1D fft; float[] audioPCM; protected int width, height; @@ -16,6 +15,10 @@ public class VisualizerCore implements Disposable { protected int barCount; public VisualizerCore(int width, int height, int x, int y) { + this.height = height; + this.width = width; + this.xPos = x; + this.yPos = y; } public void update() { @@ -23,27 +26,25 @@ public class VisualizerCore implements Disposable { if (cmi.getPlaybackIndexPosition() > cmi.getCurrentReadWindowIndex()) { cmi.readSamples(audioPCM); fft.realForward(audioPCM); - Gdx.app.debug("Visualizer", "Skipping a frame to catch up to music."); +// Gdx.app.debug("Visualizer", "Proper read"); } else { - Gdx.app.debug("Visualizer", "Not reading so music can catch up."); +// System.out.println(audioPCM[16]); +// Gdx.app.debug("Visualizer", "Not reading so music can catch up."); } } } - public void setCmi(CoreMusicInfo cmi) { + public void setMDP(MusicDataPack cmi) { this.cmi = cmi; fft = new FloatFFT_1D(cmi.getReadWindowSize()); audioPCM = new float[cmi.getReadWindowSize()]; } public void render(Batch batch, float parentAlpha) { - } @Override public void dispose() { - // TODO Auto-generated method stub - } } diff --git a/core/src/zero1hd/rhythmbullet/events/OnDifferentSongListener.java b/core/src/zero1hd/rhythmbullet/events/OnDifferentSongListener.java new file mode 100755 index 0000000..6d76ee3 --- /dev/null +++ b/core/src/zero1hd/rhythmbullet/events/OnDifferentSongListener.java @@ -0,0 +1,12 @@ +package zero1hd.rhythmbullet.events; + +import zero1hd.rhythmbullet.audio.MusicDataPack; + +public interface OnDifferentSongListener { + + /** + * Called whenever the Song Controller moves to a different song. + * @param mdp contains the next songs basic music system. + */ + public void onDifferentSong(MusicDataPack mdp); +} diff --git a/core/src/zero1hd/rhythmbullet/screens/GameScreen.java b/core/src/zero1hd/rhythmbullet/screens/GameScreen.java index 5ebae04..5439f9b 100755 --- a/core/src/zero1hd/rhythmbullet/screens/GameScreen.java +++ b/core/src/zero1hd/rhythmbullet/screens/GameScreen.java @@ -14,7 +14,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; import zero1hd.rhythmbullet.RhythmBullet; -import zero1hd.rhythmbullet.audio.CoreMusicInfo; +import zero1hd.rhythmbullet.audio.MusicDataPack; import zero1hd.rhythmbullet.audio.map.GamePlayMap; import zero1hd.rhythmbullet.stages.GameHUD; import zero1hd.rhythmbullet.stages.GamePlayArea; @@ -27,7 +27,7 @@ public class GameScreen extends ScreenAdapter { protected InputMultiplexer inputs; public RhythmBullet core; - private CoreMusicInfo music; + private MusicDataPack music; private ShaderProgram gaussianBlurShader; private ShaderProgram brightFilterShader; diff --git a/core/src/zero1hd/rhythmbullet/screens/MainMenu.java b/core/src/zero1hd/rhythmbullet/screens/MainMenu.java index 730b5bb..130c23b 100755 --- a/core/src/zero1hd/rhythmbullet/screens/MainMenu.java +++ b/core/src/zero1hd/rhythmbullet/screens/MainMenu.java @@ -12,6 +12,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.utils.viewport.ScreenViewport; import zero1hd.rhythmbullet.RhythmBullet; +import zero1hd.rhythmbullet.audio.SongController; import zero1hd.rhythmbullet.audio.SongList; import zero1hd.rhythmbullet.ui.pages.CreditsPage; import zero1hd.rhythmbullet.ui.pages.MainPage; @@ -30,16 +31,22 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter { private RhythmBullet core; - private SongList songList; + private SongController sc; private float lerpAlpha; public MainMenu(final RhythmBullet core) { this.core = core; stage = new Stage(new ScreenViewport()); targetPosition = new Vector3(stage.getCamera().position); - songList = new SongList(); + SongList songList = new SongList(); songList.setSearchPath(core.getPrefs().getString("music dir")); songList.refresh(); + + sc = new SongController(songList); + sc.setAutoPlay(true); + sc.setShuffle(true); + sc.play(); + postTransition(); } @@ -54,14 +61,14 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter { @Override public void postTransition() { - mainPage = new MainPage(core, targetPosition, songList); + mainPage = new MainPage(core, targetPosition, sc); mainPage.setPosition(0, 0); stage.addActor(mainPage); //End main menu moreOptionsPage = new MoreOptionsPage(core, targetPosition); - optionsPage = new OptionsPage(core, targetPosition, moreOptionsPage, songList); + optionsPage = new OptionsPage(core, targetPosition, moreOptionsPage, sc.getSongList()); optionsPage.setPosition(Gdx.graphics.getWidth(), 0); stage.addActor(optionsPage); @@ -131,7 +138,9 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter { if (stage.getCamera().position.x != targetPosition.x || stage.getCamera().position.y != targetPosition.y) { stage.getCamera().position.lerp(targetPosition, lerpAlpha); } - + + sc.getCurrentSong().playbackIndexUpdate(); + super.render(delta); } diff --git a/core/src/zero1hd/rhythmbullet/ui/builders/AudioGraph.java b/core/src/zero1hd/rhythmbullet/ui/builders/AudioGraph.java index d1ca4d5..b3f0f02 100755 --- a/core/src/zero1hd/rhythmbullet/ui/builders/AudioGraph.java +++ b/core/src/zero1hd/rhythmbullet/ui/builders/AudioGraph.java @@ -9,10 +9,10 @@ import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.utils.FloatArray; -import zero1hd.rhythmbullet.audio.CoreMusicInfo; +import zero1hd.rhythmbullet.audio.MusicDataPack; public class AudioGraph extends Actor { - private CoreMusicInfo audioData; + private MusicDataPack audioData; ShapeRenderer shapeRender; FloatArray mainGraph; FloatArray overlayGraph; @@ -134,7 +134,7 @@ public class AudioGraph extends Actor { * @param dataSet2 overlay graph. This one can be null. * @param audioData actual basic audio information for index position */ - public void setGraphingData(FloatArray dataSet1, FloatArray dataSet2, CoreMusicInfo audioData) { + public void setGraphingData(FloatArray dataSet1, FloatArray dataSet2, MusicDataPack audioData) { this.mainGraph = dataSet1; this.overlayGraph = dataSet2; if (dataSet2 == null) { diff --git a/core/src/zero1hd/rhythmbullet/ui/builders/AudioGraphRelation.java b/core/src/zero1hd/rhythmbullet/ui/builders/AudioGraphRelation.java index b999629..17ce8c4 100755 --- a/core/src/zero1hd/rhythmbullet/ui/builders/AudioGraphRelation.java +++ b/core/src/zero1hd/rhythmbullet/ui/builders/AudioGraphRelation.java @@ -9,10 +9,10 @@ import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.utils.FloatArray; -import zero1hd.rhythmbullet.audio.CoreMusicInfo; +import zero1hd.rhythmbullet.audio.MusicDataPack; public class AudioGraphRelation extends Actor { - private CoreMusicInfo audioData; + private MusicDataPack audioData; ShapeRenderer shapeRender; FloatArray mainGraph; FloatArray overlayGraph; @@ -134,7 +134,7 @@ public class AudioGraphRelation extends Actor { * @param dataSet2 overlay graph. This one can be null. * @param audioData actual basic audio information for index position */ - public void setGraphingData(FloatArray dataSet1, FloatArray dataSet2, CoreMusicInfo audioData) { + public void setGraphingData(FloatArray dataSet1, FloatArray dataSet2, MusicDataPack audioData) { this.mainGraph = dataSet1; this.overlayGraph = dataSet2; if (dataSet2 == null) { diff --git a/core/src/zero1hd/rhythmbullet/ui/pages/AnalyzePage.java b/core/src/zero1hd/rhythmbullet/ui/pages/AnalyzePage.java index 09830c6..df08f64 100755 --- a/core/src/zero1hd/rhythmbullet/ui/pages/AnalyzePage.java +++ b/core/src/zero1hd/rhythmbullet/ui/pages/AnalyzePage.java @@ -19,7 +19,7 @@ import com.badlogic.gdx.utils.Disposable; import zero1hd.rhythmbullet.RhythmBullet; import zero1hd.rhythmbullet.audio.AudioAnalyzer; -import zero1hd.rhythmbullet.audio.CoreMusicInfo; +import zero1hd.rhythmbullet.audio.MusicDataPack; import zero1hd.rhythmbullet.audio.SongInfo; import zero1hd.rhythmbullet.audio.map.GamePlayMap; import zero1hd.rhythmbullet.audio.map.RhythmMapAlgorithm; @@ -32,7 +32,7 @@ public class AnalyzePage extends Page implements MiniListener, Disposable { private AnalyzePage ap = this; AudioAnalyzer audioAnalyzer; - CoreMusicInfo music; + MusicDataPack music; RhythmMapAlgorithm mapGenAlgorithm; private Table songInfo; @@ -186,7 +186,7 @@ public class AnalyzePage extends Page implements MiniListener, Disposable { addActor(back); } - public void setSong(CoreMusicInfo music, SongInfo audioInfo, MiniListener listener) { + public void setSong(MusicDataPack music, SongInfo audioInfo, MiniListener listener) { confirmed = false; confirmDiffButton.setDisabled(false); sensitivityRating.setDisabled(false); diff --git a/core/src/zero1hd/rhythmbullet/ui/pages/MainPage.java b/core/src/zero1hd/rhythmbullet/ui/pages/MainPage.java index 3d1a501..d98f053 100755 --- a/core/src/zero1hd/rhythmbullet/ui/pages/MainPage.java +++ b/core/src/zero1hd/rhythmbullet/ui/pages/MainPage.java @@ -1,7 +1,5 @@ package zero1hd.rhythmbullet.ui.pages; -import java.util.Random; - import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.Batch; @@ -17,12 +15,13 @@ import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import zero1hd.rhythmbullet.RhythmBullet; -import zero1hd.rhythmbullet.audio.CoreMusicInfo; -import zero1hd.rhythmbullet.audio.SongList; +import zero1hd.rhythmbullet.audio.MusicDataPack; +import zero1hd.rhythmbullet.audio.SongController; import zero1hd.rhythmbullet.audio.visualizer.HorizontalVisualizer; +import zero1hd.rhythmbullet.events.OnDifferentSongListener; import zero1hd.rhythmbullet.screens.PreGameScreen; -public class MainPage extends Page { +public class MainPage extends Page implements OnDifferentSongListener { private Image title; private Label versionLabel; private TextButton options; @@ -32,17 +31,13 @@ public class MainPage extends Page { private TextButton credits; private WidgetGroup playButton; + private SongController sc; private HorizontalVisualizer hvisual; - private CoreMusicInfo cmi; - private SongList songList; - private Random rand; - public MainPage(RhythmBullet core, Vector3 targetPosition, SongList sl) { + public MainPage(RhythmBullet core, Vector3 targetPosition, SongController sc) { hvisual = new HorizontalVisualizer(); - this.songList = sl; - rand = new Random(); - - cmi = songList.getMusicInfoFromIndex(rand.nextInt(songList.getAmountOfSongs())); - hvisual.setCmi(cmi); + this.sc = sc; + sc.addOnDifferentSongListener(this); + hvisual.setMDP(sc.getCurrentSong()); title = new Image(core.getAssetManager().get("title.png", Texture.class)); title.setPosition(10, getHeight() - title.getHeight()-30); @@ -115,7 +110,7 @@ public class MainPage extends Page { Actions.run(new Runnable() { @Override public void run() { - core.setScreen(new PreGameScreen(core, songList)); + core.setScreen(new PreGameScreen(core, sc.getSongList())); } }), Actions.parallel(Actions.scaleTo(1, 1), Actions.alpha(0.6f)))); } @@ -132,4 +127,9 @@ public class MainPage extends Page { hvisual.render(batch, parentAlpha); super.draw(batch, parentAlpha); } + + @Override + public void onDifferentSong(MusicDataPack mdp) { + hvisual.setMDP(mdp); + } } diff --git a/core/src/zero1hd/rhythmbullet/ui/pages/MusicSelectionPage.java b/core/src/zero1hd/rhythmbullet/ui/pages/MusicSelectionPage.java index 61557f1..acc67a5 100755 --- a/core/src/zero1hd/rhythmbullet/ui/pages/MusicSelectionPage.java +++ b/core/src/zero1hd/rhythmbullet/ui/pages/MusicSelectionPage.java @@ -74,7 +74,7 @@ public class MusicSelectionPage extends Page { public void refresh() { for (int i = 0; i < songList.getAmountOfSongs(); i++) { - MusicSelectable selectable = new MusicSelectable(songList.getSongList().get(i), musicFileAnnotation, skin, assets.get("defaultCover.png", Texture.class)); + MusicSelectable selectable = new MusicSelectable(songList.getSongFileHandleFromIndex(i), musicFileAnnotation, skin, assets.get("defaultCover.png", Texture.class)); selectables.add(selectable); songTable.add(selectable); songTable.row(); diff --git a/core/src/zero1hd/rhythmbullet/ui/windows/BeatViewer.java b/core/src/zero1hd/rhythmbullet/ui/windows/BeatViewer.java index f7df927..2a58337 100755 --- a/core/src/zero1hd/rhythmbullet/ui/windows/BeatViewer.java +++ b/core/src/zero1hd/rhythmbullet/ui/windows/BeatViewer.java @@ -10,12 +10,12 @@ import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup; import com.badlogic.gdx.scenes.scene2d.ui.Window; import zero1hd.rhythmbullet.audio.AudioDataPackage; -import zero1hd.rhythmbullet.audio.CoreMusicInfo; +import zero1hd.rhythmbullet.audio.MusicDataPack; public class BeatViewer extends Window { Pixmap lights; int songIndex; - CoreMusicInfo music; + MusicDataPack music; Texture lightOn; private AudioDataPackage data; @@ -125,7 +125,7 @@ public class BeatViewer extends Window { super.act(delta); } - public void setMusic(CoreMusicInfo audioData, AudioDataPackage adp) { + public void setMusic(MusicDataPack audioData, AudioDataPackage adp) { this.music = audioData; this.data = adp; } diff --git a/core/src/zero1hd/rhythmbullet/ui/windows/MusicController.java b/core/src/zero1hd/rhythmbullet/ui/windows/MusicController.java index eb92a72..f1e8850 100755 --- a/core/src/zero1hd/rhythmbullet/ui/windows/MusicController.java +++ b/core/src/zero1hd/rhythmbullet/ui/windows/MusicController.java @@ -15,13 +15,13 @@ import com.badlogic.gdx.scenes.scene2d.ui.Window; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; -import zero1hd.rhythmbullet.audio.CoreMusicInfo; +import zero1hd.rhythmbullet.audio.MusicDataPack; public class MusicController extends Window implements OnCompletionListener { Skin skin; private Image togglePlay; private TextField info; - private CoreMusicInfo audiofile; + private MusicDataPack audiofile; public MusicController(final Skin skin) { super("Playback Controller", skin, "tinted"); @@ -110,7 +110,7 @@ public class MusicController extends Window implements OnCompletionListener { setSize(260, 75); } - public void setAudiofile(CoreMusicInfo audiofile) { + public void setAudiofile(MusicDataPack audiofile) { this.audiofile = audiofile; if (audiofile == null) { togglePlay.setDrawable(skin.getDrawable("loading")); @@ -125,7 +125,7 @@ public class MusicController extends Window implements OnCompletionListener { } } - public CoreMusicInfo getAudiofile() { + public MusicDataPack getAudiofile() { return audiofile; } diff --git a/core/src/zero1hd/rhythmbullet/ui/windows/MusicSelector.java b/core/src/zero1hd/rhythmbullet/ui/windows/MusicSelector.java index e18c080..e2574ff 100755 --- a/core/src/zero1hd/rhythmbullet/ui/windows/MusicSelector.java +++ b/core/src/zero1hd/rhythmbullet/ui/windows/MusicSelector.java @@ -11,7 +11,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Window; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; import com.badlogic.gdx.utils.Array; -import zero1hd.rhythmbullet.audio.CoreMusicInfo; +import zero1hd.rhythmbullet.audio.MusicDataPack; import zero1hd.rhythmbullet.audio.SongList; import zero1hd.rhythmbullet.util.MiniEvents; import zero1hd.rhythmbullet.util.MiniSender; @@ -88,7 +88,7 @@ public class MusicSelector extends Window { return isBack; } - public CoreMusicInfo getSelectedMusic() { + public MusicDataPack getSelectedMusic() { if (selectedMusic != null) { return songList.getAudioData(selectedMusic); } else { diff --git a/core/src/zero1hd/rhythmbullet/ui/windows/VolumeWindow.java b/core/src/zero1hd/rhythmbullet/ui/windows/VolumeWindow.java index 984e13c..c8a8801 100755 --- a/core/src/zero1hd/rhythmbullet/ui/windows/VolumeWindow.java +++ b/core/src/zero1hd/rhythmbullet/ui/windows/VolumeWindow.java @@ -9,7 +9,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Slider; import com.badlogic.gdx.scenes.scene2d.ui.Window; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; -import zero1hd.rhythmbullet.audio.CoreMusicInfo; +import zero1hd.rhythmbullet.audio.MusicDataPack; public class VolumeWindow extends Window { @@ -17,7 +17,7 @@ public class VolumeWindow extends Window { private Slider musicVolSlider; private Preferences prefs; - private CoreMusicInfo music; + private MusicDataPack music; public VolumeWindow(String title, Skin skin, Preferences prefs) { super(title, skin, "tinted"); this.prefs = prefs; @@ -67,7 +67,7 @@ public class VolumeWindow extends Window { prefs.flush(); } - public void setMusic(CoreMusicInfo music) { + public void setMusic(MusicDataPack music) { this.music = music; if (music != null) { music.getPlaybackMusic().setVolume(prefs.getFloat("music vol")/100f);