removed DC blocker from delay, was a bad idea if you want to delay CV....

This commit is contained in:
Weird Constructor 2021-06-20 09:12:02 +02:00
parent 8995541fda
commit 63644b00da
2 changed files with 9 additions and 15 deletions

View file

@ -571,7 +571,7 @@ impl DelayBuffer {
pub struct DCBlockFilter {
xm1: f64,
ym1: f64,
R: f64,
r: f64,
}
impl DCBlockFilter {
@ -579,7 +579,7 @@ impl DCBlockFilter {
Self {
xm1: 0.0,
ym1: 0.0,
R: 0.995,
r: 0.995,
}
}
@ -589,16 +589,16 @@ impl DCBlockFilter {
}
pub fn set_sample_rate(&mut self, srate: f32) {
self.R = 0.995;
self.r = 0.995;
if srate > 90000.0 {
self.R = 0.9965;
self.r = 0.9965;
} else if srate > 120000.0 {
self.R = 0.997;
self.r = 0.997;
}
}
pub fn next(&mut self, input: f32) -> f32 {
let y = input as f64 - self.xm1 + self.R * self.ym1;
let y = input as f64 - self.xm1 + self.r * self.ym1;
self.xm1 = input as f64;
self.ym1 = y;
y as f32

View file

@ -4,7 +4,7 @@
use crate::nodes::{NodeAudioContext, NodeExecContext};
use crate::dsp::{NodeId, SAtom, ProcBuf, DspNode, LedPhaseVals};
use crate::dsp::helpers::{DelayBuffer, crossfade, DCBlockFilter};
use crate::dsp::helpers::{DelayBuffer, crossfade};
#[macro_export]
macro_rules! fa_dly_s { ($formatter: expr, $v: expr, $denorm_v: expr) => { {
@ -31,7 +31,6 @@ macro_rules! fa_dly_s { ($formatter: expr, $v: expr, $denorm_v: expr) => { {
pub struct Delay {
buffer: Box<DelayBuffer>,
fb_sample: f32,
dcblock: DCBlockFilter,
}
impl Delay {
@ -39,7 +38,6 @@ impl Delay {
Self {
buffer: Box::new(DelayBuffer::new()),
fb_sample: 0.0,
dcblock: DCBlockFilter::new(),
}
}
@ -84,12 +82,10 @@ impl DspNode for Delay {
fn set_sample_rate(&mut self, srate: f32) {
self.buffer.set_sample_rate(srate);
self.dcblock.set_sample_rate(srate);
}
fn reset(&mut self) {
self.buffer.reset();
self.dcblock.reset();
}
#[inline]
@ -101,7 +97,6 @@ impl DspNode for Delay {
use crate::dsp::{out, inp, denorm};
let buffer = &mut *self.buffer;
let dcblock = &mut self.dcblock;
let inp = inp::Delay::inp(inputs);
let time = inp::Delay::time(inputs);
@ -121,9 +116,8 @@ impl DspNode for Delay {
denorm::Delay::time(time, frame));
out.write(frame,
dcblock.next(
crossfade(dry, out_sample,
denorm::Delay::mix(mix, frame).clamp(0.0, 1.0))));
crossfade(dry, out_sample,
denorm::Delay::mix(mix, frame).clamp(0.0, 1.0)));
fb_s = out_sample;
}