fixed a bug in patch loading

This commit is contained in:
Weird Constructor 2021-05-27 19:43:10 +02:00
parent 72e2e21aa1
commit bc97d238ec
2 changed files with 42 additions and 2 deletions

View file

@ -356,11 +356,11 @@ impl NodeConfigurator {
&mut self, params: &[(ParamId, f32)], atoms: &[(ParamId, SAtom)])
{
for (param_id, val) in params.iter() {
self.param_values.insert(*param_id, *val);
self.set_param(*param_id, (*val).into());
}
for (param_id, val) in atoms.iter() {
self.atom_values.insert(*param_id, val.clone());
self.set_param(*param_id, val.clone());
}
}

View file

@ -1159,3 +1159,43 @@ fn check_node_sampl_1() {
let fft = run_and_get_fft4096(&mut node_exec, 800, 20.0);
assert_eq!(fft[0], (7127, 1029));
}
#[test]
fn check_node_sampl_reload() {
{
let (node_conf, mut node_exec) = new_node_engine();
let mut matrix = Matrix::new(node_conf, 3, 3);
let smpl = NodeId::Sampl(0);
let out = NodeId::Out(0);
matrix.place(0, 0, Cell::empty(smpl)
.out(None, None, smpl.out("sig")));
matrix.place(0, 1, Cell::empty(out)
.input(out.inp("ch1"), None, None));
matrix.sync().unwrap();
let sample_p = smpl.inp_param("sample").unwrap();
let freq_p = smpl.inp_param("freq").unwrap();
matrix.set_param(sample_p, SAtom::audio_unloaded("tests/sample_sin.wav"));
hexodsp::save_patch_to_file(&mut matrix, "check_matrix_serialize.hxy")
.unwrap();
}
{
let (node_conf, mut node_exec) = new_node_engine();
let mut matrix = Matrix::new(node_conf, 3, 3);
hexodsp::load_patch_from_file(
&mut matrix, "check_matrix_serialize.hxy").unwrap();
let (rms, min, max) = run_and_get_l_rms_mimax(&mut node_exec, 50.0);
assert_float_eq!(rms, 0.505);
assert_float_eq!(min, -0.9998);
assert_float_eq!(max, 1.0);
let fft = run_and_get_fft4096(&mut node_exec, 800, 20.0);
assert_eq!(fft[0], (441, 940));
}
}