From 1ceb25bf31cdff8aa1def87a9eebf73c07ad8fed Mon Sep 17 00:00:00 2001 From: Weird Constructor Date: Sun, 6 Jun 2021 09:31:41 +0200 Subject: [PATCH] fixed sine detune test --- src/dsp/mod.rs | 9 ++++----- tests/basics.rs | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/dsp/mod.rs b/src/dsp/mod.rs index a054107..e171829 100644 --- a/src/dsp/mod.rs +++ b/src/dsp/mod.rs @@ -249,11 +249,10 @@ macro_rules! d_pit { ($x: expr) => { } } } -// 5.0 for mapping -0.2-0.2 range to -1.0 to 1.0 -// 5.0 * 0.2 => 24.0 -// 5.0 * 0.1 => 12.0 -// 5.0 * 0.008333333 => 1.0 -// 5.0 * 0.000083333 => 0.001 +// 0.2 => 24.0 +// 0.1 => 12.0 +// 0.008333333 => 1.0 +// 0.000083333 => 0.001 macro_rules! n_det { ($x: expr) => { $x / 120.0 } } macro_rules! d_det { ($x: expr) => { $x * 120.0 } } diff --git a/tests/basics.rs b/tests/basics.rs index 2920547..277172b 100644 --- a/tests/basics.rs +++ b/tests/basics.rs @@ -186,8 +186,18 @@ fn check_sine_freq_detune() { matrix.set_param(det_param, SAtom::param(det_param.norm(1.0))); run_no_input(&mut node_exec, 50.0); - let cfreq = run_and_get_counted_freq(&mut node_exec, 1000.0); - assert_float_eq!(cfreq.floor(), 493.0); + let cfreq = run_and_get_counted_freq(&mut node_exec, 250.0); + assert_float_eq!(cfreq.floor(), 466.0); + + matrix.set_param(det_param, SAtom::param(det_param.norm(-1.0))); + run_no_input(&mut node_exec, 50.0); + let cfreq = run_and_get_counted_freq(&mut node_exec, 300.0); + assert_float_eq!(cfreq.floor(), 415.0); + + matrix.set_param(det_param, SAtom::param(det_param.norm(-14.0))); + run_no_input(&mut node_exec, 50.0); + let cfreq = run_and_get_counted_freq(&mut node_exec, 400.0); + assert_float_eq!(cfreq.floor(), 196.0); } #[test]