Skip to content

quantize: restore short-window masking penalty to fix energy drops#103

Merged
fabiangreffrath merged 1 commit into
knik0:masterfrom
nschimme:fix-energy-drop
May 15, 2026
Merged

quantize: restore short-window masking penalty to fix energy drops#103
fabiangreffrath merged 1 commit into
knik0:masterfrom
nschimme:fix-energy-drop

Conversation

@nschimme
Copy link
Copy Markdown
Contributor

Commit 577c649 ("initial windows grouping support") split bmask() into short- and long-window branches and introduced target *= 1.5 for short blocks. This inflated the psychoacoustic masking threshold 50%, causing the quantizer to allocate too few bits during transients and producing audible energy drops.

Restore the pre-577c6499 multiplier of SHORT_PENALTY (0.45), which tightens the masking target for short-window blocks. Extract the formula constants as named macros: NOISETONE (noise-floor weight), TONEMASK (tone-masking component weight), and SHORT_PENALTY (short-window quality penalty) — keeping them separate so each can be tuned independently.

Benchmark report shows no performance changes but some changes in psychoacoustic model as expected where the benefits outweigh the negatives: https://github.com/nschimme/faac/actions/runs/25871625558

Commit 577c649 ("initial windows grouping support") split bmask() into
short- and long-window branches and introduced `target *= 1.5` for short
blocks. This inflated the psychoacoustic masking threshold 50%, causing
the quantizer to allocate too few bits during transients and producing
audible energy drops.

Restore the pre-577c6499 multiplier of SHORT_PENALTY (0.45), which
tightens the masking target for short-window blocks. Extract the formula
constants as named macros: NOISETONE (noise-floor weight), TONEMASK
(tone-masking component weight), and SHORT_PENALTY (short-window quality
penalty) — keeping them separate so each can be tuned independently.
@nschimme
Copy link
Copy Markdown
Contributor Author

nschimme commented May 14, 2026

@enzo1982 can you please validate that this resolves the issue #40? I loaded it in Audacity and confirmed it but I thought I had done that beforehand in the last fix too.

@enzo1982
Copy link
Copy Markdown
Contributor

@nschimme yes, I can confirm that this fixes the issue. Thank you very much for investigating this again!

@nschimme
Copy link
Copy Markdown
Contributor Author

@fabiangreffrath we're safe to merge then :-)

@fabiangreffrath fabiangreffrath merged commit 82dfc42 into knik0:master May 15, 2026
6 checks passed
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.

3 participants