Optimize bDelayPan and divisions#3706
Conversation
| if ( ( i & 1 ) == 0 ) | ||
| { | ||
| // if even : left channel | ||
| vecfIntermProcBuf[i] += vecsData[i] * fGainL; | ||
| } | ||
| else | ||
| { | ||
| // if odd : right channel | ||
| vecfIntermProcBuf[i] += vecsData[i] * fGainR; | ||
| } |
There was a problem hiding this comment.
Got rid of modulo computation
c6038cc to
ccd6f5e
Compare
ann0see
left a comment
There was a problem hiding this comment.
The function is still way too complex imo.
|
To avoid having the clipping to short twice, we may want someting like Maybe... |
|
I will study this code soon and make any comments... |
softins
left a comment
There was a problem hiding this comment.
OK, to be certain, I made separate copies of the MixEncodeTransmitData function, two from main and two from this PR. I then edited one of each to remove the if (bDelayPan) sections and the other one of each to remove the corresponding else sections instead.
I was then able to compare the "before" and "after" with no delaypan, and the "before" and "after" with delaypan, ignoring whitespace, to be sure the logic was still exactly the same in each case. I am satisfied that it is.
So this PR preserves exactly the existing behaviour of Jamulus, appears to be potentially cleaner and more efficient, and I'm approving it for merging as-is on this basis.
I think any proposal to modify and potentially improve the design of this function should be a separate PR, discussed and thoroughly tested on its own merits.
pljones
left a comment
There was a problem hiding this comment.
OK, you're right, comparing the full files makes it easier.
It's the mono/stereo and delayPan if statements that are swapped so you do all of delayPan (with mono and stereo versions) and then all of !delayPan (with mono and stereo versions), which does make more sense.
I still prefer the / 2 (rather, / 2f - having cast to float and targeting a vector of floats) to * 0.5f for readability. "Half of" is an easier concept than "50% of".
855d378 to
84609cf
Compare
Short description of changes
Moves delay pan checking slightly out of loop as this setting does not change often.
Moreover replaces some divisions with /2.0f and remove some modulo computations
CHANGELOG: Server: Optimize mixing
Context: Fixes an issue?
Related to: #3662
Does this change need documentation? What needs to be documented and how?
No
Status of this Pull Request
Ready for review
What is missing until this pull request can be merged?
Tested and it seems to work, I still would like an external test.
Checklist