package zero1hd.rhythmbullet.audio;

import java.security.InvalidParameterException;

import com.badlogic.gdx.utils.FloatArray;

public class AudioDataPackage {
	private FloatArray bassPeaks;
	private FloatArray mPeaks;
	private FloatArray umPeaks;
	
	private MusicDataPack musicInfo;
	
	private float bassMaxVal, bassAvg;
	private float mMaxVal, mAvg;
	private float uMMaxval, uMAvg;
	
	private int PUID;
	private float secPerWin;
	private float avgSPB;
	/**
	 * Sets the bass data
	 * @param bassPeaks
	 * @param bassMaxVal
	 * @param bassAvg
	 */
	public void setBassData(FloatArray bassPeaks, float bassMaxVal, float  bassAvg) {
		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;
	}
	
	/**
	 * Sets the midrange data
	 * @param mPeaks
	 * @param mMaxVal
	 * @param mAvg
	 */
	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.");
		}
		
		this.mPeaks = mPeaks;
		this.mMaxVal = mMaxVal;
		this.mAvg = mAvg;
	}
	
	/**
	 * Sets the upper-midrange data
	 * @param umPeaks
	 * @param uMMaxVal
	 * @param uMAvg
	 */
	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;
		this.uMMaxval = uMMaxVal;
		this.uMAvg = uMAvg;
	}
	
	public void setMusicInfo(MusicDataPack musicInfo) {
		if (this.musicInfo != null) {
			throw new InvalidParameterException("There is already music information in this package.");
		}
		this.musicInfo = musicInfo;
	}
	
	public void setPUID(int pUID) {
		PUID = pUID;
	}
	
	public void setAvgSPB(float avgSPB) {
		this.avgSPB = avgSPB;
	}
	
	public void setSecPerWin(float secPerWin) {
		this.secPerWin = secPerWin;
	}
	
	//All the get methods...
	public FloatArray getBassPeaks() {
		if (bassPeaks != null) {
			return bassPeaks;
		} else {
			throw new NullPointerException("Bass peaks currently null. This pack hasn't been properly packed!");
		}
	}
	
	public FloatArray getmPeaks() {
		if (mPeaks != null) {
			return mPeaks;
		} else {
			throw new NullPointerException("midrange peaks currently null. This pack hasn't been properly packed!");
		}
	}
	
	public FloatArray getuMPeaks() {
		if (umPeaks != null) {
			return umPeaks;
		} else {
			throw new NullPointerException("Upper midrange peaks currently null. This pack hasn't been properly packed!");
		}
	}
	
	public MusicDataPack getMusicInfo() {
		if (musicInfo == null) {
			throw new NullPointerException("Music info hasn't been baked in...");
		}
		return musicInfo;
	}
	
	public float getBassMaxVal() {
		return bassMaxVal;
	}
	public float getBassAvg() {
		return bassAvg;
	}
	
	public float getmAvg() {
		return mAvg;
	}
	public float getmMaxVal() {
		return mMaxVal;
	}
	
	public float getuMMaxval() {
		return uMMaxval;
	}
	public float getuMAvg() {
		return uMAvg;
	}
	
	public int getPUID() {
		return PUID;
	}
	
	public float getAvgSPB() {
		return avgSPB;
	}
	
	public float getSecPerWin() {
		return secPerWin;
	}
}
