2
$\begingroup$

I mix audio(16bit,16khz, little-endian, mono,frame-duration:60ms) packets after dividing the short values by participant count so it never gets clipped. but before that, I need to apply a certain gain to all incoming voices so that they stay at the same level. and even after mixing I again have to apply certain gain to mixed audio so that the voice remains smooth and at a certain volume.

Now, as the voice level changes, all the time for all participants the "Gain" is not constant and I have to calculate this dynamic/auto-gain all the time (from samples or RMS of a short array?). How can I do this or implement logic? I tried reading webRTC AGC modules but it's too complex for me to understand. Atleast suggest me any resource that can be helpful in this regard. Thanks in advance.

$\endgroup$

1 Answer 1

2
$\begingroup$

after dividing the short values by participant count so it never gets clipped

That's not a great idea, you are loosing a lot of SNR this way. I recommend running the processing in floating point are 32-bit fixed point and only reducing it to 16-bit when you create the output of the algorithm

I tried reading webRTC AGC modules but it's too complex for me to understand.

That is unfortunate. Speech AGC is a fairly complicated problem, at least if you need a good one. It's been well research though. As a quick outline: you need a voice activity detector, an envelope or energy detector, a non-linear gain curve, a mixing stage and another non-linear gain (compressor/limiter) to manage the output level. The details of each block are highly dependent on the requirements of your specific application.

At least suggest me any resource that can be helpful in this regard.

  1. Here is whitepaper from TI, it's dated but at least it's open https://www.ti.com/litv/pdf/spraal1
  2. Some good analysis on the webRTC AGC https://chowdera.com/2021/06/20210615125737495y.html
$\endgroup$
3
  • 1
    $\begingroup$ Thanks a lot for the useful info. I asked this type of question in stack overflow and got really heartbroken not getting the expected response. I will certainly look into those and ask back if ran into problems. $\endgroup$ Dec 29, 2021 at 2:14
  • 1
    $\begingroup$ I gave a thought about the way you said to do the calculation of mixing in 32-bit float but at the end, I am converting it to the short right? it loses data and what if there are lots of participants and mixed voice overflows short most of the time. That won't be a good experience I guess. I could have done that and later reduced it by a certain factor by calculating the top peak and highest short range if it was recorded audio. But this is real-time and the top peak always changes over time? won't the audio quality will be lost there too as the volume will be tuned to avoid overflows? $\endgroup$ Dec 29, 2021 at 3:12
  • 1
    $\begingroup$ Just use a regular audio limiter. A good one will handle this well. $\endgroup$
    – Hilmar
    Dec 29, 2021 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.