Fixed tests
This commit is contained in:
parent
815745c4ec
commit
ec88b9821c
2 changed files with 41 additions and 21 deletions
|
@ -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);
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Reference in a new issue