From 8ee47a7eac8d7afd0ad0af5ef3072bc0852bee0d Mon Sep 17 00:00:00 2001 From: Weird Constructor Date: Fri, 18 Jun 2021 05:06:14 +0200 Subject: [PATCH] finished Ad graph --- src/dsp/mod.rs | 2 ++ src/dsp/node_ad.rs | 25 +++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/dsp/mod.rs b/src/dsp/mod.rs index 1149217..da673b3 100644 --- a/src/dsp/mod.rs +++ b/src/dsp/mod.rs @@ -62,6 +62,8 @@ pub trait GraphAtomData { fn get(&self, param_idx: u32) -> Option; fn get_denorm(&self, param_idx: u32) -> f32; fn get_norm(&self, param_idx: u32) -> f32; + fn get_phase(&self) -> f32; + fn get_led(&self) -> f32; } pub type GraphFun = Box f32>; diff --git a/src/dsp/node_ad.rs b/src/dsp/node_ad.rs index e50f7a8..8152084 100644 --- a/src/dsp/node_ad.rs +++ b/src/dsp/node_ad.rs @@ -241,10 +241,31 @@ impl DspNode for Ad { let ashp_idx = NodeId::Ad(0).inp_param("ashp").unwrap().inp(); let dshp_idx = NodeId::Ad(0).inp_param("dshp").unwrap().inp(); + let atk = gd.get_norm(atk_idx as u32); + let dcy = gd.get_norm(dcy_idx as u32); let ashp = gd.get_denorm(ashp_idx as u32); + let dshp = gd.get_denorm(dshp_idx as u32); - let v = sqrt4_to_pow4(x * gd.get_norm(atk_idx as u32), ashp); - v + let a = atk * 0.5; + let d = dcy * 0.5; + if x <= a { + if a < 0.0001 { + 0.0 + } else { + let delta = 1.0 - ((a - x) / a); + sqrt4_to_pow4(delta, ashp) + } + } else if (x - a) <= d { + if d < 0.0001 { + 0.0 + } else { + let x = x - a; + let delta = ((d - x) / d); + sqrt4_to_pow4(delta, dshp) + } + } else { + 0.0 + } })) } }