Use the new GraphFun to draw a proper AD envelope without undersampling artifacts.
This commit is contained in:
parent
3360a2afe9
commit
a91dbd0787
3 changed files with 6 additions and 4 deletions
|
@ -101,7 +101,7 @@ pub trait GraphAtomData {
|
|||
fn get_led(&self) -> f32;
|
||||
}
|
||||
|
||||
pub type GraphFun = Box<dyn FnMut(&dyn GraphAtomData, bool, f32) -> f32>;
|
||||
pub type GraphFun = Box<dyn FnMut(&dyn GraphAtomData, bool, f32, f32) -> f32>;
|
||||
|
||||
/// This trait represents a DspNode for the [crate::matrix::Matrix]
|
||||
pub trait DspNode {
|
||||
|
|
|
@ -234,7 +234,7 @@ impl DspNode for Ad {
|
|||
}
|
||||
|
||||
fn graph_fun() -> Option<GraphFun> {
|
||||
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);
|
||||
|
|
|
@ -121,7 +121,7 @@ impl DspNode for Test {
|
|||
}
|
||||
|
||||
fn graph_fun() -> Option<GraphFun> {
|
||||
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
|
||||
}))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue