Skip to content

Comments

Add Level Stage#19

Merged
OpenSauce merged 1 commit intomainfrom
17-add-level-stage
Jun 14, 2025
Merged

Add Level Stage#19
OpenSauce merged 1 commit intomainfrom
17-add-level-stage

Conversation

@OpenSauce
Copy link
Owner

@OpenSauce OpenSauce commented Jun 14, 2025

This pull request introduces a new "Level" stage to the amplifier simulation and GUI. The changes include adding support for the Level stage in both the simulation backend and the user interface, enabling users to adjust the gain parameter for this stage. Below is a summary of the most important changes grouped by theme:

Backend Simulation Enhancements:

  • Added a new LevelStage struct in src/sim/stages/level.rs, implementing the Stage trait to process audio samples with a configurable gain parameter.
  • Updated src/sim/stages/mod.rs to include the level module in the simulation stages.

GUI Integration:

  • Added a new level_widget function in src/gui/widgets/level.rs to create the user interface for configuring the Level stage. This includes a slider for adjusting the gain parameter.
  • Updated src/gui/widgets/mod.rs to include the level module in the GUI widgets.
  • Modified src/gui/amp.rs to integrate the Level stage into the GUI, including updates to StageType, StageConfig, Message, and the AmplifierGui implementation to handle Level stage configuration and updates. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

Closes #17

Copilot AI review requested due to automatic review settings June 14, 2025 21:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new “Level” stage to both the simulation backend and the GUI, allowing users to adjust a gain parameter.

  • Backend: Introduces LevelStage implementing Stage with a configurable gain.
  • GUI: Adds level_widget for the Level stage slider, integrates messaging, default config, and chain construction.
  • Module imports and enums updated to include the new Level stage.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/sim/stages/mod.rs Registered the new level module under stages
src/sim/stages/level.rs Added LevelStage struct and Stage trait impl
src/gui/widgets/mod.rs Included level in GUI widgets registry
src/gui/widgets/level.rs Created UI widget for adjusting Level gain
src/gui/amp.rs Integrated Level in StageType, StageConfig, Message, GUI view/update, and audio chain
Comments suppressed due to low confidence (4)

src/sim/stages/level.rs:3

  • There are no unit tests for LevelStage. Consider adding tests that cover process, set_parameter (including boundary cases), and get_parameter to ensure correct behavior and prevent regressions.
pub struct LevelStage {

src/sim/stages/level.rs:3

  • Public API types like LevelStage would benefit from doc comments explaining its purpose and the valid parameter range for gain.
pub struct LevelStage {

src/sim/stages/level.rs:36

  • [nitpick] The error messages are inconsistent ("Unknown parameter" vs "Unknown parameter name"). Consider using a single format, e.g., Err("Unknown parameter: {name}"), to aid debugging.
_ => Err("Unknown parameter"),

src/gui/amp.rs:392

  • The pattern here may copy the LevelConfig instead of mutating the original. You should match the mutable reference, for example:
if let Some(StageConfig::Level(cfg)) = self.stages.get_mut(idx) {
    cfg.gain = gain;
}

using StageConfig::Level(cfg) where cfg is a &mut LevelConfig (e.g., ref mut cfg) to ensure the field is actually updated.

if let Some(StageConfig::Level(cfg)) = self.stages.get_mut(idx) {

@OpenSauce OpenSauce merged commit b01f055 into main Jun 14, 2025
2 checks passed
@OpenSauce OpenSauce deleted the 17-add-level-stage branch June 14, 2025 21:34
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.

Add Input and Output Level Stages

1 participant