fixed sync issue with songs (not sure what de-sync caused by as issue does not exist on other computer)
This commit is contained in:
parent
d26cef0cb1
commit
373a524010
@ -12,7 +12,7 @@ import zero1hd.rhythmbullet.util.MiniSender;
|
||||
|
||||
public class AudioAnalyzer {
|
||||
private boolean containsData;
|
||||
private MusicDataPack musicInfo;
|
||||
private MusicManager musicInfo;
|
||||
|
||||
float[] audioPCM;
|
||||
float[] spectrum;
|
||||
@ -56,7 +56,7 @@ public class AudioAnalyzer {
|
||||
private float secondsPerWindow;
|
||||
|
||||
private AudioDataPackage pack;
|
||||
public AudioAnalyzer(MusicDataPack audiofile) {
|
||||
public AudioAnalyzer(MusicManager audiofile) {
|
||||
sender = new MiniSender();
|
||||
|
||||
analysisAlgorithm = () -> {
|
||||
|
@ -9,7 +9,7 @@ public class AudioDataPackage {
|
||||
private FloatArray mPeaks;
|
||||
private FloatArray umPeaks;
|
||||
|
||||
private MusicDataPack musicInfo;
|
||||
private MusicManager musicInfo;
|
||||
|
||||
private float bassMaxVal, bassAvg;
|
||||
private float mMaxVal, mAvg;
|
||||
@ -64,7 +64,7 @@ public class AudioDataPackage {
|
||||
this.uMAvg = uMAvg;
|
||||
}
|
||||
|
||||
public void setMusicInfo(MusicDataPack musicInfo) {
|
||||
public void setMusicInfo(MusicManager musicInfo) {
|
||||
if (this.musicInfo != null) {
|
||||
throw new InvalidParameterException("There is already music information in this package.");
|
||||
}
|
||||
@ -108,7 +108,7 @@ public class AudioDataPackage {
|
||||
}
|
||||
}
|
||||
|
||||
public MusicDataPack getMusicInfo() {
|
||||
public MusicManager getMusicInfo() {
|
||||
if (musicInfo == null) {
|
||||
throw new NullPointerException("Music info hasn't been baked in...");
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import org.jaudiotagger.tag.TagException;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.audio.Music;
|
||||
import com.badlogic.gdx.audio.Music.OnCompletionListener;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.utils.GdxRuntimeException;
|
||||
@ -20,7 +21,7 @@ import javazoom.jl.decoder.Header;
|
||||
import javazoom.jl.decoder.MP3Decoder;
|
||||
import javazoom.jl.decoder.OutputBuffer;
|
||||
|
||||
public class Mp3AudioData implements MusicDataPack {
|
||||
public class Mp3AudioData implements MusicManager {
|
||||
private int readWindowSize = 1024;
|
||||
|
||||
private int currentReadWindowIndex;
|
||||
@ -64,7 +65,6 @@ public class Mp3AudioData implements MusicDataPack {
|
||||
|
||||
playbackMusic = Gdx.audio.newMusic(audioFile);
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -77,21 +77,11 @@ public class Mp3AudioData implements MusicDataPack {
|
||||
return readIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
playbackMusic.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getReadWindowSize() {
|
||||
return readWindowSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Music getPlaybackMusic() {
|
||||
return playbackMusic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSampleCount() {
|
||||
return sampleCount;
|
||||
@ -99,7 +89,7 @@ public class Mp3AudioData implements MusicDataPack {
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
reset();
|
||||
playbackMusic.stop();
|
||||
playbackMusic.dispose();
|
||||
try {
|
||||
bitstream.close();
|
||||
@ -184,4 +174,39 @@ public class Mp3AudioData implements MusicDataPack {
|
||||
public int getCurrentReadWindowIndex() {
|
||||
return currentReadWindowIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pause() {
|
||||
playbackMusic.pause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void play() {
|
||||
playbackMusic.play();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlaying() {
|
||||
return playbackMusic.isPlaying();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPosition() {
|
||||
return playbackMusic.getPosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(float position) {
|
||||
playbackMusic.setPosition(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnCompletionListener(OnCompletionListener listener) {
|
||||
playbackMusic.setOnCompletionListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVolume(float percent) {
|
||||
playbackMusic.setVolume(percent);
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
|
||||
package zero1hd.rhythmbullet.audio;
|
||||
|
||||
import com.badlogic.gdx.audio.Music;
|
||||
import com.badlogic.gdx.audio.Music.OnCompletionListener;
|
||||
import com.badlogic.gdx.utils.Disposable;
|
||||
|
||||
public interface MusicDataPack extends Disposable {
|
||||
public interface MusicManager 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.
|
||||
@ -17,23 +17,12 @@ public interface MusicDataPack extends Disposable {
|
||||
*/
|
||||
public int getPlaybackIndexPosition();
|
||||
|
||||
/**
|
||||
* Completely resets the current audio data. Think of pooling, except, only one instance which is reused instead of multiple.
|
||||
*/
|
||||
public void reset();
|
||||
|
||||
/**
|
||||
* returns the read window size.
|
||||
* @return
|
||||
*/
|
||||
public int getReadWindowSize();
|
||||
|
||||
/**
|
||||
* Gets the object to play the music. Contains playback data.
|
||||
* @return
|
||||
*/
|
||||
public Music getPlaybackMusic();
|
||||
|
||||
/**
|
||||
* read in samples and fills the array.
|
||||
* @param samples the array that should contain said samples
|
||||
@ -65,4 +54,18 @@ public interface MusicDataPack extends Disposable {
|
||||
* @return
|
||||
*/
|
||||
public int getCurrentReadWindowIndex();
|
||||
|
||||
public void pause();
|
||||
|
||||
public void play();
|
||||
|
||||
public boolean isPlaying();
|
||||
|
||||
public float getPosition();
|
||||
|
||||
public void setPosition(float position);
|
||||
|
||||
public void setOnCompletionListener(OnCompletionListener listener);
|
||||
|
||||
public void setVolume(float percent);
|
||||
}
|
@ -26,7 +26,7 @@ public class SongList {
|
||||
this.searchPath = searchPath;
|
||||
}
|
||||
|
||||
public MusicDataPack getAudioData(FileHandle file) {
|
||||
public MusicManager getAudioData(FileHandle file) {
|
||||
if (file.extension().equalsIgnoreCase("wav")) {
|
||||
return new WavAudioData(file);
|
||||
} else if (file.extension().equalsIgnoreCase("mp3")) {
|
||||
@ -35,7 +35,7 @@ public class SongList {
|
||||
return null;
|
||||
}
|
||||
|
||||
public MusicDataPack getMusicInfoFromIndex(int index) {
|
||||
public MusicManager getMusicInfoFromIndex(int index) {
|
||||
if (index > songList.size) {
|
||||
return null;
|
||||
}
|
||||
|
@ -11,9 +11,9 @@ import com.badlogic.gdx.utils.Array;
|
||||
|
||||
import zero1hd.rhythmbullet.events.OnDifferentSongListener;
|
||||
|
||||
public class SongController implements OnCompletionListener {
|
||||
public class SongListController implements OnCompletionListener {
|
||||
private SongList songList;
|
||||
private MusicDataPack mdp;
|
||||
private MusicManager mdp;
|
||||
private int currentPlaybackID;
|
||||
private boolean autoPlay;
|
||||
private boolean shuffle;
|
||||
@ -22,7 +22,7 @@ public class SongController implements OnCompletionListener {
|
||||
private Array<OnDifferentSongListener> listeners;
|
||||
|
||||
private Preferences prefs;
|
||||
public SongController(SongList songList, Preferences prefs) {
|
||||
public SongListController(SongList songList, Preferences prefs) {
|
||||
if (prefs == null) throw new NullPointerException("preferences can't be null...");
|
||||
if (songList == null) throw new NullPointerException("song list can't be null...");
|
||||
if (!songList.isSearched()) throw new InvalidParameterException("Song list has to be searched already.");
|
||||
@ -35,8 +35,8 @@ public class SongController implements OnCompletionListener {
|
||||
}
|
||||
|
||||
public void play() {
|
||||
mdp.getPlaybackMusic().play();
|
||||
mdp.getPlaybackMusic().setVolume(prefs.getFloat("music vol"));;
|
||||
mdp.play();
|
||||
mdp.setVolume(prefs.getFloat("music vol"));
|
||||
}
|
||||
|
||||
public void setSongByIndex(int index) {
|
||||
@ -101,7 +101,7 @@ public class SongController implements OnCompletionListener {
|
||||
if (mdp == null) {
|
||||
mdp = songList.getAudioData(Gdx.files.internal("music/default.mp3"));
|
||||
}
|
||||
mdp.getPlaybackMusic().setOnCompletionListener(this);
|
||||
mdp.setOnCompletionListener(this);
|
||||
sendEvent();
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ public class SongController implements OnCompletionListener {
|
||||
listeners.removeValue(listener, true);
|
||||
}
|
||||
|
||||
public MusicDataPack getCurrentSong() {
|
||||
public MusicManager getCurrentSong() {
|
||||
return mdp;
|
||||
}
|
||||
}
|
@ -7,20 +7,20 @@ import javax.sound.sampled.AudioFormat;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.audio.Music;
|
||||
import com.badlogic.gdx.audio.Music.OnCompletionListener;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
|
||||
import zero1hd.rhythmbullet.audio.wavedecoder.WavDecoder;
|
||||
|
||||
public class WavAudioData implements MusicDataPack {
|
||||
public class WavAudioData implements MusicManager {
|
||||
private int readWindowSize = 1024;
|
||||
private AudioFormat format;
|
||||
private int readIndex;
|
||||
private int currentReadWindowIndex;
|
||||
Music playbackMusic;
|
||||
private Music playbackMusic;
|
||||
WavDecoder decoder;
|
||||
|
||||
public WavAudioData(FileHandle file) {
|
||||
reset();
|
||||
try {
|
||||
decoder = new WavDecoder(file);
|
||||
} catch (InvalidParameterException | IOException e) {
|
||||
@ -41,22 +41,10 @@ public class WavAudioData implements MusicDataPack {
|
||||
return readIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
if (playbackMusic != null) {
|
||||
playbackMusic.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getReadWindowSize() {
|
||||
return readWindowSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Music getPlaybackMusic() {
|
||||
return playbackMusic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readSamples(float[] samples) {
|
||||
@ -80,7 +68,7 @@ public class WavAudioData implements MusicDataPack {
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
reset();
|
||||
playbackMusic.stop();
|
||||
playbackMusic.dispose();
|
||||
decoder.cleanAndClose();
|
||||
}
|
||||
@ -99,4 +87,41 @@ public class WavAudioData implements MusicDataPack {
|
||||
public int getCurrentReadWindowIndex() {
|
||||
return currentReadWindowIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pause() {
|
||||
playbackMusic.pause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void play() {
|
||||
System.out.println("Play is being called HERE!!");
|
||||
playbackMusic.play();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlaying() {
|
||||
return playbackMusic.isPlaying();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPosition() {
|
||||
return playbackMusic.getPosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(float position) {
|
||||
playbackMusic.setPosition(position);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnCompletionListener(OnCompletionListener listener) {
|
||||
playbackMusic.setOnCompletionListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVolume(float percent) {
|
||||
playbackMusic.setVolume(percent);
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
package zero1hd.rhythmbullet.audio.map;
|
||||
|
||||
import zero1hd.rhythmbullet.audio.MusicDataPack;
|
||||
import zero1hd.rhythmbullet.audio.MusicManager;
|
||||
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 MusicDataPack musicData;
|
||||
private MusicManager 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(MusicDataPack audioData, int totalWindows) {
|
||||
public GamePlayMap(MusicManager 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 MusicDataPack getMusicData() {
|
||||
public MusicManager getMusicData() {
|
||||
return musicData;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ import com.badlogic.gdx.graphics.g2d.Sprite;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
import zero1hd.rhythmbullet.audio.MusicDataPack;
|
||||
import zero1hd.rhythmbullet.audio.MusicManager;
|
||||
|
||||
public class BasicVisualizer extends VisualizerCore {
|
||||
private Pixmap pixmap;
|
||||
@ -52,7 +52,7 @@ public class BasicVisualizer extends VisualizerCore {
|
||||
|
||||
@Override
|
||||
public void render(Batch batch, float parentAlpha) {
|
||||
if (cmi != null) {
|
||||
if (mm != null) {
|
||||
//Averaging bins together
|
||||
for (int i = 0; i < barCount; i++) {
|
||||
bars[i].setSize(barWidth, 0);
|
||||
@ -85,8 +85,8 @@ public class BasicVisualizer extends VisualizerCore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMDP(MusicDataPack mdp) {
|
||||
super.setMDP(mdp);
|
||||
public void setMM(MusicManager mdp) {
|
||||
super.setMM(mdp);
|
||||
float validBins = (5000/((mdp.getSampleRate()/2)/((audioPCM.length/2)+1)));
|
||||
Gdx.app.debug("Visualizer", "valid frequency bins " + validBins);
|
||||
binsPerBar = MathUtils.round((validBins/barCount));
|
||||
|
@ -4,10 +4,10 @@ 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.MusicDataPack;
|
||||
import zero1hd.rhythmbullet.audio.MusicManager;
|
||||
|
||||
public class VisualizerCore implements Disposable {
|
||||
protected MusicDataPack cmi;
|
||||
protected MusicManager mm;
|
||||
private FloatFFT_1D fft;
|
||||
float[] audioPCM;
|
||||
protected int width, height;
|
||||
@ -22,18 +22,22 @@ public class VisualizerCore implements Disposable {
|
||||
}
|
||||
|
||||
public void calculate() {
|
||||
if (cmi != null) {
|
||||
if (cmi.getPlaybackIndexPosition() > cmi.getCurrentReadWindowIndex()) {
|
||||
cmi.readSamples(audioPCM);
|
||||
fft.realForward(audioPCM);
|
||||
if (mm != null) {
|
||||
mm.playbackIndexUpdate();
|
||||
if (mm.getPlaybackIndexPosition() > mm.getCurrentReadWindowIndex()) {
|
||||
while (mm.getPlaybackIndexPosition() > mm.getCurrentReadWindowIndex()) {
|
||||
mm.readSamples(audioPCM);
|
||||
fft.realForward(audioPCM);
|
||||
System.out.println(mm.getPlaybackIndexPosition() + " " + mm.getCurrentReadWindowIndex());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setMDP(MusicDataPack cmi) {
|
||||
this.cmi = cmi;
|
||||
fft = new FloatFFT_1D(cmi.getReadWindowSize());
|
||||
audioPCM = new float[cmi.getReadWindowSize()];
|
||||
public void setMM(MusicManager mm) {
|
||||
this.mm = mm;
|
||||
fft = new FloatFFT_1D(mm.getReadWindowSize());
|
||||
audioPCM = new float[mm.getReadWindowSize()];
|
||||
}
|
||||
|
||||
public void render(Batch batch, float parentAlpha) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package zero1hd.rhythmbullet.events;
|
||||
|
||||
import zero1hd.rhythmbullet.audio.MusicDataPack;
|
||||
import zero1hd.rhythmbullet.audio.MusicManager;
|
||||
|
||||
public interface OnDifferentSongListener {
|
||||
|
||||
@ -8,5 +8,5 @@ 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);
|
||||
public void onDifferentSong(MusicManager 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.MusicDataPack;
|
||||
import zero1hd.rhythmbullet.audio.MusicManager;
|
||||
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 MusicDataPack music;
|
||||
private MusicManager music;
|
||||
|
||||
private ShaderProgram gaussianBlurShader;
|
||||
private ShaderProgram brightFilterShader;
|
||||
@ -69,7 +69,7 @@ public class GameScreen extends ScreenAdapter {
|
||||
public void setGamePlayMap(GamePlayMap gpm) {
|
||||
music = gpm.getMusicData();
|
||||
gameArea.setAudioMap(gpm);
|
||||
gameHUD.setMusic(gpm.getMusicData().getPlaybackMusic());
|
||||
gameHUD.setMusic(gpm.getMusicData());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -222,7 +222,7 @@ public class GameScreen extends ScreenAdapter {
|
||||
|
||||
gameHUD.getViewport().apply();
|
||||
gameHUD.draw();
|
||||
if (music != null && !music.getPlaybackMusic().isPlaying()) {
|
||||
if (music != null && !music.isPlaying()) {
|
||||
end(true);
|
||||
}
|
||||
|
||||
@ -278,7 +278,7 @@ public class GameScreen extends ScreenAdapter {
|
||||
if (music == null) throw new NullPointerException("Idiot, you can't have a music game not have music on the gameplay screen...");
|
||||
Gdx.input.setInputProcessor(inputs);
|
||||
if (!gameHUD.isPaused()) {
|
||||
music.getPlaybackMusic().play();
|
||||
music.play();
|
||||
}
|
||||
}
|
||||
}
|
@ -12,7 +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.SongListController;
|
||||
import zero1hd.rhythmbullet.audio.SongList;
|
||||
import zero1hd.rhythmbullet.ui.pages.CreditsPage;
|
||||
import zero1hd.rhythmbullet.ui.pages.MainPage;
|
||||
@ -31,7 +31,7 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter {
|
||||
|
||||
private RhythmBullet core;
|
||||
|
||||
private SongController sc;
|
||||
private SongListController sc;
|
||||
private float lerpAlpha;
|
||||
public MainMenu(final RhythmBullet core) {
|
||||
this.core = core;
|
||||
@ -42,11 +42,9 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter {
|
||||
songList.setSearchPath(core.getPrefs().getString("music dir"));
|
||||
songList.refresh();
|
||||
|
||||
sc = new SongController(songList, core.getPrefs());
|
||||
sc = new SongListController(songList, core.getPrefs());
|
||||
sc.setAutoPlay(true);
|
||||
sc.setShuffle(true);
|
||||
sc.play();
|
||||
|
||||
postTransition();
|
||||
}
|
||||
|
||||
@ -111,6 +109,7 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter {
|
||||
@Override
|
||||
public void show() {
|
||||
Gdx.input.setInputProcessor(stage);
|
||||
sc.play();
|
||||
calcLerpAlpha(Gdx.graphics.getWidth());
|
||||
super.show();
|
||||
}
|
||||
@ -139,8 +138,6 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter {
|
||||
stage.getCamera().position.lerp(targetPosition, lerpAlpha);
|
||||
}
|
||||
|
||||
sc.getCurrentSong().playbackIndexUpdate();
|
||||
|
||||
super.render(delta);
|
||||
}
|
||||
|
||||
|
@ -279,7 +279,7 @@ public class CreativeHUD extends Stage implements MiniListener {
|
||||
mGraphWindow.normalDataG1 = adp.getmMaxVal();
|
||||
mGraphWindow.avgG1 = adp.getmAvg();
|
||||
gpa.setAudioMap(mapGen.getMap());
|
||||
ghud.setMusic(adp.getMusicInfo().getPlaybackMusic());
|
||||
ghud.setMusic(adp.getMusicInfo());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -7,8 +7,8 @@ import com.badlogic.gdx.audio.Music;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.Pixmap.Format;
|
||||
import com.badlogic.gdx.graphics.Texture.TextureFilter;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.Texture.TextureFilter;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
|
||||
@ -19,6 +19,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
|
||||
import zero1hd.rhythmbullet.RhythmBullet;
|
||||
import zero1hd.rhythmbullet.audio.MusicManager;
|
||||
import zero1hd.rhythmbullet.ui.components.HealthBar;
|
||||
import zero1hd.rhythmbullet.ui.windows.FPSWindow;
|
||||
import zero1hd.rhythmbullet.ui.windows.PauseMenu;
|
||||
@ -38,7 +39,7 @@ public class GameHUD extends Stage {
|
||||
private Image leftStatusBar;
|
||||
private Image rightStatusBar;
|
||||
private GamePlayArea gpa;
|
||||
private Music music;
|
||||
private MusicManager music;
|
||||
private ScoreManager sm;
|
||||
|
||||
private Color original, bass, um;
|
||||
@ -203,7 +204,7 @@ public class GameHUD extends Stage {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setMusic(Music music) {
|
||||
public void setMusic(MusicManager music) {
|
||||
this.music = music;
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ public class GamePlayArea extends Stage {
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
MapWindowData mwd;
|
||||
if (audioMap != null && audioMap.getMusicData().getPlaybackMusic().isPlaying()) {
|
||||
if (audioMap != null && audioMap.getMusicData().isPlaying()) {
|
||||
audioMap.getMusicData().playbackIndexUpdate();
|
||||
if ((mwd = audioMap.getCurrentWindowBasedOnIndex()) != null) {
|
||||
EntitySpawnInfo[] currentSpawnInfo = mwd.getArray();
|
||||
|
@ -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.MusicDataPack;
|
||||
import zero1hd.rhythmbullet.audio.MusicManager;
|
||||
|
||||
public class AudioGraph extends Actor {
|
||||
private MusicDataPack audioData;
|
||||
private MusicManager 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, MusicDataPack audioData) {
|
||||
public void setGraphingData(FloatArray dataSet1, FloatArray dataSet2, MusicManager 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.MusicDataPack;
|
||||
import zero1hd.rhythmbullet.audio.MusicManager;
|
||||
|
||||
public class AudioGraphRelation extends Actor {
|
||||
private MusicDataPack audioData;
|
||||
private MusicManager 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, MusicDataPack audioData) {
|
||||
public void setGraphingData(FloatArray dataSet1, FloatArray dataSet2, MusicManager audioData) {
|
||||
this.mainGraph = dataSet1;
|
||||
this.overlayGraph = dataSet2;
|
||||
if (dataSet2 == null) {
|
||||
|
@ -4,7 +4,7 @@ import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Widget;
|
||||
|
||||
import zero1hd.rhythmbullet.audio.MusicDataPack;
|
||||
import zero1hd.rhythmbullet.audio.MusicManager;
|
||||
import zero1hd.rhythmbullet.audio.visualizer.BasicVisualizer;
|
||||
|
||||
public class Visualizer extends Widget {
|
||||
@ -31,8 +31,8 @@ public class Visualizer extends Widget {
|
||||
}
|
||||
|
||||
|
||||
public void setMDP(MusicDataPack mdp) {
|
||||
vis.setMDP(mdp);
|
||||
public void setMDP(MusicManager mdp) {
|
||||
vis.setMM(mdp);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,7 +19,7 @@ import com.badlogic.gdx.utils.Disposable;
|
||||
|
||||
import zero1hd.rhythmbullet.RhythmBullet;
|
||||
import zero1hd.rhythmbullet.audio.AudioAnalyzer;
|
||||
import zero1hd.rhythmbullet.audio.MusicDataPack;
|
||||
import zero1hd.rhythmbullet.audio.MusicManager;
|
||||
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;
|
||||
MusicDataPack music;
|
||||
MusicManager music;
|
||||
RhythmMapAlgorithm mapGenAlgorithm;
|
||||
|
||||
private Table songInfo;
|
||||
@ -186,7 +186,7 @@ public class AnalyzePage extends Page implements MiniListener, Disposable {
|
||||
addActor(back);
|
||||
}
|
||||
|
||||
public void setSong(MusicDataPack music, SongInfo audioInfo, MiniListener listener) {
|
||||
public void setSong(MusicManager music, SongInfo audioInfo, MiniListener listener) {
|
||||
confirmed = false;
|
||||
confirmDiffButton.setDisabled(false);
|
||||
sensitivityRating.setDisabled(false);
|
||||
|
@ -15,8 +15,8 @@ import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
|
||||
import zero1hd.rhythmbullet.RhythmBullet;
|
||||
import zero1hd.rhythmbullet.audio.MusicDataPack;
|
||||
import zero1hd.rhythmbullet.audio.SongController;
|
||||
import zero1hd.rhythmbullet.audio.MusicManager;
|
||||
import zero1hd.rhythmbullet.audio.SongListController;
|
||||
import zero1hd.rhythmbullet.audio.visualizer.BasicVisualizer;
|
||||
import zero1hd.rhythmbullet.events.OnDifferentSongListener;
|
||||
import zero1hd.rhythmbullet.screens.PreGameScreen;
|
||||
@ -32,10 +32,10 @@ public class MainPage extends Page implements OnDifferentSongListener {
|
||||
private TextButton credits;
|
||||
private WidgetGroup playButton;
|
||||
|
||||
private SongController sc;
|
||||
private SongListController sc;
|
||||
private Visualizer hvisual;
|
||||
|
||||
public MainPage(RhythmBullet core, Vector3 targetPosition, SongController sc) {
|
||||
public MainPage(RhythmBullet core, Vector3 targetPosition, SongListController sc) {
|
||||
hvisual = new Visualizer();
|
||||
this.sc = sc;
|
||||
sc.addOnDifferentSongListener(this);
|
||||
@ -129,7 +129,7 @@ public class MainPage extends Page implements OnDifferentSongListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDifferentSong(MusicDataPack mdp) {
|
||||
public void onDifferentSong(MusicManager mdp) {
|
||||
hvisual.setMDP(mdp);
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextField;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
|
||||
import zero1hd.rhythmbullet.RhythmBullet;
|
||||
import zero1hd.rhythmbullet.audio.SongController;
|
||||
import zero1hd.rhythmbullet.audio.SongListController;
|
||||
import zero1hd.rhythmbullet.screens.CreativeScreen;
|
||||
import zero1hd.rhythmbullet.screens.MainMenu;
|
||||
|
||||
@ -27,7 +27,7 @@ public class OptionsPage extends Page {
|
||||
private ProgressBar fxVolSlider;
|
||||
private TextField directoryField;
|
||||
|
||||
public OptionsPage(RhythmBullet core, Vector3 targetPosition, MoreOptionsPage moreOptionsPage, SongController sc) {
|
||||
public OptionsPage(RhythmBullet core, Vector3 targetPosition, MoreOptionsPage moreOptionsPage, SongListController sc) {
|
||||
optionsTable.defaults().spaceLeft(40f).padTop(5f).padBottom(5f).left();
|
||||
|
||||
Label optionGeneralTitle = new Label("General", core.getDefaultSkin(), "large-font", core.getDefaultSkin().getColor("default"));
|
||||
@ -45,7 +45,7 @@ public class OptionsPage extends Page {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
musicVolPercentage.setText(MathUtils.round(musicVolSlider.getValue()) + "%");
|
||||
sc.getCurrentSong().getPlaybackMusic().setVolume(musicVolSlider.getPercent());
|
||||
sc.getCurrentSong().setVolume(musicVolSlider.getPercent());
|
||||
|
||||
core.getPrefs().putFloat("music vol", musicVolSlider.getPercent());
|
||||
}
|
||||
|
@ -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.MusicDataPack;
|
||||
import zero1hd.rhythmbullet.audio.MusicManager;
|
||||
|
||||
public class BeatViewer extends Window {
|
||||
Pixmap lights;
|
||||
int songIndex;
|
||||
MusicDataPack music;
|
||||
MusicManager music;
|
||||
Texture lightOn;
|
||||
private AudioDataPackage data;
|
||||
|
||||
@ -125,7 +125,7 @@ public class BeatViewer extends Window {
|
||||
super.act(delta);
|
||||
}
|
||||
|
||||
public void setMusic(MusicDataPack audioData, AudioDataPackage adp) {
|
||||
public void setMusic(MusicManager 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.MusicDataPack;
|
||||
import zero1hd.rhythmbullet.audio.MusicManager;
|
||||
|
||||
public class MusicController extends Window implements OnCompletionListener {
|
||||
Skin skin;
|
||||
private Image togglePlay;
|
||||
private TextField info;
|
||||
private MusicDataPack audiofile;
|
||||
private MusicManager audiofile;
|
||||
|
||||
public MusicController(final Skin skin) {
|
||||
super("Playback Controller", skin, "tinted");
|
||||
@ -34,10 +34,8 @@ public class MusicController extends Window implements OnCompletionListener {
|
||||
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
if (audiofile.getPlaybackMusic() != null) {
|
||||
audiofile.getPlaybackMusic().setPosition(audiofile.getPlaybackMusic().getPosition() - 2);
|
||||
info.setText(String.valueOf(MathUtils.round(audiofile.getPlaybackMusic().getPosition())) + " sec");
|
||||
}
|
||||
audiofile.setPosition(audiofile.getPosition() - 2);
|
||||
info.setText(String.valueOf(MathUtils.round(audiofile.getPosition())) + " sec");
|
||||
}
|
||||
});
|
||||
|
||||
@ -53,14 +51,14 @@ public class MusicController extends Window implements OnCompletionListener {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
if (audiofile != null) {
|
||||
if (audiofile.getPlaybackMusic().isPlaying()) {
|
||||
audiofile.getPlaybackMusic().pause();
|
||||
if (audiofile.isPlaying()) {
|
||||
audiofile.pause();
|
||||
|
||||
togglePlay.setDrawable(skin.getDrawable("arrow"));
|
||||
|
||||
} else {
|
||||
togglePlay.setDrawable(skin.getDrawable("pause"));
|
||||
audiofile.getPlaybackMusic().play();
|
||||
audiofile.play();
|
||||
}
|
||||
}
|
||||
super.clicked(event, x, y);
|
||||
@ -73,9 +71,9 @@ public class MusicController extends Window implements OnCompletionListener {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
if (audiofile != null) {
|
||||
audiofile.getPlaybackMusic().play();
|
||||
audiofile.getPlaybackMusic().setPosition(audiofile.getPlaybackMusic().getPosition() + 2);
|
||||
info.setText(String.valueOf(MathUtils.round(audiofile.getPlaybackMusic().getPosition())) + " sec");
|
||||
audiofile.play();
|
||||
audiofile.setPosition(audiofile.getPosition() + 2);
|
||||
info.setText(String.valueOf(MathUtils.round(audiofile.getPosition())) + " sec");
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -85,8 +83,8 @@ public class MusicController extends Window implements OnCompletionListener {
|
||||
info = new TextField(null, skin, "ui") {
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
if (audiofile != null && audiofile.getPlaybackMusic().isPlaying()) {
|
||||
setText(String.valueOf(MathUtils.round(audiofile.getPlaybackMusic().getPosition())) + " sec");
|
||||
if (audiofile != null && audiofile.isPlaying()) {
|
||||
setText(String.valueOf(MathUtils.round(audiofile.getPosition())) + " sec");
|
||||
}
|
||||
super.act(delta);
|
||||
}
|
||||
@ -99,7 +97,7 @@ public class MusicController extends Window implements OnCompletionListener {
|
||||
public boolean keyUp(InputEvent event, int keycode) {
|
||||
if (keycode == Keys.ENTER) {
|
||||
if (!info.getText().replaceAll("(?![0-9])\\S+", "").trim().isEmpty()) {
|
||||
audiofile.getPlaybackMusic().setPosition(Float.valueOf(info.getText().replaceAll("(?![0-9])\\S+", "").trim()));
|
||||
audiofile.setPosition(Float.valueOf(info.getText().replaceAll("(?![0-9])\\S+", "").trim()));
|
||||
}
|
||||
}
|
||||
return super.keyUp(event, keycode);
|
||||
@ -110,22 +108,25 @@ public class MusicController extends Window implements OnCompletionListener {
|
||||
setSize(260, 75);
|
||||
}
|
||||
|
||||
public void setAudiofile(MusicDataPack audiofile) {
|
||||
public void setAudiofile(MusicManager audiofile) {
|
||||
this.audiofile = audiofile;
|
||||
if (this.audiofile != null) {
|
||||
this.audiofile.dispose();
|
||||
this.audiofile = null;
|
||||
}
|
||||
if (audiofile == null) {
|
||||
togglePlay.setDrawable(skin.getDrawable("loading"));
|
||||
info.setText("Analyzing...");
|
||||
} else {
|
||||
audiofile.reset();
|
||||
togglePlay.setDrawable(skin.getDrawable("arrow"));
|
||||
info.setText("Ready.");
|
||||
audiofile.getPlaybackMusic().play();
|
||||
audiofile.getPlaybackMusic().pause();
|
||||
audiofile.getPlaybackMusic().setOnCompletionListener(this);
|
||||
audiofile.play();
|
||||
audiofile.pause();
|
||||
audiofile.setOnCompletionListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
public MusicDataPack getAudiofile() {
|
||||
public MusicManager 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.MusicDataPack;
|
||||
import zero1hd.rhythmbullet.audio.MusicManager;
|
||||
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 MusicDataPack getSelectedMusic() {
|
||||
public MusicManager 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.MusicDataPack;
|
||||
import zero1hd.rhythmbullet.audio.MusicManager;
|
||||
|
||||
public class VolumeWindow extends Window {
|
||||
|
||||
@ -17,7 +17,7 @@ public class VolumeWindow extends Window {
|
||||
private Slider musicVolSlider;
|
||||
private Preferences prefs;
|
||||
|
||||
private MusicDataPack music;
|
||||
private MusicManager music;
|
||||
public VolumeWindow(String title, Skin skin, Preferences prefs) {
|
||||
super(title, skin, "tinted");
|
||||
this.prefs = prefs;
|
||||
@ -35,7 +35,7 @@ public class VolumeWindow extends Window {
|
||||
save();
|
||||
musicVolPercentage.setText(MathUtils.round(musicVolSlider.getValue()) + "%");
|
||||
if (music != null) {
|
||||
music.getPlaybackMusic().setVolume(musicVolSlider.getValue()/100f);
|
||||
music.setVolume(musicVolSlider.getValue()/100f);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -67,10 +67,10 @@ public class VolumeWindow extends Window {
|
||||
prefs.flush();
|
||||
}
|
||||
|
||||
public void setMusic(MusicDataPack music) {
|
||||
public void setMusic(MusicManager music) {
|
||||
this.music = music;
|
||||
if (music != null) {
|
||||
music.getPlaybackMusic().setVolume(prefs.getFloat("music vol")/100f);
|
||||
music.setVolume(prefs.getFloat("music vol")/100f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user