Repository navigation
fix: sum true-stereo convolver results at unity gain - #1455
Conversation
WPT non-regression comparisonPASS — no regressions · 0 improved section(s) · overall 3431 → 3431 (0) Unchanged sections (28)
Baseline: Workflow run · this comment is updated on every push. |
maciejmakowski2003
left a comment
There was a problem hiding this comment.
good job! I have added a few nits
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
C++ coverageSmoke suites, Clang source-based coverage.
Lines changed in this pull request
Uncovered changed linespackages/react-native-audio-api/common/cpp/audioapi/core/effects/ConvolverNode.cppLines 137-146 137 audioBuffer_->getChannel(channel % busChannels)
138 ->sum(*intermediateBuffer_->getChannel(channel), 0, 0, RENDER_QUANTUM_SIZE, gain);
139 }
140 } else {
! 141 audioBuffer_->sum(*intermediateBuffer_);
! 142 }
143
144 internalBuffer_->copy(*audioBuffer_, 0, internalBufferIndex_, RENDER_QUANTUM_SIZE);
145 internalBufferIndex_ += RENDER_QUANTUM_SIZE;
146 }Workflow run · this comment is updated on every push. |
WPT non-regression comparisonPASS — no regressions · 0 improved section(s) · overall 3431 → 3431 (0) Unchanged sections (28)
Baseline: Workflow run · this comment is updated on every push. |
Closes #1454
normalize = falseand a 4-channel impulse response, the output rises 6 dB and now matches Chrome. Output withnormalize = trueis unchanged.Introduced changes
ConvolverNode::processNodeadds the four true-stereo results itself (L = 0 + 2,R = 1 + 3) at unity gain. Before,AudioBuffer::sumtreated them as a quad speaker layout and down-mixed them with 0.5.clamped-max) the four results are added with 0.5, the average of the stereo pair. Before, the 4 → 1 down-mix applied 0.25.calculateNormalizationScalemultiplies by 0.5 for a 4-channel response, like the// True-stereo compensationstep in Chrome'sCalculateNormalizationScale(reverb.cc). The 0.5 moves from the down-mix into the scale, so the normalized level stays the same.ConvolverTrueStereoTest.cppwith four cases: stereo and mono bus,normalizeon and off..claude/skills/utilities/SKILL.md: a two-line note thatsum()andcopy()apply speaker mixing gains between different channel counts.Measured with a constant input (stereo: L = 0.5, R = 0.25; mono: 0.5) and a 4-channel response of single-sample impulses with gains 1.0, 0.5, 0.25, 0.75:
normalizemainfalsetruefalsetrueChecklist
ConvolverNode)Tests:
ConvolverTrueStereoTest: the twonormalize = falsecases fail onmain(0.28125 vs 0.5625 stereo, 0.3125 vs 0.625 mono) and pass here. The twonormalize = truecases pass on both, which pins the unchanged level.yarn test:cpp: 612 tests pass on top ofd846d5c.clang-format23 (--dry-run --Werror) andcpplintwith the flags fromscripts/cpplint.sh: clean on the two changed C++ files.OfflineAudioContextscript in ConvolverNode: 4-channel (true stereo) impulse response is 6 dB quieter than Chrome when normalize is off #1454.Summary by CodeRabbit