made node_test finally useful for... tests!
This commit is contained in:
parent
bf8f96b56d
commit
a425733a51
3 changed files with 47 additions and 21 deletions
|
@ -439,7 +439,8 @@ macro_rules! node_list {
|
|||
[1 eoet],
|
||||
test => Test UIType::Generic UICategory::IOUtil
|
||||
(0 f n_id d_id r_id f_def stp_d 0.0, 1.0, 0.5)
|
||||
{1 0 s setting(0) fa_test_s 0 10},
|
||||
{1 0 p param(0.0) fa_test_s 0 10}
|
||||
[0 sig],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1052,14 +1053,14 @@ macro_rules! make_node_info_enum {
|
|||
pub fn norm(&self, in_idx: usize, x: f32) -> f32 {
|
||||
match in_idx {
|
||||
$($in_idx => crate::dsp::norm_v::$variant::$para(x),)+
|
||||
_ => 0.0,
|
||||
_ => x,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn denorm(&self, in_idx: usize, x: f32) -> f32 {
|
||||
match in_idx {
|
||||
$($in_idx => crate::dsp::denorm_v::$variant::$para(x),)+
|
||||
_ => 0.0,
|
||||
_ => x,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,11 +39,8 @@ impl Test {
|
|||
}
|
||||
}
|
||||
pub const f : &'static str = "F Test";
|
||||
pub const s : &'static str = "S Test";
|
||||
// pub const gain : &'static str =
|
||||
// "Amp gain\nGain input\nRange: (0..1)\n";
|
||||
// pub const sig : &'static str =
|
||||
// "Amp sig\nAmplified signal output\nRange: (-1..1)\n";
|
||||
pub const p : &'static str = "Test p\nJust an unsmoothed parameter for tests.";
|
||||
pub const sig : &'static str = "Test sig\nThe output of p as signal";
|
||||
}
|
||||
|
||||
impl DspNode for Test {
|
||||
|
@ -54,20 +51,18 @@ impl DspNode for Test {
|
|||
|
||||
#[inline]
|
||||
fn process<T: NodeAudioContext>(
|
||||
&mut self, _ctx: &mut T, _ectx: &mut NodeExecContext,
|
||||
_atoms: &[SAtom], _params: &[ProcBuf], _inputs: &[ProcBuf],
|
||||
_outputs: &mut [ProcBuf], _led: LedPhaseVals)
|
||||
&mut self, ctx: &mut T, _ectx: &mut NodeExecContext,
|
||||
atoms: &[SAtom], _params: &[ProcBuf], _inputs: &[ProcBuf],
|
||||
outputs: &mut [ProcBuf], _led: LedPhaseVals)
|
||||
{
|
||||
// use crate::dsp::out;
|
||||
// use crate::dsp::inp;
|
||||
// use crate::dsp::denorm;
|
||||
//
|
||||
// let gain = inp::Test::gain(inputs);
|
||||
// let inp = inp::Test::inp(inputs);
|
||||
// let out = out::Test::sig(outputs);
|
||||
// for frame in 0..ctx.nframes() {
|
||||
// out.write(frame, inp.read(frame) * denorm::Test::gain(gain, frame));
|
||||
// }
|
||||
use crate::dsp::{out, at};
|
||||
|
||||
let p = at::Test::p(atoms);
|
||||
let out = out::Test::sig(outputs);
|
||||
for frame in 0..ctx.nframes() {
|
||||
println!("R {}", p.f());
|
||||
out.write(frame, p.f());
|
||||
}
|
||||
}
|
||||
|
||||
fn graph_fun() -> Option<GraphFun> {
|
||||
|
|
30
tests/node_test.rs
Normal file
30
tests/node_test.rs
Normal file
|
@ -0,0 +1,30 @@
|
|||
mod common;
|
||||
use common::*;
|
||||
|
||||
#[test]
|
||||
fn check_node_test_1() {
|
||||
let (node_conf, mut node_exec) = new_node_engine();
|
||||
let mut matrix = Matrix::new(node_conf, 3, 3);
|
||||
|
||||
let test = NodeId::Test(0);
|
||||
let out = NodeId::Out(0);
|
||||
matrix.place(0, 0, Cell::empty(test)
|
||||
.out(None, None, test.out("sig")));
|
||||
matrix.place(0, 1, Cell::empty(out)
|
||||
.input(out.inp("ch1"), None, None));
|
||||
matrix.sync().unwrap();
|
||||
|
||||
let p = test.inp_param("p").unwrap();
|
||||
|
||||
matrix.set_param(p, SAtom::param(1.0));
|
||||
let res = run_for_ms(&mut node_exec, 2.0);
|
||||
assert_decimated_feq!(res.0, 1, vec![ 1.0; 10 ]);
|
||||
|
||||
matrix.set_param(p, SAtom::param(0.5));
|
||||
let res = run_for_ms(&mut node_exec, 2.0);
|
||||
assert_decimated_feq!(res.0, 1, vec![ 0.5; 10 ]);
|
||||
|
||||
matrix.set_param(p, SAtom::param(0.0));
|
||||
let res = run_for_ms(&mut node_exec, 1.0);
|
||||
assert_decimated_feq!(res.0, 1, vec![ 0.0; 10 ]);
|
||||
}
|
Loading…
Reference in a new issue