fix: improve max amplitude detection and global_gain range#53
Merged
fix: improve max amplitude detection and global_gain range#53
Conversation
- Fix iterate_frames to skip Xing/Info VBR header frames This matches mp3gain behavior and reports correct global_gain range - Add find_peak_amplitude function in replaygain.rs Decodes audio using Symphonia to measure actual PCM peak values - Update find_max_amplitude to use audio decoding when replaygain feature enabled Falls back to global_gain estimation when feature is disabled - Add clipping warning for MP3 files when peak is at 1.0 Symphonia's MP3 decoder clips samples to [-1.0, 1.0], so peaks > 1.0 cannot be detected. Warning informs users that actual peak may be higher. - Output Max PCM sample in 32768 scale (mp3gain compatible) Note: Issue #52 (MP3 peak capping) is a Symphonia limitation where the decoder clamps output samples. AAC/M4A files correctly report peaks > 1.0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #51 and partially addresses #52.
Changes
Issue #51: find_max_amplitude reports incorrect values
Fixed
iterate_framesto skip Xing/Info VBR header framesAdded
find_peak_amplitudefunction in replaygain.rsUpdated
find_max_amplitudeto use audio decodingOutput format now shows
Max PCM samplein 32768 scaleIssue #52: MP3 peak value capped at 1.0
synthesis.rsTesting
Tested with various MP3 and M4A files:
Limitations
Issue #52 cannot be fully resolved without modifying Symphonia's MP3 decoder. The decoder's clamp at [-1.0, 1.0] is a design decision in
symphonia-bundle-mp3/src/synthesis.rs:Potential future solutions: