Skip to content

fix: correct 32000 Hz filter coefficients to match original gain_analysis.c#45

Merged
M-Igashi merged 2 commits intomasterfrom
fix/32000hz-filter-coefficients
Jan 16, 2026
Merged

fix: correct 32000 Hz filter coefficients to match original gain_analysis.c#45
M-Igashi merged 2 commits intomasterfrom
fix/32000hz-filter-coefficients

Conversation

@M-Igashi
Copy link
Owner

Summary

This PR fixes incorrect 32000 Hz filter coefficients that did not match the original gain_analysis.c reference implementation.

Problem

As reported in #42, the 32000 Hz filter coefficients in mp3rgain did not match those in the original ReplayGain reference implementation. The first B coefficient was 0.00549836071843 but should have been 0.15457299681924.

Changes

  • Updated YULE_B_32000 coefficients to match ABYule[5] from gain_analysis.c
  • Updated BUTTER_A_32000 coefficients to match ABButter[5] from gain_analysis.c
  • Updated BUTTER_B_32000 coefficients to match ABButter[5] from gain_analysis.c
  • Added source comments for clarity

Verification

The coefficients were extracted from the original gain_analysis.c:

  • ABYule[5] contains 21 interleaved coefficients (B[0], A[1], B[1], A[2], ...)
  • ABButter[5] contains 5 interleaved coefficients (B[0], A[1], B[1], A[2], B[2])
  • Index 5 corresponds to 32000 Hz sample rate

Fixes #42

m_igashi added 2 commits January 16, 2026 15:08
…ysis.c

The previous 32000 Hz coefficients were incorrect and their source was
unclear. This commit updates them to match the original ReplayGain
reference implementation from gain_analysis.c.

Changes:
- Updated YULE_B_32000 coefficients (B[0] was 0.00549... but should be 0.15457...)
- Updated BUTTER_A_32000 coefficients
- Updated BUTTER_B_32000 coefficients
- Added source comments for clarity

The coefficients are extracted from ABYule[5] and ABButter[5] in
gain_analysis.c where index 5 corresponds to 32000 Hz sample rate.

Fixes #42
The test_stereo.mp3 fixture contained APE tags (MP3GAIN_UNDO and
MP3GAIN_MINMAX) which caused test_undo_without_previous_gain to fail.
This test expects the file to have no APE tag.

Removed the APE tag to restore the fixture to a clean state.
@M-Igashi M-Igashi merged commit 58231b2 into master Jan 16, 2026
9 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.

32000 Hz filter coefficients need verification

1 participant