Blame view

VRGNYMusicLights/Sources/ApplicationJava/MusicList.java 881 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
  
278cdee0   pfrison   VRGNYMusicLights ...
12
  	public ArrayList<Music> getList() { return musics; }
a89c030d   pfrison   VRGNYMusicLights ...
13
  	public void addMusic(Music music) { musics.add(music); }
d175ba55   pfrison   VRGNYMusicLight a...
14
  	public void setMusicAt(int index, Music music) { musics.set(index, music); }
a89c030d   pfrison   VRGNYMusicLights ...
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  	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...
33
  }