101 if (name.equals("hold"))
102 return hold[instance];
103 if (name.equals("decay"))
104 return decay[instance];
105 if (name.equals("sustain"))
106 return sustain[instance];
107 if (name.equals("release"))
108 return release[instance];
109 if (name.equals("shutdown"))
110 return shutdown[instance];
111 if (name.equals("attack2"))
112 return attack2[instance];
113 if (name.equals("decay2"))
114 return decay2[instance];
115 if (name.equals("release2"))
116 return release2[instance];
117
118 return null;
119 }
120
121 public void processControlLogic() {
122 for (int i = 0; i < used_count; i++) {
123
124 if (stage[i] == EG_END)
125 continue;
126
127 if ((stage[i] > EG_OFF) && (stage[i] < EG_RELEASE)) {
128 if (on[i][0] < 0.5) {
129 if (on[i][0] < -0.5) {
130 stage_count[i] = (int)(Math.pow(2,
131 this.shutdown[i][0] / 1200.0) / control_time);
132 if (stage_count[i] < 0)
133 stage_count[i] = 0;
134 stage_v[i] = out[i][0];
135 stage_ix[i] = 0;
136 stage[i] = EG_SHUTDOWN;
137 } else {
138 if ((release2[i][0] < 0.000001) && release[i][0] < 0
139 && Double.isInfinite(release[i][0])) {
140 out[i][0] = 0;
153 stage_ix[i] = 0;
154
155 double m = 1 - out[i][0];
156 stage_ix[i] = (int)(stage_count[i] * m);
157
158 stage[i] = EG_RELEASE;
159 }
160 }
161 }
162
163 switch (stage[i]) {
164 case EG_OFF:
165 active[i][0] = 1;
166 if (on[i][0] < 0.5)
167 break;
168 stage[i] = EG_DELAY;
169 stage_ix[i] = (int)(Math.pow(2,
170 this.delay[i][0] / 1200.0) / control_time);
171 if (stage_ix[i] < 0)
172 stage_ix[i] = 0;
173 case EG_DELAY:
174 if (stage_ix[i] == 0) {
175 double attack = this.attack[i][0];
176 double attack2 = this.attack2[i][0];
177
178 if (attack2 < 0.000001
179 && (attack < 0 && Double.isInfinite(attack))) {
180 out[i][0] = 1;
181 stage[i] = EG_HOLD;
182 stage_count[i] = (int)(Math.pow(2,
183 this.hold[i][0] / 1200.0) / control_time);
184 stage_ix[i] = 0;
185 } else {
186 stage[i] = EG_ATTACK;
187 stage_count[i] = (int)(Math.pow(2,
188 attack / 1200.0) / control_time);
189 stage_count[i] += (int)(attack2 / (control_time * 1000));
190 if (stage_count[i] < 0)
191 stage_count[i] = 0;
192 stage_ix[i] = 0;
|
101 if (name.equals("hold"))
102 return hold[instance];
103 if (name.equals("decay"))
104 return decay[instance];
105 if (name.equals("sustain"))
106 return sustain[instance];
107 if (name.equals("release"))
108 return release[instance];
109 if (name.equals("shutdown"))
110 return shutdown[instance];
111 if (name.equals("attack2"))
112 return attack2[instance];
113 if (name.equals("decay2"))
114 return decay2[instance];
115 if (name.equals("release2"))
116 return release2[instance];
117
118 return null;
119 }
120
121 @SuppressWarnings("fallthrough")
122 public void processControlLogic() {
123 for (int i = 0; i < used_count; i++) {
124
125 if (stage[i] == EG_END)
126 continue;
127
128 if ((stage[i] > EG_OFF) && (stage[i] < EG_RELEASE)) {
129 if (on[i][0] < 0.5) {
130 if (on[i][0] < -0.5) {
131 stage_count[i] = (int)(Math.pow(2,
132 this.shutdown[i][0] / 1200.0) / control_time);
133 if (stage_count[i] < 0)
134 stage_count[i] = 0;
135 stage_v[i] = out[i][0];
136 stage_ix[i] = 0;
137 stage[i] = EG_SHUTDOWN;
138 } else {
139 if ((release2[i][0] < 0.000001) && release[i][0] < 0
140 && Double.isInfinite(release[i][0])) {
141 out[i][0] = 0;
154 stage_ix[i] = 0;
155
156 double m = 1 - out[i][0];
157 stage_ix[i] = (int)(stage_count[i] * m);
158
159 stage[i] = EG_RELEASE;
160 }
161 }
162 }
163
164 switch (stage[i]) {
165 case EG_OFF:
166 active[i][0] = 1;
167 if (on[i][0] < 0.5)
168 break;
169 stage[i] = EG_DELAY;
170 stage_ix[i] = (int)(Math.pow(2,
171 this.delay[i][0] / 1200.0) / control_time);
172 if (stage_ix[i] < 0)
173 stage_ix[i] = 0;
174 // Fallthrough okay?
175 case EG_DELAY:
176 if (stage_ix[i] == 0) {
177 double attack = this.attack[i][0];
178 double attack2 = this.attack2[i][0];
179
180 if (attack2 < 0.000001
181 && (attack < 0 && Double.isInfinite(attack))) {
182 out[i][0] = 1;
183 stage[i] = EG_HOLD;
184 stage_count[i] = (int)(Math.pow(2,
185 this.hold[i][0] / 1200.0) / control_time);
186 stage_ix[i] = 0;
187 } else {
188 stage[i] = EG_ATTACK;
189 stage_count[i] = (int)(Math.pow(2,
190 attack / 1200.0) / control_time);
191 stage_count[i] += (int)(attack2 / (control_time * 1000));
192 if (stage_count[i] < 0)
193 stage_count[i] = 0;
194 stage_ix[i] = 0;
|