diff --git a/plugins/diopser/CHANGELOG.md b/plugins/diopser/CHANGELOG.md index 2fd30e73..2da66090 100644 --- a/plugins/diopser/CHANGELOG.md +++ b/plugins/diopser/CHANGELOG.md @@ -13,3 +13,4 @@ Versioning](https://semver.org/spec/v2.0.0.html). - On Windows, clicking on the plugin's name no longer takes you to Spectral Compressor's home page. This is a temporary workaround for an issue with an underlying library. +- Rendering the GUI now takes slightly less resources. diff --git a/plugins/diopser/src/editor/analyzer.rs b/plugins/diopser/src/editor/analyzer.rs index 52378967..9a7c9701 100644 --- a/plugins/diopser/src/editor/analyzer.rs +++ b/plugins/diopser/src/editor/analyzer.rs @@ -87,9 +87,13 @@ impl View for SpectrumAnalyzer { let nyquist = self.sample_rate.load(Ordering::Relaxed) / 2.0; // This skips background and border drawing + // NOTE: We could do the same thing like in Spectral Compressor and draw part of this + // spectrum analyzer as a single mesh but for whatever erason the aliasing/moire + // pattern here doesn't look nearly as bad. let line_width = cx.style.dpi_factor as f32 * 1.5; let paint = vg::Paint::color(cx.font_color().cloned().unwrap_or_default().into()) .with_line_width(line_width); + let mut path = vg::Path::new(); for (bin_idx, magnitude) in spectrum.iter().enumerate() { // We'll match up the bin's x-coordinate with the filter frequency parameter let frequency = (bin_idx as f32 / spectrum.len() as f32) * nyquist; @@ -106,14 +110,13 @@ impl View for SpectrumAnalyzer { let magnitude_db = nih_plug::util::gain_to_db(*magnitude); let height = ((magnitude_db + 80.0) / 100.0).clamp(0.0, 1.0); - let mut path = vg::Path::new(); path.move_to( bounds.x + (bounds.w * t), bounds.y + (bounds.h * (1.0 - height)), ); path.line_to(bounds.x + (bounds.w * t), bounds.y + bounds.h); - - canvas.stroke_path(&mut path, &paint); } + + canvas.stroke_path(&mut path, &paint); } }