From 6f14af5293c187c3f3644870f861632935658f5c Mon Sep 17 00:00:00 2001 From: Weird Constructor Date: Sat, 10 Jul 2021 22:48:20 +0200 Subject: [PATCH] apply better clamping for the tpt filters --- src/dsp/node_sfilter.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/dsp/node_sfilter.rs b/src/dsp/node_sfilter.rs index 4ed006d..9772b32 100644 --- a/src/dsp/node_sfilter.rs +++ b/src/dsp/node_sfilter.rs @@ -88,7 +88,8 @@ impl DspNode for SFilter { 0 => { for frame in 0..ctx.nframes() { let input = inp.read(frame) as f64; - let freq = (denorm::SFilter::freq(freq, frame) as f64); + let freq = denorm::SFilter::freq(freq, frame) as f64; + let freq = freq.clamp(10.0, 22050.0); out.write(frame, process_1pole_lowpass( input, freq, self.israte, &mut self.z) @@ -98,7 +99,8 @@ impl DspNode for SFilter { 1 => { for frame in 0..ctx.nframes() { let input = inp.read(frame) as f64; - let freq = (denorm::SFilter::freq(freq, frame) as f64); + let freq = denorm::SFilter::freq(freq, frame) as f64; + let freq = freq.clamp(10.0, 18000.0); out.write(frame, process_1pole_tpt_lowpass( input, freq, self.israte, &mut self.z) @@ -108,7 +110,8 @@ impl DspNode for SFilter { 2 => { for frame in 0..ctx.nframes() { let input = inp.read(frame) as f64; - let freq = (denorm::SFilter::freq(freq, frame) as f64); + let freq = denorm::SFilter::freq(freq, frame) as f64; + let freq = freq.clamp(10.0, 22050.0); out.write(frame, process_1pole_highpass( input, freq, self.israte, &mut self.z, &mut self.y) @@ -118,7 +121,8 @@ impl DspNode for SFilter { 3 => { for frame in 0..ctx.nframes() { let input = inp.read(frame) as f64; - let freq = (denorm::SFilter::freq(freq, frame) as f64); + let freq = denorm::SFilter::freq(freq, frame) as f64; + let freq = freq.clamp(10.0, 18000.0); out.write(frame, process_1pole_tpt_highpass( input, freq, self.israte, &mut self.z)