From ec88b9821ca3072c00bad9297debe93a2c8dddf1 Mon Sep 17 00:00:00 2001 From: Weird Constructor Date: Wed, 11 Aug 2021 05:05:04 +0200 Subject: [PATCH] Fixed tests --- tests/node_allp.rs | 14 ++++++++------ tests/node_bosc.rs | 48 +++++++++++++++++++++++++++++++--------------- 2 files changed, 41 insertions(+), 21 deletions(-) diff --git a/tests/node_allp.rs b/tests/node_allp.rs index 94bcc57..7db17b9 100644 --- a/tests/node_allp.rs +++ b/tests/node_allp.rs @@ -42,20 +42,22 @@ fn check_node_allp() { // starts with original signal * -0.7 let mut v = vec![0.7; (2.0 * 44.1_f32).ceil() as usize]; // silence for 1ms, which is the internal delay of the allpass - v.append(&mut vec![0.0; (1.0 * 44.1_f32).floor() as usize - 3]); + v.append(&mut vec![0.0; (1.0 * 44.1_f32).floor() as usize - 2]); // allpass feedback of the original signal for 2ms: // XXX: the smearing before and after the allpass is due to the // cubic interpolation! - v.append(&mut vec![0.0, 0.0]); - v.append(&mut vec![0.51; (2.0 * 44.1_f32).ceil() as usize]); + v.append(&mut vec![-0.03748519, 0.37841395, 0.5260659]); + v.append(&mut vec![0.51; (2.0 * 44.1_f32).ceil() as usize - 3]); // 1ms allpass silence like before: - v.append(&mut vec![0.0; (1.0 * 44.1_f32).floor() as usize - 1]); + v.append(&mut vec![0.54748523, 0.13158606, -0.016065884]); + v.append(&mut vec![0.0; (1.0 * 44.1_f32).floor() as usize - 5]); // 2ms the previous 1.0 * 0.7 fed back into the filter, // including even more smearing due to cubic interpolation: -// v.append(&mut vec![-0.000354, 0.00615, -0.005424, -0.17565, -0.39786, -0.3550714]); - v.append(&mut vec![-0.357; (2.0 * 44.1_f32).floor() as usize + 1]); + v.append(&mut vec![-0.0019286226, 0.04086761, -0.1813516, -0.35157663, -0.36315754, -0.35664573,]); + v.append(&mut vec![-0.357; (2.0 * 44.1_f32).floor() as usize - 5]); + v.append(&mut vec![-0.3550714, -0.39786762, -0.1756484, -0.005423375, 0.006157537, -0.00035427228]); v.append(&mut vec![0.0; 10]); //d// println!("res={:?}", res.1); diff --git a/tests/node_bosc.rs b/tests/node_bosc.rs index 4ca467c..be97623 100644 --- a/tests/node_bosc.rs +++ b/tests/node_bosc.rs @@ -72,23 +72,41 @@ fn check_node_bosc_1() { assert_eq!(fft[9].0, 1540); assert_eq!(fft[10].0, 1981); - pset_n(&mut matrix, bosc, "pw", 1.0); // Pulse width no mod + pset_n(&mut matrix, bosc, "pw", 1.0); // Pulse width mod run_for_ms(&mut node_exec, 10.0); let fft = run_and_get_fft4096_now(&mut node_exec, 120); - assert_eq!(fft[0].0, 215); - assert_eq!(fft[1].0, 226); - assert_eq!(fft[2].0, 431); - assert_eq!(fft[3].0, 441); - assert_eq!(fft[4].0, 452); - assert_eq!(fft[5].0, 657); - assert_eq!(fft[6].0, 668); - assert_eq!(fft[7].0, 872); - assert_eq!(fft[8].0, 883); - assert_eq!(fft[9].0, 1098); - assert_eq!(fft[10].0, 1109); - assert_eq!(fft[11].0, 1314); - assert_eq!(fft[12].0, 1324); - assert_eq!(fft[13].0, 1540); + assert_eq!(fft[0].0, 0); // DC component from short pulse + assert_eq!(fft[1].0, 11); // but full amplitude! + assert_eq!(fft[2].0, 215); + assert_eq!(fft[3].0, 226); + assert_eq!(fft[4].0, 431); + assert_eq!(fft[5].0, 441); + assert_eq!(fft[6].0, 452); + assert_eq!(fft[7].0, 657); + assert_eq!(fft[8].0, 668); + assert_eq!(fft[9].0, 872); + assert_eq!(fft[10].0, 883); + assert_eq!(fft[11].0, 1098); + assert_eq!(fft[12].0, 1109); + assert_eq!(fft[13].0, 1314); + assert_eq!(fft[14].0, 1324); + assert_eq!(fft[15].0, 1540); + +// Old test code that worked with the pulse width DC compensation: +// assert_eq!(fft[0].0, 215); +// assert_eq!(fft[1].0, 226); +// assert_eq!(fft[2].0, 431); +// assert_eq!(fft[3].0, 441); +// assert_eq!(fft[4].0, 452); +// assert_eq!(fft[5].0, 657); +// assert_eq!(fft[6].0, 668); +// assert_eq!(fft[7].0, 872); +// assert_eq!(fft[8].0, 883); +// assert_eq!(fft[9].0, 1098); +// assert_eq!(fft[10].0, 1109); +// assert_eq!(fft[11].0, 1314); +// assert_eq!(fft[12].0, 1324); +// assert_eq!(fft[13].0, 1540); } #[test]