fix: GetBandGainDB when a group center lands exactly on an octave band - #28
Open
lmtanco wants to merge 1 commit into
Open
fix: GetBandGainDB when a group center lands exactly on an octave band#28lmtanco wants to merge 1 commit into
lmtanco wants to merge 1 commit into
Conversation
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
CGammatoneMultibandExpander::GetBandGainDBinterpolates a group band's staticattenuation between its two neighbouring octave bands using two weights that always sum to 1. The branching only covers weights that are negative (the edge sentinels used by
SetGroups) or strictly positive:When a group's reconstructed centre frequency (the geometric mean of its two limits, computed in
SetGroups) lands exactly on one of the expander's internal octave bands, one of the two weights is exactly 0.0f. That case falls through to the else branch and silently returns 0.0f, discarding the band's configured attenuation, even though the correct value is just that of the other interpolation term (the other weight is exactly 1.0f).For example with the limits {500, 2000} Hz the reconstructed centre is exactly 1000.0 Hz (500 * 2000 = 1e6, and its square root are both representable exactly as floats), so the band centred at 1000 Hz would lose its static attenuation.
Fix
Just use
>=0instead of>0in the interpolation branch, as the formula is correct when one weight is 0 and the other is 1.How to test