Skip to content

fix(plugin): show saved IR, pitch and filters when the editor opens - #298

Merged
OpenSauce merged 1 commit into
mainfrom
fix/plugin-editor-restored-settings
Nov 1, 2026
Merged

OpenSauce merged 1 commit into
mainfrom
fix/plugin-editor-restored-settings

Conversation

@OpenSauce

Copy link
Copy Markdown
Owner

Summary

The editor opened with defaults for settings the engine had already restored, so the UI disagreed with the audio. Touching one input filter control also sent the displayed defaults for the other filter settings, overwriting the real values.

 PluginApp::new
-  pitch_shift_control = PitchShiftControl::new(0)
+  pitch_shift_control = PitchShiftControl::new(params.pitch_shift)
-  input_filter_config = InputFilterConfig::default()
+  input_filter_config = params.input_filters()
   if restoring stored stages
+    selected_ir = saved IR, else the preset's IR

initialize() and the editor now share that IR precedence through RustortionParams::saved_ir_or.

If neither a saved nor a preset IR exists, the Cabinet tab now reports no IR loaded instead of showing the first in the list. The engine hasn't loaded one in that case.

Not covered: an editor that is already open still doesn't follow host automation or state restores.

Evidence

  • Before: not reproduced in a host. Found by reading PluginApp::new, which hardcoded these values.
    After: make lint and make test pass. Two new tests in params.rs:
input_filters_map_each_param_to_its_field   # default params == InputFilterConfig::default()
saved_ir_takes_precedence_over_the_preset   # picked > preset > none

Not tested in a DAW. nih-plug doesn't let tests set parameter values and nothing exercises PluginApp::new, so the seeding itself needs a manual check: change the IR, pitch shift and a filter cutoff, save, reopen the project, and confirm the controls match.

Merge Danger

Door: two-way

No change to the saved state format.

Blast Radius: plugin-editor

Plugin only; the standalone is untouched. The risk is the editor showing the wrong initial values on restore.

Copilot AI balanced review requested due to automatic review settings November 1, 2026 16:07
@OpenSauce
OpenSauce merged commit 96fb6cb into main Nov 1, 2026
11 checks passed
@OpenSauce
OpenSauce deleted the fix/plugin-editor-restored-settings branch November 1, 2026 16:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

An unresolved active finding remains, flagging that the comment's rationale is inaccurate since only the cutoff swap—not the identical enabled-flag defaults—is actually guarded by the test.

1 open issue
What changed in this PR

This PR fixes the VST3/CLAP plugin editor so that when it opens, its controls reflect the settings the engine has already restored (saved IR, pitch shift, and HP/LP input filters) instead of hardcoded defaults. Previously PluginApp::new seeded PitchShiftControl::new(0) and InputFilterConfig::default(), causing the UI to disagree with the audio and to overwrite real filter values when any one filter control was touched. The IR-precedence logic (user pick → preset → none) is centralized into a new RustortionParams::saved_ir_or helper shared by both initialize() and the editor.

Changes:

  • Add RustortionParams::input_filters() and saved_ir_or() helpers plus two unit tests.
  • Seed the editor's pitch-shift and input-filter controls from the live params, and select the restored IR (saved or preset) when stored stages exist.
  • Refactor lib.rs initialize() to use saved_ir_or, keeping engine and editor IR selection consistent.
File Description
rustortion-plugin/​src/​params.rs Adds input_filters() and saved_ir_or() helpers and tests covering filter mapping and IR precedence.
rustortion-plugin/​src/​lib.rs Replaces inline IR lock/fallback in initialize() with the shared saved_ir_or helper.
rustortion-plugin/​src/​editor.rs Seeds pitch-shift and input-filter controls from params and selects the restored IR on editor open.

I reviewed the type compatibility (pitch_shift IntParam → i32, bool/f32 filter params → InputFilterConfig), confirmed the saved_ir_or refactor is behavior-equivalent to the removed inline logic, and verified set_selected_ir(None) correctly surfaces "no IR loaded" via the cabinet status. One minor documentation issue was flagged on a test comment whose "all differ" claim doesn't hold for the two boolean *_enabled defaults.

Review effort: Balanced


#[test]
fn input_filters_map_each_param_to_its_field() {
// HP and LP defaults all differ, so a swapped field fails this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants