Repository navigation
fix(plugin): show saved IR, pitch and filters when the editor opens - #298
Conversation
There was a problem hiding this comment.
🟡 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()andsaved_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.rsinitialize()to usesaved_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. |

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.
initialize()and the editor now share that IR precedence throughRustortionParams::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
PluginApp::new, which hardcoded these values.After:
make lintandmake testpass. Two new tests inparams.rs: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.