parameter fine tuning
This commit is contained in:
parent
47681a28f0
commit
8995541fda
3 changed files with 59 additions and 6 deletions
|
@ -564,6 +564,47 @@ impl DelayBuffer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// translated from Odin 2 Synthesizer Plugin
|
||||||
|
// Copyright (C) 2020 TheWaveWarden
|
||||||
|
// under GPLv3 or any later
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct DCBlockFilter {
|
||||||
|
xm1: f64,
|
||||||
|
ym1: f64,
|
||||||
|
R: f64,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DCBlockFilter {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
xm1: 0.0,
|
||||||
|
ym1: 0.0,
|
||||||
|
R: 0.995,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reset(&mut self) {
|
||||||
|
self.xm1 = 0.0;
|
||||||
|
self.ym1 = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_sample_rate(&mut self, srate: f32) {
|
||||||
|
self.R = 0.995;
|
||||||
|
if srate > 90000.0 {
|
||||||
|
self.R = 0.9965;
|
||||||
|
} else if srate > 120000.0 {
|
||||||
|
self.R = 0.997;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn next(&mut self, input: f32) -> f32 {
|
||||||
|
let y = input as f64 - self.xm1 + self.R * self.ym1;
|
||||||
|
self.xm1 = input as f64;
|
||||||
|
self.ym1 = y;
|
||||||
|
y as f32
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
@ -298,7 +298,13 @@ macro_rules! r_ems { ($x: expr, $coarse: expr) => {
|
||||||
/// The rounding function for milliseconds knobs
|
/// The rounding function for milliseconds knobs
|
||||||
macro_rules! r_tms { ($x: expr, $coarse: expr) => {
|
macro_rules! r_tms { ($x: expr, $coarse: expr) => {
|
||||||
if $coarse {
|
if $coarse {
|
||||||
|
if d_time!($x) > 1000.0 {
|
||||||
|
n_time!((d_time!($x) / 100.0).round() * 100.0)
|
||||||
|
} else if d_time!($x) > 100.0 {
|
||||||
|
n_time!((d_time!($x) / 10.0).round() * 10.0)
|
||||||
|
} else {
|
||||||
n_time!((d_time!($x)).round())
|
n_time!((d_time!($x)).round())
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
n_time!((d_time!($x) * 10.0).round() / 10.0)
|
n_time!((d_time!($x) * 10.0).round() / 10.0)
|
||||||
}
|
}
|
||||||
|
@ -363,7 +369,7 @@ define_exp!{n_declick d_declick 0.0, 50.0}
|
||||||
|
|
||||||
define_exp!{n_env d_env 0.0, 1000.0}
|
define_exp!{n_env d_env 0.0, 1000.0}
|
||||||
|
|
||||||
define_exp!{n_time d_time 0.0, 5000.0}
|
define_exp!{n_time d_time 0.5, 5000.0}
|
||||||
|
|
||||||
// Special linear gain factor for the Out node, to be able
|
// Special linear gain factor for the Out node, to be able
|
||||||
// to reach more exact "1.0".
|
// to reach more exact "1.0".
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
use crate::nodes::{NodeAudioContext, NodeExecContext};
|
use crate::nodes::{NodeAudioContext, NodeExecContext};
|
||||||
use crate::dsp::{NodeId, SAtom, ProcBuf, DspNode, LedPhaseVals};
|
use crate::dsp::{NodeId, SAtom, ProcBuf, DspNode, LedPhaseVals};
|
||||||
use crate::dsp::helpers::{DelayBuffer, crossfade};
|
use crate::dsp::helpers::{DelayBuffer, crossfade, DCBlockFilter};
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! fa_dly_s { ($formatter: expr, $v: expr, $denorm_v: expr) => { {
|
macro_rules! fa_dly_s { ($formatter: expr, $v: expr, $denorm_v: expr) => { {
|
||||||
|
@ -31,6 +31,7 @@ macro_rules! fa_dly_s { ($formatter: expr, $v: expr, $denorm_v: expr) => { {
|
||||||
pub struct Delay {
|
pub struct Delay {
|
||||||
buffer: Box<DelayBuffer>,
|
buffer: Box<DelayBuffer>,
|
||||||
fb_sample: f32,
|
fb_sample: f32,
|
||||||
|
dcblock: DCBlockFilter,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Delay {
|
impl Delay {
|
||||||
|
@ -38,6 +39,7 @@ impl Delay {
|
||||||
Self {
|
Self {
|
||||||
buffer: Box::new(DelayBuffer::new()),
|
buffer: Box::new(DelayBuffer::new()),
|
||||||
fb_sample: 0.0,
|
fb_sample: 0.0,
|
||||||
|
dcblock: DCBlockFilter::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,10 +84,12 @@ impl DspNode for Delay {
|
||||||
|
|
||||||
fn set_sample_rate(&mut self, srate: f32) {
|
fn set_sample_rate(&mut self, srate: f32) {
|
||||||
self.buffer.set_sample_rate(srate);
|
self.buffer.set_sample_rate(srate);
|
||||||
|
self.dcblock.set_sample_rate(srate);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reset(&mut self) {
|
fn reset(&mut self) {
|
||||||
self.buffer.reset();
|
self.buffer.reset();
|
||||||
|
self.dcblock.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -97,6 +101,7 @@ impl DspNode for Delay {
|
||||||
use crate::dsp::{out, inp, denorm};
|
use crate::dsp::{out, inp, denorm};
|
||||||
|
|
||||||
let buffer = &mut *self.buffer;
|
let buffer = &mut *self.buffer;
|
||||||
|
let dcblock = &mut self.dcblock;
|
||||||
|
|
||||||
let inp = inp::Delay::inp(inputs);
|
let inp = inp::Delay::inp(inputs);
|
||||||
let time = inp::Delay::time(inputs);
|
let time = inp::Delay::time(inputs);
|
||||||
|
@ -116,8 +121,9 @@ impl DspNode for Delay {
|
||||||
denorm::Delay::time(time, frame));
|
denorm::Delay::time(time, frame));
|
||||||
|
|
||||||
out.write(frame,
|
out.write(frame,
|
||||||
|
dcblock.next(
|
||||||
crossfade(dry, out_sample,
|
crossfade(dry, out_sample,
|
||||||
denorm::Delay::mix(mix, frame).clamp(0.0, 1.0)));
|
denorm::Delay::mix(mix, frame).clamp(0.0, 1.0))));
|
||||||
|
|
||||||
fb_s = out_sample;
|
fb_s = out_sample;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue