Repository navigation
Expand file tree
/
Copy pathListParameter.java
More file actions
163 lines (136 loc) · 3.28 KB
/
Copy pathListParameter.java
File metadata and controls
163 lines (136 loc) · 3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import java.io.BufferedWriter;
public class ListParameter implements Parameter {
public int v;
public int[] values;
public String[] names;
public boolean sc = false;
public float scAccumulator = 0.0f;
public float scAccumulatorInc = 1.0f;
public boolean tc = false;
public int tcIncPerSec = 0;
public long ms = 0;
final private String name;
public int scGroup=0;
public boolean ghost=true;
public final Layer parent;
public static String[] onOffNames={"off","on"};
public static int[] onOff={0,1};
public ListParameter(Layer parent,int v, int[] values,String[] names, String name) {
this.parent=parent;
this.v = v;
this.values = values;
this.names=names;
this.name = name;
}
public ListParameter clone(Layer parent) {
ListParameter param = new ListParameter(parent,this.v, this.values,this.names, this.name);
param.sc = this.sc;
param.scAccumulatorInc = this.scAccumulatorInc;
param.tc = this.tc;
param.tcIncPerSec = this.tcIncPerSec;
param.scGroup=this.scGroup;
param.ms = this.ms;
param.ghost=this.ghost;
return (param);
}
public int v() {
return(v(true));
}
public int getIndex() {
for(int i=0;i<values.length;i++){
if(v==values[i]){
return(i);
}
}
return(-1);
}
public void setIndex(int index) {
if(index>=values.length){
v=values[0];
}else{
v=values[index];
}
}
public int v(boolean useGhost) {
Layer ghost="ghostLayer".equals(this.name)?null:parent.getGhost();
if(useGhost && ghost!=null && this.ghost){
return(ghost.getListParameter(this.name).v(false));
}else{
return (v);
}
}
public String getName() {
return (name);
}
public void load(String data) {
String values[] = data.split(";");
v = Integer.parseInt(values[0]);
sc = values[1].equals("true");
tc = values[2].equals("true");
tcIncPerSec = Integer.parseInt(values[3]);
if(values.length>4){
scAccumulatorInc=Float.parseFloat(values[4]);
}
if(values.length>5){
scGroup=Integer.parseInt(values[5]);
}
if(values.length>6){
ghost=values[2].equals("true");
}
ms = System.currentTimeMillis();
}
public void save(BufferedWriter out) {
try {
out.write(this.toString());
} catch (Exception e) {
}
}
public String toString() {
return (name + ":" + v + ";" + (sc ? "true" : "false") + ";"
+ (tc ? "true" : "false") + ";" + tcIncPerSec + ";"+scAccumulatorInc
+ ";" + scGroup + ";" + ghost
+"\n"
);
}
public void randomize() {
this.v = values[(int) (Math.random() * this.values.length)];
}
public void doSc(boolean onBeat) {
if(this.scAccumulator<0)this.scAccumulator=0;
if (this.sc && onBeat ) {
if(this.scAccumulatorInc>0)
this.scAccumulator +=this.scAccumulatorInc;
else
this.scAccumulator=1;
if(this.scAccumulator>=1){
this.scAccumulator=0;
if(this.values.length==2){
if(v==values[0])
v=values[1];
else
v=values[0];
}else{
this.randomize();
}
}
}
}
public void doBump(boolean onBeat) {
}
public void doScAlter(boolean onBeat) {
}
public void doModulation(float value) {
}
public void doTc() {
if (tc && System.currentTimeMillis() > ms + tcIncPerSec) {
ms = System.currentTimeMillis();
randomize();
}
}
public void setScGroup(int group){
this.scGroup=group;
}
public int getScGroup(){
return(scGroup);
}
}