Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
chore: update code to reflect valib changes
Browse files Browse the repository at this point in the history
  • Loading branch information
SolarLiner committed Sep 2, 2024
1 parent 9725f3c commit ed7f164
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 15 deletions.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ opt-level = 1
opt-level = 0

[profile.release]
lto = "thin"
codegen-units = 1
lto = "fat"
strip = "symbols"
opt-level = 3

[profile.profiling]
inherits = "release"
Expand Down
18 changes: 7 additions & 11 deletions src/dsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,18 @@ use valib::dsp::{blocks::Bypass, BlockAdapter, DSPMeta, DSPProcess, DSPProcessBl
use valib::filters::statespace::StateSpace;
use valib::math::smooth_clamp;
use valib::oversample::{Oversample, Oversampled};
use valib::saturators::{Bjt, Saturator, Slew};
use valib::saturators::{bjt, Saturator};
use valib::simd::{
AutoF64x2, AutoSimd, SimdBool, SimdComplexField, SimdPartialOrd, SimdValue,
};
use valib::Scalar;

use clipping::ClippingStage;
use crate::params::MAX_AGE;

mod clipping;

fn emitter_follower_input<T: Scalar>() -> Bjt<T> {
Bjt {
fn emitter_follower_input<T: Scalar>() -> bjt::CommonCollector<T> {
bjt::CommonCollector {
vee: T::zero(),
vcc: T::from_f64(9.),
xbias: T::from_f64(3.75041272),
Expand Down Expand Up @@ -102,7 +101,7 @@ impl InputLevelMatching {
pub struct InputStage<T: Scalar> {
pub gain: SmoothedParam,
state_space: StateSpace<T, 1, 1, 1>,
clip: Bjt<T>,
clip: bjt::CommonCollector<T>,
}

impl<T: Scalar> DSPMeta for InputStage<T> {
Expand Down Expand Up @@ -261,7 +260,6 @@ type DspInner<T> = SwitchAB<

pub struct Dsp<T: Scalar<Element: Float>> {
inner: Oversampled<T, BlockAdapter<DspInner<T>>>,
samplerate: T,
}

impl<T: Scalar<Element: Float>> DSPMeta for Dsp<T> {
Expand Down Expand Up @@ -323,10 +321,9 @@ where
Complex<T>: SimdComplexField,
<T as SimdValue>::Element: ToPrimitive,
{
pub fn new(base_samplerate: f32, _target_samplerate: f32) -> RemoteControlled<Self> {
//let oversample = target_samplerate / base_samplerate;
//let oversample = oversample.ceil() as usize;
let oversample = 1;
pub fn new(base_samplerate: f32, target_samplerate: f32) -> RemoteControlled<Self> {
let oversample = target_samplerate / base_samplerate;
let oversample = oversample.ceil() as usize;
nih_log!("Requested oversample: {oversample}x");
let oversample = Oversample::new(oversample, MAX_BLOCK_SIZE);
let samplerate = base_samplerate * oversample.oversampling_amount() as f32;
Expand All @@ -348,7 +345,6 @@ where
1e3,
Dsp {
inner,
samplerate: T::from_f64(samplerate as _),
},
)
}
Expand Down
16 changes: 15 additions & 1 deletion src/dsp/clipping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,21 @@ impl<T: Scalar<Element: Float>> Stage3<T> {
pub fn new(samplerate: T) -> Self {
let iin = rcsource(T::from_f64(51e3), T::from_f64(0.));
let module = module(
diode_nr(DiodeClipper::new_silicon(1, 1, T::zero())),
node({
let data = DiodeClipper::new_silicon(1, 1, T::zero());
let mut wdf = DiodeNR::from_data(data);
#[cfg(debug_assertions)]
{
wdf.max_iter = 10;
wdf.max_tolerance = T::from_f64(1e-4);
}
#[cfg(not(debug_assertions))]
{
wdf.max_iter = 100;
wdf.max_tolerance = T::from_f64(1e-6);
}
wdf
}),
parallel(iin.clone(), capacitor(samplerate, T::from_f64(51e-12))),
);
Self { module, iin }
Expand Down
6 changes: 5 additions & 1 deletion src/editor/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::sync::Arc;

use std::sync::atomic::Ordering;
use components::led::Led;
use nih_plug::prelude::*;
use nih_plug_vizia::vizia::prelude::*;
Expand Down Expand Up @@ -48,6 +48,10 @@ pub(crate) fn create(
labelled_node_float(cx, false, params, |params| &params.component_matching);
})
.class("small");
Binding::new(cx, AppData::drive_led, |cx, drive| {
let display = drive.map(|x| format!("LED brightness: {}", x.load(Ordering::Relaxed)));
Label::new(cx, display);
});
})
.id("ui");
});
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mod gen;
mod params;
mod util;

const TARGET_SAMPLERATE: f32 = 96000.;
const TARGET_SAMPLERATE: f32 = 192000.;

type Sample = AutoF64x2;
type Sample32 = AutoF32x2;
Expand Down

0 comments on commit ed7f164

Please sign in to comment.