2022-07-25 03:55:54 +00:00
|
|
|
// Copyright (c) 2022 Weird Constructor <weirdconstructor@gmail.com>
|
|
|
|
// This file is a part of HexoDSP. Released under GPL-3.0-or-later.
|
|
|
|
// See README.md and COPYING for details.
|
|
|
|
|
|
|
|
mod common;
|
|
|
|
use common::*;
|
|
|
|
|
|
|
|
use hexodsp::nodes::SCOPE_SAMPLES;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn check_node_scope_1() {
|
|
|
|
let (node_conf, mut node_exec) = new_node_engine();
|
|
|
|
let mut matrix = Matrix::new(node_conf, 3, 3);
|
|
|
|
|
|
|
|
let mut chain = MatrixCellChain::new(CellDir::B);
|
2022-07-25 04:15:48 +00:00
|
|
|
chain.node_inp("scope", "in1").place(&mut matrix, 0, 0).unwrap();
|
2022-07-25 03:55:54 +00:00
|
|
|
matrix.sync().unwrap();
|
|
|
|
|
|
|
|
let scope = NodeId::Scope(0);
|
2022-07-25 04:15:48 +00:00
|
|
|
let in1_p = scope.inp_param("in1").unwrap();
|
|
|
|
let in2_p = scope.inp_param("in2").unwrap();
|
|
|
|
let in3_p = scope.inp_param("in3").unwrap();
|
2022-07-25 03:55:54 +00:00
|
|
|
|
2022-07-25 04:15:48 +00:00
|
|
|
matrix.set_param(in1_p, SAtom::param(1.0));
|
|
|
|
matrix.set_param(in2_p, SAtom::param(1.0));
|
|
|
|
matrix.set_param(in3_p, SAtom::param(1.0));
|
2022-07-25 03:55:54 +00:00
|
|
|
let _res = run_for_ms(&mut node_exec, 11.0);
|
|
|
|
|
2022-07-25 04:36:07 +00:00
|
|
|
let scope = matrix.get_scope_handle(0).unwrap();
|
2022-07-25 03:55:54 +00:00
|
|
|
let mut v = vec![];
|
|
|
|
for x in 0..SCOPE_SAMPLES {
|
2022-07-25 04:36:07 +00:00
|
|
|
v.push(scope.read(0, x));
|
2022-07-25 03:55:54 +00:00
|
|
|
}
|
2022-07-25 04:15:48 +00:00
|
|
|
assert_decimated_feq!(v, 80, vec![0.0022, 0.1836, 0.3650, 0.5464, 0.7278, 0.9093, 1.0]);
|
2022-07-25 03:55:54 +00:00
|
|
|
|
2022-07-25 04:15:48 +00:00
|
|
|
let mut v = vec![];
|
|
|
|
for x in 0..SCOPE_SAMPLES {
|
2022-07-25 04:36:07 +00:00
|
|
|
v.push(scope.read(1, x));
|
2022-07-25 04:15:48 +00:00
|
|
|
}
|
|
|
|
assert_decimated_feq!(v, 80, vec![0.0022, 0.1836, 0.3650, 0.5464, 0.7278, 0.9093, 1.0]);
|
|
|
|
|
|
|
|
let mut v = vec![];
|
|
|
|
for x in 0..SCOPE_SAMPLES {
|
2022-07-25 04:36:07 +00:00
|
|
|
v.push(scope.read(2, x));
|
2022-07-25 04:15:48 +00:00
|
|
|
}
|
2022-07-25 03:55:54 +00:00
|
|
|
assert_decimated_feq!(v, 80, vec![0.0022, 0.1836, 0.3650, 0.5464, 0.7278, 0.9093, 1.0]);
|
|
|
|
}
|