Skip to content

feat(volume-leveling): add volume leveling control and dsp processing#481

Open
bule2015 wants to merge 16 commits into
fxsound2:develop/windowsfrom
bule2015:feature/volume-normalization
Open

feat(volume-leveling): add volume leveling control and dsp processing#481
bule2015 wants to merge 16 commits into
fxsound2:develop/windowsfrom
bule2015:feature/volume-normalization

Conversation

@bule2015

@bule2015 bule2015 commented Mar 10, 2026

Copy link
Copy Markdown

Summary

This PR adds a new Volume Leveling control to FxSound and wires it through the DSP path.

Changes

  • add a Volume Leveling slider to the audio settings UI with a 0.0 to 4.0 dB range
  • persist the new setting in FxController and restore it on startup and reset-to-defaults
  • add DSP-side volume leveling state and public API plumbing in DfxDsp
  • implement volume leveling in the GraphicEq / SOS processing path
  • support stereo and surround playback, with LFE excluded from surround volume leveling
  • apply smoothed gain changes, per-buffer gain ramping, and peak limiting in the SOS processor
  • reapply all EQ bands, including band 0, after preset loads so the lowest band is not left stale
  • remove duplicate icon declarations from resources.rc
  • adjust the settings dialog height so the new control is fully visible
  • slow the gain-reduction attack so rising material feels less constrained
  • add short-window RMS averaging and bounded prediction to reduce detector jitter
  • To reduce over-compression caused by low-end buildup, adds sidechain HPF detection, two-stage release, per-buffer max gain-reduction limiting, and proper sidechain state reset in volume leveling.
  • add dedicated SOS state for tonal and headroom-aware volume leveling, including persistent tonality scoring and long-window headroom tracking
  • adapt the volume leveling detector to account for tonal balance, so muffled material can recover more level while clearer material is held back earlier
  • adjust the effective target RMS and ceiling dynamically based on recent headroom pressure, instead of treating all material with the same leveling target
  • guard tonal compensation with available headroom, so tonal shaping does not over-push dense mixes that are already close to the output ceiling
  • cache sample-rate-dependent volume leveling detector coefficients to reduce repeated per-buffer work without changing output behavior
  • retain a quiet gain floor after volume leveling has spent at least 10 seconds outputting very quiet material, so newly recovered audibility is not dropped immediately
  • track a rolling 30-second post-leveling peak window and slowly raise the retained quiet floor when safe headroom is still available
  • keep the existing peak-safe gain limiting and hard ceiling clamp in place while applying the new quiet-floor behavior

@bule2015 bule2015 force-pushed the feature/volume-normalization branch from 6789230 to 3550451 Compare March 21, 2026 14:58
@bule2015 bule2015 marked this pull request as draft March 21, 2026 15:49
The resource script contained a duplicated block of tray icon declarations.
Keeping the cleanup separate keeps the volume leveling review focused on the new DSP and UI changes.
Add DSP state, API plumbing, and SOS processing for the new volume leveling control.
This commit keeps the audio path changes isolated so reviewers can focus on the algorithm without the settings UI mixed in.
Load and persist the new volume leveling setting through FxController, and add a slider to the audio settings pane.
Keeping the UI wiring separate from the DSP commit makes the review boundary between behavior and presentation explicit.
Increase the dialog height enough to keep the new control visible, but base the pane layout on the actual component height so the extra space stays bounded.
This stays separate from the volume leveling UI commit because it is a follow-up layout adjustment.
Add field comments for the volume leveling RMS target and gain so the new SOS state matches the surrounding documentation style.
This keeps the change reviewable as a pure documentation follow-up with no behavior changes.
@bule2015 bule2015 force-pushed the feature/volume-normalization branch from 3550451 to 6907ef5 Compare March 21, 2026 17:25
@bule2015 bule2015 changed the title feat: implement volume normalization with surround and hard limiter support feat(volume-leveling): add volume leveling control and dsp processing Mar 21, 2026
Preset reloads were replaying EQ state from band 1 onward, which left the lowest band stale.
Separating this fix from volume leveling keeps the audio regression review easy to follow.
@bule2015 bule2015 marked this pull request as ready for review March 21, 2026 23:21
Slow the gain-reduction attack in volume leveling.

