Blame view

VRGNYMusicLights/Sources/MusicList.java 749 Bytes
742429d1   pfrison   VRGNYMusicLight b...
1
2
3
4
5
6
7
8
9
10
  import java.util.ArrayList;
  
  public class MusicList {
  	private ArrayList<Music> musics;
  	private SerialCom serialCom;
  
  	public MusicList(SerialCom serialCom) {
  		this.serialCom = serialCom;
  		musics = new ArrayList<>();
  	}
a89c030d   pfrison   VRGNYMusicLights ...
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  
  	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;
  	}
742429d1   pfrison   VRGNYMusicLight b...
31
  }