From: Anthony Minessale Date: Wed, 3 May 2017 20:25:04 +0000 (-0500) Subject: FS-9922: [mod_conference] Auto Energy Level X-Git-Tag: v1.8.0~535 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfe1a84c3995e1b46718e30b41a595c6c1c39599;p=thirdparty%2Ffreeswitch.git FS-9922: [mod_conference] Auto Energy Level --- diff --git a/src/mod/formats/mod_local_stream/mod_local_stream.c b/src/mod/formats/mod_local_stream/mod_local_stream.c index 1a0d015d12..8edba9aa94 100644 --- a/src/mod/formats/mod_local_stream/mod_local_stream.c +++ b/src/mod/formats/mod_local_stream/mod_local_stream.c @@ -1404,7 +1404,7 @@ SWITCH_STANDARD_API(local_stream_function) stream->write_function(stream, "-ERR invalid auto-volume level for stream: %s\n", source->name); } else { if (!source->agc) { - switch_agc_create(&source->agc, source->energy_avg, source->energy_low, 10, 3, (1000 / source->interval) * 2); + switch_agc_create(&source->agc, source->energy_avg, source->energy_low, 500, 3, (1000 / source->interval) * 2); } else { switch_agc_set_energy_avg(source->agc, source->energy_avg); switch_agc_set_energy_low(source->agc, source->energy_low); diff --git a/src/switch_resample.c b/src/switch_resample.c index bd981f626f..c9e1dc9759 100644 --- a/src/switch_resample.c +++ b/src/switch_resample.c @@ -513,15 +513,23 @@ SWITCH_DECLARE(switch_status_t) switch_agc_feed(switch_agc_t *agc, int16_t *data agc->score_count = 0; agc->score_sum = 0; - if (agc->score_avg > agc->energy_avg + agc->margin) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "[%s] OVER++ SCORE AVG: %d ENERGY AVG: %d MARGIN: %d\n", - agc->token, agc->score_avg, agc->energy_avg, agc->margin); - agc->score_over++; + if (agc->score_avg > agc->energy_avg) { + if (agc->score_avg - agc->energy_avg > agc->margin) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "[%s] OVER++ SCORE AVG: %d ENERGY AVG: %d MARGIN: %d\n", + agc->token, agc->score_avg, agc->energy_avg, agc->margin); + agc->score_over++; + } } else { agc->score_over = 0; } - if (agc->score_avg < agc->energy_avg - agc->margin && (agc->vol < 0 || agc->score_avg > agc->low_energy_point)) { + if (agc->score_avg < agc->low_energy_point) { + agc->score_under = agc->change_factor + 1; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "[%s] BELOW LOW POINT, SCORE AVG: %d ENERGY AVG: %d MARGIN: %d\n", + agc->token, agc->score_avg, agc->energy_avg, agc->margin); + } else if (((agc->score_avg < agc->energy_avg) && (agc->energy_avg - agc->score_avg > agc->margin))) { + //&& (agc->vol < 0 || agc->score_avg > agc->low_energy_point)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "[%s] UNDER++ SCORE AVG: %d ENERGY AVG: %d MARGIN: %d\n", agc->token, agc->score_avg, agc->energy_avg, agc->margin); agc->score_under++; @@ -536,10 +544,12 @@ SWITCH_DECLARE(switch_status_t) switch_agc_feed(switch_agc_t *agc, int16_t *data agc->vol--; switch_normalize_volume_granular(agc->vol); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "[%s] VOL DOWN %d\n", agc->token, agc->vol); + //agc->score_over = 0; } else if (agc->score_under > agc->change_factor) { agc->vol++; switch_normalize_volume_granular(agc->vol); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "[%s] VOL UP %d\n", agc->token, agc->vol); + //agc->score_under = 0; } }