diff --git a/src/dsp/mod.rs b/src/dsp/mod.rs index 24f3258..3d0dde5 100644 --- a/src/dsp/mod.rs +++ b/src/dsp/mod.rs @@ -101,7 +101,7 @@ pub trait GraphAtomData { fn get_led(&self) -> f32; } -pub type GraphFun = Box f32>; +pub type GraphFun = Box f32>; /// This trait represents a DspNode for the [crate::matrix::Matrix] pub trait DspNode { diff --git a/src/dsp/node_ad.rs b/src/dsp/node_ad.rs index c1c8a2d..ae15f5e 100644 --- a/src/dsp/node_ad.rs +++ b/src/dsp/node_ad.rs @@ -234,7 +234,7 @@ impl DspNode for Ad { } fn graph_fun() -> Option { - Some(Box::new(|gd: &dyn GraphAtomData, _init: bool, x: f32| -> f32 { + Some(Box::new(|gd: &dyn GraphAtomData, _init: bool, x: f32, xn: f32| -> f32 { let atk_idx = NodeId::Ad(0).inp_param("atk").unwrap().inp(); let dcy_idx = NodeId::Ad(0).inp_param("dcy").unwrap().inp(); let ashp_idx = NodeId::Ad(0).inp_param("ashp").unwrap().inp(); @@ -248,7 +248,9 @@ impl DspNode for Ad { let a = atk * 0.5; let d = dcy * 0.5; if x <= a { - if a < 0.0001 { + if xn > a { + 1.0 + } else if a < 0.0001 { 0.0 } else { let delta = 1.0 - ((a - x) / a); diff --git a/src/dsp/node_test.rs b/src/dsp/node_test.rs index 5c6a057..fa16d08 100644 --- a/src/dsp/node_test.rs +++ b/src/dsp/node_test.rs @@ -121,7 +121,7 @@ impl DspNode for Test { } fn graph_fun() -> Option { - Some(Box::new(|_gd: &dyn GraphAtomData, _init: bool, x: f32| -> f32 { + Some(Box::new(|_gd: &dyn GraphAtomData, _init: bool, x: f32, _xn: f32| -> f32 { x })) }