added the resonator from FunDSP

This commit is contained in:
Weird Constructor 2021-08-05 05:25:10 +02:00
parent 7d27d6f618
commit f8be4ca565
2 changed files with 8 additions and 3 deletions

View file

@ -645,7 +645,7 @@ macro_rules! node_list {
(1 freq n_pit d_pit r_fq f_freq stp_d -1.0, 0.5647131, 1000.0)
(2 q n_id d_id r_id f_def stp_d 0.0, 1.0, 0.5)
(3 gain n_ogin d_ogin r_id f_def stp_d 0.0, 1.0, 1.0)
{4 0 ftype setting(0) fa_biqfilt_type 0 0}
{4 0 ftype setting(0) fa_biqfilt_type 0 1}
{5 1 order setting(0) fa_biqfilt_ord 0 3}
[0 sig],
test => Test UIType::Generic UICategory::IOUtil

View file

@ -11,6 +11,7 @@ macro_rules! fa_biqfilt_type { ($formatter: expr, $v: expr, $denorm_v: expr) =>
let s =
match ($v.round() as usize) {
0 => "BtW LP",
1 => "Res",
_ => "?",
};
write!($formatter, "{}", s)
@ -60,7 +61,7 @@ impl BiqFilt {
pub const gain : &'static str =
"BiqFilt gain\nFilter gain.\nRange: (0..1)\n";
pub const ftype : &'static str =
"BiqFilt ftype\n";
"BiqFilt ftype\n'BtW LP' Butterworth Low-Pass, 'Res' Resonator";
pub const order : &'static str =
"BiqFilt order\n";
pub const sig : &'static str =
@ -130,6 +131,7 @@ impl DspNode for BiqFilt {
// recalculate coeffs of all in the cascade
let coefs =
match ftype {
1 => BiquadCoefs::resonator(self.srate, cfreq, cq),
_ => BiquadCoefs::butter_lowpass(self.srate, cfreq),
};
@ -144,7 +146,10 @@ impl DspNode for BiqFilt {
self.ogain = cgain;
}
let order = order.i() as u8;
let mut order = order.i() as u8;
if ftype == 1 { // The resonator just blows up with higher orders.
order = 0;
}
for frame in 0..ctx.nframes() {
let freq = denorm::BiqFilt::freq(freq, frame);