feat: save and load ir_gain and last selected preset#152
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds persistence for IR gain values in presets and remembers the last selected preset across application restarts. The changes enable users to save their IR cabinet gain settings as part of presets and automatically load their most recently used preset when the application starts.
- Added
ir_gainfield to thePresetstructure with serde default support for backward compatibility - Added
selected_presetfield toSettingsto persist the last opened preset - Updated preset loading/saving flow to handle IR gain values throughout the application
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/settings/mod.rs | Added selected_preset field to persist the last selected preset name |
| src/preset/mod.rs | Added ir_gain field with default value of 0.1 and updated constructor signature |
| src/gui/handlers/preset.rs | Updated preset handler to propagate ir_gain through save/load operations and made load_preset_by_name public |
| src/gui/components/ir_cabinet_control.rs | Updated constructor to accept gain parameter instead of hardcoding the default value |
| src/gui/app.rs | Added logic to load last selected preset on startup, save selected preset to settings, and pass ir_gain to preset operations |
| presets/Sabbath.json | Added ir_name and ir_gain fields to the preset |
| presets/Petrucci.json | Added ir_gain field to the preset |
Comments suppressed due to low confidence (1)
src/gui/app.rs:67
- The IR gain from the loaded preset is set on the UI component but is never applied to the audio engine during initialization. After setting up the IR cabinet control with the preset's ir_gain on line 54, you should also call
audio_manager.engine().set_ir_gain(preset.ir_gain)to ensure the audio engine uses the correct gain value when the app starts.
let mut ir_cabinet_control = IrCabinetControl::new(settings.ir_bypassed, preset.ir_gain);
ir_cabinet_control.set_available_irs(audio_manager.get_available_irs());
if settings.ir_bypassed {
audio_manager.engine().set_ir_bypass(true);
}
if let Some(ir_name) = preset.ir_name {
ir_cabinet_control.set_selected_ir(Some(ir_name.clone()));
audio_manager.engine().set_ir_cabinet(Some(ir_name));
} else if let Some(first_ir) = ir_cabinet_control.get_selected_ir() {
ir_cabinet_control.set_selected_ir(Some(first_ir.clone()));
audio_manager.engine().set_ir_cabinet(Some(first_ir));
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.