This reduces how quickly the DSP pulls level down on rising material,
which keeps playback from feeling overly constrained while leaving the
existing release path intact.
Refine volume leveling with short-window averaging and bounded prediction.

Use a 6-buffer RMS history to stabilize the detector, add a small clamped
look-ahead step, and drop the prediction offset on buffers where the prior
prediction clearly missed.
@bule2015 bule2015 force-pushed the feature/volume-normalization branch from ba45039 to 65fd4c2 Compare March 21, 2026 23:32
add a sidechain high-pass detector and two-stage release behavior so low-end buildup and large gain rebounds do not collapse harmonics. also cap per-buffer gain reduction and reset sidechain state with volume leveling state.

Made-with: Cursor
add tonality and headroom state to the sos handle.

initialize and reset the new state alongside the existing volume leveling fields so later dsp changes can use it safely.
use tonal balance and recent headroom pressure to steer volume leveling.

this updates the sos volume leveling path to estimate muffled versus clear material, adjust the effective target rms and ceiling, and smooth the resulting headroom score over time.
limit tonal upward and downward adjustments when recent headroom is tight.

this keeps the tonal detector from pushing target rms or ceiling changes too hard when the mix is already close to the output ceiling.
Cache the sample-rate-dependent coefficients used by the volume leveling detector and sidechain paths.

This avoids recalculating the same values on every buffer while keeping the existing equations and output behavior unchanged.
Keep a retained quiet gain floor after volume leveling spends at least 10 seconds outputting very quiet material.

This preserves the gain reached by quiet boosting instead of dropping back immediately once the output becomes audible, while still respecting the existing peak-safe ceiling protection.
Track a rolling 30-second post-leveling peak window and use it to slowly raise the retained quiet floor when there is still safe output headroom.

This lets extremely quiet material move closer to the output ceiling over time without bypassing the existing peak-safe gain limiting and hard ceiling clamp.
ealtun21 added a commit to ealtun21/fxsound-app that referenced this pull request Jun 3, 2026
…und2#481)

adds a volume leveling slider (0–4 dB) in audio settings backed by a
full dsp-side implementation in the sos processing layer:

- sidechain high-pass filter (120 hz) isolates program content from
  sub-bass energy before computing rms
- tonal detection (low / body / presence / air bands) adjusts the
  effective target and ceiling based on whether content is muffled or
  clear; avoids over-brightening classical and over-darkening edm
- gradient prediction smooths gain changes and backs off quickly when
  the prediction misses, preventing pumping artefacts
- headroom tracker (60 s window) biases the target up when the ceiling
  is rarely touched and down when it is under repeated pressure
- quiet-floor retention: after 10 s of very-quiet content the leveler
  boosts gain up to 10x and retains a gain floor so resumed silence
  does not immediately collapse volume
- per-buffer gain ramp eliminates zipper noise; hard ceiling clip guards
  against digital overs
- surround support: lfe channel (index 3) excluded from analysis and
  gain application; stereo path uses -1 sentinel (all channels)
- fixes setPreset band loop to start at band 0 not band 1
- always runs graphiceqprocess for valid channel counts so normalization
  gain is applied even when eq is bypassed

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bvijay74

Copy link
Copy Markdown
Member

Please retarget this PR to develop/windows branch

@bule2015 bule2015 changed the base branch from main to develop/windows June 28, 2026 02:49
@bule2015 bule2015 force-pushed the feature/volume-normalization branch from 7d4566c to 715ded6 Compare June 28, 2026 15:00
@bule2015

Copy link
Copy Markdown
Author

I retargeted this PR to the updated base branch and merged the latest changes. The merge conflicts have been resolved, and I updated the implementation to follow the recent Settings dialog changes, including keeping the volume leveling controls aligned with the new Audio/Equalizer settings layout.

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