implementation of DAFX one pole
This commit is contained in:
parent
92853ec1ea
commit
7a869e57f5
3 changed files with 30 additions and 5 deletions
|
@ -582,7 +582,7 @@ macro_rules! node_list {
|
||||||
sfilter => SFilter UIType::Generic UICategory::Signal
|
sfilter => SFilter UIType::Generic UICategory::Signal
|
||||||
(0 inp n_id d_id r_id f_def stp_d -1.0, 1.0, 0.0)
|
(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)
|
(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],
|
[0 sig],
|
||||||
test => Test UIType::Generic UICategory::IOUtil
|
test => Test UIType::Generic UICategory::IOUtil
|
||||||
(0 f n_id d_id r_id f_def stp_d 0.0, 1.0, 0.5)
|
(0 f n_id d_id r_id f_def stp_d 0.0, 1.0, 0.5)
|
||||||
|
|
|
@ -109,6 +109,22 @@ impl DspNode for SFilter {
|
||||||
out.write(frame, (m0 * input + m1 * v2) as f32);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => {},
|
_ => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,10 +44,19 @@ fn check_node_sfilter_compare() {
|
||||||
let ta = std::time::Instant::now().duration_since(ta);
|
let ta = std::time::Instant::now().duration_since(ta);
|
||||||
println!("ta2 Elapsed: {:?}", ta);
|
println!("ta2 Elapsed: {:?}", ta);
|
||||||
|
|
||||||
let fft = run_and_get_fft4096(&mut node_exec, 5, 1000.0);
|
|
||||||
for (fq, lvl) in fft {
|
pset_s(&mut matrix, sf, "ftype", 2);
|
||||||
println!("{:5}: {}", fq, lvl);
|
|
||||||
}
|
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);
|
// let fft = run_and_get_fft4096(&mut node_exec, 50, 1000.0);
|
||||||
// assert!(fft.len() == 0);
|
// assert!(fft.len() == 0);
|
||||||
|
|
Loading…
Reference in a new issue