Skip to content

Commit 0911add

Browse files
authored
Merge pull request #47 from HEnquist/develop
Develop
2 parents ecc2153 + 655db4d commit 0911add

27 files changed

+3329
-1074
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/target
22
**/*.rs.bk
3-
Cargo.lock
3+
Cargo.lock
4+
*.raw
5+
*.wav

Cargo.toml

+18-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "camilladsp"
3-
version = "0.0.14"
3+
version = "0.2.2"
44
authors = ["Henrik Enquist <[email protected]>"]
55
description = "A flexible tool for processing audio"
66

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

15+
[lib]
16+
name = "camillalib"
17+
path = "src/lib.rs"
18+
19+
[[bin]]
20+
name = "camilladsp"
21+
path = "src/bin.rs"
22+
1523
[dependencies]
1624
alsa = { version = "0.4", optional = true }
1725
serde = { version = "1.0", features = ["derive"] }
1826
serde_yaml = "0.8"
1927
serde_with = "1.4.0"
20-
rustfft = "3.0.0"
21-
fftw = { version = "0.6.0", optional = true }
22-
num-traits = "0.2"
28+
realfft = "0.2.0"
29+
fftw = { version = "0.6.2", optional = true }
2330
num = "0.2"
2431
signal-hook = "0.1.13"
2532
rand = "0.7.3"
@@ -30,4 +37,11 @@ env_logger = "0.7.1"
3037
ws = { version = "0.9.1", optional = true }
3138
libpulse-binding = { version = "2.0", optional = true }
3239
libpulse-simple-binding = { version = "2.0", optional = true }
40+
rubato = "0.4.3"
41+
42+
[dev-dependencies]
43+
criterion = "0.3"
3344

45+
[[bench]]
46+
name = "filters"
47+
harness = false

README.md

+229-34
Large diffs are not rendered by default.

benches/filters.rs

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
extern crate criterion;
2+
use criterion::{criterion_group, criterion_main, Bencher, BenchmarkId, Criterion};
3+
extern crate camillalib;
4+
5+
use camillalib::biquad::{Biquad, BiquadCoefficients};
6+
use camillalib::diffeq::DiffEq;
7+
use camillalib::fftconv::FFTConv;
8+
use camillalib::filters::Filter;
9+
use camillalib::PrcFmt;
10+
11+
/// Bench a single convolution
12+
fn run_conv(b: &mut Bencher, len: usize, chunksize: usize) {
13+
let filter = vec![0.0 as PrcFmt; len];
14+
let mut conv = FFTConv::new("test".to_string(), chunksize, &filter);
15+
let mut waveform = vec![0.0 as PrcFmt; chunksize];
16+
17+
//let mut spectrum = signal.clone();
18+
b.iter(|| conv.process_waveform(&mut waveform));
19+
}
20+
21+
/// Run all convolution benches
22+
fn bench_conv(c: &mut Criterion) {
23+
let mut group = c.benchmark_group("Conv");
24+
let chunksize = 1024;
25+
for filterlen in [chunksize, 4 * chunksize, 16 * chunksize].iter() {
26+
group.bench_with_input(
27+
BenchmarkId::new("FFTConv", filterlen),
28+
filterlen,
29+
|b, filterlen| run_conv(b, *filterlen, chunksize),
30+
);
31+
}
32+
group.finish();
33+
}
34+
35+
/// Bench biquad
36+
fn bench_biquad(c: &mut Criterion) {
37+
let chunksize = 1024;
38+
let coeffs = BiquadCoefficients::new(
39+
-0.1462978543780541,
40+
0.005350765548905586,
41+
0.21476322779271284,
42+
0.4295264555854257,
43+
0.21476322779271284,
44+
);
45+
let mut bq = Biquad::new("test".to_string(), chunksize, coeffs);
46+
let mut waveform = vec![0.0 as PrcFmt; chunksize];
47+
48+
c.bench_function("Biquad", |b| b.iter(|| bq.process_waveform(&mut waveform)));
49+
}
50+
51+
/// Bench diffew
52+
fn bench_diffeq(c: &mut Criterion) {
53+
let chunksize = 1024;
54+
let mut de = DiffEq::new(
55+
"test".to_string(),
56+
vec![1.0, -0.1462978543780541, 0.005350765548905586],
57+
vec![0.21476322779271284, 0.4295264555854257, 0.21476322779271284],
58+
);
59+
let mut waveform = vec![0.0 as PrcFmt; chunksize];
60+
61+
c.bench_function("DiffEq", |b| b.iter(|| de.process_waveform(&mut waveform)));
62+
}
63+
64+
criterion_group!(benches, bench_conv, bench_biquad, bench_diffeq);
65+
66+
criterion_main!(benches);

exampleconfigs/resample_file.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
devices:
3+
samplerate: 96000
4+
chunksize: 1024
5+
enable_resampling: true
6+
resampler_type: AccurateSync
7+
capture_samplerate: 44100
8+
playback:
9+
type: File
10+
channels: 2
11+
filename: "result_f64.raw"
12+
format: FLOAT64LE
13+
capture:
14+
type: File
15+
channels: 2
16+
filename: "sine_120_44100_f64_2ch.raw"
17+
format: FLOAT64LE
18+
extra_samples: 0
19+
20+
21+
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
devices:
3+
samplerate: 48000
4+
chunksize: 1024
5+
target_level: 1024
6+
adjust_period: 3
7+
enable_resampling: true
8+
resampler_type: BalancedAsync
9+
capture_samplerate: 44100
10+
capture:
11+
type: Alsa
12+
channels: 2
13+
device: "hw:Loopback,0,0"
14+
format: S16LE
15+
playback:
16+
type: Alsa
17+
channels: 2
18+
device: "hw:Generic_1"
19+
format: S32LE
20+
21+
22+

overview.png

66 KB
Loading

0 commit comments

Comments
 (0)