diff --git a/src/editor.rs b/src/editor.rs index 40929c8..558fcb5 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -549,7 +549,7 @@ impl View for DelayGraph { let target_time_scaling_factor = Self::compute_time_scaling_factor(¶ms); let gui_decay_weight = Self::calculate_gui_decay_weight(¶ms); - let available_width = bounds.w - outline_width - border_width * 2.0; + let available_width = border_width.mul_add(-2.0, bounds.w - outline_width); let time_scaling_factor = (Self::gui_smooth( target_time_scaling_factor, ¶ms.previous_time_scaling_factor, @@ -887,7 +887,7 @@ impl DelayGraph { bounds.x + x_offset, bounds.y + border_width, line_width, - bounds.h - border_width * 2.0, + border_width.mul_add(-2.0, bounds.h), ), None, ); @@ -920,7 +920,7 @@ impl DelayGraph { line_width: f32, border_width: f32, ) { - let available_height = bounds.h - border_width * 2.0; + let available_height = border_width.mul_add(-2.0, bounds.h); // Calculate and draw input meter let input_db = util::gain_to_db(input_meter.load(Ordering::Relaxed)); let input_height = { @@ -948,7 +948,7 @@ impl DelayGraph { (tick_fraction * available_height).max(0.0) }; path = vg::Path::new(); - let x_val = bounds.x + bounds.w - border_width - 0.5 * line_width; + let x_val = 0.5f32.mul_add(-line_width, bounds.x + bounds.w - border_width); path.move_to((x_val, bounds.y + bounds.h - border_width)); path.line_to((x_val, bounds.y + bounds.h - border_width - output_height)); // let x_val = line_width.mul_add(-0.5, bounds.x + bounds.w); @@ -976,7 +976,7 @@ impl DelayGraph { border_width: f32, ) { let tap_counter = params.tap_counter.load(Ordering::SeqCst); - let available_height = bounds.h - border_width * 2.0; + let available_height = border_width.mul_add(-2.0, bounds.h); let (r, g, b) = (velocity_color.r(), velocity_color.g(), velocity_color.b()); let ambient_color = Color::rgba(r, g, b, BLUE_GLOW_ALPHA); @@ -1258,7 +1258,7 @@ impl DelayGraph { pan_foreground_path.add_rect( vg::Rect::from_xywh( note_center_x, - note_center_y - line_width * 0.35, + line_width.mul_add(-0.35, note_center_y), pan_foreground_length, line_width * 0.7, ), diff --git a/src/lib.rs b/src/lib.rs index e508a37..58bb14b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1457,9 +1457,9 @@ impl Del2 { fn v2s_f32_hz_then_khz_three_digits() -> Arc String + Send + Sync> { Arc::new(move |value| { if value < 100.0 { - format!("{:.1} Hz", value) + format!("{value:.1} Hz") } else if value < 1000.0 { - format!("{:.0} Hz", value) + format!("{value:.0} Hz") } else if value < 10000.0 { format!("{:.2} kHz", value / 1000.0) } else { diff --git a/src/svf_simper.rs b/src/svf_simper.rs index ea1b767..cfae07b 100644 --- a/src/svf_simper.rs +++ b/src/svf_simper.rs @@ -52,13 +52,13 @@ impl SVFSimper { pub fn new(cutoff: f32, resonance: f32, sample_rate: f32) -> Self { let g = (consts::PI * (cutoff / sample_rate)).tan(); // let k = 2f32 - (1.9f32 * resonance.min(1f32).max(0f32)); - let k = 2f32 - (2.0f32 * resonance.min(1f32).max(0f32)); + let k = 2.0f32.mul_add(-resonance.min(1f32).max(0f32), 2f32); - let a1 = 1.0 / (1.0 + (g * (g + k))); + let a1 = 1.0 / g.mul_add(g + k, 1.0); let a2 = g * a1; let a3 = g * a2; - SVFSimper { + Self { a1: f32x4::splat(a1), a2: f32x4::splat(a2), a3: f32x4::splat(a3),