Skip to content

Commit

Permalink
Merge pull request #47 from HEnquist/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
HEnquist authored Jun 25, 2020
2 parents ecc2153 + 655db4d commit 0911add
Show file tree
Hide file tree
Showing 27 changed files with 3,329 additions and 1,074 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/target
**/*.rs.bk
Cargo.lock
Cargo.lock
*.raw
*.wav
22 changes: 18 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "camilladsp"
version = "0.0.14"
version = "0.2.2"
authors = ["Henrik Enquist <[email protected]>"]
description = "A flexible tool for processing audio"

Expand All @@ -12,14 +12,21 @@ pulse-backend = ["libpulse-simple-binding", "libpulse-binding"]
socketserver = ["ws"]
FFTW = ["fftw"]

[lib]
name = "camillalib"
path = "src/lib.rs"

[[bin]]
name = "camilladsp"
path = "src/bin.rs"

[dependencies]
alsa = { version = "0.4", optional = true }
serde = { version = "1.0", features = ["derive"] }
serde_yaml = "0.8"
serde_with = "1.4.0"
rustfft = "3.0.0"
fftw = { version = "0.6.0", optional = true }
num-traits = "0.2"
realfft = "0.2.0"
fftw = { version = "0.6.2", optional = true }
num = "0.2"
signal-hook = "0.1.13"
rand = "0.7.3"
Expand All @@ -30,4 +37,11 @@ env_logger = "0.7.1"
ws = { version = "0.9.1", optional = true }
libpulse-binding = { version = "2.0", optional = true }
libpulse-simple-binding = { version = "2.0", optional = true }
rubato = "0.4.3"

[dev-dependencies]
criterion = "0.3"

[[bench]]
name = "filters"
harness = false
263 changes: 229 additions & 34 deletions README.md

Large diffs are not rendered by default.

66 changes: 66 additions & 0 deletions benches/filters.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
extern crate criterion;
use criterion::{criterion_group, criterion_main, Bencher, BenchmarkId, Criterion};
extern crate camillalib;

use camillalib::biquad::{Biquad, BiquadCoefficients};
use camillalib::diffeq::DiffEq;
use camillalib::fftconv::FFTConv;
use camillalib::filters::Filter;
use camillalib::PrcFmt;

/// Bench a single convolution
fn run_conv(b: &mut Bencher, len: usize, chunksize: usize) {
let filter = vec![0.0 as PrcFmt; len];
let mut conv = FFTConv::new("test".to_string(), chunksize, &filter);
let mut waveform = vec![0.0 as PrcFmt; chunksize];

//let mut spectrum = signal.clone();
b.iter(|| conv.process_waveform(&mut waveform));
}

/// Run all convolution benches
fn bench_conv(c: &mut Criterion) {
let mut group = c.benchmark_group("Conv");
let chunksize = 1024;
for filterlen in [chunksize, 4 * chunksize, 16 * chunksize].iter() {
group.bench_with_input(
BenchmarkId::new("FFTConv", filterlen),
filterlen,
|b, filterlen| run_conv(b, *filterlen, chunksize),
);
}
group.finish();
}

/// Bench biquad
fn bench_biquad(c: &mut Criterion) {
let chunksize = 1024;
let coeffs = BiquadCoefficients::new(
-0.1462978543780541,
0.005350765548905586,
0.21476322779271284,
0.4295264555854257,
0.21476322779271284,
);
let mut bq = Biquad::new("test".to_string(), chunksize, coeffs);
let mut waveform = vec![0.0 as PrcFmt; chunksize];

c.bench_function("Biquad", |b| b.iter(|| bq.process_waveform(&mut waveform)));
}

/// Bench diffew
fn bench_diffeq(c: &mut Criterion) {
let chunksize = 1024;
let mut de = DiffEq::new(
"test".to_string(),
vec![1.0, -0.1462978543780541, 0.005350765548905586],
vec![0.21476322779271284, 0.4295264555854257, 0.21476322779271284],
);
let mut waveform = vec![0.0 as PrcFmt; chunksize];

c.bench_function("DiffEq", |b| b.iter(|| de.process_waveform(&mut waveform)));
}

criterion_group!(benches, bench_conv, bench_biquad, bench_diffeq);

criterion_main!(benches);
21 changes: 21 additions & 0 deletions exampleconfigs/resample_file.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
devices:
samplerate: 96000
chunksize: 1024
enable_resampling: true
resampler_type: AccurateSync
capture_samplerate: 44100
playback:
type: File
channels: 2
filename: "result_f64.raw"
format: FLOAT64LE
capture:
type: File
channels: 2
filename: "sine_120_44100_f64_2ch.raw"
format: FLOAT64LE
extra_samples: 0



22 changes: 22 additions & 0 deletions exampleconfigs/simpleconfig_resample.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
devices:
samplerate: 48000
chunksize: 1024
target_level: 1024
adjust_period: 3
enable_resampling: true
resampler_type: BalancedAsync
capture_samplerate: 44100
capture:
type: Alsa
channels: 2
device: "hw:Loopback,0,0"
format: S16LE
playback:
type: Alsa
channels: 2
device: "hw:Generic_1"
format: S32LE



Binary file added overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0911add

Please sign in to comment.