Skip to content

Commit

Permalink
rustify update_filter
Browse files Browse the repository at this point in the history
  • Loading branch information
magnetophon committed Nov 19, 2024
1 parent d1700e2 commit e558b64
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1095,14 +1095,15 @@ impl Del2 {
let low_params = &velocity_params.velocity_low;
let high_params = &velocity_params.velocity_high;

for delay_tap in self.delay_taps.iter_mut() {
self.delay_taps.iter_mut().for_each(|delay_tap| {
if delay_tap.is_alive {
let velocity = delay_tap.velocity;

// Unsafe block to get a mutable reference to the filter parameters
let filter_params = unsafe { Arc::get_mut_unchecked(&mut delay_tap.filter_params) };

let res = Self::lerp(low_params.res.value(), high_params.res.value(), velocity);

let velocity_cutoff = Self::log_interpolate(
low_params.cutoff.value(),
high_params.cutoff.value(),
Expand All @@ -1122,6 +1123,7 @@ impl Del2 {
util::gain_to_db(high_params.drive.value()),
velocity,
);

let drive = util::db_to_gain(drive_db);

let mode =
Expand All @@ -1136,7 +1138,7 @@ impl Del2 {
// Update filter mix mode
delay_tap.ladders.set_mix(mode);
}
}
});
}

fn lerp(a: f32, b: f32, x: f32) -> f32 {
Expand Down

0 comments on commit e558b64

Please sign in to comment.