]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
dsp.c: Fix erroneous fax tone detection. 34/3334/1
authorRichard Mudgett <rmudgett@digium.com>
Fri, 22 Jul 2016 03:28:25 +0000 (22:28 -0500)
committerRichard Mudgett <rmudgett@digium.com>
Tue, 26 Jul 2016 16:55:58 +0000 (11:55 -0500)
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

index d9ce16167f94943c1fc391c97bc55c268c73de22..86094a339e51b133100d3fb5bef5532863813f78 100644 (file)
@@ -161,8 +161,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 */
@@ -177,8 +176,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
@@ -574,7 +571,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;
                }