Commit e0e6374e authored by Pierre Donat-Bouillud's avatar Pierre Donat-Bouillud

Cubic non linear distorsion bench

parent 706cd1ad
Pipeline #1033 failed with stage
in 1 minute and 20 seconds
......@@ -265,6 +265,30 @@ fn autowah_bench(c: &mut Criterion) {
);
}
fn cubicnl_bench(c: &mut Criterion) {
let mut rng = SmallRng::seed_from_u64(345987);
let unity_interval = Uniform::new_inclusive(-1., 1.);
c.bench_function_over_inputs(
"cubicnl",
move |b: &mut Bencher, n: &usize| {
let mut cubicnl = Cubicnl::new(0.9, 2.1);
let mut input = vec![DspEdge::new(1, 1, *n, 44100); 1];
//let size = input[0].buffer().len();
input[0].buffer_mut().copy_from_slice(
&rng.sample_iter(&unity_interval)
.take(*n)
.collect::<Vec<f32>>(),
);
b.iter(|| {
let mut output = vec![DspEdge::new(1, 1, *n, 44100); 1];
cubicnl.process(&input, &mut output)
})
},
vec![64, 128, 256, 512, 1024, 2048, 4096],
);
}
criterion_group!(
benches,
osc_bench,
......@@ -276,6 +300,7 @@ criterion_group!(
zita_reverb_bench,
freeverb_bench,
compressor_bench,
autowah_bench
autowah_bench,
cubicnl_bench
);
criterion_main!(benches);
......@@ -2299,14 +2299,14 @@ impl AudioEffect for Cubicnl {
self.instanceInit(actual_samplerate);
}
let mut fSlow0: f32 = (self.fHslider0 as f32);
let mut fSlow1: f32 = f32::powf(10.0, (2.0 * (self.fHslider1 as f32)));
let fSlow0: f32 = self.fHslider0 as f32;
let fSlow1: f32 = f32::powf(10.0, 2.0 * (self.fHslider1 as f32));
for i in 0..count {
let mut fTemp0: f32 = f32::max(
-1.0,
f32::min(1.0, (fSlow0 + (fSlow1 * (input[i as usize] as f32)))),
f32::min(1.0, fSlow0 + (fSlow1 * (input[i as usize] as f32))),
);
output[i as usize] = ((fTemp0 * (1.0 - (0.333333343 * faustpower2_f(fTemp0)))) as f32);
output[i as usize] = (fTemp0 * (1.0 - (0.333333343 * faustpower2_f(fTemp0)))) as f32;
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment