From bf8f96b56db25158c153d613d833752a4ae4b194 Mon Sep 17 00:00:00 2001 From: Weird Constructor Date: Tue, 15 Jun 2021 20:01:03 +0200 Subject: [PATCH] simplified code a bit more --- src/dsp/node_ad.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/dsp/node_ad.rs b/src/dsp/node_ad.rs index 60593b5..e59d8c3 100644 --- a/src/dsp/node_ad.rs +++ b/src/dsp/node_ad.rs @@ -133,11 +133,11 @@ impl DspNode for Ad { let mult = at::Ad::mult(atoms); // 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 { - 1 => (atk_shape, atk, 1.0), - 2 => (dcy_shape, dcy, 0.0), - _ => (atk_shape, atk, 0.0), + 1 => (atk_shape, atk, 1.0, 1.0), + 2 => (dcy_shape, dcy, 0.0, -1.0), + _ => (atk_shape, atk, 0.0, 0.0), }; let mult : f64 = match mult.i() { @@ -153,18 +153,13 @@ impl DspNode for Ad { self.stage = 1; self.last_time = -1.0; target = 1.0; + delta = 1.0; shape_src = atk_shape; inc_time_src = atk; } let cur_time = denorm::Ad::atk(inc_time_src, frame); if self.last_time != cur_time { - let delta = - match self.stage { - 1 => 1.0, - 2 => -1.0, - _ => 0.0, - }; self.inc = if cur_time <= 0.0001 { delta @@ -198,6 +193,7 @@ impl DspNode for Ad { self.last_time = -1.0; self.value = target; target = 0.0; + delta = -1.0; shape_src = dcy_shape; inc_time_src = dcy; } @@ -208,6 +204,7 @@ impl DspNode for Ad { self.last_time = -1.0; self.value = target; target = 0.0; + delta = 0.0; self.trig_sig.trigger(); } },