PJSIP Automatic Gain Control

PJSIP Automatic Gain Control

2014-04-26 Dennis Guse

PJSIP contains an un-documentated feature that does volume adjustments during media-flow.

The conference bridge contains a very basic Automatic Gain Control that adjusts the volume level of each to-be-mixed signals, if the volume difference to the previous frame is to large.

It is however implement as define-directive in the C-code and thus enabled during compile time.

Here is the code:

 1 #define ATTACK_A    (conf->clock_rate / conf->samples_per_frame)
 2 #define ATTACK_B    1
 3 #define DECAY_A     0
 4 #define DECAY_B     1
 5 
 6 #define SIMPLE_AGC(last, target) \
 7     if (target >= last) \
 8     target = (ATTACK_A*(last+1)+ATTACK_B*target)/(ATTACK_A+ATTACK_B); \
 9     else \
10     target = (DECAY_A*last+DECAY_B*target)/(DECAY_A+DECAY_B)
11 
12 #define MAX_LEVEL   (32767)
13 #define MIN_LEVEL   (-32768)
14 
15 #define IS_OVERFLOW(s) ((s > MAX_LEVEL) || (s < MIN_LEVEL))

The investigation for this feature started as some severe "quality changes" (during a call the sound got quantizied heavily with a lower volume) unexpectetedly occured using PJSIP under perfect conditions:

  • Edirol UA-25EX
  • Beyer Dynamics DT-290
  • noise-free room (laboratory)
  • Dummy head
  • Operation System: Ubuntu 13.10

Finding and disabling the AGC lead us to another issue that was masked by it. Somehow the EchoCanceler kicks in after around 5s seconds of continuous speech and the resulting signal is sounds heavily reduced in volume (spectogram is similar to original signal). And the AGC increases the volume again fast enough leading to "quantisation"-like sound.

So disabling the EchoCanceler (a runtime option) as well as (just to be sure) the AGC fixes the problem.

Thanks to Frank Haase for his support and wisdom!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值