simplified code a bit more

This commit is contained in:
Weird Constructor 2021-06-15 20:01:03 +02:00
parent 152f193388
commit bf8f96b56d

View file

@ -133,11 +133,11 @@ impl DspNode for Ad {
let mult = at::Ad::mult(atoms); let mult = at::Ad::mult(atoms);
// block start: // block start:
let (mut shape_src, mut inc_time_src, mut target) = let (mut shape_src, mut inc_time_src, mut target, mut delta) =
match self.stage { match self.stage {
1 => (atk_shape, atk, 1.0), 1 => (atk_shape, atk, 1.0, 1.0),
2 => (dcy_shape, dcy, 0.0), 2 => (dcy_shape, dcy, 0.0, -1.0),
_ => (atk_shape, atk, 0.0), _ => (atk_shape, atk, 0.0, 0.0),
}; };
let mult : f64 = let mult : f64 =
match mult.i() { match mult.i() {
@ -153,18 +153,13 @@ impl DspNode for Ad {
self.stage = 1; self.stage = 1;
self.last_time = -1.0; self.last_time = -1.0;
target = 1.0; target = 1.0;
delta = 1.0;
shape_src = atk_shape; shape_src = atk_shape;
inc_time_src = atk; inc_time_src = atk;
} }
let cur_time = denorm::Ad::atk(inc_time_src, frame); let cur_time = denorm::Ad::atk(inc_time_src, frame);
if self.last_time != cur_time { if self.last_time != cur_time {
let delta =
match self.stage {
1 => 1.0,
2 => -1.0,
_ => 0.0,
};
self.inc = self.inc =
if cur_time <= 0.0001 { if cur_time <= 0.0001 {
delta delta
@ -198,6 +193,7 @@ impl DspNode for Ad {
self.last_time = -1.0; self.last_time = -1.0;
self.value = target; self.value = target;
target = 0.0; target = 0.0;
delta = -1.0;
shape_src = dcy_shape; shape_src = dcy_shape;
inc_time_src = dcy; inc_time_src = dcy;
} }
@ -208,6 +204,7 @@ impl DspNode for Ad {
self.last_time = -1.0; self.last_time = -1.0;
self.value = target; self.value = target;
target = 0.0; target = 0.0;
delta = 0.0;
self.trig_sig.trigger(); self.trig_sig.trigger();
} }
}, },