Fix GCC-PHAT normalization pointer desync in beamformer#92
Open
goyalpalak18 wants to merge 2 commits intoeembc:mainfrom
Open
Fix GCC-PHAT normalization pointer desync in beamformer#92goyalpalak18 wants to merge 2 commits intoeembc:mainfrom
goyalpalak18 wants to merge 2 commits intoeembc:mainfrom
Conversation
Signed-off-by: goyalpalak18 <goyalpalak1806@gmail.com>
Contributor
|
Thank you for reporting this issue. |
Signed-off-by: goyalpalak18 <goyalpalak1806@gmail.com>
Author
|
@llefaucheur Makes sense. Dropped my old logic and applied your fix. Pushed. |
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.
File + Function
src/ee_abf_f32.cbeamformer_f32_run()Exact Problem
I noticed that the PHAT normalization loop uses a
continueto skip zero-magnitude bins, but it only advances thePHATNORMread pointer (pf32_1) and totally forgets to advance theXYcomplex array write pointer (pf32_2). Every time a bin has a zero magnitude,pf32_1advances butpf32_2stays put. The moment we hit a single zero bin, the pointers desync. From that point forward, every single division applies the wrong bin's magnitude to the wrongXYcomplex pair.Root Cause
This boils down to two compounding errors:
max(abs(XY), 1e-12)to guaranteePHATNORMis never zero. We missed this clamp in the C implementation, allowingth_cmplx_mag_f32()to output exact zeros.continuestatement skipspf32_2 += 2. The intent was right, but it violates the loop invariant sincepf32_2still needs to advance to stay in sync withpf32_1.Impact After Fix
XYbin by its corresponding magnitude.icorr) is finally accurate.