...
 
Commits (6)
......@@ -11,6 +11,7 @@ use rand::distributions::Uniform;
use rand::prelude::*;
use audio_adaptive::audiograph::*;
use audio_adaptive::faust_effect::*;
use audio_adaptive::samplerate;
fn osc_bench(c: &mut Criterion) {
......@@ -129,5 +130,128 @@ fn mixer_bench(c: &mut Criterion) {
);
}
criterion_group!(benches, osc_bench, mod_bench, resampler_bench, mixer_bench);
fn guitar_bench(c: &mut Criterion) {
c.bench_function_over_inputs(
"guitar",
move |b: &mut Bencher, n: &usize| {
let mut guitar = Guitar::new(1., 0.45, 0.9, 1);
let input = vec![DspEdge::new(1, 1, *n, 44100); 1];
b.iter(|| {
let mut output = vec![DspEdge::new(1, 1, *n, 44100); 1];
guitar.process(&input, &mut output)
})
},
vec![64, 128, 256, 512, 1024, 2048, 4096],
);
}
fn transpose_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(
"transpose",
move |b: &mut Bencher, n: &usize| {
let mut transposer = Transposer::new(11);
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];
transposer.process(&input, &mut output)
})
},
vec![64, 128, 256, 512, 1024, 2048, 4096],
);
}
fn zita_reverb_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(
"zita_reverb",
move |b: &mut Bencher, n: &usize| {
let mut transposer = ZitaReverb::new(10., 300, 10000, 6., 10., 96_200);
let mut inputs = vec![DspEdge::new(1, 1, *n, 44100); 2];
//let size = input[0].buffer().len();
inputs[0].buffer_mut().copy_from_slice(
&rng.sample_iter(&unity_interval)
.take(*n)
.collect::<Vec<f32>>(),
);
inputs[1].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); 2];
transposer.process(&inputs, &mut output)
})
},
vec![64, 128, 256, 512, 1024, 2048, 4096],
);
}
fn freeverb_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(
"freeverb",
move |b: &mut Bencher, n: &usize| {
let mut freeverb = MonoFreeverb::new(0.2, 0.6, 0.8, 0.4);
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];
freeverb.process(&input, &mut output)
})
},
vec![64, 128, 256, 512, 1024, 2048, 4096],
);
}
fn compressor_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(
"compressor",
move |b: &mut Bencher, n: &usize| {
let mut compressor = Compressor::new(2., 20., 0.5, 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];
compressor.process(&input, &mut output)
})
},
vec![64, 128, 256, 512, 1024, 2048, 4096],
);
}
criterion_group!(
benches,
osc_bench,
mod_bench,
resampler_bench,
mixer_bench,
guitar_bench,
transpose_bench,
zita_reverb_bench,
freeverb_bench,
compressor_bench
);
criterion_main!(benches);
import("stdfaust.lib");
// We don't care about the values here. Just need it for the generation
ratio = hslider("ratio", 2, 1, 1000, 0.1);
thresh = hslider("thresh", 20, 0, 100, 1);
att = hslider("att", 0.5, 0, 100, 0.1);
rel = hslider("rel", 1, 0, 100, 0.1);
process = co.compressor_mono(ratio,thresh,att,rel) ;
import("stdfaust.lib");
// We don't care about the values here. Just need it for the generation
fb1 = hslider("fb1", 0.5, 0, 1, 0.01);
fb2 = hslider("fb2", 0.5, 0, 1, 0.01);
damp = hslider("damp", 0.5, 0, 1, 0.01);
spread = hslider("spread", 0.5, 0, 1, 0.01);
process = re.mono_freeverb(fb1, fb2, damp, spread) ;
import("stdfaust.lib");
rdel = hslider("rdel", 6, 0, 1000, 0.1);
f1 = hslider("f1", 100, 15, 30000, 1);
f2 = hslider("f2", 600, 15, 30000, 1);
t60dc = hslider("t60dc", 3, 0, 1000, 0.1);
t60m = hslider("t60m", 6, 0, 1000, 0.1);
fsmax = hslider("fsmax", 44100, 1, 96000, 1);
process = re.zita_rev1_stereo(5, 100, 600, 3, 6, 44100);
process = re.zita_rev1_stereo(rdel, f1, f2, t60dc, t60m, fsmax);
import("stdfaust.lib");
process = re.zita_rev1_stereo(
......@@ -103,6 +103,9 @@ impl DspNode {
)),
"guitar" => Box::new(faust_effect::Guitar::from_node_infos(&node_infos)),
"transpose" => Box::new(faust_effect::Transposer::from_node_infos(&node_infos)),
"zita_reverb" => Box::new(faust_effect::ZitaReverb::from_node_infos(&node_infos)),
"freeverb" => Box::new(faust_effect::MonoFreeverb::from_node_infos(&node_infos)),
"compressor" => Box::new(faust_effect::Compressor::from_node_infos(&node_infos)),
"sink" => Box::new(InputsOutputsAdaptor::new(
node_infos.nb_inlets as usize,
nb_channels,
......
This diff is collapsed.