fixed issue with data cleaning thread crashing
This commit is contained in:
		@@ -3,7 +3,7 @@ package zero1hd.rhythmbullet.audio;
 | 
			
		||||
import com.badlogic.gdx.files.FileHandle;
 | 
			
		||||
 | 
			
		||||
public class Audio {
 | 
			
		||||
	public static BasicMusicInfo getAudioData(FileHandle file) {
 | 
			
		||||
	public static CoreMusicInfo getAudioData(FileHandle file) {
 | 
			
		||||
		if (file.extension().equalsIgnoreCase("wav")) {
 | 
			
		||||
			return new WavAudioData(file);
 | 
			
		||||
		} else if (file.extension().equalsIgnoreCase("mp3")) {
 | 
			
		||||
 
 | 
			
		||||
@@ -14,7 +14,7 @@ public class AudioAnalyzer {
 | 
			
		||||
	private boolean containsData;
 | 
			
		||||
	private boolean finalized;
 | 
			
		||||
	FloatFFT_1D fft;
 | 
			
		||||
	private BasicMusicInfo audioData;
 | 
			
		||||
	private CoreMusicInfo musicInfo;
 | 
			
		||||
 | 
			
		||||
	float[] audioPCM;
 | 
			
		||||
	float[] spectrum;
 | 
			
		||||
@@ -63,7 +63,7 @@ public class AudioAnalyzer {
 | 
			
		||||
		analysisAlgorithm = () -> {
 | 
			
		||||
			progress = 0;
 | 
			
		||||
			int tasksDone = 0;
 | 
			
		||||
			long totalTasks = audioData.getSampleCount()/audioData.getReadWindowSize();
 | 
			
		||||
			long totalTasks = musicInfo.getSampleCount()/musicInfo.getReadWindowSize();
 | 
			
		||||
			
 | 
			
		||||
			bassThresholdMultiplier = 1.5f;
 | 
			
		||||
			mThresholdMultiplier = 1.4f;
 | 
			
		||||
@@ -82,7 +82,7 @@ public class AudioAnalyzer {
 | 
			
		||||
			mThresholdCalcRange = thresholdRangeCalc(0.4f);
 | 
			
		||||
			umThresholdCalcRange = thresholdRangeCalc(0.4f);
 | 
			
		||||
			
 | 
			
		||||
			Gdx.app.debug("Read freq", String.valueOf(audioData.getSampleRate()));
 | 
			
		||||
			Gdx.app.debug("Read freq", String.valueOf(musicInfo.getSampleRate()));
 | 
			
		||||
			Gdx.app.debug("Using following bin ranges", "\nBass freq begin: " + bassBinBegin + "\nBass freq end: " + bassBinEnd + "\nMain freq begin: " + umBinBegin + "\nMain freq end: " + umBinEnd);
 | 
			
		||||
 | 
			
		||||
			Gdx.app.debug("Total tasks", String.valueOf(totalTasks));
 | 
			
		||||
@@ -91,10 +91,10 @@ public class AudioAnalyzer {
 | 
			
		||||
			Gdx.app.debug("Threshold Calc Range M", String.valueOf(umThresholdCalcRange));
 | 
			
		||||
			Gdx.app.debug("Threshold Calc Range Bass", String.valueOf(bassThresholdCalcRange));
 | 
			
		||||
			
 | 
			
		||||
			fft = new FloatFFT_1D(audioData.getReadWindowSize());
 | 
			
		||||
			fft = new FloatFFT_1D(musicInfo.getReadWindowSize());
 | 
			
		||||
			int seedDigit = 0;
 | 
			
		||||
			
 | 
			
		||||
			while (audioData.readSamples(audioPCM) > 0 && work) {
 | 
			
		||||
			while (musicInfo.readSamples(audioPCM) > 0 && work) {
 | 
			
		||||
				
 | 
			
		||||
				fft.realForward(audioPCM);
 | 
			
		||||
				
 | 
			
		||||
@@ -188,7 +188,6 @@ public class AudioAnalyzer {
 | 
			
		||||
			
 | 
			
		||||
			Gdx.app.debug("Audio Analyzer", "Threshold calculated.");
 | 
			
		||||
 | 
			
		||||
			
 | 
			
		||||
			//pruning data
 | 
			
		||||
			float prunnedCurrentVal;
 | 
			
		||||
			FloatArray bassPrunned = new FloatArray();
 | 
			
		||||
@@ -218,7 +217,7 @@ public class AudioAnalyzer {
 | 
			
		||||
			}
 | 
			
		||||
			Gdx.app.debug("Audio Analyzer", "Data prunned.");
 | 
			
		||||
 | 
			
		||||
			secondsPerWindow = audioData.getReadWindowSize()/audioData.getSampleRate();
 | 
			
		||||
			secondsPerWindow = musicInfo.getReadWindowSize()/musicInfo.getSampleRate();
 | 
			
		||||
			//peak detection
 | 
			
		||||
			
 | 
			
		||||
			int lastID = 0;
 | 
			
		||||
@@ -289,16 +288,20 @@ public class AudioAnalyzer {
 | 
			
		||||
			
 | 
			
		||||
			pack = new AudioDataPackage();
 | 
			
		||||
			pack.setBassData(bassPeaks, bassMaxValue, bassAvg);
 | 
			
		||||
			pack.setmPeaks(mPeaks, mMaxValue, mAvg);
 | 
			
		||||
			pack.setUmPeaks(umPeaks, umMaxValue, umAvg);
 | 
			
		||||
			pack.setmData(mPeaks, mMaxValue, mAvg);
 | 
			
		||||
			pack.setUmData(umPeaks, umMaxValue, umAvg);
 | 
			
		||||
			
 | 
			
		||||
			pack.setPUID(PUID);
 | 
			
		||||
			pack.setAvgSPB(avgSPB);
 | 
			
		||||
			pack.setSecPerWin(secondsPerWindow);
 | 
			
		||||
			pack.setMusicInfo(musicInfo);
 | 
			
		||||
			
 | 
			
		||||
			sender.send(MiniEvents.MUSIC_DATA_CLEANED);
 | 
			
		||||
			if (work) {
 | 
			
		||||
				finalized = true;
 | 
			
		||||
				Gdx.app.debug("Audio Analyzer", "data cleaned and ready for map gen.");
 | 
			
		||||
				sender.send(MiniEvents.MUSIC_DATA_CLEANED);
 | 
			
		||||
			}
 | 
			
		||||
		};
 | 
			
		||||
		
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public void shrinkData() {
 | 
			
		||||
@@ -307,11 +310,11 @@ public class AudioAnalyzer {
 | 
			
		||||
		umSpectralFlux = null;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public void startAnalyticalThread(BasicMusicInfo audiofile) {
 | 
			
		||||
	public void startAnalyticalThread(CoreMusicInfo audiofile) {
 | 
			
		||||
		audioPCM = new float[audiofile.getReadWindowSize()];
 | 
			
		||||
		spectrum = new float[(audiofile.getReadWindowSize()/2)+1];
 | 
			
		||||
		lastSpectrum = new float[(audiofile.getReadWindowSize()/2)+1];
 | 
			
		||||
		this.audioData = audiofile;
 | 
			
		||||
		this.musicInfo = audiofile;
 | 
			
		||||
		work = true;
 | 
			
		||||
		
 | 
			
		||||
		ExecutorService exec = Executors.newSingleThreadExecutor();
 | 
			
		||||
@@ -342,7 +345,7 @@ public class AudioAnalyzer {
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	private int thresholdRangeCalc(float durationOfRange) {
 | 
			
		||||
		return (int) (durationOfRange/(audioData.getReadWindowSize()/audioData.getSampleRate()));
 | 
			
		||||
		return (int) (durationOfRange/(musicInfo.getReadWindowSize()/musicInfo.getSampleRate()));
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public float getBassMaxValue() {
 | 
			
		||||
@@ -377,8 +380,8 @@ public class AudioAnalyzer {
 | 
			
		||||
		return PUID;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public BasicMusicInfo getAudioData() {
 | 
			
		||||
		return audioData;
 | 
			
		||||
	public CoreMusicInfo getAudioData() {
 | 
			
		||||
		return musicInfo;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public float getAvgSPB() {
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@ public class AudioDataPackage {
 | 
			
		||||
	private FloatArray mPeaks;
 | 
			
		||||
	private FloatArray umPeaks;
 | 
			
		||||
	
 | 
			
		||||
	private BasicMusicInfo musicInfo;
 | 
			
		||||
	private CoreMusicInfo musicInfo;
 | 
			
		||||
	
 | 
			
		||||
	private float bassMaxVal, bassAvg;
 | 
			
		||||
	private float mMaxVal, mAvg;
 | 
			
		||||
@@ -25,13 +25,12 @@ public class AudioDataPackage {
 | 
			
		||||
	 * @param bassAvg
 | 
			
		||||
	 */
 | 
			
		||||
	public void setBassData(FloatArray bassPeaks, float bassMaxVal, float  bassAvg) {
 | 
			
		||||
		if (bassPeaks != null) {
 | 
			
		||||
			this.bassPeaks = bassPeaks;
 | 
			
		||||
			this.bassMaxVal = bassMaxVal;
 | 
			
		||||
			this.bassAvg = bassAvg;
 | 
			
		||||
		} else {
 | 
			
		||||
		if (this.bassPeaks != null) {
 | 
			
		||||
			throw new InvalidParameterException("The bass peaks of this audio pack has already been set.");
 | 
			
		||||
		}
 | 
			
		||||
		this.bassPeaks = bassPeaks;
 | 
			
		||||
		this.bassMaxVal = bassMaxVal;
 | 
			
		||||
		this.bassAvg = bassAvg;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
@@ -40,8 +39,8 @@ public class AudioDataPackage {
 | 
			
		||||
	 * @param mMaxVal
 | 
			
		||||
	 * @param mAvg
 | 
			
		||||
	 */
 | 
			
		||||
	public void setmPeaks(FloatArray mPeaks, float mMaxVal, float mAvg) {
 | 
			
		||||
		if (mPeaks != null) {
 | 
			
		||||
	public void setmData(FloatArray mPeaks, float mMaxVal, float mAvg) {
 | 
			
		||||
		if (this.mPeaks != null) {
 | 
			
		||||
			throw new InvalidParameterException("The midrange peaks of this audio pack has already been set.");
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
@@ -56,8 +55,8 @@ public class AudioDataPackage {
 | 
			
		||||
	 * @param uMMaxVal
 | 
			
		||||
	 * @param uMAvg
 | 
			
		||||
	 */
 | 
			
		||||
	public void setUmPeaks(FloatArray umPeaks, float uMMaxVal, float uMAvg) {
 | 
			
		||||
		if (umPeaks != null) {
 | 
			
		||||
	public void setUmData(FloatArray umPeaks, float uMMaxVal, float uMAvg) {
 | 
			
		||||
		if (this.umPeaks != null) {
 | 
			
		||||
			throw new InvalidParameterException("The upper midrange peaks have already been set.");
 | 
			
		||||
		}
 | 
			
		||||
		this.umPeaks = umPeaks;
 | 
			
		||||
@@ -65,8 +64,8 @@ public class AudioDataPackage {
 | 
			
		||||
		this.uMAvg = uMAvg;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public void setMusicInfo(BasicMusicInfo musicInfo) {
 | 
			
		||||
		if (musicInfo != null) {
 | 
			
		||||
	public void setMusicInfo(CoreMusicInfo musicInfo) {
 | 
			
		||||
		if (this.musicInfo != null) {
 | 
			
		||||
			throw new InvalidParameterException("There is already music information in this package.");
 | 
			
		||||
		}
 | 
			
		||||
		this.musicInfo = musicInfo;
 | 
			
		||||
@@ -109,7 +108,7 @@ public class AudioDataPackage {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public BasicMusicInfo getMusicInfo() {
 | 
			
		||||
	public CoreMusicInfo getMusicInfo() {
 | 
			
		||||
		if (musicInfo == null) {
 | 
			
		||||
			throw new NullPointerException("Music info hasn't been baked in...");
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,7 @@ package zero1hd.rhythmbullet.audio;
 | 
			
		||||
import com.badlogic.gdx.audio.Music;
 | 
			
		||||
import com.badlogic.gdx.utils.Disposable;
 | 
			
		||||
 | 
			
		||||
public interface BasicMusicInfo extends Disposable {
 | 
			
		||||
public interface CoreMusicInfo 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.
 | 
			
		||||
@@ -20,7 +20,7 @@ import javazoom.jl.decoder.Header;
 | 
			
		||||
import javazoom.jl.decoder.MP3Decoder;
 | 
			
		||||
import javazoom.jl.decoder.OutputBuffer;
 | 
			
		||||
 | 
			
		||||
public class Mp3AudioData implements BasicMusicInfo {
 | 
			
		||||
public class Mp3AudioData implements CoreMusicInfo {
 | 
			
		||||
	private int readWindowSize = 1024;
 | 
			
		||||
 | 
			
		||||
	private Music playbackMusic;
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@ import com.badlogic.gdx.files.FileHandle;
 | 
			
		||||
 | 
			
		||||
import zero1hd.wavedecoder.WavDecoder;
 | 
			
		||||
 | 
			
		||||
public class WavAudioData implements BasicMusicInfo {
 | 
			
		||||
public class WavAudioData implements CoreMusicInfo {
 | 
			
		||||
	private int readWindowSize = 1024;
 | 
			
		||||
	private AudioFormat format;
 | 
			
		||||
	int readIndex;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,13 @@
 | 
			
		||||
package zero1hd.rhythmbullet.audio.map;
 | 
			
		||||
 | 
			
		||||
import zero1hd.rhythmbullet.audio.BasicMusicInfo;
 | 
			
		||||
import zero1hd.rhythmbullet.audio.CoreMusicInfo;
 | 
			
		||||
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 BasicMusicInfo musicData;
 | 
			
		||||
	private CoreMusicInfo 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(BasicMusicInfo audioData, int totalWindows) {
 | 
			
		||||
	public GamePlayMap(CoreMusicInfo 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 BasicMusicInfo getMusicData() {
 | 
			
		||||
	public CoreMusicInfo getMusicData() {
 | 
			
		||||
		return musicData;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
 
 | 
			
		||||
@@ -153,8 +153,4 @@ public class RhythmMapAlgorithm implements Runnable {
 | 
			
		||||
	public MiniSender getSender() {
 | 
			
		||||
		return sender;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public EntityManager getEm() {
 | 
			
		||||
		return em;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,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.BasicMusicInfo;
 | 
			
		||||
import zero1hd.rhythmbullet.audio.CoreMusicInfo;
 | 
			
		||||
import zero1hd.rhythmbullet.audio.map.GamePlayMap;
 | 
			
		||||
import zero1hd.rhythmbullet.stages.GamePlayArea;
 | 
			
		||||
import zero1hd.rhythmbullet.stages.ui.GameHUD;
 | 
			
		||||
@@ -26,7 +26,7 @@ public class GameScreen extends ScreenAdapter {
 | 
			
		||||
 | 
			
		||||
	public RhythmBullet core;
 | 
			
		||||
	
 | 
			
		||||
	private BasicMusicInfo music;
 | 
			
		||||
	private CoreMusicInfo music;
 | 
			
		||||
	
 | 
			
		||||
	SpriteBatch bgBatch;
 | 
			
		||||
	private ShaderProgram bgShader;
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,7 @@ import com.badlogic.gdx.utils.Align;
 | 
			
		||||
 | 
			
		||||
import zero1hd.rhythmbullet.RhythmBullet;
 | 
			
		||||
import zero1hd.rhythmbullet.audio.AudioAnalyzer;
 | 
			
		||||
import zero1hd.rhythmbullet.audio.BasicMusicInfo;
 | 
			
		||||
import zero1hd.rhythmbullet.audio.CoreMusicInfo;
 | 
			
		||||
import zero1hd.rhythmbullet.audio.AudioInfo;
 | 
			
		||||
import zero1hd.rhythmbullet.audio.map.GamePlayMap;
 | 
			
		||||
import zero1hd.rhythmbullet.audio.map.RhythmMapAlgorithm;
 | 
			
		||||
@@ -31,7 +31,7 @@ public class AnalyzePage extends Page implements MiniListener {
 | 
			
		||||
	private AnalyzePage ap = this;
 | 
			
		||||
	
 | 
			
		||||
	AudioAnalyzer audioAnalyzer;
 | 
			
		||||
	BasicMusicInfo music;
 | 
			
		||||
	CoreMusicInfo music;
 | 
			
		||||
	RhythmMapAlgorithm mapGenAlgorithm;
 | 
			
		||||
	
 | 
			
		||||
	private Table songInfo;
 | 
			
		||||
@@ -86,7 +86,7 @@ public class AnalyzePage extends Page implements MiniListener {
 | 
			
		||||
			
 | 
			
		||||
			@Override
 | 
			
		||||
			public void changed(ChangeEvent event, Actor actor) {
 | 
			
		||||
				sensitivityRatingTitle.setText("Base Difficulty: " + MathUtils.round(sensitivityRating.getValue()*100) +"%");
 | 
			
		||||
				sensitivityRatingTitle.setText("Base Difficulty: " + MathUtils.round(sensitivityRating.getValue()*100) + "%");
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
		
 | 
			
		||||
@@ -185,7 +185,7 @@ public class AnalyzePage extends Page implements MiniListener {
 | 
			
		||||
		addActor(back);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public void setSong(BasicMusicInfo music, AudioInfo audioInfo, MiniListener listener) {
 | 
			
		||||
	public void setSong(CoreMusicInfo music, AudioInfo audioInfo, MiniListener listener) {
 | 
			
		||||
		confirmed = false;
 | 
			
		||||
		confirmDiffButton.setDisabled(false);
 | 
			
		||||
		sensitivityRating.setDisabled(false);
 | 
			
		||||
 
 | 
			
		||||
@@ -4,12 +4,12 @@ import com.badlogic.gdx.scenes.scene2d.ui.Skin;
 | 
			
		||||
import com.badlogic.gdx.scenes.scene2d.ui.Window;
 | 
			
		||||
import com.badlogic.gdx.utils.FloatArray;
 | 
			
		||||
 | 
			
		||||
import zero1hd.rhythmbullet.audio.BasicMusicInfo;
 | 
			
		||||
import zero1hd.rhythmbullet.audio.CoreMusicInfo;
 | 
			
		||||
import zero1hd.rhythmbullet.ui.builders.AudioGraph;
 | 
			
		||||
 | 
			
		||||
public class BassUMGraphWindow extends Window {
 | 
			
		||||
	AudioGraph graph;
 | 
			
		||||
	BasicMusicInfo audioData;
 | 
			
		||||
	CoreMusicInfo audioData;
 | 
			
		||||
	
 | 
			
		||||
	public BassUMGraphWindow(String title, Skin skin) {
 | 
			
		||||
		super(title, skin, "tinted");
 | 
			
		||||
@@ -30,7 +30,7 @@ public class BassUMGraphWindow extends Window {
 | 
			
		||||
		return graph;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public void setData(FloatArray dataSet1, FloatArray dataSet2, BasicMusicInfo audioData) {
 | 
			
		||||
	public void setData(FloatArray dataSet1, FloatArray dataSet2, CoreMusicInfo audioData) {
 | 
			
		||||
		this.audioData = audioData;
 | 
			
		||||
		graph.setGraphingData(dataSet1, dataSet2);
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -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.BasicMusicInfo;
 | 
			
		||||
import zero1hd.rhythmbullet.audio.CoreMusicInfo;
 | 
			
		||||
 | 
			
		||||
public class BeatViewer extends Window {
 | 
			
		||||
	Pixmap lights;
 | 
			
		||||
	int songIndex;
 | 
			
		||||
	BasicMusicInfo music;
 | 
			
		||||
	CoreMusicInfo music;
 | 
			
		||||
	Texture lightOn;
 | 
			
		||||
	private AudioDataPackage data;
 | 
			
		||||
	
 | 
			
		||||
@@ -125,7 +125,7 @@ public class BeatViewer extends Window {
 | 
			
		||||
		super.act(delta);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public void setMusic(BasicMusicInfo audioData, AudioDataPackage adp) {
 | 
			
		||||
	public void setMusic(CoreMusicInfo audioData, AudioDataPackage adp) {
 | 
			
		||||
		this.music = audioData;
 | 
			
		||||
		this.data = adp;
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -4,12 +4,12 @@ import com.badlogic.gdx.scenes.scene2d.ui.Skin;
 | 
			
		||||
import com.badlogic.gdx.scenes.scene2d.ui.Window;
 | 
			
		||||
import com.badlogic.gdx.utils.FloatArray;
 | 
			
		||||
 | 
			
		||||
import zero1hd.rhythmbullet.audio.BasicMusicInfo;
 | 
			
		||||
import zero1hd.rhythmbullet.audio.CoreMusicInfo;
 | 
			
		||||
import zero1hd.rhythmbullet.ui.builders.AudioGraph;
 | 
			
		||||
 | 
			
		||||
public class MGraphWindow extends Window {
 | 
			
		||||
	private AudioGraph graph;
 | 
			
		||||
	private BasicMusicInfo audioData;
 | 
			
		||||
	private CoreMusicInfo audioData;
 | 
			
		||||
 | 
			
		||||
	public MGraphWindow(String title, Skin skin) {
 | 
			
		||||
		super(title, skin, "tinted");
 | 
			
		||||
@@ -30,7 +30,7 @@ public class MGraphWindow extends Window {
 | 
			
		||||
		return graph;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public void setData(FloatArray dataSet1, FloatArray dataSet2, BasicMusicInfo audioData) {
 | 
			
		||||
	public void setData(FloatArray dataSet1, FloatArray dataSet2, CoreMusicInfo audioData) {
 | 
			
		||||
		this.audioData = audioData;
 | 
			
		||||
		graph.setGraphingData(dataSet1, dataSet2);
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -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.BasicMusicInfo;
 | 
			
		||||
import zero1hd.rhythmbullet.audio.CoreMusicInfo;
 | 
			
		||||
 | 
			
		||||
public class MusicController extends Window implements OnCompletionListener {
 | 
			
		||||
	Skin skin;
 | 
			
		||||
	private Image togglePlay;
 | 
			
		||||
	private TextField info;
 | 
			
		||||
	private BasicMusicInfo audiofile;
 | 
			
		||||
	private CoreMusicInfo 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(BasicMusicInfo audiofile) {
 | 
			
		||||
	public void setAudiofile(CoreMusicInfo audiofile) {
 | 
			
		||||
		this.audiofile = audiofile;
 | 
			
		||||
		if (audiofile == null) {
 | 
			
		||||
			togglePlay.setDrawable(skin.getDrawable("loading"));
 | 
			
		||||
@@ -125,7 +125,7 @@ public class MusicController extends Window implements OnCompletionListener {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public BasicMusicInfo getAudiofile() {
 | 
			
		||||
	public CoreMusicInfo getAudiofile() {
 | 
			
		||||
		return audiofile;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
 | 
			
		||||
import com.badlogic.gdx.utils.Array;
 | 
			
		||||
 | 
			
		||||
import zero1hd.rhythmbullet.audio.Audio;
 | 
			
		||||
import zero1hd.rhythmbullet.audio.BasicMusicInfo;
 | 
			
		||||
import zero1hd.rhythmbullet.audio.CoreMusicInfo;
 | 
			
		||||
import zero1hd.rhythmbullet.util.MiniEvents;
 | 
			
		||||
import zero1hd.rhythmbullet.util.MiniSender;
 | 
			
		||||
 | 
			
		||||
@@ -95,7 +95,7 @@ public class MusicSelector extends Window {
 | 
			
		||||
		return isBack;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public BasicMusicInfo getSelectedMusic() {
 | 
			
		||||
	public CoreMusicInfo getSelectedMusic() {
 | 
			
		||||
		if (selectedMusic != null) {
 | 
			
		||||
			return Audio.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.BasicMusicInfo;
 | 
			
		||||
import zero1hd.rhythmbullet.audio.CoreMusicInfo;
 | 
			
		||||
 | 
			
		||||
public class VolumeWindow extends Window {
 | 
			
		||||
 | 
			
		||||
@@ -17,7 +17,7 @@ public class VolumeWindow extends Window {
 | 
			
		||||
	private Slider musicVolSlider;
 | 
			
		||||
	private Preferences prefs;
 | 
			
		||||
	
 | 
			
		||||
	private BasicMusicInfo music;
 | 
			
		||||
	private CoreMusicInfo 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(BasicMusicInfo music) {
 | 
			
		||||
	public void setMusic(CoreMusicInfo music) {
 | 
			
		||||
		this.music = music;
 | 
			
		||||
		if (music != null) {
 | 
			
		||||
			music.getPlaybackMusic().setVolume(prefs.getFloat("music vol")/100f);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user