Smoothen AudioBridge mix instead of clamping/truncating (see #3593 and #3601)#3610
Smoothen AudioBridge mix instead of clamping/truncating (see #3593 and #3601)#3610
Conversation
|
In this approach there is no smooth transition between audio segments. Each segment has it's own gain which knows nothing about other gains, so transition between segments would be very rough. In AGC previous segments affect scale factors and transition is clean and smooth. |
|
Moreover, there is only one gain value for the whole segment, so if we have a single spike inside normal segment - entire segment will be scaled. |
|
Yes, it is a more simplified approach, but it's also hundreds of less lines of code and no dependency 😅 Anything that gets merged I have to mantain, which means I need to know what the code does, which is harder to do with too many changes I have little control on. Did you have a chance to test this patch with multiple voices, or was this an analysis just by looking at the code? |
|
I didn't test this PR, just looked at the code, but I have some experience with simple approaches to audio processing (long story short, they work only in a very limited cases, but not in real life). |
|
So, tried commit ab93ea0 with same audio that I used in my tests (4 tabs with same audio input and 1 tab in another browser that listens) |
|
@m08pvv ack, thanks for testing, for its simpler approach it was worth a try 😅 |
| } | ||
|
|
||
| /* Helper to limit/clamp mixed audio */ | ||
| static inline void janus_audiobridge_limit_mix(opus_int32 *sumBuffer, opus_int16 *outBuffer, int samples) { |
There was a problem hiding this comment.
These are overkill and not reliable. 1 random false noise could make whole mixing result worse.

Tentative patch to try and more properly limit the mix the AudioBridge prepares, in presence of loud(er) contributions. This is an attempt to try and do something similar as #3593 (but without the external libwebrtc dependency), also taking into account the cap proposed in #3601 (in order never to clip). See #3593 (comment) for details.
I tested this briefly and it seems to be doing its job, but it will need to be properly tested in all the different potential AudioBridge configurations, most importantly with stereo and/or grouping too. Recording seems fine, forwarders will need to be evaluated.