--- a/src/audiofilters/msvolume.c 2013-01-14 16:13:45.000000000 +0100 +++ b/src/audiofilters/msvolume.c 2014-01-07 02:52:31.956299139 +0100 @@ -69,6 +69,7 @@ float ng_threshold; float ng_floorgain; float ng_gain; + float agc_threshold; MSBufferizer *buffer; bool_t agc_enabled; bool_t noise_gate_enabled; @@ -101,6 +102,7 @@ v->ng_threshold=noise_thres; v->ng_floorgain=min_ng_floorgain; v->ng_gain = 1; + v->agc_threshold = agc_threshold; v->remove_dc=FALSE; #ifdef HAVE_SPEEXDSP v->speex_pp=NULL; @@ -153,7 +155,7 @@ static float volume_agc_process(Volume *v, mblk_t *om) { static int counter; // target is: 1 - float gain_reduct = (agc_threshold + v->level_pk) / 1; + float gain_reduct = (v->agc_threshold + v->level_pk) / 1; /* actual gain ramp timing the same as with echo limiter process */ if (!(++counter % 20)) ms_debug("_level=%f, gain reduction=%f, gain=%f, ng_gain=%f %f %f", @@ -281,6 +283,21 @@ return 0; } +static int volume_set_agc_threshold(MSFilter *f, void *arg){ + Volume *v=(Volume*)f->data; + float val = *(float*)arg; + + if (val < 0 || val > 1) { + ms_error("Error: agc threshold must be in range [0..1]"); + + return -1; + } + + v->agc_threshold = val; + + return 0; +} + static int volume_set_ea_threshold(MSFilter *f, void*arg){ Volume *v=(Volume*)f->data; float val=*(float*)arg; @@ -511,6 +528,7 @@ { MS_VOLUME_SET_EA_TRANSMIT_THRESHOLD, volume_set_ea_transmit_threshold }, { MS_FILTER_SET_SAMPLE_RATE, volume_set_sample_rate }, { MS_VOLUME_ENABLE_AGC , volume_set_agc }, + { MS_VOLUME_SET_AGC_THRESHOLD, volume_set_agc_threshold}, { MS_VOLUME_ENABLE_NOISE_GATE, volume_enable_noise_gate}, { MS_VOLUME_SET_NOISE_GATE_THRESHOLD, volume_set_noise_gate_threshold}, { MS_VOLUME_SET_NOISE_GATE_FLOORGAIN, volume_set_noise_gate_floorgain}, --- a/include/mediastreamer2/msvolume.h 2011-04-05 12:55:43.000000000 +0200 +++ b/include/mediastreamer2/msvolume.h 2014-01-07 02:49:30.400295504 +0100 @@ -69,6 +69,8 @@ #define MS_VOLUME_SET_EA_TRANSMIT_THRESHOLD MS_FILTER_METHOD(MS_VOLUME_ID,17,float) +#define MS_VOLUME_SET_AGC_THRESHOLD MS_FILTER_METHOD(MS_VOLUME_ID,18,float) + #define MS_VOLUME_DB_LOWEST (-120) /*arbitrary value returned when linear volume is 0*/