visualizer tested and improved
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 60 KiB |
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 8.2 KiB |
@ -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");
|
||||
|
@ -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 = () -> {
|
||||
|
@ -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...");
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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.
|
123
core/src/zero1hd/rhythmbullet/audio/SongController.java
Executable file
@ -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<OnDifferentSongListener> 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;
|
||||
}
|
||||
}
|
@ -7,12 +7,13 @@ import com.badlogic.gdx.utils.Array;
|
||||
public class SongList {
|
||||
private Array<FileHandle> 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<FileHandle> getSongList() {
|
||||
return songList;
|
||||
}
|
||||
|
||||
public int getAmountOfSongs() {
|
||||
return songList.size;
|
||||
public boolean isSearched() {
|
||||
return searched;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
12
core/src/zero1hd/rhythmbullet/events/OnDifferentSongListener.java
Executable file
@ -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);
|
||||
}
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
|