Skip to content

Fix volume filter normalization applying gain to the first sample only - #1351

Merged
ddennedy merged 1 commit into
mltframework:masterfrom
eseifert:fix-volume-normalize-s16-samples
Oct 25, 2026
Merged

ddennedy merged 1 commit into
mltframework:masterfrom
eseifert:fix-volume-normalize-s16-samples

Conversation

@eseifert

Copy link
Copy Markdown
Contributor

Since channel_mask was added, the s16 normalize path read and wrote p[0] for every sample instead of the sample of the current channel. The audio was left unscaled while the first sample was multiplied repeatedly, and whenever the gain was above 1 every sample was replaced by a value derived from that first sample, which turned the signal into a near constant. Regressed in 3412c3f.

Reproduced by a -30 dBFS tone through volume gain=normalize that came out as a near-constant square wave on master (8 zero crossings, peak 32767), a properly scaled sine with the fix (66 zero crossings, peak 10360).

Since channel_mask was added, the s16 normalize path read and wrote p[0] for every sample instead of the sample of the current channel. The audio was left unscaled while the first sample was multiplied repeatedly, and whenever the gain was above 1 every sample was replaced by a value derived from that first sample, which turned the signal into a near constant. Regressed in 3412c3f.
@ddennedy

Copy link
Copy Markdown
Member

Thank you for the fix. FYI, the normalize function of the volume filter is deprecated as documented https://mltframework.org/plugins/FilterVolume/

@ddennedy ddennedy added this to the v7.44.0 milestone Oct 25, 2026
@ddennedy
ddennedy merged commit bfe970d into mltframework:master Oct 25, 2026
15 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.

2 participants