<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][17519] </title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=17519">17519</a></dd>
<dt>Author</dt> <dd>steveu</dd>
<dt>Date</dt> <dd>2010-05-11 09:38:36 -0500 (Tue, 11 May 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fixed a typo in spandsp's msvc/inttypes.h
Updated sig_tone processing in spandsp to the latest, to allow moy to
proceed with his signaling work.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunklibsspandspsrcsig_tonec">freeswitch/trunk/libs/spandsp/src/sig_tone.c</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandspprivatesig_toneh">freeswitch/trunk/libs/spandsp/src/spandsp/private/sig_tone.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandspsig_toneh">freeswitch/trunk/libs/spandsp/src/spandsp/sig_tone.h</a></li>
<li><a href="#freeswitchtrunklibsspandsptestssig_tone_testsc">freeswitch/trunk/libs/spandsp/tests/sig_tone_tests.c</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunklibsspandspsrcsig_tonec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/sig_tone.c (17518 => 17519)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/sig_tone.c        2010-05-11 01:59:33 UTC (rev 17518)
+++ freeswitch/trunk/libs/spandsp/src/sig_tone.c        2010-05-11 14:38:36 UTC (rev 17519)
</span><span class="lines">@@ -1,8 +1,8 @@
</span><span class="cx"> /*
</span><span class="cx">  * SpanDSP - a series of DSP components for telephony
</span><span class="cx">  *
</span><del>- * sig_tone.c - Signalling tone processing for the 2280Hz, 2600Hz and similar
- *              signalling tone used in older protocols.
</del><ins>+ * sig_tone.c - Signalling tone processing for the 2280Hz, 2400Hz, 2600Hz
+ *              and similar signalling tones used in older protocols.
</ins><span class="cx">  *
</span><span class="cx">  * Written by Steve Underwood &lt;steveu@coppice.org&gt;
</span><span class="cx">  *
</span><span class="lines">@@ -23,7 +23,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: sig_tone.c,v 1.33 2009/09/04 14:38:46 steveu Exp $
</del><ins>+ * $Id: sig_tone.c,v 1.39 2010/03/11 14:22:30 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -53,6 +53,7 @@
</span><span class="cx"> #include &quot;spandsp/saturated.h&quot;
</span><span class="cx"> #include &quot;spandsp/vector_int.h&quot;
</span><span class="cx"> #include &quot;spandsp/complex.h&quot;
</span><ins>+#include &quot;spandsp/power_meter.h&quot;
</ins><span class="cx"> #include &quot;spandsp/dds.h&quot;
</span><span class="cx"> #include &quot;spandsp/super_tone_rx.h&quot;
</span><span class="cx"> #include &quot;spandsp/sig_tone.h&quot;
</span><span class="lines">@@ -62,57 +63,65 @@
</span><span class="cx"> /*! PI */
</span><span class="cx"> #define PI 3.14159265358979323
</span><span class="cx"> 
</span><del>-/* The coefficients for the data notch filter. This filter is also the
-   guard filter for tone detection. */
-
-sig_tone_descriptor_t sig_tones[4] =
</del><ins>+enum
</ins><span class="cx"> {
</span><del>-    {
-        /* 2280Hz (e.g. AC15, and many other European protocols) */
-        {2280,  0},
-        {{-10, -20}, {0, 0}},       /* -10+-1 dBmO and -20+-1 dBm0 */
-        ms_to_samples(400),         /* 300ms to 550ms */
-    
-        ms_to_samples(225),
-    
-        ms_to_samples(225),
-        TRUE,
-    
-        24,
-        64,
</del><ins>+    NOTCH_COEFF_SET_2280HZ = 0,
+    NOTCH_COEFF_SET_2400HZ,
+    NOTCH_COEFF_SET_2600HZ
+};
</ins><span class="cx"> 
</span><del>-        1,
-        {
-            {
</del><ins>+/* The coefficients for the data notch filters. These filters are also the
+   guard filters for tone detection. */
+static const sig_tone_notch_coeffs_t notch_coeffs[3] =
+{
+    {                                                   /* 2280 Hz */
</ins><span class="cx"> #if defined(SPANDSP_USE_FIXED_POINT)
</span><del>-                {  3600,        14397,          32767},
-                {     0,        -9425,         -28954},
-                {     0,        14196,          32767},
-                {     0,       -17393,         -28954},
-                12,
</del><ins>+        {  3600,        14397,          32767},
+        {     0,        -9425,         -28954},
+        {     0,        14196,          32767},
+        {     0,       -17393,         -28954},
+        12,
</ins><span class="cx"> #else
</span><del>-                {0.878906f,     0.439362f,      1.0f},
-                {0.0f,         -0.287627f,     -0.883605f},
-                {0.0f,          0.433228f,      1.0f},
-                {0.0f,         -0.530792f,     -0.883605f},
</del><ins>+        {0.878906f,     0.439362f,      1.0f},
+        {0.0f,         -0.287627f,     -0.883605f},
+        {0.0f,          0.433228f,      1.0f},
+        {0.0f,         -0.530792f,     -0.883605f},
</ins><span class="cx"> #endif
</span><del>-            },
-            {
</del><ins>+    },
+    {                                                   /* 2400Hz */
</ins><span class="cx"> #if defined(SPANDSP_USE_FIXED_POINT)
</span><del>-                {     0,            0,              0},
-                {     0,            0,              0},
-                {     0,            0,              0},
-                {     0,            0,              0},
-                0,
</del><ins>+        {  3530,        20055,          32767},
+        {     0,       -14950,         -28341},
+        {     0,        20349,          32767},
+        {     0,       -22633,         -28341},
+        12,
</ins><span class="cx"> #else
</span><del>-                {0.0f,          0.0f,           0.0f},
-                {0.0f,          0.0f,           0.0f},
-                {0.0f,          0.0f,           0.0f},
-                {0.0f,          0.0f,           0.0f},
</del><ins>+        {0.862000f,     0.612055f,      1.0f},
+        {0.0f,         -0.456264f,     -0.864899f},
+        {0.0f,          0.621021f,      1.0f},
+        {0.0f,         -0.690738f,     -0.864899f},
</ins><span class="cx"> #endif
</span><del>-            }
-        },
</del><ins>+    },
+    {                                                   /* 2600Hz */
</ins><span class="cx"> #if defined(SPANDSP_USE_FIXED_POINT)
</span><ins>+        {  3530,        29569,          32767},
+        {     0,       -24010,         -28341},
+        {     0,        29844,          32767},
+        {     0,       -31208,         -28341},
+        12,
+#else
+        {0.862000f,     0.902374f,      1.0f},
+        {0.0f,         -0.732727f,     -0.864899f},
+        {0.0f,          0.910766f,      1.0f},
+        {0.0f,         -0.952393f,     -0.864899f},
+#endif
+    }
+};
+
+static const sig_tone_flat_coeffs_t flat_coeffs[1] =
+{
+    {
+#if defined(SPANDSP_USE_FIXED_POINT)
</ins><span class="cx">         { 12900,       -16384,         -16384}, 
</span><span class="cx">         {     0,        -8578,         -11796},
</span><span class="cx">         15,
</span><span class="lines">@@ -120,163 +129,96 @@
</span><span class="cx">         {0.393676f,    -0.5f,          -0.5f}, 
</span><span class="cx">         {0.0f,         -0.261778f,     -0.359985f},
</span><span class="cx"> #endif
</span><ins>+    }
+};
</ins><span class="cx"> 
</span><del>-        31744,
-        1024,
</del><ins>+static const sig_tone_descriptor_t sig_tones[3] =
+{
+    {
+        /* 2280Hz (e.g. AC15, and many other European protocols) */
+        {2280,  0},
+        {{-10, -20}, {0, 0}},       /* -10+-1 dBm0 and -20+-1 dBm0 */
+        ms_to_samples(400),         /* High to low timout - 300ms to 550ms */
+        ms_to_samples(225),         /* Sharp to flat timeout */
+        ms_to_samples(225),         /* Notch insertion timeout */
</ins><span class="cx">     
</span><del>-        31744,
-        187,
-    
-        31744,
-        187,
-    
-        -1,
-        -32,
-    
-        57
</del><ins>+        ms_to_samples(3),           /* Tone on persistence check */
+        ms_to_samples(8),           /* Tone off persistence check */
+
+        1,
+        {
+            &amp;notch_coeffs[NOTCH_COEFF_SET_2280HZ],
+            NULL,
+        },
+        &amp;flat_coeffs[NOTCH_COEFF_SET_2280HZ],
+
+        13.0f,
+        -30.0f,
+        -30.0f
</ins><span class="cx">     },
</span><span class="cx">     {
</span><span class="cx">         /* 2600Hz (e.g. many US protocols) */
</span><span class="cx">         {2600, 0},
</span><span class="cx">         {{-8, -8}, {0, 0}},
</span><del>-        ms_to_samples(400),
-    
</del><ins>+        ms_to_samples(0),
+        ms_to_samples(0),
</ins><span class="cx">         ms_to_samples(225),
</span><span class="cx">     
</span><del>-        ms_to_samples(225),
-        FALSE,
-    
-        24,
-        64,
</del><ins>+        ms_to_samples(3),
+        ms_to_samples(8),
</ins><span class="cx"> 
</span><span class="cx">         1,
</span><span class="cx">         {
</span><del>-            {            
-#if defined(SPANDSP_USE_FIXED_POINT)
-                {  3539,        29569,          32767},
-                {     0,       -24010,         -28341},
-                {     0,        29844,          32767},
-                {     0,       -31208,         -28341},
-                12,
-#else
-                {0.864014f,     0.902374f,      1.0f},
-                {0.0f,         -0.732727f,     -0.864899f},
-                {0.0f,          0.910766f,      1.0f},
-                {0.0f,         -0.952393f,     -0.864899f},
-#endif
-            },
-            {            
-#if defined(SPANDSP_USE_FIXED_POINT)
-                {     0,            0,              0},
-                {     0,            0,              0},
-                {     0,            0,              0},
-                {     0,            0,              0},
-                0,
-#else
-                {0.0f,          0.0f,           0.0f},
-                {0.0f,          0.0f,           0.0f},
-                {0.0f,          0.0f,           0.0f},
-                {0.0f,          0.0f,           0.0f},
-#endif
-            }
</del><ins>+            &amp;notch_coeffs[NOTCH_COEFF_SET_2600HZ],
+            NULL,
</ins><span class="cx">         },
</span><del>-#if defined(SPANDSP_USE_FIXED_POINT)
-        { 32768,            0,              0},
-        {     0,            0,              0},
-        15,
-#else
-        {1.0f,          0.0f,           0.0f},
-        {0.0f,          0.0f,           0.0f},
-#endif
</del><ins>+        NULL,
</ins><span class="cx">     
</span><del>-        31744,
-        1024,
-    
-        31744,
-        170,
-    
-        31744,
-        170,
-    
-        -1,
-        -32,
-    
-        52
</del><ins>+        15.6f,
+        -30.0f,
+        -30.0f
</ins><span class="cx">     },
</span><span class="cx">     {
</span><span class="cx">         /* 2400Hz/2600Hz (e.g. SS5 and SS5bis) */
</span><del>-        {2600, 2400},
</del><ins>+        {2400, 2600},
</ins><span class="cx">         {{-8, -8}, {-8, -8}},
</span><del>-        ms_to_samples(400),
-
</del><ins>+        ms_to_samples(0),
+        ms_to_samples(0),
</ins><span class="cx">         ms_to_samples(225),
</span><span class="cx"> 
</span><del>-        ms_to_samples(225),
-        FALSE,
</del><ins>+        ms_to_samples(3),
+        ms_to_samples(8),
</ins><span class="cx"> 
</span><del>-        24,
-        64,
-
</del><span class="cx">         2,
</span><span class="cx">         {
</span><del>-            {
-#if defined(SPANDSP_USE_FIXED_POINT)
-                {  3539,        29569,          32767},
-                {     0,       -24010,         -28341},
-                {     0,        29844,          32767},
-                {     0,       -31208,         -28341},
-                12,
-#else
-                {0.864014f,     0.902374f,      1.0f},
-                {0.0f,         -0.732727f,     -0.864899f},
-                {0.0f,          0.910766f,      1.0f},
-                {0.0f,         -0.952393f,     -0.864899f},
-#endif
-            },
-            {
-#if defined(SPANDSP_USE_FIXED_POINT)
-                {  3539,        20349,          32767},
-                {     0,       -22075,         -31856},
-                {     0,        20174,          32767},
-                {     0,       -17832,         -31836},
-                12,
-#else
-                {0.864014f,     0.621007f,      1.0f},
-                {0.0f,         -0.673667f,     -0.972167f},
-                {0.0f,          0.615669f,      1.0f},
-                {0.0f,         -0.544180f,     -0.971546f},
-#endif
-            }
</del><ins>+            &amp;notch_coeffs[NOTCH_COEFF_SET_2400HZ],
+            &amp;notch_coeffs[NOTCH_COEFF_SET_2600HZ]
</ins><span class="cx">         },
</span><del>-#if defined(SPANDSP_USE_FIXED_POINT)
-        { 32768,            0,              0},
-        {     0,            0,              0},
-        15,
-#else
-        {1.0f,          0.0f,           0.0f},
-        {0.0f,          0.0f,           0.0f},
-#endif
</del><ins>+        NULL,
</ins><span class="cx">     
</span><del>-        31744,
-        1024,
-    
-        31744,
-        170,
-    
-        31744,
-        170,
-    
-        -1,
-        -32,
-    
-        52
</del><ins>+        15.6f,
+        -30.0f,
+        -30.0f
</ins><span class="cx">     }
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+static const int tone_present_bits[2] =
+{
+    SIG_TONE_1_PRESENT,
+    SIG_TONE_2_PRESENT
+};
+
+static const int tone_change_bits[2] =
+{
+    SIG_TONE_1_CHANGE,
+    SIG_TONE_2_CHANGE
+};
+
</ins><span class="cx"> SPAN_DECLARE(int) sig_tone_tx(sig_tone_tx_state_t *s, int16_t amp[], int len)
</span><span class="cx"> {
</span><span class="cx">     int i;
</span><span class="cx">     int j;
</span><ins>+    int k;
</ins><span class="cx">     int n;
</span><span class="cx">     int16_t tone;
</span><span class="cx">     int need_update;
</span><span class="lines">@@ -306,7 +248,7 @@
</span><span class="cx">         if (!(s-&gt;current_tx_tone &amp; SIG_TONE_TX_PASSTHROUGH))
</span><span class="cx">             vec_zeroi16(&amp;amp[i], n);
</span><span class="cx">         /*endif*/
</span><del>-        if ((s-&gt;current_tx_tone &amp; (SIG_TONE_1_PRESENT  ||  SIG_TONE_2_PRESENT)))
</del><ins>+        if ((s-&gt;current_tx_tone &amp; (SIG_TONE_1_PRESENT | SIG_TONE_2_PRESENT)))
</ins><span class="cx">         {
</span><span class="cx">             /* Are we in the early phase (high tone energy level), or the sustaining
</span><span class="cx">                phase (low tone energy level) of tone generation? */
</span><span class="lines">@@ -325,26 +267,19 @@
</span><span class="cx">                 high_low = 1;
</span><span class="cx">             }
</span><span class="cx">             /*endif*/
</span><del>-            if ((s-&gt;current_tx_tone &amp; SIG_TONE_1_PRESENT)  &amp;&amp;  s-&gt;phase_rate[0])
</del><ins>+            for (k = 0;  k &lt; s-&gt;desc-&gt;tones;  k++)
</ins><span class="cx">             {
</span><del>-                for (j = i;  j &lt; i + n;  j++)
</del><ins>+                if ((s-&gt;current_tx_tone &amp; tone_present_bits[k])  &amp;&amp;  s-&gt;phase_rate[k])
</ins><span class="cx">                 {
</span><del>-                    tone = dds_mod(&amp;(s-&gt;phase_acc[0]), s-&gt;phase_rate[0], s-&gt;tone_scaling[0][high_low], 0);
-                    amp[j] = saturate(amp[j] + tone);
</del><ins>+                    for (j = i;  j &lt; i + n;  j++)
+                    {
+                        tone = dds_mod(&amp;(s-&gt;phase_acc[k]), s-&gt;phase_rate[k], s-&gt;tone_scaling[k][high_low], 0);
+                        amp[j] = saturate(amp[j] + tone);
+                    }
+                    /*endfor*/
</ins><span class="cx">                 }
</span><del>-                /*endfor*/
</del><ins>+                /*endif*/
</ins><span class="cx">             }
</span><del>-            /*endif*/
-            if ((s-&gt;current_tx_tone &amp; SIG_TONE_2_PRESENT)  &amp;&amp;  s-&gt;phase_rate[1])
-            {
-                for (j = i;  j &lt; i + n;  j++)
-                {
-                    tone = dds_mod(&amp;(s-&gt;phase_acc[1]), s-&gt;phase_rate[1], s-&gt;tone_scaling[1][high_low], 0);
-                    amp[j] = saturate(amp[j] + tone);
-                }
-                /*endfor*/
-            }
-            /*endif*/
</del><span class="cx">         }
</span><span class="cx">         /*endif*/
</span><span class="cx">         if (need_update  &amp;&amp;  s-&gt;sig_update)
</span><span class="lines">@@ -421,82 +356,74 @@
</span><span class="cx"> SPAN_DECLARE(int) sig_tone_rx(sig_tone_rx_state_t *s, int16_t amp[], int len)
</span><span class="cx"> {
</span><span class="cx"> #if defined(SPANDSP_USE_FIXED_POINT)
</span><del>-    int32_t x;
-    int32_t notched_signal;
-    int32_t bandpass_signal;
</del><ins>+    int16_t x;
+    int32_t v;
+    int16_t notched_signal[2];
+    int16_t bandpass_signal;
</ins><span class="cx"> #else
</span><span class="cx">     float x;
</span><del>-    float notched_signal;
</del><ins>+    float v;
+    float notched_signal[2];
</ins><span class="cx">     float bandpass_signal;
</span><span class="cx"> #endif
</span><span class="cx">     int i;
</span><span class="cx">     int j;
</span><del>-    int32_t mown_notch[2];
-    int32_t mown_bandpass;
</del><ins>+    int32_t notch_power[2];
+    int32_t flat_power;
</ins><span class="cx"> 
</span><span class="cx">     for (i = 0;  i &lt; len;  i++)
</span><span class="cx">     {
</span><del>-        if (s-&gt;signaling_state_duration &lt; INT_MAX)
-            s-&gt;signaling_state_duration++;
</del><ins>+        if (s-&gt;signalling_state_duration &lt; INT_MAX)
+            s-&gt;signalling_state_duration++;
</ins><span class="cx">         /*endif*/
</span><del>-        notched_signal = 0;
</del><span class="cx">         for (j = 0;  j &lt; s-&gt;desc-&gt;tones;  j++)
</span><span class="cx">         {
</span><span class="cx">             /* The notch filter is two cascaded biquads. */
</span><del>-            notched_signal = amp[i];
-
</del><span class="cx"> #if defined(SPANDSP_USE_FIXED_POINT)
</span><del>-            notched_signal *= s-&gt;desc-&gt;tone[j].notch_a1[0];
-            notched_signal += s-&gt;tone[j].notch_z1[1]*s-&gt;desc-&gt;tone[j].notch_b1[1];
-            notched_signal += s-&gt;tone[j].notch_z1[2]*s-&gt;desc-&gt;tone[j].notch_b1[2];
-            x = notched_signal;
-            notched_signal += s-&gt;tone[j].notch_z1[1]*s-&gt;desc-&gt;tone[j].notch_a1[1];
-            notched_signal += s-&gt;tone[j].notch_z1[2]*s-&gt;desc-&gt;tone[j].notch_a1[2];
-            s-&gt;tone[j].notch_z1[2] = s-&gt;tone[j].notch_z1[1];
-            s-&gt;tone[j].notch_z1[1] = x &gt;&gt; 15;
-
-            notched_signal += s-&gt;tone[j].notch_z2[1]*s-&gt;desc-&gt;tone[j].notch_b2[1];
-            notched_signal += s-&gt;tone[j].notch_z2[2]*s-&gt;desc-&gt;tone[j].notch_b2[2];
-            x = notched_signal;
-            notched_signal += s-&gt;tone[j].notch_z2[1]*s-&gt;desc-&gt;tone[j].notch_a2[1];
-            notched_signal += s-&gt;tone[j].notch_z2[2]*s-&gt;desc-&gt;tone[j].notch_a2[2];
-            s-&gt;tone[j].notch_z2[2] = s-&gt;tone[j].notch_z2[1];
-            s-&gt;tone[j].notch_z2[1] = x &gt;&gt; 15;
-
-            notched_signal &gt;&gt;= s-&gt;desc-&gt;notch_postscale;
</del><ins>+            v = ((int32_t) amp[i]*s-&gt;desc-&gt;notch[j]-&gt;a1[0])
+              + ((int32_t) s-&gt;tone[j].notch_z1[0]*s-&gt;desc-&gt;notch[j]-&gt;b1[1])
+              + ((int32_t) s-&gt;tone[j].notch_z1[1]*s-&gt;desc-&gt;notch[j]-&gt;b1[2]);
+            x = v &gt;&gt; 15;
+            v +=   ((int32_t) s-&gt;tone[j].notch_z1[0]*s-&gt;desc-&gt;notch[j]-&gt;a1[1])
+                 + ((int32_t) s-&gt;tone[j].notch_z1[1]*s-&gt;desc-&gt;notch[j]-&gt;a1[2]);
+            s-&gt;tone[j].notch_z1[1] = s-&gt;tone[j].notch_z1[0];
+            s-&gt;tone[j].notch_z1[0] = x;
+            v +=   ((int32_t) s-&gt;tone[j].notch_z2[0]*s-&gt;desc-&gt;notch[j]-&gt;b2[1])
+                 + ((int32_t) s-&gt;tone[j].notch_z2[1]*s-&gt;desc-&gt;notch[j]-&gt;b2[2]);
+            x = v &gt;&gt; 15;
+            v +=   ((int32_t) s-&gt;tone[j].notch_z2[0]*s-&gt;desc-&gt;notch[j]-&gt;a2[1])
+                 + ((int32_t) s-&gt;tone[j].notch_z2[1]*s-&gt;desc-&gt;notch[j]-&gt;a2[2]);
+            s-&gt;tone[j].notch_z2[1] = s-&gt;tone[j].notch_z2[0];
+            s-&gt;tone[j].notch_z2[0] = x;
+            notched_signal[j] = v &gt;&gt; s-&gt;desc-&gt;notch[j]-&gt;postscale;
</ins><span class="cx"> #else
</span><del>-            notched_signal *= s-&gt;desc-&gt;tone[j].notch_a1[0];
-            notched_signal += s-&gt;tone[j].notch_z1[1]*s-&gt;desc-&gt;tone[j].notch_b1[1];
-            notched_signal += s-&gt;tone[j].notch_z1[2]*s-&gt;desc-&gt;tone[j].notch_b1[2];
-            x = notched_signal;
-            notched_signal += s-&gt;tone[j].notch_z1[1]*s-&gt;desc-&gt;tone[j].notch_a1[1];
-            notched_signal += s-&gt;tone[j].notch_z1[2]*s-&gt;desc-&gt;tone[j].notch_a1[2];
-            s-&gt;tone[j].notch_z1[2] = s-&gt;tone[j].notch_z1[1];
-            s-&gt;tone[j].notch_z1[1] = x;
-
-            notched_signal += s-&gt;tone[j].notch_z2[1]*s-&gt;desc-&gt;tone[j].notch_b2[1];
-            notched_signal += s-&gt;tone[j].notch_z2[2]*s-&gt;desc-&gt;tone[j].notch_b2[2];
-            x = notched_signal;
-            notched_signal += s-&gt;tone[j].notch_z2[1]*s-&gt;desc-&gt;tone[j].notch_a2[1];
-            notched_signal += s-&gt;tone[j].notch_z2[2]*s-&gt;desc-&gt;tone[j].notch_a2[2];
-            s-&gt;tone[j].notch_z2[2] = s-&gt;tone[j].notch_z2[1];
-            s-&gt;tone[j].notch_z2[1] = x;
</del><ins>+            v = amp[i]*s-&gt;desc-&gt;notch[j]-&gt;a1[0]
+              + s-&gt;tone[j].notch_z1[0]*s-&gt;desc-&gt;notch[j]-&gt;b1[1]
+              + s-&gt;tone[j].notch_z1[1]*s-&gt;desc-&gt;notch[j]-&gt;b1[2];
+            x = v;
+            v +=   s-&gt;tone[j].notch_z1[0]*s-&gt;desc-&gt;notch[j]-&gt;a1[1]
+                 + s-&gt;tone[j].notch_z1[1]*s-&gt;desc-&gt;notch[j]-&gt;a1[2];
+            s-&gt;tone[j].notch_z1[1] = s-&gt;tone[j].notch_z1[0];
+            s-&gt;tone[j].notch_z1[0] = x;
+            v +=   s-&gt;tone[j].notch_z2[0]*s-&gt;desc-&gt;notch[j]-&gt;b2[1]
+                 + s-&gt;tone[j].notch_z2[1]*s-&gt;desc-&gt;notch[j]-&gt;b2[2];
+            x = v;
+            v +=   s-&gt;tone[j].notch_z2[0]*s-&gt;desc-&gt;notch[j]-&gt;a2[1]
+                 + s-&gt;tone[j].notch_z2[1]*s-&gt;desc-&gt;notch[j]-&gt;a2[2];
+            s-&gt;tone[j].notch_z2[1] = s-&gt;tone[j].notch_z2[0];
+            s-&gt;tone[j].notch_z2[0] = x;
+            notched_signal[j] = v;
</ins><span class="cx"> #endif
</span><span class="cx">             /* Modulus and leaky integrate the notched data. The result of
</span><del>-               this isn't used in low tone detect mode, but we must keep notch_zl
-               rolling along. */
-            s-&gt;tone[j].notch_zl = ((s-&gt;tone[j].notch_zl*s-&gt;desc-&gt;notch_slugi) &gt;&gt; 15)
-                                + ((abs((int) notched_signal)*s-&gt;desc-&gt;notch_slugp) &gt;&gt; 15);
-            /* Mow the grass to weed out the noise! */
-            mown_notch[j] = s-&gt;tone[0].notch_zl &amp; s-&gt;desc-&gt;notch_threshold;
</del><ins>+               this isn't used in low tone detect mode, but we must keep the
+               power measurement rolling along. */
+            notch_power[j] = power_meter_update(&amp;s-&gt;tone[j].power, notched_signal[j]);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (s-&gt;tone_present)
</del><ins>+        if (s-&gt;tone[0].tone_present  ||  s-&gt;tone[1].tone_present)
</ins><span class="cx">         {
</span><del>-            if (s-&gt;flat_mode_timeout &lt;= 0)
</del><ins>+            if (s-&gt;flat_mode_timeout  &amp;&amp;  --s-&gt;flat_mode_timeout == 0)
</ins><span class="cx">                 s-&gt;flat_mode = TRUE;
</span><del>-            else
-                s-&gt;flat_mode_timeout--;
</del><span class="cx">             /*endif*/
</span><span class="cx">         }
</span><span class="cx">         else
</span><span class="lines">@@ -509,55 +436,51 @@
</span><span class="cx">         if (s-&gt;flat_mode)
</span><span class="cx">         {
</span><span class="cx">             /* Flat mode */
</span><del>-    
-            /* The bandpass filter is a single bi-quad stage */
</del><span class="cx">             bandpass_signal = amp[i];
</span><ins>+            if (s-&gt;desc-&gt;flat)
+            {
+                /* The bandpass filter is a single bi-quad stage */
</ins><span class="cx"> #if defined(SPANDSP_USE_FIXED_POINT)
</span><del>-            bandpass_signal *= s-&gt;desc-&gt;broad_a[0];
-            bandpass_signal += s-&gt;broad_z[1]*s-&gt;desc-&gt;broad_b[1];
-            bandpass_signal += s-&gt;broad_z[2]*s-&gt;desc-&gt;broad_b[2];
-            x = bandpass_signal;
-            bandpass_signal += s-&gt;broad_z[1]*s-&gt;desc-&gt;broad_a[1];
-            bandpass_signal += s-&gt;broad_z[2]*s-&gt;desc-&gt;broad_a[2];
-            s-&gt;broad_z[2] = s-&gt;broad_z[1];
-            s-&gt;broad_z[1] = x &gt;&gt; 15;
-            bandpass_signal &gt;&gt;= s-&gt;desc-&gt;broad_postscale;
</del><ins>+                v = ((int32_t) amp[i]*s-&gt;desc-&gt;flat-&gt;a[0])
+                  + ((int32_t) s-&gt;flat_z[0]*s-&gt;desc-&gt;flat-&gt;b[1])
+                  + ((int32_t) s-&gt;flat_z[1]*s-&gt;desc-&gt;flat-&gt;b[2]);
+                x = v &gt;&gt; 15;
+                v +=   ((int32_t) s-&gt;flat_z[0]*s-&gt;desc-&gt;flat-&gt;a[1])
+                     + ((int32_t) s-&gt;flat_z[1]*s-&gt;desc-&gt;flat-&gt;a[2]);
+                s-&gt;flat_z[1] = s-&gt;flat_z[0];
+                s-&gt;flat_z[0] = x;
+                bandpass_signal = v &gt;&gt; s-&gt;desc-&gt;flat-&gt;postscale;
</ins><span class="cx"> #else
</span><del>-            bandpass_signal *= s-&gt;desc-&gt;broad_a[0];
-            bandpass_signal += s-&gt;broad_z[1]*s-&gt;desc-&gt;broad_b[1];
-            bandpass_signal += s-&gt;broad_z[2]*s-&gt;desc-&gt;broad_b[2];
-            x = bandpass_signal;
-            bandpass_signal += s-&gt;broad_z[1]*s-&gt;desc-&gt;broad_a[1];
-            bandpass_signal += s-&gt;broad_z[2]*s-&gt;desc-&gt;broad_a[2];
-            s-&gt;broad_z[2] = s-&gt;broad_z[1];
-            s-&gt;broad_z[1] = x;
-#endif            
-            /* Leaky integrate the bandpassed data */
-            s-&gt;broad_zl = ((s-&gt;broad_zl*s-&gt;desc-&gt;broad_slugi) &gt;&gt; 15)
-                        + ((abs((int) bandpass_signal)*s-&gt;desc-&gt;broad_slugp) &gt;&gt; 15);
</del><ins>+                v = amp[i]*s-&gt;desc-&gt;flat-&gt;a[0]
+                  + s-&gt;flat_z[0]*s-&gt;desc-&gt;flat-&gt;b[1]
+                  + s-&gt;flat_z[1]*s-&gt;desc-&gt;flat-&gt;b[2];
+                x = v;
+                v +=   s-&gt;flat_z[0]*s-&gt;desc-&gt;flat-&gt;a[1]
+                     + s-&gt;flat_z[1]*s-&gt;desc-&gt;flat-&gt;a[2];
+                s-&gt;flat_z[1] = s-&gt;flat_z[0];
+                s-&gt;flat_z[0] = x;
+                bandpass_signal = v;
+#endif
+            }
+            flat_power = power_meter_update(&amp;s-&gt;flat_power, bandpass_signal);
</ins><span class="cx">     
</span><del>-            /* For the broad band receiver we use a simple linear threshold! */
-            if (s-&gt;tone_present)
</del><ins>+            /* For the flat receiver we use a simple power threshold! */
+            if (s-&gt;tone[0].tone_present)
</ins><span class="cx">             {
</span><del>-                s-&gt;tone_present = (s-&gt;broad_zl &gt; s-&gt;desc-&gt;broad_threshold);
-                if (!s-&gt;tone_present)
</del><ins>+                s-&gt;tone[0].tone_present = (flat_power &gt; s-&gt;flat_detection_threshold);
+                if (!s-&gt;tone[0].tone_present)
</ins><span class="cx">                 {
</span><del>-                    if (s-&gt;sig_update)
-                        s-&gt;sig_update(s-&gt;user_data, SIG_TONE_1_CHANGE, 0, s-&gt;signaling_state_duration);
-                    /*endif*/
-                    s-&gt;signaling_state_duration = 0;
</del><ins>+                    s-&gt;signalling_state &amp;= ~tone_present_bits[0];
+                    s-&gt;signalling_state |= tone_change_bits[0];
</ins><span class="cx">                 }
</span><span class="cx">                 /*endif*/
</span><span class="cx">             }
</span><span class="cx">             else
</span><span class="cx">             {
</span><del>-                s-&gt;tone_present = (s-&gt;broad_zl &gt; s-&gt;desc-&gt;broad_threshold);
-                if (s-&gt;tone_present)
</del><ins>+                s-&gt;tone[0].tone_present = (flat_power &gt; s-&gt;flat_detection_threshold);
+                if (s-&gt;tone[0].tone_present)
</ins><span class="cx">                 {
</span><del>-                    if (s-&gt;sig_update)
-                        s-&gt;sig_update(s-&gt;user_data, SIG_TONE_1_CHANGE | SIG_TONE_1_PRESENT, 0, s-&gt;signaling_state_duration);
-                    /*endif*/
-                    s-&gt;signaling_state_duration = 0;
</del><ins>+                    s-&gt;signalling_state |= (tone_present_bits[0] | tone_change_bits[0]);
</ins><span class="cx">                 }
</span><span class="cx">                 /*endif*/
</span><span class="cx">             }
</span><span class="lines">@@ -565,17 +488,14 @@
</span><span class="cx"> 
</span><span class="cx">             /* Notch insertion logic */    
</span><span class="cx">             /* tone_present and tone_on are equivalent in flat mode */
</span><del>-            if (s-&gt;tone_present)
</del><ins>+            if (s-&gt;tone[0].tone_present)
</ins><span class="cx">             {
</span><del>-                s-&gt;notch_enabled = s-&gt;desc-&gt;notch_allowed;
</del><span class="cx">                 s-&gt;notch_insertion_timeout = s-&gt;desc-&gt;notch_lag_time;
</span><span class="cx">             }
</span><span class="cx">             else
</span><span class="cx">             {
</span><del>-                if (s-&gt;notch_insertion_timeout &gt; 0)
</del><ins>+                if (s-&gt;notch_insertion_timeout)
</ins><span class="cx">                     s-&gt;notch_insertion_timeout--;
</span><del>-                else
-                    s-&gt;notch_enabled = FALSE;
</del><span class="cx">                 /*endif*/
</span><span class="cx">             }
</span><span class="cx">             /*endif*/
</span><span class="lines">@@ -583,91 +503,84 @@
</span><span class="cx">         else
</span><span class="cx">         {
</span><span class="cx">             /* Sharp mode */
</span><ins>+            flat_power = power_meter_update(&amp;s-&gt;flat_power, amp[i]);
</ins><span class="cx"> 
</span><del>-            /* Modulus and leaky integrate the data */
-            s-&gt;broad_zl = ((s-&gt;broad_zl*s-&gt;desc-&gt;unfiltered_slugi) &gt;&gt; 15)
-                        + ((abs((int) amp[i])*s-&gt;desc-&gt;unfiltered_slugp) &gt;&gt; 15);
-     
-            /* Mow the grass to weed out the noise! */
-            mown_bandpass = s-&gt;broad_zl &amp; s-&gt;desc-&gt;unfiltered_threshold;
-    
-            /* Persistence checking and notch insertion logic */
-            if (!s-&gt;tone_present)
</del><ins>+            for (j = 0;  j &lt; s-&gt;desc-&gt;tones;  j++)
</ins><span class="cx">             {
</span><del>-                if (mown_notch[0] &lt; mown_bandpass)
</del><ins>+                /* Persistence checking and notch insertion logic */
+                if (s-&gt;tone[j].tone_present)
</ins><span class="cx">                 {
</span><del>-                    /* Tone is detected this sample */
-                    if (s-&gt;tone_persistence_timeout &lt;= 0)
</del><ins>+                    if (flat_power &lt; s-&gt;sharp_detection_threshold
+                        ||
+                        (notch_power[j] &gt;&gt; 6)*s-&gt;detection_ratio &gt; (flat_power &gt;&gt; 6))
</ins><span class="cx">                     {
</span><del>-                        s-&gt;tone_present = TRUE;
-                        s-&gt;notch_enabled = s-&gt;desc-&gt;notch_allowed;
-                        s-&gt;tone_persistence_timeout = s-&gt;desc-&gt;tone_off_check_time;
-                        s-&gt;notch_insertion_timeout = s-&gt;desc-&gt;notch_lag_time;
-                        if (s-&gt;sig_update)
-                            s-&gt;sig_update(s-&gt;user_data, SIG_TONE_1_CHANGE | SIG_TONE_1_PRESENT, 0, s-&gt;signaling_state_duration);
</del><ins>+                        /* Tone is not detected this sample */
+                        if (--s-&gt;tone[j].tone_persistence_timeout == 0)
+                        {
+                            /* Tone off is confirmed */
+                            s-&gt;tone[j].tone_present = FALSE;
+                            s-&gt;tone[j].tone_persistence_timeout = s-&gt;desc-&gt;tone_on_check_time;
+                            s-&gt;signalling_state &amp;= ~tone_present_bits[j];
+                            s-&gt;signalling_state |= tone_change_bits[j];
+                        }
</ins><span class="cx">                         /*endif*/
</span><del>-                        s-&gt;signaling_state_duration = 0;
</del><span class="cx">                     }
</span><span class="cx">                     else
</span><span class="cx">                     {
</span><del>-                        s-&gt;tone_persistence_timeout--;
-                        if (s-&gt;notch_insertion_timeout &gt; 0)
-                            s-&gt;notch_insertion_timeout--;
-                        else
-                            s-&gt;notch_enabled = FALSE;
-                        /*endif*/
</del><ins>+                        s-&gt;tone[j].tone_persistence_timeout = s-&gt;desc-&gt;tone_off_check_time;
</ins><span class="cx">                     }
</span><span class="cx">                     /*endif*/
</span><span class="cx">                 }
</span><span class="cx">                 else
</span><span class="cx">                 {
</span><del>-                    s-&gt;tone_persistence_timeout = s-&gt;desc-&gt;tone_on_check_time;
-                    if (s-&gt;notch_insertion_timeout &gt; 0)
</del><ins>+                    if (s-&gt;notch_insertion_timeout)
</ins><span class="cx">                         s-&gt;notch_insertion_timeout--;
</span><del>-                    else
-                        s-&gt;notch_enabled = FALSE;
</del><span class="cx">                     /*endif*/
</span><del>-                }
-                /*endif*/
-            }
-            else
-            {
-                if (mown_notch[0] &gt; mown_bandpass)
-                {
-                    /* Tone is not detected this sample */
-                    if (s-&gt;tone_persistence_timeout &lt;= 0)
</del><ins>+                    if (flat_power &gt; s-&gt;sharp_detection_threshold
+                        &amp;&amp;
+                        (notch_power[j] &gt;&gt; 6)*s-&gt;detection_ratio &lt; (flat_power &gt;&gt; 6))
</ins><span class="cx">                     {
</span><del>-                        s-&gt;tone_present = FALSE;
-                        s-&gt;tone_persistence_timeout = s-&gt;desc-&gt;tone_on_check_time;
-                        if (s-&gt;sig_update)
-                            s-&gt;sig_update(s-&gt;user_data, SIG_TONE_1_CHANGE, 0, s-&gt;signaling_state_duration);
</del><ins>+                        /* Tone is detected this sample */
+                        if (--s-&gt;tone[j].tone_persistence_timeout == 0)
+                        {
+                            /* Tone on is confirmed */
+                            s-&gt;tone[j].tone_present = TRUE;
+                            s-&gt;tone[j].tone_persistence_timeout = s-&gt;desc-&gt;tone_off_check_time;
+                            s-&gt;notch_insertion_timeout = s-&gt;desc-&gt;notch_lag_time;
+                            s-&gt;signalling_state |= (tone_present_bits[j] | tone_change_bits[j]);
+                        }
</ins><span class="cx">                         /*endif*/
</span><del>-                        s-&gt;signaling_state_duration = 0;
</del><span class="cx">                     }
</span><span class="cx">                     else
</span><span class="cx">                     {
</span><del>-                        s-&gt;tone_persistence_timeout--;
</del><ins>+                        s-&gt;tone[j].tone_persistence_timeout = s-&gt;desc-&gt;tone_on_check_time;
</ins><span class="cx">                     }
</span><span class="cx">                     /*endif*/
</span><span class="cx">                 }
</span><del>-                else
-                {
-                    s-&gt;tone_persistence_timeout = s-&gt;desc-&gt;tone_off_check_time;
-                }
</del><span class="cx">                 /*endif*/
</span><span class="cx">             }
</span><ins>+            /*endfor*/
+        }
+        /*endif*/
+        if (s-&gt;signalling_state &amp; (SIG_TONE_1_CHANGE | SIG_TONE_2_CHANGE))
+        {
+            if (s-&gt;sig_update)
+                s-&gt;sig_update(s-&gt;user_data, s-&gt;signalling_state, 0, s-&gt;signalling_state_duration);
</ins><span class="cx">             /*endif*/
</span><ins>+            s-&gt;signalling_state &amp;= ~(SIG_TONE_1_CHANGE | SIG_TONE_2_CHANGE);
+            s-&gt;signalling_state_duration = 0;
</ins><span class="cx">         }
</span><span class="cx">         /*endif*/
</span><span class="cx"> 
</span><span class="cx">         if ((s-&gt;current_rx_tone &amp; SIG_TONE_RX_PASSTHROUGH))
</span><span class="cx">         {
</span><del>-            if ((s-&gt;current_rx_tone &amp; SIG_TONE_RX_FILTER_TONE)  ||  s-&gt;notch_enabled)
-                amp[i] = (int16_t) notched_signal;
</del><ins>+            if ((s-&gt;current_rx_tone &amp; SIG_TONE_RX_FILTER_TONE)  ||  s-&gt;notch_insertion_timeout)
+                amp[i] = saturate16(notched_signal[0]);
</ins><span class="cx">             /*endif*/
</span><span class="cx">         }
</span><span class="cx">         else
</span><span class="cx">         {
</span><ins>+            /* Simply mute the media path */
</ins><span class="cx">             amp[i] = 0;
</span><span class="cx">         }
</span><span class="cx">         /*endif*/
</span><span class="lines">@@ -685,6 +598,11 @@
</span><span class="cx"> 
</span><span class="cx"> SPAN_DECLARE(sig_tone_rx_state_t *) sig_tone_rx_init(sig_tone_rx_state_t *s, int tone_type, tone_report_func_t sig_update, void *user_data)
</span><span class="cx"> {
</span><ins>+#if !defined(SPANDSP_USE_FIXED_POINT)
+    int i;
+    int j;
+#endif
+    
</ins><span class="cx">     if (sig_update == NULL  ||  tone_type &lt; 1  ||  tone_type &gt; 3)
</span><span class="cx">         return NULL;
</span><span class="cx">     /*endif*/
</span><span class="lines">@@ -695,16 +613,31 @@
</span><span class="cx">             return NULL;
</span><span class="cx">     }
</span><span class="cx">     memset(s, 0, sizeof(*s));
</span><ins>+#if !defined(SPANDSP_USE_FIXED_POINT)
+    for (i = 0;  i &lt; 3;  i++)
+    {
+        for (j = 0;  j &lt; 2;  j++)
+        {
+            s-&gt;tone[j].notch_z1[i] = 0.0f;
+            s-&gt;tone[j].notch_z2[i] = 0.0f;
+        }
+        s-&gt;flat_z[i] = 0.0f;
+    }
+#endif
</ins><span class="cx"> 
</span><span class="cx">     s-&gt;sig_update = sig_update;
</span><span class="cx">     s-&gt;user_data = user_data;
</span><span class="cx"> 
</span><span class="cx">     s-&gt;desc = &amp;sig_tones[tone_type - 1];
</span><span class="cx"> 
</span><del>-    s-&gt;flat_mode_timeout = 0;
-    s-&gt;notch_insertion_timeout = 0;
-    s-&gt;tone_persistence_timeout = 0;
-    s-&gt;signaling_state_duration = 0;
</del><ins>+    power_meter_init(&amp;s-&gt;tone[0].power, 5);
+    power_meter_init(&amp;s-&gt;tone[1].power, 5);
+    power_meter_init(&amp;s-&gt;flat_power, 5);
+
+    s-&gt;flat_detection_threshold = power_meter_level_dbm0(s-&gt;desc-&gt;flat_detection_threshold);
+    s-&gt;sharp_detection_threshold = power_meter_level_dbm0(s-&gt;desc-&gt;sharp_detection_threshold);
+    s-&gt;detection_ratio = powf(10.0f, s-&gt;desc-&gt;detection_ratio/10.0f) + 1.0f;
+
</ins><span class="cx">     return s;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandspprivatesig_toneh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/spandsp/private/sig_tone.h (17518 => 17519)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/private/sig_tone.h        2010-05-11 01:59:33 UTC (rev 17518)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/private/sig_tone.h        2010-05-11 14:38:36 UTC (rev 17519)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx">  * SpanDSP - a series of DSP components for telephony
</span><span class="cx">  *
</span><span class="cx">  * private/sig_tone.h - Signalling tone processing for the 2280Hz, 2400Hz, 2600Hz
</span><del>- *                      and similar signalling tone used in older protocols.
</del><ins>+ *                      and similar signalling tones used in older protocols.
</ins><span class="cx">  *
</span><span class="cx">  * Written by Steve Underwood &lt;steveu@coppice.org&gt;
</span><span class="cx">  *
</span><span class="lines">@@ -23,116 +23,116 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: sig_tone.h,v 1.4 2009/09/04 14:38:47 steveu Exp $
</del><ins>+ * $Id: sig_tone.h,v 1.9 2010/03/11 14:22:30 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> #if !defined(_SPANDSP_PRIVATE_SIG_TONE_H_)
</span><span class="cx"> #define _SPANDSP_PRIVATE_SIG_TONE_H_
</span><span class="cx"> 
</span><ins>+/*! \brief The coefficient set for a pair of cascaded bi-quads that make a signalling notch filter. */
+typedef struct
+{
+#if defined(SPANDSP_USE_FIXED_POINT)
+    int16_t a1[3];
+    int16_t b1[3];
+    int16_t a2[3];
+    int16_t b2[3];
+    int postscale;
+#else
+    float a1[3];
+    float b1[3];
+    float a2[3];
+    float b2[3];
+#endif
+} sig_tone_notch_coeffs_t;
+
+/*! \brief The coefficient set for a bi-quad that makes a signalling flat filter.
+           Some signalling tone schemes require such a filter, and some don't.
+           It is termed a flat filter, to distinguish it from the sharp filter,
+           but obviously it is not actually flat. It is a broad band weighting
+           filter. */
+typedef struct
+{
+#if defined(SPANDSP_USE_FIXED_POINT)
+    /*! \brief Flat mode bandpass bi-quad parameters */
+    int16_t a[3];
+    /*! \brief Flat mode bandpass bi-quad parameters */
+    int16_t b[3];
+    /*! \brief Post filter scaling */
+    int postscale;
+#else
+    /*! \brief Flat mode bandpass bi-quad parameters */
+    float a[3];
+    /*! \brief Flat mode bandpass bi-quad parameters */
+    float b[3];
+#endif
+} sig_tone_flat_coeffs_t;
+
</ins><span class="cx"> /*!
</span><del>-    Signaling tone descriptor. This defines the working state for a
-    single instance of the transmit and receive sides of a signaling
</del><ins>+    signalling tone descriptor. This defines the working state for a
+    single instance of the transmit and receive sides of a signalling
</ins><span class="cx">     tone processor.
</span><span class="cx"> */
</span><del>-struct sig_tone_descriptor_s
</del><ins>+typedef struct
</ins><span class="cx"> {
</span><span class="cx">     /*! \brief The tones used. */
</span><span class="cx">     int tone_freq[2];
</span><del>-    /*! \brief The high and low tone amplitudes for each of the tones. */
</del><ins>+    /*! \brief The high and low tone amplitudes for each of the tones, in dBm0. */
</ins><span class="cx">     int tone_amp[2][2];
</span><span class="cx"> 
</span><span class="cx">     /*! \brief The delay, in audio samples, before the high level tone drops
</span><del>-               to a low level tone. */
</del><ins>+               to a low level tone. Some signalling protocols require the
+               signalling tone be started at a high level, to ensure crisp
+               initial detection at the receiver, but require the tone
+               amplitude to drop by a number of dBs if it is sustained,
+               to reduce crosstalk levels. */
</ins><span class="cx">     int high_low_timeout;
</span><span class="cx"> 
</span><del>-    /*! \brief Some signaling tone detectors use a sharp initial filter,
-               changing to a broader band filter after some delay. This
</del><ins>+    /*! \brief Some signalling tone detectors use a sharp initial filter,
+               changing to a broader, flatter, filter after some delay. This
</ins><span class="cx">                parameter defines the delay. 0 means it never changes. */
</span><span class="cx">     int sharp_flat_timeout;
</span><span class="cx"> 
</span><span class="cx">     /*! \brief Parameters to control the behaviour of the notch filter, used
</span><del>-               to remove the tone from the voice path in some protocols. */
</del><ins>+               to remove the tone from the voice path in some protocols. The
+               notch is applied as fast as possible, when the signalling tone
+               is detected. Its removal is delayed by this timeout, to avoid
+               clicky noises from repeated switching of the filter on rapid
+               pulses of signalling tone. */
</ins><span class="cx">     int notch_lag_time;
</span><del>-    /*! \brief TRUE if the notch may be used in the media flow. */
-    int notch_allowed;
</del><span class="cx"> 
</span><span class="cx">     /*! \brief The tone on persistence check, in audio samples. */
</span><span class="cx">     int tone_on_check_time;
</span><span class="cx">     /*! \brief The tone off persistence check, in audio samples. */
</span><span class="cx">     int tone_off_check_time;
</span><span class="cx"> 
</span><del>-    /*! \brief ??? */
</del><ins>+    /*! \brief The number of tones used. */
</ins><span class="cx">     int tones;
</span><span class="cx">     /*! \brief The coefficients for the cascaded bi-quads notch filter. */
</span><del>-    struct
-    {
-#if defined(SPANDSP_USE_FIXED_POINT)
-        int32_t notch_a1[3];
-        int32_t notch_b1[3];
-        int32_t notch_a2[3];
-        int32_t notch_b2[3];
-        int notch_postscale;
-#else
-        float notch_a1[3];
-        float notch_b1[3];
-        float notch_a2[3];
-        float notch_b2[3];
-#endif
-    } tone[2];
</del><ins>+    const sig_tone_notch_coeffs_t *notch[2];
+    /*! \brief The coefficients for the single bi-quad flat mode filter. */
+    const sig_tone_flat_coeffs_t *flat;
</ins><span class="cx"> 
</span><del>-#if defined(SPANDSP_USE_FIXED_POINT)
-    /*! \brief Flat mode bandpass bi-quad parameters */
-    int32_t broad_a[3];
-    /*! \brief Flat mode bandpass bi-quad parameters */
-    int32_t broad_b[3];
-    /*! \brief Post filter scaling */
-    int broad_postscale;
-#else
-    /*! \brief Flat mode bandpass bi-quad parameters */
-    float broad_a[3];
-    /*! \brief Flat mode bandpass bi-quad parameters */
-    float broad_b[3];
-#endif
-    /*! \brief The coefficients for the post notch leaky integrator. */
-    int32_t notch_slugi;
-    /*! \brief ??? */
-    int32_t notch_slugp;
</del><ins>+    /*! \brief Minimum signalling tone to total power ratio, in dB */
+    int16_t detection_ratio;
+    /*! \brief Minimum total power for detection in sharp mode, in dB */
+    int16_t sharp_detection_threshold;
+    /*! \brief Minimum total power for detection in flat mode, in dB */
+    int16_t flat_detection_threshold;
+} sig_tone_descriptor_t;
</ins><span class="cx"> 
</span><del>-    /*! \brief The coefficients for the post modulus leaky integrator in the
-               unfiltered data path.  The prescale value incorporates the
-               detection ratio. This is called the guard ratio in some
-               protocols. */
-    int32_t unfiltered_slugi;
-    /*! \brief ??? */
-    int32_t unfiltered_slugp;
-
-    /*! \brief The coefficients for the post modulus leaky integrator in the
-               bandpass filter data path. */
-    int32_t broad_slugi;
-    /*! \brief ??? */
-    int32_t broad_slugp;
-
-    /*! \brief Masks which effectively threshold the notched, weighted and
-               bandpassed data. */
-    int32_t notch_threshold;
-    /*! \brief ??? */
-    int32_t unfiltered_threshold;
-    /*! \brief ??? */
-    int32_t broad_threshold;
-};
-
</del><span class="cx"> /*!
</span><del>-    Signaling tone transmit state
</del><ins>+    Signalling tone transmit state
</ins><span class="cx">  */
</span><span class="cx"> struct sig_tone_tx_state_s
</span><span class="cx"> {
</span><del>-    /*! \brief The callback function used to handle signaling changes. */
</del><ins>+    /*! \brief The callback function used to handle signalling changes. */
</ins><span class="cx">     tone_report_func_t sig_update;
</span><span class="cx">     /*! \brief A user specified opaque pointer passed to the callback function. */
</span><span class="cx">     void *user_data;
</span><span class="cx"> 
</span><span class="cx">     /*! \brief Tone descriptor */
</span><del>-    sig_tone_descriptor_t *desc;
</del><ins>+    const sig_tone_descriptor_t *desc;
</ins><span class="cx"> 
</span><span class="cx">     /*! The phase rates for the one or two tones */
</span><span class="cx">     int32_t phase_rate[2];
</span><span class="lines">@@ -148,22 +148,22 @@
</span><span class="cx">     int current_tx_tone;
</span><span class="cx">     /*! \brief Current transmit timeout */
</span><span class="cx">     int current_tx_timeout;
</span><del>-    /*! \brief Time in current signaling state, in samples. */
-    int signaling_state_duration;
</del><ins>+    /*! \brief Time in current signalling state, in samples. */
+    int signalling_state_duration;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> /*!
</span><del>-    Signaling tone receive state
</del><ins>+    Signalling tone receive state
</ins><span class="cx">  */
</span><span class="cx"> struct sig_tone_rx_state_s
</span><span class="cx"> {
</span><del>-    /*! \brief The callback function used to handle signaling changes. */
</del><ins>+    /*! \brief The callback function used to handle signalling changes. */
</ins><span class="cx">     tone_report_func_t sig_update;
</span><span class="cx">     /*! \brief A user specified opaque pointer passed to the callback function. */
</span><span class="cx">     void *user_data;
</span><span class="cx"> 
</span><span class="cx">     /*! \brief Tone descriptor */
</span><del>-    sig_tone_descriptor_t *desc;
</del><ins>+    const sig_tone_descriptor_t *desc;
</ins><span class="cx"> 
</span><span class="cx">     /*! \brief The current receive tone */
</span><span class="cx">     int current_rx_tone;
</span><span class="lines">@@ -174,45 +174,54 @@
</span><span class="cx">     {
</span><span class="cx"> #if defined(SPANDSP_USE_FIXED_POINT)
</span><span class="cx">         /*! \brief The z's for the notch filter */
</span><del>-        int32_t notch_z1[3];
</del><ins>+        int16_t notch_z1[2];
</ins><span class="cx">         /*! \brief The z's for the notch filter */
</span><del>-        int32_t notch_z2[3];
</del><ins>+        int16_t notch_z2[2];
</ins><span class="cx"> #else
</span><span class="cx">         /*! \brief The z's for the notch filter */
</span><del>-        float notch_z1[3];
</del><ins>+        float notch_z1[2];
</ins><span class="cx">         /*! \brief The z's for the notch filter */
</span><del>-        float notch_z2[3];
</del><ins>+        float notch_z2[2];
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-        /*! \brief The z's for the notch integrators. */
-        int32_t notch_zl;
</del><ins>+        /*! \brief The power output of the notch. */
+        power_meter_t power;
+        /*! \brief Persistence check for tone present */
+        int tone_persistence_timeout;
+        /*! \brief TRUE if the tone is declared to be present */
+        int tone_present;
</ins><span class="cx">     } tone[2];
</span><span class="cx"> 
</span><span class="cx"> #if defined(SPANDSP_USE_FIXED_POINT)
</span><span class="cx">     /*! \brief The z's for the weighting/bandpass filter. */
</span><del>-    int32_t broad_z[3];
</del><ins>+    int16_t flat_z[2];
</ins><span class="cx"> #else
</span><span class="cx">     /*! \brief The z's for the weighting/bandpass filter. */
</span><del>-    float broad_z[3];
</del><ins>+    float flat_z[2];
</ins><span class="cx"> #endif
</span><del>-    /*! \brief The z for the broadband integrator. */
-    int32_t broad_zl;
</del><ins>+    /*! \brief The output power of the flat (unfiltered or flat filtered) path. */
+    power_meter_t flat_power;
</ins><span class="cx"> 
</span><del>-    /*! \brief ??? */
</del><ins>+    /*! \brief The minimum reading from the power meter for detection in flat mode */
+    int32_t flat_detection_threshold;
+    /*! \brief The minimum reading from the power meter for detection in sharp mode */
+    int32_t sharp_detection_threshold;
+    /*! \brief The minimum ratio between notched power and total power for detection */
+    int32_t detection_ratio;
+
+    /*! \brief TRUE if in flat mode. FALSE if in sharp mode. */
</ins><span class="cx">     int flat_mode;
</span><del>-    /*! \brief ??? */
-    int tone_present;
-    /*! \brief ??? */
</del><ins>+    /*! \brief TRUE if the notch filter is enabled in the media path */
</ins><span class="cx">     int notch_enabled;
</span><span class="cx">     /*! \brief ??? */
</span><span class="cx">     int flat_mode_timeout;
</span><span class="cx">     /*! \brief ??? */
</span><span class="cx">     int notch_insertion_timeout;
</span><del>-    /*! \brief ??? */
-    int tone_persistence_timeout;
</del><span class="cx">     
</span><span class="cx">     /*! \brief ??? */
</span><del>-    int signaling_state_duration;
</del><ins>+    int signalling_state;
+    /*! \brief ??? */
+    int signalling_state_duration;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandspsig_toneh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/spandsp/sig_tone.h (17518 => 17519)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/sig_tone.h        2010-05-11 01:59:33 UTC (rev 17518)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/sig_tone.h        2010-05-11 14:38:36 UTC (rev 17519)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx">  * SpanDSP - a series of DSP components for telephony
</span><span class="cx">  *
</span><span class="cx">  * sig_tone.h - Signalling tone processing for the 2280Hz, 2400Hz, 2600Hz
</span><del>- *              and similar signalling tone used in older protocols.
</del><ins>+ *              and similar signalling tones used in older protocols.
</ins><span class="cx">  *
</span><span class="cx">  * Written by Steve Underwood &lt;steveu@coppice.org&gt;
</span><span class="cx">  *
</span><span class="lines">@@ -23,15 +23,15 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: sig_tone.h,v 1.20 2009/09/04 14:38:46 steveu Exp $
</del><ins>+ * $Id: sig_tone.h,v 1.23 2010/03/09 13:43:04 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="cx"> 
</span><del>-/*! \page sig_tone_page The signaling tone processor
</del><ins>+/*! \page sig_tone_page The 2280/2400/2600Hz signalling tone processor
</ins><span class="cx"> \section sig_tone_sec_1 What does it do?
</span><del>-The signaling tone processor handles the 2280Hz, 2400Hz and 2600Hz tones, used
-in many analogue signaling procotols, and digital ones derived from them.
</del><ins>+The signalling tone processor handles the 2280Hz, 2400Hz and 2600Hz tones, used
+in many analogue signalling procotols, and digital ones derived from them.
</ins><span class="cx"> 
</span><span class="cx"> \section sig_tone_sec_2 How does it work?
</span><span class="cx"> Most single and two voice frequency signalling systems share many features, as these
</span><span class="lines">@@ -57,30 +57,30 @@
</span><span class="cx"> /* The optional tone sets */
</span><span class="cx"> enum
</span><span class="cx"> {
</span><del>-    /*! European 2280Hz signaling tone. Tone 1 is 2280Hz. Tone 2 is not used. */
</del><ins>+    /*! European 2280Hz signalling tone. Tone 1 is 2280Hz. Tone 2 is not used. */
</ins><span class="cx">     SIG_TONE_2280HZ = 1,
</span><del>-    /*! US 2600Hz signaling tone. Tone 1 is 2600Hz. Tone 2 is not used. */
</del><ins>+    /*! US 2600Hz signalling tone. Tone 1 is 2600Hz. Tone 2 is not used. */
</ins><span class="cx">     SIG_TONE_2600HZ,
</span><del>-    /*! US 2400Hz + 2600Hz signaling tones. Tone 1 is 2600Hz. Tone 2 is 2400Hz. */
</del><ins>+    /*! US 2400Hz + 2600Hz signalling tones. Tone 1 is 2600Hz. Tone 2 is 2400Hz. */
</ins><span class="cx">     SIG_TONE_2400HZ_2600HZ
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> /* Mode control and report bits for transmit and receive */
</span><span class="cx"> enum
</span><span class="cx"> {
</span><del>-    /*! Signaling tone 1 is present */
</del><ins>+    /*! Signalling tone 1 is present */
</ins><span class="cx">     SIG_TONE_1_PRESENT          = 0x001,
</span><del>-    /*! Signaling tone 1 has changed state (ignored when setting tx mode) */
</del><ins>+    /*! Signalling tone 1 has changed state (ignored when setting tx mode) */
</ins><span class="cx">     SIG_TONE_1_CHANGE           = 0x002,
</span><del>-    /*! Signaling tone 2 is present */
</del><ins>+    /*! Signalling tone 2 is present */
</ins><span class="cx">     SIG_TONE_2_PRESENT          = 0x004,
</span><del>-    /*! Signaling tone 2 has changed state (ignored when setting tx mode) */
</del><ins>+    /*! Signalling tone 2 has changed state (ignored when setting tx mode) */
</ins><span class="cx">     SIG_TONE_2_CHANGE           = 0x008,
</span><span class="cx">     /*! The media signal is passing through. Tones might be added to it. */
</span><span class="cx">     SIG_TONE_TX_PASSTHROUGH     = 0x010,
</span><span class="cx">     /*! The media signal is passing through. Tones might be extracted from it, if detected. */
</span><span class="cx">     SIG_TONE_RX_PASSTHROUGH     = 0x040,
</span><del>-    /*! Force filtering of the signaling tone, whether signaling is being detected or not.
</del><ins>+    /*! Force filtering of the signalling tone, whether signalling is being detected or not.
</ins><span class="cx">         This is mostly useful for test purposes. */
</span><span class="cx">     SIG_TONE_RX_FILTER_TONE     = 0x080,
</span><span class="cx">     /*! Request an update of the transmit status, upon timeout of the previous status. */
</span><span class="lines">@@ -89,13 +89,6 @@
</span><span class="cx">     SIG_TONE_RX_UPDATE_REQUEST  = 0x200
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-/*!
-    Signaling tone descriptor. This defines the working state for a
-    single instance of the transmit and receive sides of a signaling
-    tone processor.
-*/
-typedef struct sig_tone_descriptor_s sig_tone_descriptor_t;
-
</del><span class="cx"> typedef struct sig_tone_tx_state_s sig_tone_tx_state_t;
</span><span class="cx"> 
</span><span class="cx"> typedef struct sig_tone_rx_state_s sig_tone_rx_state_t;
</span><span class="lines">@@ -107,7 +100,7 @@
</span><span class="cx"> 
</span><span class="cx"> /*! Process a block of received audio samples.
</span><span class="cx">     \brief Process a block of received audio samples.
</span><del>-    \param s The signaling tone context.
</del><ins>+    \param s The signalling tone context.
</ins><span class="cx">     \param amp The audio sample buffer.
</span><span class="cx">     \param len The number of samples in the buffer.
</span><span class="cx">     \return The number of samples unprocessed. */
</span><span class="lines">@@ -115,36 +108,36 @@
</span><span class="cx"> 
</span><span class="cx"> /*! Set the receive mode.
</span><span class="cx">     \brief Set the receive mode.
</span><del>-    \param s The signaling tone context.
</del><ins>+    \param s The signalling tone context.
</ins><span class="cx">     \param mode The new mode for the receiver.
</span><span class="cx">     \param duration The duration for this mode, before an update is requested.
</span><span class="cx">                     A duration of zero means forever. */
</span><span class="cx"> SPAN_DECLARE(void) sig_tone_rx_set_mode(sig_tone_rx_state_t *s, int mode, int duration);
</span><span class="cx"> 
</span><del>-/*! Initialise a signaling tone receiver context.
-    \brief Initialise a signaling tone context.
-    \param s The signaling tone context.
-    \param tone_type The type of signaling tone.
-    \param sig_update Callback function to handle signaling updates.
</del><ins>+/*! Initialise a signalling tone receiver context.
+    \brief Initialise a signalling tone context.
+    \param s The signalling tone context.
+    \param tone_type The type of signalling tone.
+    \param sig_update Callback function to handle signalling updates.
</ins><span class="cx">     \param user_data An opaque pointer.
</span><span class="cx">     \return A pointer to the signalling tone context, or NULL if there was a problem. */
</span><span class="cx"> SPAN_DECLARE(sig_tone_rx_state_t *) sig_tone_rx_init(sig_tone_rx_state_t *s, int tone_type, tone_report_func_t sig_update, void *user_data);
</span><span class="cx"> 
</span><del>-/*! Release a signaling tone receiver context.
-    \brief Release a signaling tone receiver context.
-    \param s The signaling tone context.
</del><ins>+/*! Release a signalling tone receiver context.
+    \brief Release a signalling tone receiver context.
+    \param s The signalling tone context.
</ins><span class="cx">     \return 0 for OK */
</span><span class="cx"> SPAN_DECLARE(int) sig_tone_rx_release(sig_tone_rx_state_t *s);
</span><span class="cx"> 
</span><del>-/*! Free a signaling tone receiver context.
-    \brief Free a signaling tone receiver context.
-    \param s The signaling tone context.
</del><ins>+/*! Free a signalling tone receiver context.
+    \brief Free a signalling tone receiver context.
+    \param s The signalling tone context.
</ins><span class="cx">     \return 0 for OK */
</span><span class="cx"> SPAN_DECLARE(int) sig_tone_rx_free(sig_tone_rx_state_t *s);
</span><span class="cx"> 
</span><del>-/*! Generate a block of signaling tone audio samples.
-    \brief Generate a block of signaling tone audio samples.
-    \param s The signaling tone context.
</del><ins>+/*! Generate a block of signalling tone audio samples.
+    \brief Generate a block of signalling tone audio samples.
+    \param s The signalling tone context.
</ins><span class="cx">     \param amp The audio sample buffer.
</span><span class="cx">     \param len The number of samples to be generated.
</span><span class="cx">     \return The number of samples actually generated. */
</span><span class="lines">@@ -152,30 +145,30 @@
</span><span class="cx"> 
</span><span class="cx"> /*! Set the tone mode.
</span><span class="cx">     \brief Set the tone mode.
</span><del>-    \param s The signaling tone context.
</del><ins>+    \param s The signalling tone context.
</ins><span class="cx">     \param mode The new mode for the transmitted tones.
</span><span class="cx">     \param duration The duration for this mode, before an update is requested.
</span><span class="cx">                     A duration of zero means forever. */
</span><span class="cx"> SPAN_DECLARE(void) sig_tone_tx_set_mode(sig_tone_tx_state_t *s, int mode, int duration);
</span><span class="cx"> 
</span><del>-/*! Initialise a signaling tone transmitter context.
-    \brief Initialise a signaling tone context.
-    \param s The signaling tone context.
-    \param tone_type The type of signaling tone.
-    \param sig_update Callback function to handle signaling updates.
</del><ins>+/*! Initialise a signalling tone transmitter context.
+    \brief Initialise a signalling tone context.
+    \param s The signalling tone context.
+    \param tone_type The type of signalling tone.
+    \param sig_update Callback function to handle signalling updates.
</ins><span class="cx">     \param user_data An opaque pointer.
</span><span class="cx">     \return A pointer to the signalling tone context, or NULL if there was a problem. */
</span><span class="cx"> SPAN_DECLARE(sig_tone_tx_state_t *) sig_tone_tx_init(sig_tone_tx_state_t *s, int tone_type, tone_report_func_t sig_update, void *user_data);
</span><span class="cx"> 
</span><del>-/*! Release a signaling tone transmitter context.
-    \brief Release a signaling tone transmitter context.
-    \param s The signaling tone context.
</del><ins>+/*! Release a signalling tone transmitter context.
+    \brief Release a signalling tone transmitter context.
+    \param s The signalling tone context.
</ins><span class="cx">     \return 0 for OK */
</span><span class="cx"> SPAN_DECLARE(int) sig_tone_tx_release(sig_tone_tx_state_t *s);
</span><span class="cx"> 
</span><del>-/*! Free a signaling tone transmitter context.
-    \brief Free a signaling tone transmitter context.
-    \param s The signaling tone context.
</del><ins>+/*! Free a signalling tone transmitter context.
+    \brief Free a signalling tone transmitter context.
+    \param s The signalling tone context.
</ins><span class="cx">     \return 0 for OK */
</span><span class="cx"> SPAN_DECLARE(int) sig_tone_tx_free(sig_tone_tx_state_t *s);
</span><span class="cx"> 
</span></span></pre></div>
<a id="freeswitchtrunklibsspandsptestssig_tone_testsc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/tests/sig_tone_tests.c (17518 => 17519)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/tests/sig_tone_tests.c        2010-05-11 01:59:33 UTC (rev 17518)
+++ freeswitch/trunk/libs/spandsp/tests/sig_tone_tests.c        2010-05-11 14:38:36 UTC (rev 17519)
</span><span class="lines">@@ -22,12 +22,12 @@
</span><span class="cx">  * along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: sig_tone_tests.c,v 1.27 2009/09/23 16:02:59 steveu Exp $
</del><ins>+ * $Id: sig_tone_tests.c,v 1.32 2010/03/11 14:22:30 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="cx"> 
</span><del>-/*! \page sig_tone_tests_page The signaling tone processor tests
</del><ins>+/*! \page sig_tone_tests_page The 2280/2400/2600Hz signalling tone Rx/Tx tests
</ins><span class="cx"> \section sig_tone_tests_sec_1 What does it do?
</span><span class="cx"> ???.
</span><span class="cx"> 
</span><span class="lines">@@ -55,17 +55,38 @@
</span><span class="cx"> 
</span><span class="cx"> #define SAMPLES_PER_CHUNK           160
</span><span class="cx"> 
</span><ins>+#define MITEL_DIR                   &quot;../test-data/mitel/&quot;
+#define BELLCORE_DIR                &quot;../test-data/bellcore/&quot;
+
+const char *bellcore_files[] =
+{
+    MITEL_DIR    &quot;mitel-cm7291-talkoff.wav&quot;,
+    BELLCORE_DIR &quot;tr-tsy-00763-1.wav&quot;,
+    BELLCORE_DIR &quot;tr-tsy-00763-2.wav&quot;,
+    BELLCORE_DIR &quot;tr-tsy-00763-3.wav&quot;,
+    BELLCORE_DIR &quot;tr-tsy-00763-4.wav&quot;,
+    BELLCORE_DIR &quot;tr-tsy-00763-5.wav&quot;,
+    BELLCORE_DIR &quot;tr-tsy-00763-6.wav&quot;,
+    &quot;&quot;
+};
+
+static int number_of_tones = 1;
+
</ins><span class="cx"> static int sampleno = 0;
</span><span class="cx"> static int tone_1_present = 0;
</span><span class="cx"> static int tone_2_present = 0;
</span><span class="cx"> static int tx_section = 0;
</span><span class="cx"> static int dial_pulses = 0;
</span><span class="cx"> 
</span><ins>+static int rx_handler_callbacks = 0;
+static int tx_handler_callbacks = 0;
+
</ins><span class="cx"> static void tx_handler(void *user_data, int what, int level, int duration)
</span><span class="cx"> {
</span><span class="cx">     sig_tone_tx_state_t *s;
</span><span class="cx">     
</span><span class="cx">     s = (sig_tone_tx_state_t *) user_data;
</span><ins>+    tx_handler_callbacks++;
</ins><span class="cx">     //printf(&quot;What - %d, duration - %d\n&quot;, what, duration);
</span><span class="cx">     if ((what &amp; SIG_TONE_TX_UPDATE_REQUEST))
</span><span class="cx">     {
</span><span class="lines">@@ -84,13 +105,19 @@
</span><span class="cx">                 tx_section++;
</span><span class="cx">             else
</span><span class="cx">                 tx_section--;
</span><ins>+            /*endif*/
</ins><span class="cx">             sig_tone_tx_set_mode(s, 0, ms_to_samples(67));
</span><span class="cx">             break;
</span><span class="cx">         case 2:
</span><span class="cx">             tx_section++;
</span><del>-            sig_tone_tx_set_mode(s, SIG_TONE_1_PRESENT, ms_to_samples(600));
</del><ins>+            printf(&quot;600ms on - %d samples\n&quot;, ms_to_samples(600));
+            if (number_of_tones == 2)
+                sig_tone_tx_set_mode(s, SIG_TONE_2_PRESENT, ms_to_samples(600));
+            else
+                sig_tone_tx_set_mode(s, SIG_TONE_1_PRESENT, ms_to_samples(600));
</ins><span class="cx">             break;
</span><span class="cx">         case 3:
</span><ins>+            printf(&quot;End of sequence\n&quot;);
</ins><span class="cx">             sig_tone_tx_set_mode(s, SIG_TONE_1_PRESENT | SIG_TONE_TX_PASSTHROUGH, 0);
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="lines">@@ -104,6 +131,7 @@
</span><span class="cx"> {
</span><span class="cx">     float ms;
</span><span class="cx"> 
</span><ins>+    rx_handler_callbacks++;
</ins><span class="cx">     ms = 1000.0f*(float) duration/(float) SAMPLE_RATE;
</span><span class="cx">     printf(&quot;What - %d, duration - %d\n&quot;, what, duration);
</span><span class="cx">     if ((what &amp; SIG_TONE_1_CHANGE))
</span><span class="lines">@@ -121,52 +149,184 @@
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><del>-static void map_frequency_response(sig_tone_rx_state_t *s)
</del><ins>+static void map_frequency_response(sig_tone_rx_state_t *s,
+                                   double f1,
+                                   double f2,
+                                   double f3,
+                                   double f4)
</ins><span class="cx"> {
</span><del>-    int16_t buf[8192];
</del><ins>+    int16_t buf[SAMPLES_PER_CHUNK];
</ins><span class="cx">     int i;
</span><span class="cx">     int len;
</span><span class="cx">     double sumin;
</span><span class="cx">     double sumout;
</span><span class="cx">     swept_tone_state_t *swept;
</span><ins>+    double freq;
+    double gain;
</ins><span class="cx">     
</span><span class="cx">     /* Things like noise don't highlight the frequency response of the high Q notch
</span><span class="cx">        very well. We use a slowly swept frequency to check it. */
</span><ins>+    printf(&quot;Frequency response test\n&quot;);
+    sig_tone_rx_set_mode(s, SIG_TONE_RX_PASSTHROUGH | SIG_TONE_RX_FILTER_TONE, 0);
</ins><span class="cx">     swept = swept_tone_init(NULL, 200.0f, 3900.0f, -10.0f, 120*SAMPLE_RATE, 0);
</span><span class="cx">     for (;;)
</span><span class="cx">     {
</span><span class="cx">         if ((len = swept_tone(swept, buf, SAMPLES_PER_CHUNK)) &lt;= 0)
</span><span class="cx">             break;
</span><ins>+        /*endif*/
</ins><span class="cx">         sumin = 0.0;
</span><span class="cx">         for (i = 0;  i &lt; len;  i++)
</span><span class="cx">             sumin += (double) buf[i]*(double) buf[i];
</span><ins>+        /*endfor*/
</ins><span class="cx">         sig_tone_rx(s, buf, len);
</span><span class="cx">         sumout = 0.0;
</span><span class="cx">         for (i = 0;  i &lt; len;  i++)
</span><span class="cx">             sumout += (double) buf[i]*(double) buf[i];
</span><span class="cx">         /*endfor*/
</span><del>-        printf(&quot;%7.1f %f\n&quot;, swept_tone_current_frequency(swept), 10.0*log10(sumout/sumin));
</del><ins>+        freq = swept_tone_current_frequency(swept);
+        if (sumin)
+            gain = 10.0*log10(sumout/sumin);
+        else
+            gain = 0.0;
+        printf(&quot;%7.1f Hz %f dBm0\n&quot;, freq, gain);
+        if (gain &gt; 0.0
+            ||
+            (freq &lt; f1  &amp;&amp;  gain &lt; -1.0)
+            ||
+            (freq &gt; f2  &amp;&amp;  freq &lt; f3  &amp;&amp;  gain &gt; -30.0)
+            ||
+            (freq &gt; f4  &amp;&amp;  gain &lt; -1.0))
+        {
+            printf(&quot;    Failed\n&quot;);
+            exit(2);
+        }
+        /*endif*/
</ins><span class="cx">     }
</span><span class="cx">     /*endfor*/
</span><span class="cx">     swept_tone_free(swept);
</span><ins>+    printf(&quot;    Passed\n&quot;);
</ins><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><del>-int main(int argc, char *argv[])
</del><ins>+static void speech_immunity_tests(sig_tone_rx_state_t *s)
</ins><span class="cx"> {
</span><ins>+    int j;
+    int total_hits;
+    SNDFILE *inhandle;
+    int16_t amp[SAMPLE_RATE];
+    int frames;
+
+    printf(&quot;Speech immunity test\n&quot;);
+    total_hits = 0;
+    for (j = 0;  bellcore_files[j][0];  j++)
+    {
+        /* Push some silence through, so we should be in the tone off state */
+        vec_zeroi16(amp, SAMPLE_RATE);
+        sig_tone_rx(s, amp, SAMPLE_RATE);
+        rx_handler_callbacks = 0;
+        if ((inhandle = sf_open_telephony_read(bellcore_files[j], 1)) == NULL)
+        {
+            printf(&quot;    Cannot open speech file '%s'\n&quot;, bellcore_files[j]);
+            exit(2);
+        }
+        /*endif*/
+        while ((frames = sf_readf_short(inhandle, amp, SAMPLE_RATE)))
+        {
+            sig_tone_rx(s, amp, frames);
+        }
+        /*endwhile*/
+        if (sf_close(inhandle) != 0)
+        {
+            printf(&quot;    Cannot close speech file '%s'\n&quot;, bellcore_files[j]);
+            exit(2);
+        }
+        /*endif*/
+        printf(&quot;    File %d gave %d false hits.\n&quot;, j + 1, rx_handler_callbacks);
+        total_hits += rx_handler_callbacks;
+    }
+    /*endfor*/
+    printf(&quot;    %d hits in total\n&quot;, total_hits);
+    if (total_hits &gt; 0)
+    {
+        printf(&quot;    Failed\n&quot;);
+        exit(2);
+    }
+    /*endif*/
+    printf(&quot;    Passed\n&quot;);
+}
+/*- End of function --------------------------------------------------------*/
+
+static void level_and_ratio_tests(sig_tone_rx_state_t *s, double pitch)
+{
+    awgn_state_t noise_source;
+    int32_t phase_rate;
+    uint32_t phase;
+    int16_t gain;
+    int16_t amp[SAMPLE_RATE];
+    int i;
+    int j;
+    int k;
+    float noise_level;
+    float tone_level;
+    power_meter_t noise_meter;
+    power_meter_t tone_meter;
+    int16_t noise;
+    int16_t tone;
+
+    printf(&quot;Acceptable level and ratio test\n&quot;);
+    phase = 0;
+    phase_rate = dds_phase_rate(pitch);
+    for (k = -25;  k &gt; -60;  k--)
+    {
+        noise_level = k;
+        awgn_init_dbm0(&amp;noise_source, 1234567, noise_level);
+        tone_level = noise_level;
+        /* Push some silence through, so we should be in the tone off state */
+        vec_zeroi16(amp, SAMPLE_RATE);
+        sig_tone_rx(s, amp, SAMPLE_RATE);
+        power_meter_init(&amp;noise_meter, 6);
+        power_meter_init(&amp;tone_meter, 6);
+        for (j = 0;  j &lt; 20;  j++)
+        {
+            rx_handler_callbacks = 0;
+            gain = dds_scaling_dbm0(tone_level);
+            for (i = 0;  i &lt; SAMPLES_PER_CHUNK;  i++)
+            {
+                noise = awgn(&amp;noise_source);
+                tone = dds_mod(&amp;phase, phase_rate, gain, 0);
+                power_meter_update(&amp;noise_meter, noise);
+                power_meter_update(&amp;tone_meter, tone);
+                amp[i] = noise + tone;
+            }
+            /*endfor*/
+            sig_tone_rx(s, amp, SAMPLES_PER_CHUNK);
+            if (rx_handler_callbacks)
+            {
+                printf(&quot;Hit at tone = %fdBm0, noise = %fdBm0\n&quot;, tone_level, noise_level);
+                printf(&quot;Noise = %fdBm0, tone = %fdBm0\n&quot;, power_meter_current_dbm0(&amp;noise_meter), power_meter_current_dbm0(&amp;tone_meter));
+            }
+            /*endif*/
+            tone_level += 1.0f;
+        }
+        /*endfor*/
+    }
+    /*endfor*/
+    printf(&quot;    Passed\n&quot;);
+}
+/*- End of function --------------------------------------------------------*/
+
+static void sequence_tests(sig_tone_tx_state_t *tx_state, sig_tone_rx_state_t *rx_state, codec_munge_state_t *munge)
+{
+    int i;
+    awgn_state_t noise_source;
+    SNDFILE *outhandle;
</ins><span class="cx">     int16_t amp[SAMPLES_PER_CHUNK];
</span><span class="cx">     int16_t out_amp[2*SAMPLES_PER_CHUNK];
</span><del>-    SNDFILE *outhandle;
</del><span class="cx">     int outframes;
</span><del>-    int i;
-    int type;
</del><span class="cx">     int rx_samples;
</span><span class="cx">     int tx_samples;
</span><del>-    sig_tone_tx_state_t tx_state;
-    sig_tone_rx_state_t rx_state;
-    awgn_state_t noise_source;
-    codec_munge_state_t *munge;
</del><span class="cx"> 
</span><ins>+    printf(&quot;Signalling sequence test\n&quot;);
</ins><span class="cx">     if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME, 2)) == NULL)
</span><span class="cx">     {
</span><span class="cx">         fprintf(stderr, &quot;    Cannot create audio file '%s'\n&quot;, OUT_FILE_NAME);
</span><span class="lines">@@ -175,7 +335,58 @@
</span><span class="cx">     /*endif*/
</span><span class="cx"> 
</span><span class="cx">     awgn_init_dbm0(&amp;noise_source, 1234567, -20.0f);
</span><ins>+    for (sampleno = 0;  sampleno &lt; 60000;  sampleno += SAMPLES_PER_CHUNK)
+    {
+        if (sampleno == 8000)
+        {
+            /* 100ms seize */
+            printf(&quot;100ms seize - %d samples\n&quot;, ms_to_samples(100));
+            dial_pulses = 0;
+            sig_tone_tx_set_mode(tx_state, 0, ms_to_samples(100));
+        }
+        /*endif*/
+        for (i = 0;  i &lt; SAMPLES_PER_CHUNK;  i++)
+            amp[i] = awgn(&amp;noise_source);
+        /*endfor*/
+        tx_samples = sig_tone_tx(tx_state, amp, SAMPLES_PER_CHUNK);
+        for (i = 0;  i &lt; tx_samples;  i++)
+            out_amp[2*i] = amp[i];
+        /*endfor*/
+        codec_munge(munge, amp, tx_samples);
+        rx_samples = sig_tone_rx(rx_state, amp, tx_samples);
+        for (i = 0;  i &lt; rx_samples;  i++)
+            out_amp[2*i + 1] = amp[i];
+        /*endfor*/
+        outframes = sf_writef_short(outhandle, out_amp, rx_samples);
+        if (outframes != rx_samples)
+        {
+            fprintf(stderr, &quot;    Error writing audio file\n&quot;);
+            exit(2);
+        }
+        /*endif*/
+    }
+    /*endfor*/
+    if (sf_close(outhandle) != 0)
+    {
+        fprintf(stderr, &quot;    Cannot close audio file '%s'\n&quot;, OUT_FILE_NAME);
+        exit(2);
+    }
+    /*endif*/
+}
+/*- End of function --------------------------------------------------------*/
</ins><span class="cx"> 
</span><ins>+int main(int argc, char *argv[])
+{
+    int type;
+    sig_tone_tx_state_t tx_state;
+    sig_tone_rx_state_t rx_state;
+    codec_munge_state_t *munge;
+    double f1;
+    double f2;
+    double fc;
+    double f3;
+    double f4;
+
</ins><span class="cx">     for (type = 1;  type &lt;= 3;  type++)
</span><span class="cx">     {
</span><span class="cx">         sampleno = 0;
</span><span class="lines">@@ -183,6 +394,11 @@
</span><span class="cx">         tone_2_present = 0;
</span><span class="cx">         tx_section = 0;
</span><span class="cx">         munge = NULL;
</span><ins>+        f1 =
+        f2 =
+        fc =
+        f3 =
+        f4 = 0.0;
</ins><span class="cx">         switch (type)
</span><span class="cx">         {
</span><span class="cx">         case 1:
</span><span class="lines">@@ -190,69 +406,49 @@
</span><span class="cx">             munge = codec_munge_init(MUNGE_CODEC_ALAW, 0);
</span><span class="cx">             sig_tone_tx_init(&amp;tx_state, SIG_TONE_2280HZ, tx_handler, &amp;tx_state);
</span><span class="cx">             sig_tone_rx_init(&amp;rx_state, SIG_TONE_2280HZ, rx_handler, &amp;rx_state);
</span><del>-            rx_state.current_rx_tone |= SIG_TONE_RX_PASSTHROUGH;
</del><ins>+            number_of_tones = 1;
+            f1 = 2280.0 - 200.0;
+            f2 = 2280.0 - 20.0;
+            fc = 2280.0;
+            f3 = 2280.0 + 20.0;
+            f4 = 2280.0 + 200.0;
</ins><span class="cx">             break;
</span><span class="cx">         case 2:
</span><span class="cx">             printf(&quot;2600Hz tests.\n&quot;);
</span><span class="cx">             munge = codec_munge_init(MUNGE_CODEC_ULAW, 0);
</span><span class="cx">             sig_tone_tx_init(&amp;tx_state, SIG_TONE_2600HZ, tx_handler, &amp;tx_state);
</span><span class="cx">             sig_tone_rx_init(&amp;rx_state, SIG_TONE_2600HZ, rx_handler, &amp;rx_state);
</span><del>-            rx_state.current_rx_tone |= SIG_TONE_RX_PASSTHROUGH;
</del><ins>+            number_of_tones = 1;
+            f1 = 2600.0 - 200.0;
+            f2 = 2600.0 - 20.0;
+            fc = 2600.0;
+            f3 = 2600.0 + 20.0;
+            f4 = 2600.0 + 200.0;
</ins><span class="cx">             break;
</span><span class="cx">         case 3:
</span><span class="cx">             printf(&quot;2400Hz/2600Hz tests.\n&quot;);
</span><span class="cx">             munge = codec_munge_init(MUNGE_CODEC_ULAW, 0);
</span><span class="cx">             sig_tone_tx_init(&amp;tx_state, SIG_TONE_2400HZ_2600HZ, tx_handler, &amp;tx_state);
</span><span class="cx">             sig_tone_rx_init(&amp;rx_state, SIG_TONE_2400HZ_2600HZ, rx_handler, &amp;rx_state);
</span><del>-            rx_state.current_rx_tone |= SIG_TONE_RX_PASSTHROUGH;
</del><ins>+            number_of_tones = 2;
+            f1 = 2400.0 - 200.0;
+            f2 = 2400.0 - 20.0;
+            fc = 2400.0;
+            f3 = 2400.0 + 20.0;
+            f4 = 2400.0 + 200.0;
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         /*endswitch*/
</span><del>-        /* Set to the default of hook condition */
-        sig_tone_rx_set_mode(&amp;rx_state, SIG_TONE_RX_PASSTHROUGH | SIG_TONE_RX_FILTER_TONE, 0);
</del><ins>+        /* Set to the default on hook condition */
+        map_frequency_response(&amp;rx_state, f1, f2, f3, f4);
+        speech_immunity_tests(&amp;rx_state);
+        level_and_ratio_tests(&amp;rx_state, fc);
+
</ins><span class="cx">         sig_tone_tx_set_mode(&amp;tx_state, SIG_TONE_1_PRESENT | SIG_TONE_2_PRESENT | SIG_TONE_TX_PASSTHROUGH, 0);
</span><del>-
-        map_frequency_response(&amp;rx_state);
-
</del><span class="cx">         sig_tone_rx_set_mode(&amp;rx_state, SIG_TONE_RX_PASSTHROUGH, 0);
</span><del>-        for (sampleno = 0;  sampleno &lt; 30000;  sampleno += SAMPLES_PER_CHUNK)
-        {
-            if (sampleno == 8000)
-            {
-                /* 100ms seize */
-                printf(&quot;100ms seize - %d samples\n&quot;, ms_to_samples(100));
-                dial_pulses = 0;
-                sig_tone_tx_set_mode(&amp;tx_state, 0, ms_to_samples(100));
-            }
-            for (i = 0;  i &lt; SAMPLES_PER_CHUNK;  i++)
-                amp[i] = awgn(&amp;noise_source);
-            /*endfor*/
-            tx_samples = sig_tone_tx(&amp;tx_state, amp, SAMPLES_PER_CHUNK);
-            for (i = 0;  i &lt; tx_samples;  i++)
-                out_amp[2*i] = amp[i];
-            /*endfor*/
-            codec_munge(munge, amp, tx_samples);
-            rx_samples = sig_tone_rx(&amp;rx_state, amp, tx_samples);
-            for (i = 0;  i &lt; rx_samples;  i++)
-                out_amp[2*i + 1] = amp[i];
-            /*endfor*/
-            outframes = sf_writef_short(outhandle, out_amp, rx_samples);
-            if (outframes != rx_samples)
-            {
-                fprintf(stderr, &quot;    Error writing audio file\n&quot;);
-                exit(2);
-            }
-            /*endif*/
-        }
-        /*endfor*/
</del><ins>+        sequence_tests(&amp;tx_state, &amp;rx_state, munge);
</ins><span class="cx">     }
</span><span class="cx">     /*endfor*/
</span><del>-    if (sf_close(outhandle) != 0)
-    {
-        fprintf(stderr, &quot;    Cannot close audio file '%s'\n&quot;, OUT_FILE_NAME);
-        exit(2);
-    }
-    /*endif*/
</del><span class="cx">     
</span><span class="cx">     printf(&quot;Tests completed.\n&quot;);
</span><span class="cx">     return  0;
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>

</body>
</html>