implementation of DAFX one pole

This commit is contained in:
Weird Constructor 2021-07-10 22:30:43 +02:00
parent 92853ec1ea
commit 7a869e57f5
3 changed files with 30 additions and 5 deletions

View file

@ -582,7 +582,7 @@ macro_rules! node_list {
sfilter => SFilter UIType::Generic UICategory::Signal
(0 inp n_id d_id r_id f_def stp_d -1.0, 1.0, 0.0)
(1 freq n_pit d_pit r_fq f_freq stp_d -1.0, 0.5647131, 1000.0)
{2 0 ftype setting(0) fa_sfilter_type 0 1}
{2 0 ftype setting(0) fa_sfilter_type 0 2}
[0 sig],
test => Test UIType::Generic UICategory::IOUtil
(0 f n_id d_id r_id f_def stp_d 0.0, 1.0, 0.5)

View file

@ -109,6 +109,22 @@ impl DspNode for SFilter {
out.write(frame, (m0 * input + m1 * v2) as f32);
}
},
// from DAFX by will pirkle:
2 => {
for frame in 0..ctx.nframes() {
let input = inp.read(frame) as f64;
let o =
(-std::f64::consts::TAU
* (denorm::SFilter::freq(freq, frame) as f64)
* self.israte).cos();
let y = 2.0 - o;
let b = (y * y - 1.0).sqrt() - y;
let a = 1.0 + b;
self.z = a * input - b * self.z;
out.write(frame, self.z as f32);
}
}
_ => {},
}
}

View file

@ -44,10 +44,19 @@ fn check_node_sfilter_compare() {
let ta = std::time::Instant::now().duration_since(ta);
println!("ta2 Elapsed: {:?}", ta);
let fft = run_and_get_fft4096(&mut node_exec, 5, 1000.0);
for (fq, lvl) in fft {
println!("{:5}: {}", fq, lvl);
}
pset_s(&mut matrix, sf, "ftype", 2);
let ta = std::time::Instant::now();
let (out_l, _) = run_for_ms(&mut node_exec, 10000.0);
save_wav("check_noise_sfilt3.wav", &out_l);
let ta = std::time::Instant::now().duration_since(ta);
println!("ta3 Elapsed: {:?}", ta);
// let fft = run_and_get_fft4096(&mut node_exec, 5, 1000.0);
// for (fq, lvl) in fft {
// println!("{:5}: {}", fq, lvl);
// }
// let fft = run_and_get_fft4096(&mut node_exec, 50, 1000.0);
// assert!(fft.len() == 0);