From 159e437e5a3f48d97584e711e3b6163adb9cdff5 Mon Sep 17 00:00:00 2001 From: Richard Mudgett Date: Thu, 21 Jul 2016 22:28:25 -0500 Subject: dsp.c: Fix erroneous fax tone detection. The Goertzel calculations get less accurate the lower the signal level being worked with becomes because there is less resolution remaining. If it is too low we can erroneously detect a tone where none really exists. The searched for fax frequencies not only need to be so much stronger than the background noise they must also be a minimum strength. * Add needed minimum threshold test to tone_detect(). * Set TONE_THRESHOLD to allow low volume frequency spread detection. ASTERISK-26237 #close Reported by: Richard Mudgett Change-Id: I84dbba7f7628fa13720add6a88eae3b129e066fc --- main/dsp.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'main/dsp.c') diff --git a/main/dsp.c b/main/dsp.c index 087416358..18f2a22d8 100644 --- a/main/dsp.c +++ b/main/dsp.c @@ -171,8 +171,7 @@ enum gsamp_thresh { */ #define DTMF_THRESHOLD 8.0e7 -#define FAX_THRESHOLD 8.0e7 -#define FAX_2ND_HARMONIC 2.0 /* 4dB */ +#define TONE_THRESHOLD 7.8e7 #define DEF_DTMF_NORMAL_TWIST 6.31 /* 8.0dB */ #define DEF_RELAX_DTMF_NORMAL_TWIST 6.31 /* 8.0dB */ @@ -187,8 +186,6 @@ enum gsamp_thresh { #define DTMF_RELATIVE_PEAK_ROW 6.3 /* 8dB */ #define DTMF_RELATIVE_PEAK_COL 6.3 /* 8dB */ -#define DTMF_2ND_HARMONIC_ROW (relax ? 1.7 : 2.5) /* 4dB normal */ -#define DTMF_2ND_HARMONIC_COL 63.1 /* 18dB */ #define DTMF_TO_TOTAL_ENERGY 42.0 #define BELL_MF_THRESHOLD 1.6e9 @@ -583,7 +580,8 @@ static int tone_detect(struct ast_dsp *dsp, tone_detect_state_t *s, int16_t *amp ast_debug(10, "tone %d, Ew=%.2E, Et=%.2E, s/n=%10.2f\n", s->freq, tone_energy, s->energy, tone_energy / (s->energy - tone_energy)); hit = 0; - if (tone_energy > s->energy * s->threshold) { + if (TONE_THRESHOLD <= tone_energy + && tone_energy > s->energy * s->threshold) { ast_debug(10, "Hit! count=%d\n", s->hit_count); hit = 1; } -- cgit v1.2.3