MusicList.java 749 Bytes
import java.util.ArrayList;

public class MusicList {
	private ArrayList<Music> musics;
	private SerialCom serialCom;

	public MusicList(SerialCom serialCom) {
		this.serialCom = serialCom;
		musics = new ArrayList<>();
	}

	public void addMusic(Music music) { musics.add(music); }
	public void deleteMusic(int index) { musics.remove(index); }
	
	public double[] render(long tick) {
		if(musics.size() == 0)
			return null;
		double[] lights = musics.get(0).render(tick);
		for(int i=1; i<musics.size(); i++) {
			double[] tmpRender = musics.get(i).render(tick);
			for(int j=0; j<lights.length; j++) {
				lights[j] += tmpRender[j];
				if(lights[j] < 0)
					lights[j] = 0;
				if(lights[j] > 1)
					lights[j] = 1;
			}
		}
		return lights;
	}
}