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 + } })) } }