]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Lots of little cosmetic cleanups
authorSteve Underwood <steveu@coppice.org>
Thu, 14 Mar 2013 13:22:51 +0000 (21:22 +0800)
committerSteve Underwood <steveu@coppice.org>
Thu, 14 Mar 2013 13:22:51 +0000 (21:22 +0800)
110 files changed:
libs/spandsp/src/complex_filters.c
libs/spandsp/src/crc.c
libs/spandsp/src/dds_int.c
libs/spandsp/src/dtmf.c
libs/spandsp/src/echo.c
libs/spandsp/src/filter_tools.c
libs/spandsp/src/floating_fudge.h
libs/spandsp/src/fsk.c
libs/spandsp/src/gsm0610_encode.c
libs/spandsp/src/gsm0610_local.h
libs/spandsp/src/lpc10_encdecs.h
libs/spandsp/src/math_fixed.c
libs/spandsp/src/modem_connect_tones.c
libs/spandsp/src/msvc/config.h
libs/spandsp/src/msvc/inttypes.h
libs/spandsp/src/msvc/spandsp.h
libs/spandsp/src/oki_adpcm.c
libs/spandsp/src/sig_tone.c
libs/spandsp/src/spandsp/complex.h
libs/spandsp/src/spandsp/complex_vector_float.h
libs/spandsp/src/spandsp/complex_vector_int.h
libs/spandsp/src/spandsp/dc_restore.h
libs/spandsp/src/spandsp/dtmf.h
libs/spandsp/src/spandsp/echo.h
libs/spandsp/src/spandsp/fast_convert.h
libs/spandsp/src/spandsp/fir.h
libs/spandsp/src/spandsp/fsk.h
libs/spandsp/src/spandsp/g168models.h
libs/spandsp/src/spandsp/hdlc.h
libs/spandsp/src/spandsp/noise.h
libs/spandsp/src/spandsp/oki_adpcm.h
libs/spandsp/src/spandsp/playout.h
libs/spandsp/src/spandsp/private/dtmf.h
libs/spandsp/src/spandsp/private/echo.h
libs/spandsp/src/spandsp/private/hdlc.h
libs/spandsp/src/spandsp/private/oki_adpcm.h
libs/spandsp/src/spandsp/private/t31.h
libs/spandsp/src/spandsp/private/t85.h
libs/spandsp/src/spandsp/super_tone_rx.h
libs/spandsp/src/spandsp/super_tone_tx.h
libs/spandsp/src/spandsp/t38_terminal.h
libs/spandsp/src/spandsp/t42.h
libs/spandsp/src/spandsp/t4_rx.h
libs/spandsp/src/spandsp/t4_t6_encode.h
libs/spandsp/src/spandsp/t4_tx.h
libs/spandsp/src/spandsp/t81_t82_arith_coding.h
libs/spandsp/src/spandsp/t85.h
libs/spandsp/src/spandsp/tone_detect.h
libs/spandsp/src/spandsp/v8.h
libs/spandsp/src/spandsp/vector_int.h
libs/spandsp/src/super_tone_tx.c
libs/spandsp/src/swept_tone.c
libs/spandsp/src/t35.c
libs/spandsp/src/t42.c
libs/spandsp/src/t4_t6_decode.c
libs/spandsp/src/t4_t6_encode.c
libs/spandsp/src/t4_tx.c
libs/spandsp/src/testcpuid.c
libs/spandsp/src/time_scale.c
libs/spandsp/src/tone_detect.c
libs/spandsp/src/v27ter_tx.c
libs/spandsp/src/v42.c
libs/spandsp/src/v42bis.c
libs/spandsp/src/v8.c
libs/spandsp/src/vector_float.c
libs/spandsp/test-data/etsi/fax/generate_etsi_300_242_pages.c
libs/spandsp/test-data/itu/fax/generate_dithered_tif.c
libs/spandsp/test-data/itu/fax/generate_sized_pages.c
libs/spandsp/tests/ademco_contactid_tests.c
libs/spandsp/tests/adsi_tests.c
libs/spandsp/tests/async_tests.c
libs/spandsp/tests/at_interpreter_tests.c
libs/spandsp/tests/awgn_tests.c
libs/spandsp/tests/bell_mf_rx_tests.c
libs/spandsp/tests/dc_restore_tests.c
libs/spandsp/tests/dtmf_rx_tests.c
libs/spandsp/tests/echo_tests.c
libs/spandsp/tests/fax_decode.c
libs/spandsp/tests/fax_tester.c
libs/spandsp/tests/fax_tests.c
libs/spandsp/tests/fax_utils.c
libs/spandsp/tests/fsk_tests.c
libs/spandsp/tests/g711_tests.c
libs/spandsp/tests/g722_tests.c
libs/spandsp/tests/g726_tests.c
libs/spandsp/tests/gsm0610_tests.c
libs/spandsp/tests/hdlc_tests.c
libs/spandsp/tests/ima_adpcm_tests.c
libs/spandsp/tests/image_translate_tests.c
libs/spandsp/tests/make_g168_css.c
libs/spandsp/tests/modem_connect_tones_tests.c
libs/spandsp/tests/modem_echo_tests.c
libs/spandsp/tests/noise_tests.c
libs/spandsp/tests/pcap_parse.c
libs/spandsp/tests/playout_tests.c
libs/spandsp/tests/power_meter_tests.c
libs/spandsp/tests/queue_tests.c
libs/spandsp/tests/r2_mf_rx_tests.c
libs/spandsp/tests/rfc2198_sim_tests.c
libs/spandsp/tests/saturated_tests.c
libs/spandsp/tests/schedule_tests.c
libs/spandsp/tests/sig_tone_tests.c
libs/spandsp/tests/super_tone_rx_tests.c
libs/spandsp/tests/super_tone_tx_tests.c
libs/spandsp/tests/t31_pseudo_terminal_tests.c
libs/spandsp/tests/t85_tests.c
libs/spandsp/tests/tone_generate_tests.c
libs/spandsp/tests/udptl.c
libs/spandsp/tests/v18_tests.c
libs/spandsp/tests/v22bis_tests.c

index 36af84b36a26fcf1c107af1c88fb341c99a02913..d54e55818a43ac049f238cf7fc168cc70198cef8 100644 (file)
@@ -101,7 +101,7 @@ SPAN_DECLARE(void) cfilter_delete(cfilter_t *cfi)
 SPAN_DECLARE(complexf_t) cfilter_step(cfilter_t *cfi, const complexf_t *z)
 {
     complexf_t cc;
-    
+
     cc.re = filter_step(cfi->ref, z->re);
     cc.im = filter_step(cfi->imf, z->im);
     return cc;
index f970fe8a2c763800d0507a676b844a804aa92209..f7407eda1f58a93d2809d8306f8822ccba0a4bdb 100644 (file)
 
 static const uint32_t crc_itu32_table[] =
 {
-    0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 
-    0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 
-    0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 
-    0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 
-    0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 
-    0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 
-    0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 
-    0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 
-    0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 
-    0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, 
-    0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 
-    0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 
-    0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 
-    0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 
-    0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 
-    0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 
-    0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 
-    0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 
-    0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 
-    0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 
-    0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 
-    0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, 
-    0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 
-    0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 
-    0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 
-    0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 
-    0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 
-    0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 
-    0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 
-    0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 
-    0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 
+    0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
+    0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
+    0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
+    0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
+    0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
+    0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
+    0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
+    0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
+    0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
+    0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
+    0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
+    0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
+    0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
+    0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
+    0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
+    0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
+    0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
+    0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
+    0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
+    0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
+    0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
+    0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
+    0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
+    0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
+    0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
+    0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
+    0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
+    0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
+    0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
+    0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
+    0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
     0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
 };
 
index ad126f620a6e541068c0b52212eda3f32927e27e..3f1734b88beb1dc5d633b0e8d84efe03baa9a2c2 100644 (file)
@@ -348,7 +348,7 @@ SPAN_DECLARE(int16_t) dds_lookup(uint32_t phase)
         step = DDS_STEPS - step;
     amp = sine_table[step];
     if ((phase & (2*DDS_STEPS)))
-       amp = -amp;
+        amp = -amp;
     return amp;
 }
 /*- End of function --------------------------------------------------------*/
index 196e3d3eca39c4d149d5e67d246af6d30edf7e0c..6884d2b770c063d9a478765211a84882c870929d 100644 (file)
@@ -22,7 +22,7 @@
  * License along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
+
 /*! \file */
 
 #if defined(HAVE_CONFIG_H)
@@ -129,7 +129,7 @@ SPAN_DECLARE(int) dtmf_rx(dtmf_rx_state_t *s, const int16_t amp[], int samples)
             limit = sample + (DTMF_SAMPLES_PER_BLOCK - s->current_sample);
         else
             limit = samples;
-        /* The following unrolled loop takes only 35% (rough estimate) of the 
+        /* The following unrolled loop takes only 35% (rough estimate) of the
            time of a rolled loop on the machine on which it was developed */
         for (j = sample;  j < limit;  j++)
         {
index 0b1aaac2aa2b125a4818732037944405ac0201c3..84926fa3c4c75971f6c08ff16791409a6e1fcbae 100644 (file)
 /* The FIR taps must be adapted as 32 bit values, to get the necessary finesse
    in the adaption process. However, they are applied as 16 bit values (bits 30-15
    of the 32 bit values) in the FIR. For the working 16 bit values, we need 4 sets.
-   
+
    3 of the 16 bit sets are used on a rotating basis. Normally the canceller steps
    round these 3 sets at regular intervals. Any time we detect double talk, we can go
    back to the set from two steps ago with reasonable assurance it is a well adapted
    set. We cannot just go back one step, as we may have rotated the sets just before
    double talk or tone was detected, and that set may already be somewhat corrupted.
-   
+
    When narrowband energy is detected we need to continue adapting to it, to echo
    cancel it. However, the adaption will almost certainly be going astray. Broadband
    (or even complex sequences of narrowband) energy will normally lead to a well
@@ -129,7 +129,7 @@ static int narrowband_detect(echo_can_state_t *ec)
     int score;
     int len = 32;
     int alen = 9;
-    
+
     k = ec->curr_pos;
     for (i = 0;  i < len;  i++)
     {
@@ -292,7 +292,7 @@ SPAN_DECLARE(int) echo_can_release(echo_can_state_t *ec)
 SPAN_DECLARE(int) echo_can_free(echo_can_state_t *ec)
 {
     int i;
-    
+
     fir16_free(&ec->fir_state);
     free(ec->fir_taps32);
     for (i = 0;  i < 4;  i++)
@@ -361,7 +361,7 @@ static __inline__ int16_t echo_can_hpf(int32_t coeff[2], int16_t amp)
 {
     int32_t z;
 
-    /* 
+    /*
        Filter DC, 3dB point is 160Hz (I think), note 32 bit precision required
        otherwise values do not track down to 0. Zero at DC, Pole at (1-Beta)
        only real axis.  Some chip sets (like Si labs) don't need
@@ -371,7 +371,7 @@ static __inline__ int16_t echo_can_hpf(int32_t coeff[2], int16_t amp)
        Note: removes some low frequency from the signal, this reduces
        the speech quality when listening to samples through headphones
        but may not be obvious through a telephone handset.
-                                                                    
+
        Note that the 3dB frequency in radians is approx Beta, e.g. for
        Beta = 2^(-3) = 0.125, 3dB freq is 0.125 rads = 159Hz.
 
index 17437471668d77a8fc980e48542983316a922b99..88967e93ed71c9674f513b5168bd335ffb77824d 100644 (file)
@@ -25,7 +25,7 @@
  * License along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
+
 #if defined(HAVE_CONFIG_H)
 #include "config.h"
 #endif
@@ -55,7 +55,7 @@
 #define TRUE (!FALSE)
 #endif
 
-#define MAXPZ      8192
+#define MAXPZ       8192
 #define SEQ_LEN     8192
 #define MAX_FFT_LEN SEQ_LEN
 
@@ -139,7 +139,7 @@ void compute_raised_cosine_filter(double coeffs[],
     int i;
     int j;
     int h;
-    
+
     f1 = (1.0 - beta)*alpha;
     f2 = (1.0 + beta)*alpha;
     tau = 0.5/alpha;
@@ -162,10 +162,10 @@ void compute_raised_cosine_filter(double coeffs[],
     if (sinc_compensate)
     {
         for (i = 1;  i <= SEQ_LEN/2;  i++)
-           {
+        {
             x = 3.1415926535*(double) i/(double) SEQ_LEN;
-               vec[i].re *= (x/sin(x));
-           }
+            vec[i].re *= (x/sin(x));
+        }
     }
     for (i = 0;  i <= SEQ_LEN/2;  i++)
         vec[i].re *= tau;
@@ -228,7 +228,7 @@ void truncate_coeffs(double coeffs[], int len, int bits, int hilbert)
 
     fac = pow(2.0, (double) (bits - 1.0));
     h = (len - 1)/2;
-    max = (hilbert)  ?  coeffs[h - 1]  :  coeffs[h];   /* Max coeff */
+    max = (hilbert)  ?  coeffs[h - 1]  :  coeffs[h];    /* Max coeff */
     scale = (fac - 1.0)/(fac*max);
     for (i = 0;  i < len;  i++)
     {
index 2ef0423399f0606b8ddb967836e4892baf725878..a2e46db46d91f500fe8923168156122036c02dd7 100644 (file)
@@ -37,42 +37,42 @@ extern "C"
 #if !defined(HAVE_SINF)
 static __inline__ float sinf(float x)
 {
-       return (float) sin((double) x);
+    return (float) sin((double) x);
 }
 #endif
 
 #if !defined(HAVE_COSF)
 static __inline__ float cosf(float x)
 {
-       return (float) cos((double) x);
+    return (float) cos((double) x);
 }
 #endif
 
 #if !defined(HAVE_TANF)
 static __inline__ float tanf(float x)
 {
-       return (float) tan((double) x);
+    return (float) tan((double) x);
 }
 #endif
 
 #if !defined(HAVE_ASINF)
 static __inline__ float asinf(float x)
 {
-       return (float) asin((double) x);
+    return (float) asin((double) x);
 }
 #endif
 
 #if !defined(HAVE_ACOSF)
 static __inline__ float acosf(float x)
 {
-       return (float) acos((double) x);
+    return (float) acos((double) x);
 }
 #endif
 
 #if !defined(HAVE_ATANF)
 static __inline__ float atanf(float x)
 {
-       return (float) atan((double) x);
+    return (float) atan((double) x);
 }
 
 #endif
@@ -80,7 +80,7 @@ static __inline__ float atanf(float x)
 #if !defined(HAVE_ATAN2F)
 static __inline__ float atan2f(float y, float x)
 {
-       return (float) atan2((double) y, (double) x);
+    return (float) atan2((double) y, (double) x);
 }
 
 #endif
@@ -88,14 +88,14 @@ static __inline__ float atan2f(float y, float x)
 #if !defined(HAVE_CEILF)
 static __inline__ float ceilf(float x)
 {
-       return (float) ceil((double) x);
+    return (float) ceil((double) x);
 }
 #endif
 
 #if !defined(HAVE_FLOORF)
 static __inline__ float floorf(float x)
 {
-       return (float) floor((double) x);
+    return (float) floor((double) x);
 }
 
 #endif
@@ -117,7 +117,7 @@ static __inline__ float expf(float x)
 #if !defined(HAVE_LOGF)
 static __inline__ float logf(float x)
 {
-       return (float) logf((double) x);
+    return (float) logf((double) x);
 }
 #endif
 
index d95f7574689044ab0e43399fcbc2cd689323017b..56f155169e74c873cce673aef144bc43ed9ac36c 100644 (file)
@@ -144,7 +144,7 @@ SPAN_DECLARE(int) fsk_tx_restart(fsk_tx_state_t *s, const fsk_spec_t *spec)
     s->phase_acc = 0;
     s->baud_frac = 0;
     s->current_phase_rate = s->phase_rates[1];
-    
+
     s->shutdown = FALSE;
     return 0;
 }
@@ -273,7 +273,7 @@ SPAN_DECLARE(int) fsk_rx_restart(fsk_rx_state_t *s, const fsk_spec_t *spec, int
 
     /* Detect by correlating against the tones we want, over a period
        of one baud. The correlation must be quadrature. */
-    
+
     /* First we need the quadrature tone generators to correlate
        against. */
     s->phase_rate[0] = dds_phase_rate((float) spec->freq_zero);
@@ -303,7 +303,7 @@ SPAN_DECLARE(int) fsk_rx_restart(fsk_rx_state_t *s, const fsk_spec_t *spec, int
     s->frame_state = 0;
     s->frame_bits = 0;
     s->last_bit = 0;
-    
+
     /* Initialise a power detector, so sense when a signal is present. */
     power_meter_init(&(s->power), 4);
     s->signal_present = 0;
index c9e5251ef03f99dfb41b490d8cda096eb86ee8eb..2c359688fede95f2d9a86353bb07931a52435d7d 100644 (file)
@@ -170,32 +170,32 @@ SPAN_DECLARE(int) gsm0610_pack_wav49(uint8_t c[], const gsm0610_frame_t *s)
     uint16_t sr;
     int i;
 
-       sr = 0;
-       sr = (sr >> 6) | (s->LARc[0] << 10);
-       sr = (sr >> 6) | (s->LARc[1] << 10);
-       *c++ = (uint8_t) (sr >> 4);
-       sr = (sr >> 5) | (s->LARc[2] << 11);
-       *c++ = (uint8_t) (sr >> 7);
-       sr = (sr >> 5) | (s->LARc[3] << 11);
-       sr = (sr >> 4) | (s->LARc[4] << 12);
-       *c++ = (uint8_t) (sr >> 6);
-       sr = (sr >> 4) | (s->LARc[5] << 12);
-       sr = (sr >> 3) | (s->LARc[6] << 13);
-       *c++ = (uint8_t) (sr >> 7);
-       sr = (sr >> 3) | (s->LARc[7] << 13);
+    sr = 0;
+    sr = (sr >> 6) | (s->LARc[0] << 10);
+    sr = (sr >> 6) | (s->LARc[1] << 10);
+    *c++ = (uint8_t) (sr >> 4);
+    sr = (sr >> 5) | (s->LARc[2] << 11);
+    *c++ = (uint8_t) (sr >> 7);
+    sr = (sr >> 5) | (s->LARc[3] << 11);
+    sr = (sr >> 4) | (s->LARc[4] << 12);
+    *c++ = (uint8_t) (sr >> 6);
+    sr = (sr >> 4) | (s->LARc[5] << 12);
+    sr = (sr >> 3) | (s->LARc[6] << 13);
+    *c++ = (uint8_t) (sr >> 7);
+    sr = (sr >> 3) | (s->LARc[7] << 13);
 
     for (i = 0;  i < 4;  i++)
     {
-       sr = (sr >> 7) | (s->Nc[i] << 9);
-       *c++ = (uint8_t) (sr >> 5);
-       sr = (sr >> 2) | (s->bc[i] << 14);
-       sr = (sr >> 2) | (s->Mc[i] << 14);
-       sr = (sr >> 6) | (s->xmaxc[i] << 10);
-       *c++ = (uint8_t) (sr >> 3);
-       sr = (sr >> 3) | (s->xMc[i][0] << 13);
-       *c++ = (uint8_t) (sr >> 8);
-       sr = (sr >> 3) | (s->xMc[i][1] << 13);
-       sr = (sr >> 3) | (s->xMc[i][2] << 13);
+        sr = (sr >> 7) | (s->Nc[i] << 9);
+        *c++ = (uint8_t) (sr >> 5);
+        sr = (sr >> 2) | (s->bc[i] << 14);
+        sr = (sr >> 2) | (s->Mc[i] << 14);
+        sr = (sr >> 6) | (s->xmaxc[i] << 10);
+        *c++ = (uint8_t) (sr >> 3);
+        sr = (sr >> 3) | (s->xMc[i][0] << 13);
+        *c++ = (uint8_t) (sr >> 8);
+        sr = (sr >> 3) | (s->xMc[i][1] << 13);
+        sr = (sr >> 3) | (s->xMc[i][2] << 13);
         sr = (sr >> 3) | (s->xMc[i][3] << 13);
         *c++ = (uint8_t) (sr >> 7);
         sr = (sr >> 3) | (s->xMc[i][4] << 13);
index e3150f62de7dca511fd43f2b75071f97bac33c1d..84c4c20edca292d577cc0c899a29a30aa2a4fe2c 100644 (file)
@@ -31,7 +31,7 @@
 
 #define GSM0610_FRAME_LEN               160
 
-#define        GSM0610_MAGIC                   0xD
+#define GSM0610_MAGIC                   0xD
 
 #include "spandsp/private/gsm0610.h"
 
index f146652ac40f146c866805a5ceecbb81a67475ee..621b15a83a59f2920081d17562c4aa930d19474b 100644 (file)
@@ -62,7 +62,7 @@ void lpc10_voicing(lpc10_encode_state_t *st,
                    int32_t half,
                    float *minamd,
                    float *maxamd,
-                      int32_t *mintau,
+                   int32_t *mintau,
                    float *ivrc,
                    int32_t *obound);
 
index b4d57a917d925b867aaf6a6fd2324189482794d4..f538f106f4a27bbc1e62ea1c1677f70ff0ed0edd 100644 (file)
@@ -180,7 +180,7 @@ SPAN_DECLARE(int16_t) fixed_sin(uint16_t x)
     }
     z = fixed_sine_table[step] + ((frac*(fixed_sine_table[step_after] - fixed_sine_table[step])) >> 6);
     if ((x & 0x8000))
-       z = -z;
+        z = -z;
     return z;
 }
 /*- End of function --------------------------------------------------------*/
@@ -206,7 +206,7 @@ SPAN_DECLARE(int16_t) fixed_cos(uint16_t x)
     }
     z = fixed_sine_table[step] + ((frac*(fixed_sine_table[step_after] - fixed_sine_table[step])) >> 6);
     if ((x & 0x8000))
-       z = -z;
+        z = -z;
     return z;
 }
 /*- End of function --------------------------------------------------------*/
index 0ad2b4bda415d6997142d81bfea51386459586cb..76b42a23fc7b9300363f5137f8f7c20f38fc3422 100644 (file)
@@ -23,7 +23,7 @@
  * License along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
+
 /*! \file */
 
 /* CNG is 0.5s+-15% of 1100+-38Hz, 3s+-15% off, repeating.
@@ -36,7 +36,7 @@
 
    ANS/ is 3.3+-0.7s of 2100+-15Hz, with phase reversals (180+-10 degrees, hopping in <1ms) every 450+-25ms.
 
-   ANSam/ is 2100+-1Hz, with phase reversals (180+-10 degrees, hopping in <1ms) every 450+-25ms, and AM with a sinewave of 15+-0.1Hz. 
+   ANSam/ is 2100+-1Hz, with phase reversals (180+-10 degrees, hopping in <1ms) every 450+-25ms, and AM with a sinewave of 15+-0.1Hz.
    The modulated envelope ranges in amplitude between (0.8+-0.01) and (1.2+-0.01) times its average
    amplitude. It lasts up to 5s, but will be stopped early if the V.8 protocol proceeds. */
 
@@ -702,7 +702,7 @@ SPAN_DECLARE_NONSTD(int) modem_connect_tones_rx_fillin(modem_connect_tones_rx_st
 SPAN_DECLARE(int) modem_connect_tones_rx_get(modem_connect_tones_rx_state_t *s)
 {
     int x;
-    
+
     x = s->hit;
     s->hit = MODEM_CONNECT_TONES_NONE;
     return x;
index 42494d345f69b0762a11572947d088bf26b88172..876f66f56aaaf72a33eea6bfeefc339438232de9 100644 (file)
@@ -54,8 +54,8 @@
     #endif
   #endif // VC8+
 
-  // disable the following warnings 
-  #pragma warning(disable:4100) // The formal parameter is not referenced in the body of the function. The unreferenced parameter is ignored. 
+  // disable the following warnings
+  #pragma warning(disable:4100) // The formal parameter is not referenced in the body of the function. The unreferenced parameter is ignored.
   #pragma warning(disable:4200) // Non standard extension C zero sized array
   #pragma warning(disable:4706) // assignment within conditional expression
   #pragma warning(disable:4244) // conversion from 'type1' to 'type2', possible loss of data
index beb93cae10b8aedc5cc57e30474ef03f6913ebdf..032ec3c36cbe16688774c4476718d0b6c16226a3 100644 (file)
@@ -48,10 +48,10 @@ typedef __int64                     int64_t;
 #endif
 
 #if !defined(INT16_MAX)
-#define INT16_MAX   0x7FFF 
+#define INT16_MAX   0x7FFF
 #endif
 #if !defined(INT16_MIN)
-#define INT16_MIN   (-INT16_MAX - 1) 
+#define INT16_MIN   (-INT16_MAX - 1)
 #endif
 
 #if !defined(INT32_MAX)
index 6ba0b82cece6f34a610bcb80eb73fa12d1524d85..806c9ce92050d1567150d68f7b612f4d059919c0 100644 (file)
 #include <spandsp/v29tx.h>
 #include <spandsp/v17rx.h>
 #include <spandsp/v17tx.h>
+#include <spandsp/v32bis.h>
 #include <spandsp/v22bis.h>
 #include <spandsp/v27ter_rx.h>
 #include <spandsp/v27ter_tx.h>
+#if defined(SPANDSP_SUPPORT_V34)
+#include <spandsp/v34.h>
+#endif
 #include <spandsp/v18.h>
 #include <spandsp/timezone.h>
 #include <spandsp/t4_rx.h>
index f3fd6d9f95464599e309a530ac119e51a18ebd2a..f6d54b804c49368b1e519e27520c7f7448f720b8 100644 (file)
@@ -159,7 +159,7 @@ static int16_t decode(oki_adpcm_state_t *s, uint8_t adpcm)
      *
      * x = adpcm & 0x07;
      * e = (step_size[s->step_index]*(x + x + 1)) >> 3;
-     * 
+     *
      * Seems an obvious improvement on a modern machine, but remember
      * the truncation errors do not come out the same. It would
      * not, therefore, be an exact match for what this code is doing.
@@ -251,7 +251,7 @@ SPAN_DECLARE(oki_adpcm_state_t *) oki_adpcm_init(oki_adpcm_state_t *s, int bit_r
     }
     memset(s, 0, sizeof(*s));
     s->bit_rate = bit_rate;
-    
+
     return s;
 }
 /*- End of function --------------------------------------------------------*/
@@ -281,7 +281,7 @@ SPAN_DECLARE(int) oki_adpcm_decode(oki_adpcm_state_t *s,
     int samples;
     float z;
 
-#if (_MSC_VER >= 1400) 
+#if (_MSC_VER >= 1400)
     __analysis_assume(s->phase >= 0  &&  s->phase <= 4);
 #endif
     samples = 0;
index ed6b2fa52312ff792ab3998d98228e8d3a8580f3..5e4e18017800aa8d2d312932d3a24a8595ef2069 100644 (file)
@@ -117,11 +117,11 @@ static const sig_tone_flat_coeffs_t flat_coeffs[1] =
 {
     {
 #if defined(SPANDSP_USE_FIXED_POINT)
-        { 12900,       -16384,         -16384}, 
+        { 12900,       -16384,         -16384},
         {     0,        -8578,         -11796},
         15,
 #else
-        {0.393676f,    -0.5f,          -0.5f}, 
+        {0.393676f,    -0.5f,          -0.5f},
         {0.0f,         -0.261778f,     -0.359985f},
 #endif
     }
@@ -136,7 +136,7 @@ static const sig_tone_descriptor_t sig_tones[3] =
         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 */
-    
+
         ms_to_samples(3),           /* Tone on persistence check */
         ms_to_samples(8),           /* Tone off persistence check */
 
@@ -158,7 +158,7 @@ static const sig_tone_descriptor_t sig_tones[3] =
         ms_to_samples(0),
         ms_to_samples(0),
         ms_to_samples(225),
-    
+
         ms_to_samples(3),
         ms_to_samples(8),
 
@@ -168,7 +168,7 @@ static const sig_tone_descriptor_t sig_tones[3] =
             NULL,
         },
         NULL,
-    
+
         15.6f,
         -30.0f,
         -30.0f
@@ -190,7 +190,7 @@ static const sig_tone_descriptor_t sig_tones[3] =
             &notch_coeffs[NOTCH_COEFF_SET_2600HZ]
         },
         NULL,
-    
+
         15.6f,
         -30.0f,
         -30.0f
@@ -299,7 +299,7 @@ SPAN_DECLARE(void) sig_tone_tx_set_mode(sig_tone_tx_state_t *s, int mode, int du
 {
     int old_tones;
     int new_tones;
-    
+
     old_tones = s->current_tx_tone & (SIG_TONE_1_PRESENT | SIG_TONE_2_PRESENT);
     new_tones = mode & (SIG_TONE_1_PRESENT | SIG_TONE_2_PRESENT);
     if (new_tones  &&  old_tones != new_tones)
@@ -490,7 +490,7 @@ SPAN_DECLARE(int) sig_tone_rx(sig_tone_rx_state_t *s, int16_t amp[], int len)
 #endif
             }
             flat_power = power_meter_update(&s->flat_power, bandpass_signal);
-    
+
             /* For the flat receiver we use a simple power threshold! */
             if ((s->signalling_state & (SIG_TONE_1_PRESENT | SIG_TONE_2_PRESENT)))
             {
@@ -634,7 +634,7 @@ SPAN_DECLARE(sig_tone_rx_state_t *) sig_tone_rx_init(sig_tone_rx_state_t *s, int
 #if !defined(SPANDSP_USE_FIXED_POINT)
     int j;
 #endif
-    
+
     if (sig_update == NULL  ||  tone_type < 1  ||  tone_type > 3)
         return NULL;
     /*endif*/
index af98c078d14e120dea60fec47dd19b35d027ae9f..4958a5898f31a3e95811403cbdb9e08b88b1c3e8 100644 (file)
@@ -381,7 +381,7 @@ static __inline__ complexf_t complex_divf(const complexf_t *x, const complexf_t
 {
     complexf_t z;
     float f;
-    
+
     f = y->re*y->re + y->im*y->im;
     z.re = ( x->re*y->re + x->im*y->im)/f;
     z.im = (-x->re*y->im + x->im*y->re)/f;
@@ -393,7 +393,7 @@ static __inline__ complex_t complex_div(const complex_t *x, const complex_t *y)
 {
     complex_t z;
     double f;
-    
+
     f = y->re*y->re + y->im*y->im;
     z.re = ( x->re*y->re + x->im*y->im)/f;
     z.im = (-x->re*y->im + x->im*y->re)/f;
@@ -406,7 +406,7 @@ static __inline__ complexl_t complex_divl(const complexl_t *x, const complexl_t
 {
     complexl_t z;
     long double f;
-    
+
     f = y->re*y->re + y->im*y->im;
     z.re = ( x->re*y->re + x->im*y->im)/f;
     z.im = (-x->re*y->im + x->im*y->re)/f;
index 4dc3569f7af002dd1a09304944a5af4401442e3d..68e1302778a1f763a7e8447668aa0fa4f1aa73a6 100644 (file)
@@ -34,7 +34,7 @@ extern "C"
 static __inline__ void cvec_copyf(complexf_t z[], const complexf_t x[], int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = x[i];
 }
@@ -43,7 +43,7 @@ static __inline__ void cvec_copyf(complexf_t z[], const complexf_t x[], int n)
 static __inline__ void cvec_copy(complex_t z[], const complex_t x[], int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = x[i];
 }
@@ -53,7 +53,7 @@ static __inline__ void cvec_copy(complex_t z[], const complex_t x[], int n)
 static __inline__ void cvec_copyl(complexl_t z[], const complexl_t x[], int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = x[i];
 }
@@ -63,7 +63,7 @@ static __inline__ void cvec_copyl(complexl_t z[], const complexl_t x[], int n)
 static __inline__ void cvec_zerof(complexf_t z[], int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = complex_setf(0.0f, 0.0f);
 }
@@ -72,7 +72,7 @@ static __inline__ void cvec_zerof(complexf_t z[], int n)
 static __inline__ void cvec_zero(complex_t z[], int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = complex_set(0.0, 0.0);
 }
@@ -82,7 +82,7 @@ static __inline__ void cvec_zero(complex_t z[], int n)
 static __inline__ void cvec_zerol(complexl_t z[], int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = complex_setl(0.0, 0.0);
 }
@@ -92,7 +92,7 @@ static __inline__ void cvec_zerol(complexl_t z[], int n)
 static __inline__ void cvec_setf(complexf_t z[], complexf_t *x, int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = *x;
 }
@@ -101,7 +101,7 @@ static __inline__ void cvec_setf(complexf_t z[], complexf_t *x, int n)
 static __inline__ void cvec_set(complex_t z[], complex_t *x, int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = *x;
 }
@@ -111,7 +111,7 @@ static __inline__ void cvec_set(complex_t z[], complex_t *x, int n)
 static __inline__ void cvec_setl(complexl_t z[], complexl_t *x, int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = *x;
 }
index 320457d57f0f185236a136893c104f25bd8092d9..a77207a63f9bd4a301f7424b0e346c7ca3a96b77 100644 (file)
@@ -70,7 +70,7 @@ static __inline__ void cvec_zeroi32(complexi32_t z[], int n)
 static __inline__ void cvec_seti(complexi_t z[], complexi_t *x, int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = *x;
 }
@@ -79,7 +79,7 @@ static __inline__ void cvec_seti(complexi_t z[], complexi_t *x, int n)
 static __inline__ void cvec_seti16(complexi16_t z[], complexi16_t *x, int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = *x;
 }
@@ -88,7 +88,7 @@ static __inline__ void cvec_seti16(complexi16_t z[], complexi16_t *x, int n)
 static __inline__ void cvec_seti32(complexi32_t z[], complexi32_t *x, int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = *x;
 }
index 94ff6c7e70c5f46ec0397414b45f1d64c7007f45..5579e0c57a2aa23b697e46dd1c02e863390ba71f 100644 (file)
@@ -35,7 +35,7 @@
 
 Telecoms signals often contain considerable DC, but DC upsets a lot of signal
 processing functions. Placing a zero DC restorer at the front of the processing
-chain can often simplify the downstream processing. 
+chain can often simplify the downstream processing.
 
 \section dc_restore_page_sec_2 How does it work?
 
@@ -44,10 +44,10 @@ the DC bias in the signal. A 32 bit estimate is used for the 16 bit audio, so
 the noise introduced by the estimation can be keep in the lower bits, and the 16
 bit DC value, which is subtracted from the signal, is fairly clean. The
 following code fragment shows the algorithm used. dc_bias is a 32 bit integer,
-while the sample and the resulting clean_sample are 16 bit integers. 
+while the sample and the resulting clean_sample are 16 bit integers.
 
     dc_bias += ((((int32_t) sample << 15) - dc_bias) >> 14);
-    clean_sample = sample - (dc_bias >> 15); 
+    clean_sample = sample - (dc_bias >> 15);
 */
 
 /*!
index 58ea779088cf1833c9f28b5ab57e5f2be491ca8f..df9660feeef580e8686561904b6722cf97960827 100644 (file)
@@ -31,7 +31,7 @@
 The DTMF receiver detects the standard DTMF digits. It is compliant with
 ITU-T Q.23, ITU-T Q.24, and the local DTMF specifications of most administrations.
 Its passes the test suites. It also scores *very* well on the standard
-talk-off tests. 
+talk-off tests.
 
 The current design uses floating point extensively. It is not tolerant of DC.
 It is expected that a DC restore stage will be placed before the DTMF detector.
@@ -66,7 +66,7 @@ TODO:
 \section dtmf_tx_page_sec_1 What does it do?
 
 The DTMF tone generation module provides for the generation of the
-repertoire of 16 DTMF dual tones. 
+repertoire of 16 DTMF dual tones.
 
 \section dtmf_tx_page_sec_2 How does it work?
 */
@@ -96,7 +96,7 @@ extern "C"
     \param s The DTMF generator context.
     \param amp The buffer for the generated signal.
     \param max_samples The required number of generated samples.
-    \return The number of samples actually generated. This may be less than 
+    \return The number of samples actually generated. This may be less than
             max_samples if the input buffer empties. */
 SPAN_DECLARE(int) dtmf_tx(dtmf_tx_state_t *s, int16_t amp[], int max_samples);
 
index ec8c53b023e2a6898657649088a54576e7024eae..14f856068fc3bcc381ad54c2a097933afd33c1d7 100644 (file)
@@ -2,8 +2,8 @@
  * SpanDSP - a series of DSP components for telephony
  *
  * echo.h - An echo cancellor, suitable for electrical and acoustic
- *             cancellation. This code does not currently comply with
- *             any relevant standards (e.g. G.164/5/7/8).
+ *          cancellation. This code does not currently comply with
+ *          any relevant standards (e.g. G.164/5/7/8).
  *
  * Written by Steve Underwood <steveu@coppice.org>
  *
@@ -43,7 +43,7 @@ the duration of that impulse response. The signal transmitted to the telephone l
 is passed through the FIR filter. Once the FIR is properly adapted, the resulting
 output is an estimate of the echo signal received from the line. This is subtracted
 from the received signal. The result is an estimate of the signal which originated
-at the far end of the line, free from echos of our own transmitted signal. 
+at the far end of the line, free from echos of our own transmitted signal.
 
 The least mean squares (LMS) algorithm is attributed to Widrow and Hoff, and was
 introduced in 1960. It is the commonest form of filter adaption used in things
@@ -67,7 +67,7 @@ complexity filter is adequate for this, so pre-whitening adds little to the
 compute requirements of the echo canceller.
 
 An FIR filter adapted using pre-whitened NLMS performs well, provided certain
-conditions are met: 
+conditions are met:
 
     - The transmitted signal has poor self-correlation.
     - There is no signal being generated within the environment being cancelled.
@@ -95,7 +95,7 @@ adaption is only performed when we are transmitting a significant signal level,
 and the environment is not, things will be OK. Clearly, it is easy to tell when
 we are sending a significant signal. Telling, if the environment is generating a
 significant signal, and doing it with sufficient speed that the adaption will
-not have diverged too much more we stop it, is a little harder. 
+not have diverged too much more we stop it, is a little harder.
 
 The key problem in detecting when the environment is sourcing significant energy
 is that we must do this very quickly. Given a reasonably long sample of the
@@ -103,13 +103,13 @@ received signal, there are a number of strategies which may be used to assess
 whether that signal contains a strong far end component. However, by the time
 that assessment is complete the far end signal will have already caused major
 mis-convergence in the adaption process. An assessment algorithm is needed which
-produces a fairly accurate result from a very short burst of far end energy. 
+produces a fairly accurate result from a very short burst of far end energy.
 
 \section echo_can_page_sec_3 How do I use it?
 The echo cancellor processes both the transmit and receive streams sample by
 sample. The processing function is not declared inline. Unfortunately,
 cancellation requires many operations per sample, so the call overhead is only a
-minor burden. 
+minor burden.
 */
 
 #include "fir.h"
index 10679eab4da2ad5e63625bafb1bf061eeeeeca26..e6da451f9c58387134c05ec6af6a32bfd12fd5b3 100644 (file)
@@ -273,16 +273,17 @@ extern "C"
 
     __inline float rintf(float flt)
     {
-       _asm
-       {       fld flt
-               frndint
-       }
+        _asm
+        {
+            fld flt
+            frndint
+        }
     }
 
     __inline double rint(double dbl)
     {
-        _asm 
-       {
+        _asm
+        {
             fld dbl
             frndint
         }
@@ -318,12 +319,12 @@ extern "C"
 
     __inline long int lrint(double x)
     {
-               return (long int)_mm_cvtsd_si64x( _mm_loadu_pd ((const double*)&x) );
+        return (long int)_mm_cvtsd_si64x( _mm_loadu_pd ((const double*)&x) );
     }
 
     __inline long int lrintf(float x)
     {
-               return _mm_cvt_ss2si( _mm_load_ss((const float*)&x) );
+        return _mm_cvt_ss2si( _mm_load_ss((const float*)&x) );
     }
 
     __inline long int lfastrint(double x)
index 52aab24db0b0945fda866be7a4cf12591cd08357..74b0bc2d3f6ddbb743cb3f8240e9114b5f5bdc4c 100644 (file)
@@ -197,7 +197,7 @@ static __inline__ int16_t fir16(fir16_state_t *fir, int16_t sample)
         y += fir->coeffs[i]*fir->history[i + offset2];
 #endif
     if (fir->curr_pos <= 0)
-       fir->curr_pos = fir->taps;
+        fir->curr_pos = fir->taps;
     fir->curr_pos--;
     return (int16_t) (y >> 15);
 }
@@ -212,7 +212,7 @@ static __inline__ const int16_t *fir32_create(fir32_state_t *fir,
     fir->coeffs = coeffs;
     fir->history = (int16_t *) malloc(taps*sizeof(int16_t));
     if (fir->history)
-       memset(fir->history, '\0', taps*sizeof(int16_t));
+        memset(fir->history, '\0', taps*sizeof(int16_t));
     return fir->history;
 }
 /*- End of function --------------------------------------------------------*/
@@ -245,7 +245,7 @@ static __inline__ int16_t fir32(fir32_state_t *fir, int16_t sample)
     for (  ;  i >= 0;  i--)
         y += fir->coeffs[i]*fir->history[i + offset2];
     if (fir->curr_pos <= 0)
-       fir->curr_pos = fir->taps;
+        fir->curr_pos = fir->taps;
     fir->curr_pos--;
     return (int16_t) (y >> 15);
 }
@@ -253,7 +253,7 @@ static __inline__ int16_t fir32(fir32_state_t *fir, int16_t sample)
 
 static __inline__ const float *fir_float_create(fir_float_state_t *fir,
                                                 const float *coeffs,
-                                               int taps)
+                                                int taps)
 {
     fir->taps = taps;
     fir->curr_pos = taps - 1;
@@ -264,7 +264,7 @@ static __inline__ const float *fir_float_create(fir_float_state_t *fir,
     return fir->history;
 }
 /*- End of function --------------------------------------------------------*/
-    
+
 static __inline__ void fir_float_free(fir_float_state_t *fir)
 {
     free(fir->history);
@@ -288,7 +288,7 @@ static __inline__ int16_t fir_float(fir_float_state_t *fir, int16_t sample)
     for (  ;  i >= 0;  i--)
         y += fir->coeffs[i]*fir->history[i + offset2];
     if (fir->curr_pos <= 0)
-       fir->curr_pos = fir->taps;
+        fir->curr_pos = fir->taps;
     fir->curr_pos--;
     return  (int16_t) y;
 }
index 9358b565cbc338e88840a7c4b3546cccc8231283..bcb8df1de76008b6f51239de07b2c214f91242a4 100644 (file)
@@ -29,7 +29,7 @@
 \section fsk_page_sec_1 What does it do?
 Most of the oldest telephony modems use incoherent FSK modulation. This module can
 be used to implement both the transmit and receive sides of a number of these
-modems. There are integrated definitions for: 
+modems. There are integrated definitions for:
 
  - V.21
  - V.23
@@ -38,7 +38,7 @@ modems. There are integrated definitions for:
  - Weitbrecht (Used for TDD - Telecoms Device for the Deaf)
 
 The audio output or input is a stream of 16 bit samples, at 8000 samples/second.
-The transmit and receive sides can be used independantly. 
+The transmit and receive sides can be used independantly.
 
 \section fsk_page_sec_2 The transmitter
 
@@ -48,7 +48,7 @@ switched, producing a clean spectrum. The symbols are not generally an integer
 number of samples long. However, the symbol time for the fastest data rate
 generally used (1200bps) is more than 7 samples long. The jitter resulting from
 switching at the nearest sample is, therefore, acceptable. No interpolation is
-used. 
+used.
 
 \section fsk_page_sec_3 The receiver
 
@@ -60,7 +60,7 @@ one that matches the frequency being transmitted during the correlation
 interval. Because the transmission is totally asynchronous, the demodulation
 process must run sample by sample to find the symbol transitions. The
 correlation is performed on a sliding window basis, so the computational load of
-demodulating sample by sample is not great. 
+demodulating sample by sample is not great.
 
 Two modes of symbol synchronisation are provided:
 
@@ -159,7 +159,7 @@ SPAN_DECLARE(fsk_tx_state_t *) fsk_tx_init(fsk_tx_state_t *s,
                                            void *user_data);
 
 SPAN_DECLARE(int) fsk_tx_restart(fsk_tx_state_t *s, const fsk_spec_t *spec);
-    
+
 SPAN_DECLARE(int) fsk_tx_release(fsk_tx_state_t *s);
 
 SPAN_DECLARE(int) fsk_tx_free(fsk_tx_state_t *s);
index 4e71112eefb4214929bf188696515a819491c788..686925c3692f394a7442c48fd041ac720c6e72e9 100644 (file)
@@ -2,7 +2,7 @@
  * SpanDSP - a series of DSP components for telephony
  *
  * g168models.h - line models for echo cancellation tests against the G.168
- *               spec.
+ *                spec.
  *
  * Written by Steve Underwood <steveu@coppice.org>
  *
index ce37a701fcc7494a709175fd87eabb1396ac7f99..cf5efe4330faf8b094847a4a2bad77a1913729ab 100644 (file)
@@ -40,10 +40,10 @@ HDLC may not be a DSP function, but is needed to accompany several DSP component
 #if !defined(_SPANDSP_HDLC_H_)
 #define _SPANDSP_HDLC_H_
 
-/*! 
+/*!
     HDLC_MAXFRAME_LEN is the maximum length of a stuffed HDLC frame, excluding the CRC.
 */
-#define HDLC_MAXFRAME_LEN       400    
+#define HDLC_MAXFRAME_LEN       400
 
 typedef void (*hdlc_frame_handler_t)(void *user_data, const uint8_t *pkt, int len, int ok);
 typedef void (*hdlc_underflow_handler_t)(void *user_data);
index 9014e482ef0e8d3d51516faab61a9c9e802d252c..ef867e3f02b3e462999a4d5f678febe5b4091d5a 100644 (file)
@@ -37,7 +37,7 @@ AWGN. It is designed to be of sufficiently low complexity to generate large
 volumes of reasonable quality noise, in real time.
 
 Hoth noise is used to model indoor ambient noise when evaluating communications
-systems such as telephones. It is named after D.F. Hoth, who made the first 
+systems such as telephones. It is named after D.F. Hoth, who made the first
 systematic study of this. The official definition of Hoth noise is IEEE
 standard 269-2001 (revised from 269-1992), "Draft Standard Methods for Measuring
 Transmission Performance of Analog and Digital Telephone Sets, Handsets and Headsets."
index c3707f07f8887c3701fb527a09a0e571cc3b113a..4b99a93358a7f46c7fab1b354296548154353918 100644 (file)
@@ -2,7 +2,7 @@
  * SpanDSP - a series of DSP components for telephony
  *
  * oki_adpcm.h - Conversion routines between linear 16 bit PCM data and
- *                      OKI (Dialogic) ADPCM format.
+ *               OKI (Dialogic) ADPCM format.
  *
  * Written by Steve Underwood <steveu@coppice.org>
  *
index 41d4a0cb46d7b6938253307f1f4a7c1a2f02fbde..582fcb2c51be08cda8af4864e35a1dcd82c0d856 100644 (file)
@@ -51,7 +51,7 @@ enum
 
 /* Frame types */
 #define PLAYOUT_TYPE_CONTROL    0
-#define PLAYOUT_TYPE_SILENCE   1
+#define PLAYOUT_TYPE_SILENCE    1
 #define PLAYOUT_TYPE_SPEECH     2
 
 typedef int timestamp_t;
index eae20ad4d541b5ef49b3575a769cd8c78ddf883b..c773ee61eefd41f8a8049ff5dc02bdceb908e351 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * SpanDSP - a series of DSP components for telephony
  *
- * private/dtmf.h - DTMF tone generation and detection 
+ * private/dtmf.h - DTMF tone generation and detection
  *
  * Written by Steve Underwood <steveu@coppice.org>
  *
index 98153ef0f8a48bf941db04ef307cc2e71abcb295..f2802842322f068a41276ccf44ad438f5cfb47e4 100644 (file)
@@ -2,8 +2,8 @@
  * SpanDSP - a series of DSP components for telephony
  *
  * private/echo.h - An echo cancellor, suitable for electrical and acoustic
- *                     cancellation. This code does not currently comply with
- *                     any relevant standards (e.g. G.164/5/7/8).
+ *                  cancellation. This code does not currently comply with
+ *                  any relevant standards (e.g. G.164/5/7/8).
  *
  * Written by Steve Underwood <steveu@coppice.org>
  *
@@ -44,11 +44,11 @@ struct echo_can_state_s
     int nonupdate_dwell;
 
     int curr_pos;
-       
+
     int taps;
     int tap_mask;
     int adaption_mode;
-    
+
     int32_t supp_test1;
     int32_t supp_test2;
     int32_t supp1;
@@ -78,14 +78,14 @@ struct echo_can_state_s
     /* DC and near DC blocking filter states */
     int32_t tx_hpf[2];
     int32_t rx_hpf[2];
-   
+
     /* Parameters for the optional Hoth noise generator */
     int cng_level;
     int cng_rndnum;
     int cng_filter;
-    
+
     /* Snapshot sample of coeffs used for development */
-    int16_t *snapshot;       
+    int16_t *snapshot;
 };
 
 #endif
index b5a677887d160802bf6036019dd0b06e2b0690b1..de87394daf65302a296ccd0a116cf0be323df8e1 100644 (file)
@@ -129,7 +129,7 @@ struct hdlc_tx_state_s
     int byte;
     /*! \brief The number of bits remaining in byte. */
     int bits;
-    
+
     /*! \brief TRUE if transmission should end on buffer underflow .*/
     int tx_end;
 };
index f039213c433279fab7ab4971413f8c2a5938a9fc..9970b5837cfa698bb0728a20834b742e3dd481ba 100644 (file)
@@ -2,7 +2,7 @@
  * SpanDSP - a series of DSP components for telephony
  *
  * private/oki_adpcm.h - Conversion routines between linear 16 bit PCM data
- *                              and OKI (Dialogic) ADPCM format.
+ *                       and OKI (Dialogic) ADPCM format.
  *
  * Written by Steve Underwood <steveu@coppice.org>
  *
index 740ec28073ec6df975c39fa97f50ebfcd0f7ab99..2686b5f5035fa5a7b61cc99c9bc6af1675450c52 100644 (file)
@@ -212,7 +212,7 @@ struct t31_state_s
     /*! TRUE if DLE prefix just used */
     int dled;
 
-       /*! \brief Samples of silence awaited, as specified in a "wait for silence" command */
+    /*! \brief Samples of silence awaited, as specified in a "wait for silence" command */
     int silence_awaited;
 
     /*! \brief The current bit rate for the FAX fast message transfer modem. */
index c3e62e8c83f61f8bd0314d7dcc3835681d960523..586a5cc22ffc6e7824038df7d6ab52d3df0a31a3 100644 (file)
@@ -136,7 +136,7 @@ struct t85_decode_state_s
     /*! The number of bit planes expected, according to the header. Always 1 for true T.85 */
     uint8_t bit_planes;
     uint8_t current_bit_plane;
-    
+
     /*! The width of the full image, in pixels */
     uint32_t xd;
     /*! The height of the full image, in pixels */
index c819a4442dca18b08d542b63226b3d060667ec82..4ea640c685545a643dd7a0a75dfe5b00c2be9611 100644 (file)
@@ -43,7 +43,7 @@ If tones are close in frequency a single Goertzel set to the centre of the
 frequency range will be used. This optimises the efficiency of the detector. The
 Goertzel filters are applied without applying any special window functional
 (i.e. they use a rectangular window), so they have a sinc like response.
-However, for most tone patterns their rejection qualities are adequate. 
+However, for most tone patterns their rejection qualities are adequate.
 
 The detector aims to meet the need of the standard call progress tones, to
 ITU-T E.180/Q.35 (busy, dial, ringback, reorder). Also, the extended tones,
index 9f7ed6d6a1c467d6c0ec1034e828b631e2ea520f..55b8d670f0fc3cd6261d8a4e4fb05077a327e9eb 100644 (file)
@@ -33,7 +33,7 @@
 The supervisory tone generator may be configured to generate most of the world's
 telephone supervisory tones - things like ringback, busy, number unobtainable,
 and so on. It uses tree structure tone descriptions, which can deal with quite
-complex cadence patterns. 
+complex cadence patterns.
 
 \section super_tone_tx_page_sec_2 How does it work?
 
index a847d96cf30de27dad024fa68bcae65a8c0ac380..dbf0dca9cb872da4f4e2b01458b5f1c44503583c 100644 (file)
@@ -45,7 +45,7 @@ enum
     /*! This option enables the regular repeat transmission of indicator signals,
         during periods when no FAX signal transmission occurs. */
     T38_TERMINAL_OPTION_REGULAR_INDICATORS = 0x02,
-    /*! This option enables the regular repeat transmission of indicator signals for the 
+    /*! This option enables the regular repeat transmission of indicator signals for the
         first 2s, during periods when no FAX signal transmission occurs. */
     T38_TERMINAL_OPTION_2S_REPEATING_INDICATORS = 0x04,
     /*! This option suppresses the transmission of indicators. This is usually used with
index 3e9540e966e720e2c0c276f399999d65f44bbcd8..fe2c83aeab24f27c7877288ff2f32fbae276cc33 100644 (file)
@@ -51,13 +51,13 @@ extern "C"
 SPAN_DECLARE(void) srgb_to_lab(lab_params_t *s, uint8_t lab[], const uint8_t srgb[], int pixels);
 
 SPAN_DECLARE(void) lab_to_srgb(lab_params_t *s, uint8_t srgb[], const uint8_t lab[], int pixels);
-    
+
 SPAN_DECLARE(void) set_lab_illuminant(lab_params_t *s, float new_xn, float new_yn, float new_zn);
 
 SPAN_DECLARE(void) set_lab_gamut(lab_params_t *s, int L_min, int L_max, int a_min, int a_max, int b_min, int b_max, int ab_are_signed);
 
 SPAN_DECLARE(void) set_lab_gamut2(lab_params_t *s, int L_P, int L_Q, int a_P, int a_Q, int b_P, int b_Q);
-    
+
 SPAN_DECLARE(int) t42_itulab_to_itulab(logging_state_t *logging, tdata_t *dst, tsize_t *dstlen, tdata_t src, tsize_t srclen, uint32_t width, uint32_t height);
 
 SPAN_DECLARE(int) t42_itulab_to_jpeg(logging_state_t *logging, lab_params_t *s, tdata_t *dst, tsize_t *dstlen, tdata_t src, tsize_t srclen);
index f2ff4fa0eec7681e8ed52745006868b28f7af211..3b359c7d797ac19484562df4f754c26e09e4071c 100644 (file)
@@ -261,7 +261,7 @@ typedef struct
     /*! \brief The size of the image on the line, in bytes */
     int line_image_size;
 } t4_stats_t;
-    
+
 #if defined(__cplusplus)
 extern "C" {
 #endif
@@ -369,19 +369,19 @@ SPAN_DECLARE(void) t4_rx_set_vendor(t4_rx_state_t *s, const char *vendor);
     \param model The model string, or NULL. */
 SPAN_DECLARE(void) t4_rx_set_model(t4_rx_state_t *s, const char *model);
 
-/*! Get the current image transfer statistics. 
+/*! Get the current image transfer statistics.
     \brief Get the current transfer statistics.
     \param s The T.4 context.
     \param t A pointer to a statistics structure. */
 SPAN_DECLARE(void) t4_rx_get_transfer_statistics(t4_rx_state_t *s, t4_stats_t *t);
 
-/*! Get the short text name of an encoding format. 
+/*! Get the short text name of an encoding format.
     \brief Get the short text name of an encoding format.
     \param encoding The encoding type.
     \return A pointer to the string. */
 SPAN_DECLARE(const char *) t4_encoding_to_str(int encoding);
 
-/*! Get the short text name of an image format. 
+/*! Get the short text name of an image format.
     \brief Get the short text name of an image format.
     \param encoding The image format.
     \return A pointer to the string. */
index 27ab9aa68e61c9de4747d81e1acc7e1b89e7da7a..7431d64f081a3022c714ca8e4595062005674600 100644 (file)
@@ -42,7 +42,7 @@ extern "C" {
 SPAN_DECLARE(int) t4_t6_encode_image_complete(t4_t6_encode_state_t *s);
 
 /*! \brief Get the next bit of the current image. The image will
-           be padded for the current minimum scan line time. 
+           be padded for the current minimum scan line time.
     \param s The T.4/T.6 context.
     \return The next bit (i.e. 0 or 1). SIG_STATUS_END_OF_DATA for no more data. */
 SPAN_DECLARE(int) t4_t6_encode_get_bit(t4_t6_encode_state_t *s);
@@ -52,7 +52,7 @@ SPAN_DECLARE(int) t4_t6_encode_get_bit(t4_t6_encode_state_t *s);
     \param s The T.4/T.6 context.
     \param buf The buffer into which the chunk is to written.
     \param max_len The maximum length of the chunk.
-    \return The actual length of the chunk. If this is less than max_len it 
+    \return The actual length of the chunk. If this is less than max_len it
             indicates that the end of the document has been reached. */
 SPAN_DECLARE(int) t4_t6_encode_get(t4_t6_encode_state_t *s, uint8_t buf[], int max_len);
 
index 3e04237fe03a3d5d87d71a15b8252b5a2aab9724..8ee19be5916945f3fee573c8fcc30e4697ddf2c3 100644 (file)
@@ -277,7 +277,7 @@ SPAN_DECLARE(int) t4_tx_get_bit(t4_tx_state_t *s);
     \param s The T.4 context.
     \param buf The buffer into which the chunk is to written.
     \param max_len The maximum length of the chunk.
-    \return The actual length of the chunk. If this is less than max_len it 
+    \return The actual length of the chunk. If this is less than max_len it
             indicates that the end of the document has been reached. */
 SPAN_DECLARE(int) t4_tx_get(t4_tx_state_t *s, uint8_t buf[], size_t max_len);
 
@@ -383,7 +383,7 @@ SPAN_DECLARE(int) t4_tx_get_pages_in_file(t4_tx_state_t *s);
     \return The page number, or -1 if there is an error. */
 SPAN_DECLARE(int) t4_tx_get_current_page_in_file(t4_tx_state_t *s);
 
-/*! Get the current image transfer statistics. 
+/*! Get the current image transfer statistics.
     \brief Get the current transfer statistics.
     \param s The T.4 context.
     \param t A pointer to a statistics structure. */
index 905e0491becbb5c0b0eaa38e967b7913e8573bb9..e5b4ec45674c95c3a09b7b48b3302ae5c4807395 100644 (file)
@@ -63,7 +63,6 @@ SPAN_DECLARE(void) t81_t82_arith_encode(t81_t82_arith_encode_state_t *s, int cx,
 
 SPAN_DECLARE(void) t81_t82_arith_encode_flush(t81_t82_arith_encode_state_t *s);
 
-    
 SPAN_DECLARE(t81_t82_arith_decode_state_t *) t81_t82_arith_decode_init(t81_t82_arith_decode_state_t *s);
 
 SPAN_DECLARE(int) t81_t82_arith_decode_restart(t81_t82_arith_decode_state_t *s, int reuse_st);
index 07dd88931fcbb5d5c7521cda4ec857b35b4a8de3..29bd6ad7c1e7002565833953a2c2699f0db84115 100644 (file)
@@ -74,7 +74,7 @@ SPAN_DECLARE(int) t85_encode_image_complete(t85_encode_state_t *s);
     \param s The T.85 context.
     \param buf The buffer into which the chunk is to written.
     \param max_len The maximum length of the chunk.
-    \return The actual length of the chunk. If this is less than max_len it 
+    \return The actual length of the chunk. If this is less than max_len it
             indicates that the end of the document has been reached. */
 SPAN_DECLARE(int) t85_encode_get(t85_encode_state_t *s, uint8_t buf[], size_t max_len);
 
@@ -113,7 +113,7 @@ SPAN_DECLARE(t85_encode_state_t *) t85_encode_init(t85_encode_state_t *s,
 SPAN_DECLARE(int) t85_encode_restart(t85_encode_state_t *s,
                                      uint32_t image_width,
                                      uint32_t image_length);
-    
+
 SPAN_DECLARE(int) t85_encode_release(t85_encode_state_t *s);
 
 SPAN_DECLARE(int) t85_encode_free(t85_encode_state_t *s);
index bf779ca41eaed91af3ce8a0604f088c6c7296847..df75f230d64cf2f01c08cb3502c223322f0ed939 100644 (file)
@@ -191,7 +191,7 @@ static __inline__ void goertzel_samplex(goertzel_state_t *s, float amp)
 */
 SPAN_DECLARE(int) periodogram_generate_coeffs(complexf_t coeffs[], float freq, int sample_rate, int window_len);
 
-/*! Generate the phase offset to be expected between successive periodograms evaluated at the 
+/*! Generate the phase offset to be expected between successive periodograms evaluated at the
     specified interval.
     \param offset A point to the generated phase offset.
     \param freq The frequency being matched by the periodogram, in Hz.
index fa9df4a0c56ea16ad2f35854a07db6da5784ce34..0c1924c1e85f50551601c7bb862568b91caa5f0e 100644 (file)
@@ -22,7 +22,7 @@
  * License along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
+
 /*! \file */
 
 /*! \page v8_page The V.8 modem negotiation protocol
index c20f02a7d990e1835616facbc82a1f962953e96a..daec30670e93c63ddb335801ea47ddb596c73eb1 100644 (file)
@@ -70,7 +70,7 @@ static __inline__ void vec_zeroi32(int32_t z[], int n)
 static __inline__ void vec_seti(int z[], int x, int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = x;
 }
@@ -79,7 +79,7 @@ static __inline__ void vec_seti(int z[], int x, int n)
 static __inline__ void vec_seti16(int16_t z[], int16_t x, int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = x;
 }
@@ -88,7 +88,7 @@ static __inline__ void vec_seti16(int16_t z[], int16_t x, int n)
 static __inline__ void vec_seti32(int32_t z[], int32_t x, int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = x;
 }
@@ -117,7 +117,7 @@ SPAN_DECLARE(void) vec_circular_lmsi16(const int16_t x[], int16_t y[], int n, in
 /*! \brief Find the minimum and maximum values in an int16_t vector.
     \param x The vector to be searched.
     \param n The number of elements in the vector.
-    \param out A two element vector. The first will receive the 
+    \param out A two element vector. The first will receive the
            maximum. The second will receive the minimum. This parameter
            may be set to NULL.
     \return The absolute maximum value. Since the range of negative numbers
index b43f20628eae117d298e7f321ff85d88c02dc991..3809bb4bf8e9a0c02f670f9ab5f91ca47e336b85 100644 (file)
@@ -59,7 +59,7 @@
     oddity amongst supervisory tones. It is designed to sound loud and nasty. Most
     tones are one or two pure sine pitches, or one AM moduluated pitch. This alert
     tone varies between countries, but AT&T are a typical example.
-    
+
     AT&T Receiver Off-Hook Tone is 1400 Hz, 2060 Hz, 2450 Hz and 2600 Hz at 0dBm0/frequency
     on and off every .1 second. On some older space division switching systems
     Receiver Off-Hook was 1400 Hz, 2060 Hz, 2450 Hz and 2600 Hz at +5 VU on and
@@ -82,7 +82,7 @@ SPAN_DECLARE(super_tone_tx_step_t *) super_tone_tx_make_step(super_tone_tx_step_
             return NULL;
     }
     if (f1 >= 1.0f)
-    {    
+    {
         s->tone[0].phase_rate = dds_phase_ratef(f1);
         s->tone[0].gain = dds_scaling_dbm0f(l1);
     }
@@ -278,7 +278,6 @@ SPAN_DECLARE(int) super_tone_tx(super_tone_tx_state_t *s, int16_t amp[], int max
                 tree = s->levels[--s->level];
             }
         }
-        
     }
     return samples;
 }
index f2b5eb7e24584f902d3835f73aef095f023f31b4..f5ccc9bed8c1c898c4cc50c63ace3fbfd7bc9aa8 100644 (file)
@@ -80,7 +80,7 @@ SPAN_DECLARE(int) swept_tone(swept_tone_state_t *s, int16_t amp[], int max_len)
     int i;
     int len;
     int chunk_len;
-    
+
     for (len = 0;  len < max_len;  )
     {
         chunk_len = max_len - len;
index 4186504a4cba9fd35c81498f249c78113c3ac8f6..3e210854ab69ac6fc9084e09cc6189e9b81f7f0e 100644 (file)
@@ -300,7 +300,7 @@ static const nsf_data_t vendor_00[] =
     {"\x00\x41", 2, "Swasaki Communication", FALSE, NULL},
     {"\x00\x45", 2, "Muratec", FALSE, Muratec45},
     {"\x00\x46", 2, "Pheonix", FALSE, NULL},
-    {"\x00\x48", 2, "Muratec", FALSE, Muratec48},              /* Not registered */
+    {"\x00\x48", 2, "Muratec", FALSE, Muratec48},           /* Not registered */
     {"\x00\x49", 2, "Japan Electric", FALSE, NULL},
     {"\x00\x4D", 2, "Okura Electric", FALSE, NULL},
     {"\x00\x51", 2, "Sanyo", FALSE, Sanyo},
@@ -502,7 +502,7 @@ static const nsf_data_t vendor_b5[] =
     {"\x00\x6E", 2, "Microsoft", FALSE, NULL},
     {"\x00\x72", 2, "Speaking Devices", FALSE, NULL},
     {"\x00\x74", 2, "Compaq", FALSE, NULL},
-    {"\x00\x76", 2, "Microsoft", FALSE, NULL},         /* uses LSB for country but MSB for manufacturer */
+    {"\x00\x76", 2, "Microsoft", FALSE, NULL},      /* uses LSB for country but MSB for manufacturer */
     {"\x00\x78", 2, "Cylink", FALSE, NULL},
     {"\x00\x7A", 2, "Pitney Bowes", FALSE, NULL},
     {"\x00\x7C", 2, "Digiboard", FALSE, NULL},
index 0163ff52f5d5547b3e4aa8e1c8377a705a82f0e2..c8ed0a08046216cefa74774e27eb4c29a00c1036 100644 (file)
@@ -422,7 +422,7 @@ SPAN_DECLARE(void) srgb_to_lab(lab_params_t *s, uint8_t lab[], const uint8_t srg
         x /= s->x_n;
         y /= s->y_n;
         z /= s->z_n;
-    
+
         /* XYZ to Lab */
         xx = (x <= 0.008856f)  ?  (7.787f*x + 0.1379f)  :  cbrtf(x);
         yy = (y <= 0.008856f)  ?  (7.787f*y + 0.1379f)  :  cbrtf(y);
@@ -456,7 +456,7 @@ SPAN_DECLARE(void) lab_to_srgb(lab_params_t *s, uint8_t srgb[], const uint8_t la
         itu_to_lab(s, &l, lab);
 
         /* Lab to XYZ */
-        ll = (1.0f/116.0f)*(l.L + 16.0f); 
+        ll = (1.0f/116.0f)*(l.L + 16.0f);
         y = ll;
         y = (y <= 0.2068f)  ?  (0.1284f*(y - 0.1379f))  :  y*y*y;
         x = ll + (1.0f/500.0f)*l.a;
@@ -668,7 +668,7 @@ SPAN_DECLARE(int) t42_itulab_to_jpeg(logging_state_t *logging, lab_params_t *s,
         free(*dst);
         fclose(out);
         return FALSE;
-    }    
+    }
     fclose(out);
 #endif
 
@@ -1054,7 +1054,7 @@ SPAN_DECLARE(int) t42_itulab_to_itulab(logging_state_t *logging, tdata_t *dst, t
         free(*dst);
         fclose(out);
         return FALSE;
-    }        
+    }
     fclose(out);
 #endif
 
@@ -1105,6 +1105,7 @@ SPAN_DECLARE(int) t42_itulab_to_srgb(logging_state_t *logging, lab_params_t *s,
             span_log(logging, SPAN_LOG_FLOW, "%s\n", escape.error_message);
         else
             span_log(logging, SPAN_LOG_FLOW, "Unspecified libjpeg error.\n");
+printf("Error %s.\n", escape.error_message);
         if (scan_line_out)
             free(scan_line_out);
         fclose(in);
@@ -1134,14 +1135,17 @@ SPAN_DECLARE(int) t42_itulab_to_srgb(logging_state_t *logging, lab_params_t *s,
     if (!is_itu_fax(logging, s, decompressor.marker_list))
     {
         span_log(logging, SPAN_LOG_FLOW, "Is not an ITU FAX.\n");
-        return FALSE;
+printf("Is not an ITU FAX 1.\n");
+        //return FALSE;
     }
     /* Copy size, resolution, etc */
     *width = decompressor.image_width;
     *height = decompressor.image_height;
+printf("Is %d x %d\n", decompressor.image_width, decompressor.image_height);
 
     jpeg_start_decompress(&decompressor);
 
+printf("Is %d x %d x %d.\n", decompressor.output_width, decompressor.output_height, decompressor.num_components);
     if ((scan_line_in = (JSAMPROW) malloc(decompressor.output_width*decompressor.num_components)) == NULL)
         return FALSE;
 
@@ -1151,6 +1155,7 @@ SPAN_DECLARE(int) t42_itulab_to_srgb(logging_state_t *logging, lab_params_t *s,
         jpeg_read_scanlines(&decompressor, &scan_line_in, 1);
         lab_to_srgb(s, scan_line_out, scan_line_in, decompressor.output_width);
     }
+printf("Next %d\n", decompressor.output_scanline);
 
     free(scan_line_in);
     jpeg_finish_decompress(&decompressor);
@@ -1159,6 +1164,7 @@ SPAN_DECLARE(int) t42_itulab_to_srgb(logging_state_t *logging, lab_params_t *s,
 
     *dstlen = pos;
 
+printf("Next2 %d\n", decompressor.output_scanline);
     return TRUE;
 }
 /*- End of function --------------------------------------------------------*/
index d91992a04ef248a8d54b7bcb3fa0c834695fa640..03b24ae4f37382a38764a8b12372f7d3fa1bf00b 100644 (file)
  * Copyright (c) 1990-1997 Sam Leffler
  * Copyright (c) 1991-1997 Silicon Graphics, Inc.
  *
- * Permission to use, copy, modify, distribute, and sell this software and 
+ * Permission to use, copy, modify, distribute, and sell this software and
  * its documentation for any purpose is hereby granted without fee, provided
  * that (i) the above copyright notices and this permission notice appear in
  * all copies of the software and related documentation, and (ii) the names of
  * Sam Leffler and Silicon Graphics may not be used in any advertising or
  * publicity relating to the software without the specific, prior written
  * permission of Sam Leffler and Silicon Graphics.
- * 
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
- * 
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
  * Decoder support is derived from code in Frank Cringle's viewfax program;
@@ -541,8 +541,8 @@ static int put_bits(t4_t6_decode_state_t *s, uint32_t bit_string, int quantity)
                         /* TODO: we really should record that something wasn't right at this point. */
                         s->a0 = old_a0;
                         break;
-                       }
-                   }
+                    }
+                }
                 s->run_length += (s->a0 - old_a0);
                 add_run_to_row(s);
                 /* We need to move one step in one direction or the other, to change to the
index c33b65ae24b4f6d23add0857ee49a8183de7d89d..22885f4ac1317ecd792378390aae5ebef187dd94 100644 (file)
  * Copyright (c) 1990-1997 Sam Leffler
  * Copyright (c) 1991-1997 Silicon Graphics, Inc.
  *
- * Permission to use, copy, modify, distribute, and sell this software and 
+ * Permission to use, copy, modify, distribute, and sell this software and
  * its documentation for any purpose is hereby granted without fee, provided
  * that (i) the above copyright notices and this permission notice appear in
  * all copies of the software and related documentation, and (ii) the names of
  * Sam Leffler and Silicon Graphics may not be used in any advertising or
  * publicity relating to the software without the specific, prior written
  * permission of Sam Leffler and Silicon Graphics.
- * 
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
- * 
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  */
 
@@ -508,7 +508,7 @@ static int row_to_run_lengths(uint32_t list[], const uint8_t row[], int width)
                     x <<= frag;
                     flip ^= 0xFF000000;
                     rem -= frag;
-                }   
+                }
                 /* Save the remainder of the word */
                 span = (i << 3) + 8 - rem;
             }
@@ -647,7 +647,7 @@ static void encode_2d_row(t4_t6_encode_state_t *s, const uint8_t *row_buf)
     uint32_t *p;
 
     /*
-                                                    b1          b2 
+                                                    b1          b2
             XX  XX  XX  XX  XX  --  --  --  --  --  XX  XX  XX  --  --  --  --  --
             XX  XX  XX  --  --  --  --  --  XX  XX  XX  XX  XX  XX  --  --  --  --
                         a0                  a1                      a2
@@ -657,18 +657,18 @@ static void encode_2d_row(t4_t6_encode_state_t *s, const uint8_t *row_buf)
             This mode is identified when the position of b2 lies to the left of a1. When this mode
             has been coded, a0 is set on the element of the coding line below b2 in preparation for
             the next coding (i.e. on a0').
-            
-                                    b1          b2 
+
+                                    b1          b2
             XX  XX  XX  XX  --  --  XX  XX  XX  --  --  --  --  --
-            XX  XX  --  --  --  --  --  --  --  --  --  --  XX  XX 
+            XX  XX  --  --  --  --  --  --  --  --  --  --  XX  XX
                     a0                          a0'         a1
                                 Pass mode
-                                
+
 
             However, the state where b2 occurs just above a1, as shown in the figure below, is not
             considered as a pass mode.
 
-                                    b1          b2 
+                                    b1          b2
             XX  XX  XX  XX  --  --  XX  XX  XX  --  --  --  --  --
             XX  XX  --  --  --  --  --  --  --  XX  XX  XX  XX  XX
                     a0                          a1
@@ -693,7 +693,7 @@ static void encode_2d_row(t4_t6_encode_state_t *s, const uint8_t *row_buf)
 
                                                             Vertical
                                                             <a1 b1>
-                                                                    b1              b2 
+                                                                    b1              b2
             --  XX  XX  XX  XX  XX  --  --  --  --  --  --  --  --  XX  XX  XX  XX  --  --  --
             --  --  --  --  --  --  --  --  --  --  --  --  XX  XX  XX  XX  XX  XX  XX  --  --
                                     a0                      a1                          a2
index 840b27a2f2e98c1e8b216cc7ad98773a871f8005..5a964f6f7fcd1bdf5d4ca35bbc52041449c3949d 100644 (file)
@@ -133,7 +133,7 @@ static void TIFFFXDefaultDirectory(TIFF *tif)
 
     /* Since we may have overriddden another directory method, we call it now to
        allow it to set up the rest of its own methods. */
-    if (_ParentExtender) 
+    if (_ParentExtender)
         (*_ParentExtender)(tif);
 }
 /*- End of function --------------------------------------------------------*/
@@ -141,11 +141,11 @@ static void TIFFFXDefaultDirectory(TIFF *tif)
 SPAN_DECLARE(void) TIFF_FX_init(void)
 {
     static int first_time = TRUE;
-    
+
     if (!first_time)
         return;
     first_time = FALSE;
-    
+
     /* Grab the inherited method and install */
     _ParentExtender = TIFFSetTagExtender(TIFFFXDefaultDirectory);
 }
@@ -175,7 +175,7 @@ static int read_colour_map(t4_tx_state_t *s, int bits_per_sample)
     map_z = NULL;
     if (!TIFFGetField(s->tiff.tiff_file, TIFFTAG_COLORMAP, &map_L, &map_a, &map_b, &map_z))
         return -1;
-    
+
     /* TODO: This only allows for 8 bit deep maps */
     if ((s->colour_map = realloc(s->colour_map, 3*256)) == NULL)
         return -1;
index 92fdd68176aeee69289fdbba6deb0daf9ae5eb20..8453067e9eb12fc325006e4beb0fbfbd0044ef63 100644 (file)
@@ -75,7 +75,6 @@ static __inline__ int flag_is_changeable_p(uint32_t flag)
         " popfl\n"
         : "=&r" (f1), "=&r" (f2)
         : "ir" (flag));
-
     return ((f1^f2) & flag) != 0;
 }
 /*- End of function --------------------------------------------------------*/
@@ -96,21 +95,21 @@ int has_MMX(void)
     /*endif*/
     __asm__ __volatile__(
         " push  %%ebx;\n"
-       " mov   $1,%%eax;\n"
-       " cpuid;\n"
-       " xor   %%eax,%%eax;\n"
-       " test  $0x800000,%%edx;\n"
-       " jz    1f;\n"              /* no MMX support */
-       " inc   %%eax;\n"           /* MMX support */
+        " mov    $1,%%eax;\n"
+        " cpuid;\n"
+        " xor   %%eax,%%eax;\n"
+        " test    $0x800000,%%edx;\n"
+        " jz    1f;\n"                /* no MMX support */
+        " inc   %%eax;\n"        /* MMX support */
         "1:\n"
         " pop  %%ebx;\n"
-       : "=a" (result)
-        : 
+        : "=a" (result)
+        :
         : "ecx", "edx");
     return result;
 }
 /*- End of function --------------------------------------------------------*/
-        
+
 int has_SIMD(void)
 {
     int result;
@@ -120,16 +119,16 @@ int has_SIMD(void)
     /*endif*/
     __asm__ __volatile__(
         " push  %%ebx;\n"
-       " mov   $1,%%eax;\n"
-       " cpuid;\n"
-       " xor   %%eax,%%eax;\n"
-       " test  $0x02000000,%%edx;\n"
-       " jz    1f;\n"                  /* no SIMD support */
-       " inc   %%eax;\n"               /* SIMD support */
+        " mov    $1,%%eax;\n"
+        " cpuid;\n"
+        " xor   %%eax,%%eax;\n"
+        " test    $0x02000000,%%edx;\n"
+        " jz    1f;\n"                /* no SIMD support */
+        " inc    %%eax;\n"        /* SIMD support */
         "1:\n"
         " pop  %%ebx;\n"
-       : "=a" (result)
-        : 
+        : "=a" (result)
+        :
         : "ecx", "edx");
     return result;
 }
@@ -144,21 +143,21 @@ int has_SIMD2(void)
     /*endif*/
     __asm__ __volatile__(
         " push  %%ebx;\n"
-       " mov   $1,%%eax;\n"
-       " cpuid;\n"
-       " xor   %%eax,%%eax;\n"
-       " test  $0x04000000,%%edx;\n"
-       " jz    1f;\n"                  /* no SIMD2 support */
-       " inc   %%eax;\n"               /* SIMD2 support */
+        " mov    $1,%%eax;\n"
+        " cpuid;\n"
+        " xor   %%eax,%%eax;\n"
+        " test    $0x04000000,%%edx;\n"
+        " jz    1f;\n"                /* no SIMD2 support */
+        " inc    %%eax;\n"        /* SIMD2 support */
         "1:\n"
         " pop  %%ebx;\n"
-       : "=a" (result)
-        : 
+        : "=a" (result)
+        :
         : "ecx", "edx");
     return result;
 }
 /*- End of function --------------------------------------------------------*/
-        
+
 int has_3DNow(void)
 {
     int result;
@@ -168,21 +167,21 @@ int has_3DNow(void)
     /*endif*/
     __asm__ __volatile__(
         " push  %%ebx;\n"
-       " mov   $0x80000000,%%eax;\n"
-       " cpuid;\n"
+        " mov    $0x80000000,%%eax;\n"
+        " cpuid;\n"
         " xor   %%ecx,%%ecx;\n"
-       " cmp   $0x80000000,%%eax;\n"
-       " jbe   1f;\n"                  /* no extended MSR(1), so no 3DNow! */
-       " mov   $0x80000001,%%eax;\n"
-       " cpuid;\n"
+        " cmp    $0x80000000,%%eax;\n"
+        " jbe    1f;\n"                /* no extended MSR(1), so no 3DNow! */
+        " mov    $0x80000001,%%eax;\n"
+        " cpuid;\n"
         " xor   %%ecx,%%ecx;\n"
-       " test  $0x80000000,%%edx;\n"
-       " jz    1f;\n"                  /* no 3DNow! support */
-       " inc   %%ecx;\n"               /* 3DNow! support */
+        " test    $0x80000000,%%edx;\n"
+        " jz    1f;\n"                /* no 3DNow! support */
+        " inc   %%ecx;\n"        /* 3DNow! support */
         "1:\n"
         " pop  %%ebx;\n"
-       : "=c" (result)
-        : 
+        : "=c" (result)
+        :
         : "eax", "edx");
     return result;
 }
index 605e1c5fb5075bfe49c14647b62cf65ab00bfd74..5b2a64a66b218860f0f1e33db30d51e78ede2e94 100644 (file)
@@ -86,7 +86,7 @@ static __inline__ void overlap_add(int16_t amp1[], int16_t amp2[], int len)
     int i;
     float weight;
     float step;
-    
+
     step = 1.0f/len;
     weight = 0.0f;
     for (i = 0;  i < len;  i++)
index 2887af51d6cd12948b4dddcaa73c63f7fc64ff4e..4dfea5d5bfde71600e2f6b68d085c0d6d9701fc2 100644 (file)
@@ -22,7 +22,7 @@
  * License along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
+
 /*! \file */
 
 #if defined(HAVE_CONFIG_H)
index 6b0706aaf36a67b6e9f5775e5e3ec99fb00d01d6..a8779152711c3754bbea224545bf5cfca2353728 100644 (file)
@@ -171,7 +171,7 @@ static complexf_t getbaud(v27ter_tx_state_t *s)
 
     if (s->in_training)
     {
-               /* Send the training sequence */
+        /* Send the training sequence */
         if (++s->training_step <= V27TER_TRAINING_SEG_5)
         {
             if (s->training_step <= V27TER_TRAINING_SEG_4)
index 3e73d67c27aeb7f2927656a21cdb822f0592fab1..3830f5c53a83dfa8f8284c9c2b86f641f9d1a25f 100644 (file)
@@ -246,7 +246,7 @@ static int tx_supervisory_frame(lapm_state_t *s, uint8_t addr, uint8_t ctrl, uin
 {
     v42_frame_t *f;
     uint8_t *buf;
-    
+
     if ((f = get_next_free_ctrl_frame(s)) == NULL)
         return -1;
     buf = f->buf;
@@ -438,7 +438,7 @@ static void transmit_xid(v42_state_t *ss, uint8_t addr)
     *buf++ = 2;
     *buf++ = (param_val >> 8) & 0xFF;
     *buf++ = (param_val & 0xFF);
-    
+
     *buf++ = PI_TX_WINDOW_SIZE;
     *buf++ = 1;
     *buf++ = ss->config.v42_tx_window_size_k;
@@ -466,7 +466,7 @@ static void transmit_xid(v42_state_t *ss, uint8_t addr)
         *buf++ = '4';
         *buf++ = '2';
 
-        /* V.42bis P0 
+        /* V.42bis P0
            00 Compression in neither direction (default);
            01 Negotiation initiator-responder direction only;
            10 Negotiation responder-initiator direction only;
@@ -1155,7 +1155,7 @@ static int lapm_config(v42_state_t *ss)
 static void reset_lapm(v42_state_t *ss)
 {
     lapm_state_t *s;
-    
+
     s = &ss->lapm;
     /* Reset the LAP.M state */
     s->local_busy = FALSE;
index 2b25df28c272e17a3c8d467b853a3b80293fb7a5..fec129a6f2591826690c7c3e035e8ae18c111ff1 100644 (file)
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-/* THIS IS A WORK IN PROGRESS. IT IS NOT FINISHED. 
-   Currently it performs the core compression and decompression functions OK.
-   However, a number of the bells and whistles in V.42bis are incomplete. */
-
 /*! \file */
 
 #if defined(HAVE_CONFIG_H)
@@ -59,7 +55,7 @@
 /* Index number of first dictionary entry used to store a string */
 #define V42BIS_N5                           (V42BIS_N4 + V42BIS_N6)
 /* Number of control codewords */
-#define V42BIS_N6                           3 
+#define V42BIS_N6                           3
 /* V.42bis/9.2 */
 #define V42BIS_ESC_STEP                     51
 
@@ -489,7 +485,7 @@ SPAN_DECLARE(int) v42bis_compress_flush(v42bis_state_t *ss)
 {
     v42bis_comp_state_t *s;
     int len;
-    
+
     s = &ss->compress;
     if (s->update_at)
         return 0;
@@ -692,7 +688,7 @@ SPAN_DECLARE(int) v42bis_decompress_flush(v42bis_state_t *ss)
 {
     v42bis_comp_state_t *s;
     int len;
-    
+
     s = &ss->decompress;
     len = s->string_length;
     send_string(s);
index 37ef368a44bd8e68b18ebc14a12344aac49c0ec9..e04a1eba9cf44e3ce060baedceb32f70ff8323b6 100644 (file)
@@ -22,7 +22,7 @@
  * License along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
+
 /*! \file */
 
 #if defined(HAVE_CONFIG_H)
@@ -271,7 +271,7 @@ SPAN_DECLARE(void) v8_log_supported_modulations(v8_state_t *s, int modulation_sc
 {
     const char *comma;
     int i;
-    
+
     comma = "";
     span_log(&s->logging, SPAN_LOG_FLOW, "");
     for (i = 0;  i < 32;  i++)
@@ -562,7 +562,7 @@ static void put_bit(void *user_data, int bit)
         s->bit_cnt = 0;
         s->rx_data_ptr = 0;
     }
-    
+
     if (s->preamble_type != V8_SYNC_UNKNOWN)
     {
         /* Parse octets with 1 bit start, 1 bit stop */
@@ -654,13 +654,13 @@ static void send_cm_jm(v8_state_t *s)
     int val;
     unsigned int offered_modulations;
     int bytes;
-    
+
     /* Send a CM, or a JM as appropriate */
     v8_put_preamble(s);
     v8_put_byte(s, V8_CM_JM_SYNC_OCTET);
     /* Data call */
     v8_put_byte(s, (s->result.call_function << 5) | V8_CALL_FUNCTION_TAG);
-    
+
     /* Supported modulations */
     offered_modulations = s->result.modulations;
     bytes = 0;
@@ -949,14 +949,14 @@ SPAN_DECLARE_NONSTD(int) v8_rx(v8_state_t *s, const int16_t *amp, int len)
         if (s->got_cm_jm)
         {
             span_log(&s->logging, SPAN_LOG_FLOW, "CM recognised\n");
-            
+
             s->result.status = V8_STATUS_V8_OFFERED;
             report_event(s);
-            
+
             /* Stop sending ANSam or ANSam/ and send JM instead */
             fsk_tx_init(&s->v21tx, &preset_fsk_specs[FSK_V21CH2], get_bit, s);
             /* Set the timeout for JM */
-            s->negotiation_timer = ms_to_samples(5000); 
+            s->negotiation_timer = ms_to_samples(5000);
             s->state = V8_JM_ON;
             send_cm_jm(s);
             s->modem_connect_tone_tx_on = ms_to_samples(75);
@@ -1101,7 +1101,7 @@ SPAN_DECLARE(int) v8_release(v8_state_t *s)
 SPAN_DECLARE(int) v8_free(v8_state_t *s)
 {
     int ret;
-    
+
     ret = queue_free(s->tx_queue);
     free(s);
     return ret;
index dd09e449e15ba850ce574f1659275c2ef0214370..b02e4288a9166bb09e0cd4d94e51ce8565915060 100644 (file)
@@ -52,7 +52,7 @@ SPAN_DECLARE(void) vec_copyf(float z[], const float x[], int n)
 {
     int i;
     __m128 n1;
+
     if ((i = n & ~3))
     {
         for (i -= 4;  i >= 0;  i -= 4)
@@ -76,7 +76,7 @@ SPAN_DECLARE(void) vec_copyf(float z[], const float x[], int n)
 SPAN_DECLARE(void) vec_copyf(float z[], const float x[], int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = x[i];
 }
@@ -86,7 +86,7 @@ SPAN_DECLARE(void) vec_copyf(float z[], const float x[], int n)
 SPAN_DECLARE(void) vec_copy(double z[], const double x[], int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = x[i];
 }
@@ -96,7 +96,7 @@ SPAN_DECLARE(void) vec_copy(double z[], const double x[], int n)
 SPAN_DECLARE(void) vec_copyl(long double z[], const long double x[], int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = x[i];
 }
@@ -111,7 +111,7 @@ SPAN_DECLARE(void) vec_negatef(float z[], const float x[], int n)
     static const float *fmask = (float *) &mask;
     __m128 n1;
     __m128 n2;
+
     if ((i = n & ~3))
     {
         n2 = _mm_set1_ps(*fmask);
@@ -137,7 +137,7 @@ SPAN_DECLARE(void) vec_negatef(float z[], const float x[], int n)
 SPAN_DECLARE(void) vec_negatef(float z[], const float x[], int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = -x[i];
 }
@@ -147,7 +147,7 @@ SPAN_DECLARE(void) vec_negatef(float z[], const float x[], int n)
 SPAN_DECLARE(void) vec_negate(double z[], const double x[], int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = -x[i];
 }
@@ -157,7 +157,7 @@ SPAN_DECLARE(void) vec_negate(double z[], const double x[], int n)
 SPAN_DECLARE(void) vec_negatel(long double z[], const long double x[], int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = -x[i];
 }
@@ -169,7 +169,7 @@ SPAN_DECLARE(void) vec_zerof(float z[], int n)
 {
     int i;
     __m128 n1;
+
     if ((i = n & ~3))
     {
         n1 = _mm_setzero_ps();
@@ -191,7 +191,7 @@ SPAN_DECLARE(void) vec_zerof(float z[], int n)
 SPAN_DECLARE(void) vec_zerof(float z[], int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = 0.0f;
 }
@@ -201,7 +201,7 @@ SPAN_DECLARE(void) vec_zerof(float z[], int n)
 SPAN_DECLARE(void) vec_zero(double z[], int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = 0.0;
 }
@@ -211,7 +211,7 @@ SPAN_DECLARE(void) vec_zero(double z[], int n)
 SPAN_DECLARE(void) vec_zerol(long double z[], int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = 0.0L;
 }
@@ -223,7 +223,7 @@ SPAN_DECLARE(void) vec_setf(float z[], float x, int n)
 {
     int i;
     __m128 n1;
+
     if ((i = n & ~3))
     {
         n1 = _mm_set1_ps(x);
@@ -245,7 +245,7 @@ SPAN_DECLARE(void) vec_setf(float z[], float x, int n)
 SPAN_DECLARE(void) vec_setf(float z[], float x, int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = x;
 }
@@ -255,7 +255,7 @@ SPAN_DECLARE(void) vec_setf(float z[], float x, int n)
 SPAN_DECLARE(void) vec_set(double z[], double x, int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = x;
 }
@@ -265,7 +265,7 @@ SPAN_DECLARE(void) vec_set(double z[], double x, int n)
 SPAN_DECLARE(void) vec_setl(long double z[], long double x, int n)
 {
     int i;
-    
+
     for (i = 0;  i < n;  i++)
         z[i] = x;
 }
@@ -278,7 +278,7 @@ SPAN_DECLARE(void) vec_addf(float z[], const float x[], const float y[], int n)
     int i;
     __m128 n1;
     __m128 n2;
+
     if ((i = n & ~3))
     {
         for (i -= 4;  i >= 0;  i -= 4)
@@ -339,7 +339,7 @@ SPAN_DECLARE(void) vec_scaledxy_addf(float z[], const float x[], float x_scale,
     __m128 n2;
     __m128 n3;
     __m128 n4;
+
     if ((i = n & ~3))
     {
         n3 = _mm_set1_ps(x_scale);
@@ -403,7 +403,7 @@ SPAN_DECLARE(void) vec_scaledy_addf(float z[], const float x[], const float y[],
     __m128 n1;
     __m128 n2;
     __m128 n3;
+
     if ((i = n & ~3))
     {
         n3 = _mm_set1_ps(y_scale);
@@ -464,7 +464,7 @@ SPAN_DECLARE(void) vec_subf(float z[], const float x[], const float y[], int n)
     int i;
     __m128 n1;
     __m128 n2;
+
     if ((i = n & ~3))
     {
         for (i -= 4;  i >= 0;  i -= 4)
@@ -552,7 +552,7 @@ SPAN_DECLARE(void) vec_scalar_mulf(float z[], const float x[], float y, int n)
     int i;
     __m128 n1;
     __m128 n2;
+
     if ((i = n & ~3))
     {
         n2 = _mm_set1_ps(y);
@@ -600,7 +600,7 @@ SPAN_DECLARE(void) vec_scalar_addf(float z[], const float x[], float y, int n)
     int i;
     __m128 n1;
     __m128 n2;
+
     if ((i = n & ~3))
     {
         n2 = _mm_set1_ps(y);
@@ -659,7 +659,7 @@ SPAN_DECLARE(void) vec_scalar_subf(float z[], const float x[], float y, int n)
     int i;
     __m128 n1;
     __m128 n2;
+
     if ((i = n & ~3))
     {
         n2 = _mm_set1_ps(y);
@@ -719,7 +719,7 @@ SPAN_DECLARE(void) vec_mulf(float z[], const float x[], const float y[], int n)
     __m128 n1;
     __m128 n2;
     __m128 n3;
+
     if ((i = n & ~3))
     {
         for (i -= 4;  i >= 0;  i -= 4)
@@ -781,7 +781,7 @@ SPAN_DECLARE(float) vec_dot_prodf(const float x[], const float y[], int n)
     __m128 n2;
     __m128 n3;
     __m128 n4;
+
     z = 0.0f;
     if ((i = n & ~3))
     {
@@ -869,7 +869,7 @@ SPAN_DECLARE(void) vec_lmsf(const float x[], float y[], int n, float error)
     __m128 n2;
     __m128 n3;
     __m128 n4;
+
     if ((i = n & ~3))
     {
         n3 = _mm_set1_ps(error);
index 5fe521df68104efc11a0322a247e81627297a7c4..c862a2ba8051c01b65d438cf3e1d3de0d9f07cf3 100644 (file)
@@ -210,7 +210,7 @@ static void set_pixel_range(uint8_t buf[], int row, int start, int end)
 static void clear_pixel_range(uint8_t buf[], int row, int start, int end)
 {
     int i;
-    
+
     for (i = start;  i <= end;  i++)
         clear_pixel(buf, row, i);
 }
@@ -602,11 +602,11 @@ int main(int argc, char *argv[])
         TIFFSetField(tiff_file, TIFFTAG_XRESOLUTION, floorf(x_resolution*2.54f + 0.5f));
         TIFFSetField(tiff_file, TIFFTAG_YRESOLUTION, floorf(y_resolution*2.54f + 0.5f));
         TIFFSetField(tiff_file, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH);
-    
+
         TIFFSetField(tiff_file, TIFFTAG_SOFTWARE, "spandsp");
         if (gethostname(buf, sizeof(buf)) == 0)
             TIFFSetField(tiff_file, TIFFTAG_HOSTCOMPUTER, buf);
-    
+
         TIFFSetField(tiff_file, TIFFTAG_IMAGEDESCRIPTION, "Blank test image");
         TIFFSetField(tiff_file, TIFFTAG_MAKE, "soft-switch.org");
         TIFFSetField(tiff_file, TIFFTAG_MODEL, "test data");
index 03ae0e8602a66214085af2dba921f14afe3d71db..4276b8c83574c7743f687d7138216d03d488a42e 100644 (file)
@@ -29,7 +29,7 @@
     This program generates an A4 sized FAX image of a fine checkerboard. This doesn't
     compress well, so it results in a rather large file for a single page. This is
     good for testing the handling of extreme pages.
-    
+
     Note that due to a bug in FAX image handling, versions of libtiff up to 3.8.2 fail
     to handle this complex image properly, if 2-D compression is used. The bug should
     be fixed in CVS at the time of writing, and so should be fixed in released versions
index a075f622e544cc2fd3a744168c835a257712660f..983e5e49b93244ae468e46f0b52feddaf965cba0 100644 (file)
@@ -83,189 +83,189 @@ struct
         T4_X_RESOLUTION_R8,
         T4_Y_RESOLUTION_FINE,
         T4_WIDTH_R8_A4,
-        2200
+        1100*2
     },
     {
         "R8_77_B4.tif",
         T4_X_RESOLUTION_R8,
         T4_Y_RESOLUTION_FINE,
         T4_WIDTH_R8_B4,
-        2400
+        1200*2
     },
     {
         "R8_77_A3.tif",
         T4_X_RESOLUTION_R8,
         T4_Y_RESOLUTION_FINE,
         T4_WIDTH_R8_A3,
-        3111
+        1556*2
     },
     {
         "R8_154_A4.tif",
         T4_X_RESOLUTION_R8,
         T4_Y_RESOLUTION_SUPERFINE,
         T4_WIDTH_R8_A4,
-        4400
+        1100*4
     },
     {
         "R8_154_B4.tif",
         T4_X_RESOLUTION_R8,
         T4_Y_RESOLUTION_SUPERFINE,
         T4_WIDTH_R8_B4,
-        4800
+        1200*4
     },
     {
         "R8_154_A3.tif",
         T4_X_RESOLUTION_R8,
         T4_Y_RESOLUTION_SUPERFINE,
         T4_WIDTH_R8_A3,
-        6222
+        1556*4
     },
     {
         "R300_300_A4.tif",
         T4_X_RESOLUTION_300,
         T4_Y_RESOLUTION_300,
         T4_WIDTH_300_A4,
-        4400
+        1100*3
     },
     {
         "R300_300_B4.tif",
         T4_X_RESOLUTION_300,
         T4_Y_RESOLUTION_300,
         T4_WIDTH_300_B4,
-        4800
+        1200*3
     },
     {
         "R300_300_A3.tif",
         T4_X_RESOLUTION_300,
         T4_Y_RESOLUTION_300,
         T4_WIDTH_300_A3,
-        6222
+        1556*3
     },
     {
         "R300_600_A4.tif",
         T4_X_RESOLUTION_300,
         T4_Y_RESOLUTION_600,
         T4_WIDTH_300_A4,
-        4400
+        1100*6
     },
     {
         "R300_600_B4.tif",
         T4_X_RESOLUTION_300,
         T4_Y_RESOLUTION_600,
         T4_WIDTH_300_B4,
-        4800
+        1200*6
     },
     {
         "R300_600_A3.tif",
         T4_X_RESOLUTION_300,
         T4_Y_RESOLUTION_600,
         T4_WIDTH_300_A3,
-        6222
+        1556*6
     },
     {
         "R16_154_A4.tif",
         T4_X_RESOLUTION_R16,
         T4_Y_RESOLUTION_SUPERFINE,
         T4_WIDTH_R16_A4,
-        4400
+        1100*4
     },
     {
         "R16_154_B4.tif",
         T4_X_RESOLUTION_R16,
         T4_Y_RESOLUTION_SUPERFINE,
         T4_WIDTH_R16_B4,
-        4800
+        1200*4
     },
     {
         "R16_154_A3.tif",
         T4_X_RESOLUTION_R16,
         T4_Y_RESOLUTION_SUPERFINE,
         T4_WIDTH_R16_A3,
-        6222
+        1556*4
     },
     {
         "R16_800_A4.tif",
         T4_X_RESOLUTION_R16,
         T4_Y_RESOLUTION_800,
         T4_WIDTH_R16_A4,
-        4400
+        1100*8
     },
     {
         "R16_800_B4.tif",
         T4_X_RESOLUTION_R16,
         T4_Y_RESOLUTION_800,
         T4_WIDTH_R16_B4,
-        4800
+        1200*8
     },
     {
         "R16_800_A3.tif",
         T4_X_RESOLUTION_R16,
         T4_Y_RESOLUTION_800,
         T4_WIDTH_R16_A3,
-        6222
+        1556*8
     },
     {
         "R600_600_A4.tif",
         T4_X_RESOLUTION_600,
         T4_Y_RESOLUTION_600,
         T4_WIDTH_600_A4,
-        4400
+        1100*6
     },
     {
         "R600_600_B4.tif",
         T4_X_RESOLUTION_600,
         T4_Y_RESOLUTION_600,
         T4_WIDTH_600_B4,
-        4800
+        1200*6
     },
     {
         "R600_600_A3.tif",
         T4_X_RESOLUTION_600,
         T4_Y_RESOLUTION_600,
         T4_WIDTH_600_A3,
-        6222
+        1556*6
     },
     {
         "R600_1200_A4.tif",
         T4_X_RESOLUTION_600,
         T4_Y_RESOLUTION_1200,
         T4_WIDTH_600_A4,
-        4400
+        1100*12
     },
     {
         "R600_1200_B4.tif",
         T4_X_RESOLUTION_600,
         T4_Y_RESOLUTION_1200,
         T4_WIDTH_600_B4,
-        4800
+        1200*12
     },
     {
         "R600_1200_A3.tif",
         T4_X_RESOLUTION_600,
         T4_Y_RESOLUTION_1200,
         T4_WIDTH_600_A3,
-        6222
+        1556*12
     },
     {
         "R1200_1200_A4.tif",
         T4_X_RESOLUTION_1200,
         T4_Y_RESOLUTION_1200,
         T4_WIDTH_1200_A4,
-        4400
+        1100*12
     },
     {
         "R1200_1200_B4.tif",
         T4_X_RESOLUTION_1200,
         T4_Y_RESOLUTION_1200,
         T4_WIDTH_1200_B4,
-        4800
+        1200*12
     },
     {
         "R1200_1200_A3.tif",
         T4_X_RESOLUTION_1200,
         T4_Y_RESOLUTION_1200,
         T4_WIDTH_1200_A3,
-        6222
+        1556*12
     },
     {
         NULL,
@@ -291,7 +291,7 @@ int main(int argc, char *argv[])
     int compression;
     int photo_metric;
     int fill_order;
-    
+
     compression = T4_COMPRESSION_ITU_T6;
     photo_metric = PHOTOMETRIC_MINISWHITE;
     fill_order = FILLORDER_LSB2MSB;
@@ -336,17 +336,17 @@ int main(int argc, char *argv[])
         TIFFSetField(tiff_file, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
         TIFFSetField(tiff_file, TIFFTAG_PHOTOMETRIC, photo_metric);
         TIFFSetField(tiff_file, TIFFTAG_FILLORDER, fill_order);
-    
+
         x_resolution = sequence[i].x_res/100.0f;
         y_resolution = sequence[i].y_res/100.0f;
         TIFFSetField(tiff_file, TIFFTAG_XRESOLUTION, floorf(x_resolution*2.54f + 0.5f));
         TIFFSetField(tiff_file, TIFFTAG_YRESOLUTION, floorf(y_resolution*2.54f + 0.5f));
         TIFFSetField(tiff_file, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH);
-    
+
         TIFFSetField(tiff_file, TIFFTAG_SOFTWARE, "spandsp");
         if (gethostname(buf, sizeof(buf)) == 0)
             TIFFSetField(tiff_file, TIFFTAG_HOSTCOMPUTER, buf);
-    
+
         TIFFSetField(tiff_file, TIFFTAG_IMAGEDESCRIPTION, "Blank test image");
         TIFFSetField(tiff_file, TIFFTAG_MAKE, "soft-switch.org");
         TIFFSetField(tiff_file, TIFFTAG_MODEL, "test data");
@@ -362,7 +362,7 @@ int main(int argc, char *argv[])
                 tm->tm_min,
                 tm->tm_sec);
         TIFFSetField(tiff_file, TIFFTAG_DATETIME, buf);
-    
+
         TIFFSetField(tiff_file, TIFFTAG_IMAGELENGTH, sequence[i].length);
         TIFFSetField(tiff_file, TIFFTAG_PAGENUMBER, 0, 1);
         TIFFSetField(tiff_file, TIFFTAG_CLEANFAXDATA, CLEANFAXDATA_CLEAN);
index ba75905fb2c9f65bb638246d5ff1de5d91dc448f..a54b22c6e9a995c6aaa3eaa99fbf6402471cf5ab 100644 (file)
@@ -240,7 +240,7 @@ static int end_to_end_tests(void)
         samples = ademco_contactid_receiver_tx(receiver, amp, SAMPLES_PER_CHUNK);
         for (j = samples;  j < SAMPLES_PER_CHUNK;  j++)
             amp[j] = 0;
-        
+
         /* We add AWGN and codec impairments to the signal, to stress the tone detector. */
         codec_munge(munge, amp, SAMPLES_PER_CHUNK);
         for (j = 0;  j < SAMPLES_PER_CHUNK;  j++)
index d077de99866605f0b8d8348b40c876d17e725663..17be38bcc471b8db3d34086e7587efb08605fe87 100644 (file)
@@ -233,7 +233,7 @@ static void put_adsi_msg(void *user_data, const uint8_t *msg, int len)
     int field_len;
     int message_type;
     uint8_t body[256];
-    
+
     printf("Good message received (%d bytes)\n", len);
     good_message_received = TRUE;
     for (i = 0;  i < len;  i++)
@@ -784,7 +784,7 @@ int main(int argc, char *argv[])
         }
     }
     outhandle = NULL;
-    
+
     tdd_character_set_tests();
 
     if (decode_test_file)
index 1f49d5651213853b66c76c8d90d44fafe5bfaf91..bd1a7d9d0799f75c5e522b8a00c9853b932cb415 100644 (file)
@@ -60,7 +60,7 @@ int v14_test_async_tx_get_bit(void *user_data)
     async_tx_state_t *s;
     int bit;
     static int destuff = 0;
-    
+
     /* Special routine to test V.14 rate adaption, by randomly skipping
        stop bits. */
     s = (async_tx_state_t *) user_data;
@@ -110,7 +110,7 @@ int v14_test_async_tx_get_bit(void *user_data)
 static int test_get_async_byte(void *user_data)
 {
     int byte;
-    
+
     byte = tx_async_chars & 0xFF;
     tx_async_chars++;
     return byte;
@@ -150,7 +150,7 @@ int main(int argc, char *argv[])
         printf("Test failed.\n");
         exit(2);
     }
-    
+
     printf("Test with async 7E1\n");
     async_tx_init(&tx_async, 7, ASYNC_PARITY_EVEN, 1, FALSE, test_get_async_byte, NULL);
     async_rx_init(&rx_async, 7, ASYNC_PARITY_EVEN, 1, FALSE, test_put_async_byte, NULL);
index 68915c9c58b10933dbbecb66b6098976e6ee0455..bdb26e1becb3a14c6484c2dd1b0bddec2829b7d4 100644 (file)
@@ -244,7 +244,7 @@ static const struct command_response_s general_test_seq[] =
     {"AT+FIT=?\r", "\r\n+FIT:(0-255),(0-1)\r\n\r\nOK\r\n"},         /* T.31 8.5.4 - DTE inactivity timeout */
     {"AT+FIT?\r", "\r\n+FIT:0,0\r\n\r\nOK\r\n"},
     {"AT+FLO=?\r", "\r\n+FLO:(0-2)\r\n\r\nOK\r\n"},                 /* T.31 says to implement something similar to +IFC */
-    {"AT+FLO?\r", "\r\n+FLO:2\r\n\r\nOK\r\n"}, 
+    {"AT+FLO?\r", "\r\n+FLO:2\r\n\r\nOK\r\n"},
     {"AT+FMI?\r", "\r\n" MANUFACTURER "\r\n\r\nOK\r\n"},            /* T.31 says to duplicate +GMI */
     {"AT+FMM?\r", "\r\n" PACKAGE "\r\n\r\nOK\r\n"},                 /* T.31 says to duplicate +GMM */
     {"AT+FMR?\r", "\r\n" VERSION "\r\n\r\nOK\r\n"},                 /* T.31 says to duplicate +GMR */
@@ -279,7 +279,7 @@ static const struct command_response_s general_test_seq[] =
     {"AT+ICLOK?\r", "\r\n+ICLOK:0\r\n\r\nOK\r\n"},                  /* V.250 6.2.14 - Select sync transmit clock source */
     {"AT+IDSR?\r", "\r\n+IDSR:0\r\n\r\nOK\r\n"},                    /* V.250 6.2.16 - Select data set ready option */
     {"AT+IFC=?\r", "\r\n+IFC:(0-2),(0-2)\r\n\r\nOK\r\n"},           /* V.250 6.2.12 - DTE-DCE local flow control */
-    {"AT+IFC?\r", "\r\n+IFC:2,2\r\n\r\nOK\r\n"}, 
+    {"AT+IFC?\r", "\r\n+IFC:2,2\r\n\r\nOK\r\n"},
     {"AT+ILRR\r", "\r\nOK\r\n"},                                    /* V.250 6.2.13 - DTE-DCE local rate reporting */
     {"AT+ILSD=?\r", "\r\n+ILSD:(0,1)\r\n\r\nOK\r\n"},               /* V.250 6.2.15 - Select long space disconnect option */
     {"AT+ILSD?\r", "\r\n+ILSD:0\r\n\r\nOK\r\n"},
@@ -459,13 +459,13 @@ static int at_send_hdlc(at_state_t *s, uint8_t *t, int len)
 static int general_test(at_state_t *s)
 {
     int i;
-    
+
     for (i = 0;  general_test_seq[i].command[0];  i++)
     {
         response_buf_ptr = 0;
         response_buf[0] = '\0';
         command_response_test_step = i;
-        at_send(s, general_test_seq[i].command);    
+        at_send(s, general_test_seq[i].command);
         if (strcmp(general_test_seq[command_response_test_step].response, response_buf) != 0)
         {
             printf("Incorrect response\n");
@@ -544,7 +544,7 @@ static int at_tx_handler(at_state_t *s, void *user_data, const uint8_t *buf, siz
         putchar(buf[i]);
     }
     response_buf[response_buf_ptr] = '\0';
-    
+
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
@@ -552,7 +552,7 @@ static int at_tx_handler(at_state_t *s, void *user_data, const uint8_t *buf, siz
 int main(int argc, char *argv[])
 {
     at_state_t *at_state;
-    
+
     if ((at_state = at_init(NULL, at_tx_handler, NULL, modem_call_control, NULL)) == NULL)
     {
         fprintf(stderr, "Cannot start the AT interpreter\n");
index 478c07cdd9d02f28ac77c17d60b025892d08d4e8..f5ba0c71ac5d77ff63b8b6c3462eb950b0bab5fe 100644 (file)
@@ -134,7 +134,7 @@ int main(int argc, char *argv[])
         /* Now send it out for graphing. */
         printf("%6d %.7f %.7f\n", i - 32768, x, p);
     }
-    
+
     printf("Tests passed.\n");
     return 0;
 }
index 68c9a7a05bcc2f6f96d30e6aaa59707716b05268..ed33c95d35276e64c3fba79ab42abb37032392a5 100644 (file)
@@ -236,14 +236,14 @@ int main(int argc, char *argv[])
 
     /* Test 1: Mitel's test 1 isn't really a test. Its a calibration step,
        which has no meaning here. */
-    printf ("Test 1: Calibration\n");
-    printf ("    Passed\n");
+    printf("Test 1: Calibration\n");
+    printf("    Passed\n");
 
     /* Test 2: Decode check
        This is a sanity check, that all digits are reliably detected
        under ideal conditions.  Each possible digit is repeated 10 times,
        with 68ms bursts. The level of each tone is about 6dB down from clip */
-    printf ("Test 2: Decode check\n");
+    printf("Test 2: Decode check\n");
     my_mf_gen_init(0.0, -3, 0.0, -3, 68, 68);
     s = ALL_POSSIBLE_DIGITS;
     digit[1] = '\0';
@@ -258,14 +258,14 @@ int main(int argc, char *argv[])
             actual = bell_mf_rx_get(mf_state, buf, 128);
             if (actual != 1  ||  buf[0] != digit[0])
             {
-                printf ("    Sent     '%s'\n", digit);
-                printf ("    Received '%s' [%d]\n", buf, actual);
-                printf ("    Failed\n");
-                exit (2);
+                printf("    Sent     '%s'\n", digit);
+                printf("    Received '%s' [%d]\n", buf, actual);
+                printf("    Failed\n");
+                exit(2);
             }
         }
     }
-    printf ("    Passed\n");
+    printf("    Passed\n");
 
     /* Test 3: Recognition bandwidth and channel centre frequency check.
        Use all digits. Each digit types requires four tests to complete
@@ -295,7 +295,7 @@ int main(int argc, char *argv[])
 
        The spec calls for +-1.5% +-10Hz of bandwidth.
     */
-    printf ("Test 3: Recognition bandwidth and channel centre frequency check\n");
+    printf("Test 3: Recognition bandwidth and channel centre frequency check\n");
     s = ALL_POSSIBLE_DIGITS;
     digit[1] = '\0';
     j = 0;
@@ -320,17 +320,17 @@ int main(int argc, char *argv[])
         }
         rrb = (float) (nplus + nminus)/10.0;
         rcfo = (float) (nplus - nminus)/10.0;
-        printf ("    %c (low)  rrb = %5.2f%%, rcfo = %5.2f%%, max -ve = %5.2f, max +ve = %5.2f\n",
-                digit[0],
-                rrb,
-                rcfo,
-                (float) nminus/10.0,
-                (float) nplus/10.0);
+        printf("    %c (low)  rrb = %5.2f%%, rcfo = %5.2f%%, max -ve = %5.2f, max +ve = %5.2f\n",
+               digit[0],
+               rrb,
+               rcfo,
+               (float) nminus/10.0,
+               (float) nplus/10.0);
 
         if (rrb < 3.0 + rcfo + (2.0*100.0*10.0/bell_mf_tones[j].f1)  ||  rrb >= 15.0 + rcfo)
         {
-            printf ("    Failed\n");
-            exit (2);
+            printf("    Failed\n");
+            exit(2);
         }
 
         for (nplus = 0, i = 1;  i <= 60;  i++)
@@ -351,27 +351,27 @@ int main(int argc, char *argv[])
         }
         rrb = (float) (nplus + nminus)/10.0;
         rcfo = (float) (nplus - nminus)/10.0;
-        printf ("    %c (high) rrb = %5.2f%%, rcfo = %5.2f%%, max -ve = %5.2f, max +ve = %5.2f\n",
-                digit[0],
-                rrb,
-                rcfo,
-                (float) nminus/10.0,
-                (float) nplus/10.0);
+        printf("    %c (high) rrb = %5.2f%%, rcfo = %5.2f%%, max -ve = %5.2f, max +ve = %5.2f\n",
+               digit[0],
+               rrb,
+               rcfo,
+               (float) nminus/10.0,
+               (float) nplus/10.0);
         if (rrb < 3.0 + rcfo + (2.0*100.0*10.0/bell_mf_tones[j].f2)  ||  rrb >= 15.0 + rcfo)
         {
-            printf ("    Failed\n");
-            exit (2);
+            printf("    Failed\n");
+            exit(2);
         }
         j++;
     }
-    printf ("    Passed\n");
+    printf("    Passed\n");
 
     /* Test 4: Acceptable amplitude ratio (twist).
        Twist all digits in both directions, and check the maximum twist
        we can accept. The way this is done is styled after the Mitel DTMF
        test, and has good and bad points. */
 
-    printf ("Test 4: Acceptable amplitude ratio (twist)\n");
+    printf("Test 4: Acceptable amplitude ratio (twist)\n");
     s = ALL_POSSIBLE_DIGITS;
     digit[1] = '\0';
     while (*s)
@@ -538,12 +538,12 @@ int main(int argc, char *argv[])
     if (!callback_ok)
     {
         printf("    Failed\n");
-       exit (2);
+        exit(2);
     }
     printf("    Passed\n");
 
     duration = time (NULL) - now;
-    printf ("Tests passed in %ds\n", duration);
+    printf("Tests passed in %ds\n", duration);
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
index ef5c32208b6678e7ef2b13a92e5dada0220f182a..6fae1458a7ec9153162f43aecd2b04ab9830605c 100644 (file)
@@ -37,7 +37,7 @@
 #include <time.h>
 
 #include "spandsp.h"
-    
+
 int main (int argc, char *argv[])
 {
     awgn_state_t *noise_source;
index 38ee420bdbbfdc22a5454218f5d8a0d81d5f253d..89a456bd82af1fdc90a33330eb2409a835fbe249 100644 (file)
 
 The DTMF detection test suite performs similar tests to the Mitel test tape,
 traditionally used for testing DTMF receivers. Mitel seem to have discontinued
-this product, but all it not lost. 
+this product, but all it not lost.
 
 The first side of the Mitel tape consists of a number of tone and tone+noise
 based tests. The test suite synthesizes equivalent test data. Being digitally
 generated, this data is rather more predictable than the test data on the nasty
-old stretchy cassette tapes which Mitel sold. 
+old stretchy cassette tapes which Mitel sold.
 
 The second side of the Mitel tape contains fragments of real speech from real
 phone calls captured from the North American telephone network. These are
@@ -62,14 +62,14 @@ copies of this seem to be unobtainable. However, Bellcore produce a much more
 aggressive set of three cassette tapes. All six side (about 30 minutes each) are
 filled with much tougher fragments of real speech from the North American
 telephone network. If you can do well in this test, nobody cares about your
-results against the Mitel test tape. 
+results against the Mitel test tape.
 
 A fresh set of tapes was purchased for these tests, and digitised, producing 6
 wave files of 16 bit signed PCM data, sampled at 8kHz. They were transcribed
 using a speed adjustable cassette player. The test tone at the start of the
 tapes is pretty accurate, and the new tapes should not have had much opportunity
 to stretch. It is believed these transcriptions are about as good as the source
-material permits. 
+material permits.
 
 PLEASE NOTE
 
@@ -79,7 +79,7 @@ you also have no right to use this data. The original tapes are the copyright
 material of BellCore, and they charge over US$200 for a set. I doubt they sell
 enough copies to consider this much of a business. However, it is their data,
 and it is their right to do as they wish with it. Currently I see no indication
-they wish to give it away for free. 
+they wish to give it away for free.
 */
 
 #if defined(HAVE_CONFIG_H)
@@ -460,7 +460,7 @@ static void mitel_cm7291_side_1_tests(void)
     printf("    Passed\n");
 
     /* Test 4: Acceptable amplitude ratio (twist).
-       Use only the diagonal pairs of tones (digits 1, 5, 9 and D). 
+       Use only the diagonal pairs of tones (digits 1, 5, 9 and D).
        There are eight sections to the test. Each section contains 200
        pulses with a 50ms duration for each pulse. Initially the amplitude
        of both tones is 6dB down from clip. The two sections to test one
@@ -477,7 +477,7 @@ static void mitel_cm7291_side_1_tests(void)
 
        The Acceptable Amplitude Ratio in dB is equal to the number of
        responses registered in (a) or (b), divided by 10.
-       
+
        TODO: This is supposed to work in 1/10dB steps, but here I used 1dB
              steps, as the current tone generator has its amplitude set in
              1dB steps.
@@ -527,7 +527,7 @@ static void mitel_cm7291_side_1_tests(void)
        clip. The amplitude of each is gradually attenuated by -35dB at a
        rate of 1dB per pulse. The Dynamic Range in dB is equal to the
        number of responses from the receiver during the test.
-       
+
        Well not really, but that is the Mitel test. Lets sweep a bit further,
        and see what the real range is */
     printf("Test 5: Dynamic range\n");
@@ -555,7 +555,7 @@ static void mitel_cm7291_side_1_tests(void)
        are transmitted at an amplitude of -6dB from clip per frequency.
        Pulse duration starts at 49ms and is gradually reduced to 10ms.
        Guard time in ms is equal to (500 - number of responses)/10.
-       
+
        That is the Mitel test, and we will follow it. Its totally bogus,
        though. Just what the heck is a pass or fail here? */
 
@@ -580,7 +580,7 @@ static void mitel_cm7291_side_1_tests(void)
        level is -24dBV, the second -18dBV and the third -12dBV.. The
        acceptable signal to noise ratio is the lowest ratio of signal
        to noise in the test where the receiver responds to all 1000 pulses.
-       
+
        Well, that is the Mitel test, but it doesn't tell you what the
        decoder can really do. Lets do a more comprehensive test */
 
@@ -597,7 +597,7 @@ static void mitel_cm7291_side_1_tests(void)
             // TODO: Clip
             for (sample = 0;  sample < len;  sample++)
                 amp[sample] = saturate(amp[sample] + awgn(&noise_source));
-            
+
             codec_munge(munge, amp, len);
             dtmf_rx(dtmf_state, amp, len);
 
@@ -735,10 +735,10 @@ static void dial_tone_tolerance_tests(void)
     printf("    Acceptable signal to dial tone ratio is %ddB\n", -15 - j);
     if ((use_dialtone_filter  &&  (-15 - j) > -12)
         ||
-        (!use_dialtone_filter  &&  (-15 - j) > 10)) 
+        (!use_dialtone_filter  &&  (-15 - j) > 10))
     {
         printf("    Failed\n");
-        exit(2); 
+        exit(2);
     }
     printf("    Passed\n");
 }
index c0f62a92663a12bbfc2e0d382eb5493d86a0e9d3..aba34d92b9cfe93ecc2629b1074628ee28159d42 100644 (file)
@@ -112,7 +112,7 @@ typedef struct
     fir_float_state_t *fir;
     float history[35*8];
     int pos;
-    float factor; 
+    float factor;
     float power;
     float peak;
 } level_measurement_device_t;
@@ -361,7 +361,7 @@ static void print_results(void)
 {
     if (!quiet)
         printf("test  model  ERL   time     Max Rin  Max Rout Max Sgen Max Sin  Max Sout\n");
-    printf("%-4s  %-1d      %-5.1f%6.2fs%9.2f%9.2f%9.2f%9.2f%9.2f\n", 
+    printf("%-4s  %-1d      %-5.1f%6.2fs%9.2f%9.2f%9.2f%9.2f%9.2f\n",
            test_name,
            chan_model.model_no,
            20.0f*log10f(-chan_model.erl + 1.0e-10f),
@@ -404,7 +404,7 @@ static int channel_model_create(channel_model_state_t *chan, int model, float er
         sizeof(line_model_d8_coeffs)/sizeof(line_model_d8_coeffs[0]),
         sizeof(line_model_d9_coeffs)/sizeof(line_model_d9_coeffs[0])
     };
-    static const float ki[] = 
+    static const float ki[] =
     {
         3.05e-5f,
         LINE_MODEL_D2_GAIN,
@@ -488,13 +488,13 @@ static void write_log_files(int16_t rout, int16_t sin)
     fprintf(fdump,
             " %d %d %d %d %d %d %d %d %d %d\n",
             ctx->clean_nlp,
-            ctx->Ltx, 
+            ctx->Ltx,
             ctx->Lrx,
-            ctx->Lclean, 
+            ctx->Lclean,
             (ctx->nonupdate_dwell > 0),
             ctx->adapt,
             ctx->Lclean_bg,
-            ctx->Pstates, 
+            ctx->Pstates,
             ctx->Lbgn_upper,
             ctx->Lbgn);
 #endif
@@ -616,7 +616,7 @@ static void run_test(echo_can_state_t *ctx, int16_t (*tx_source)(void), int16_t
 
 static void print_test_title(const char *title)
 {
-    if (quiet == FALSE) 
+    if (quiet == FALSE)
         printf(title);
 }
 /*- End of function --------------------------------------------------------*/
@@ -653,7 +653,7 @@ static int perform_test_sanity(void)
     echo_can_adaption_mode(ctx, ECHO_CAN_USE_ADAPTION | ECHO_CAN_USE_NLP | ECHO_CAN_USE_CNG);
     run_test(ctx, local_css_signal, silence, 5000);
     echo_can_adaption_mode(ctx, ECHO_CAN_USE_ADAPTION);
-    
+
     for (i = 0;  i < SAMPLE_RATE*10;  i++)
     {
         tx = local_css_signal();
@@ -715,7 +715,7 @@ static int perform_test_sanity(void)
         //result_sound[result_cur++] = (ctx->narrowband_score)*5; //  ?  SAMPLE_RATE  :  -SAMPLE_RATE;
         //result_sound[result_cur++] = ctx->tap_rotate_counter*10;
         ////result_sound[result_cur++] = ctx->vad;
-        
+
         put_residue(clean - far_tx);
         if (result_cur >= RESULT_CHANNELS*SAMPLE_RATE)
         {
@@ -812,7 +812,7 @@ static int perform_test_2b(void)
     echo_can_flush(ctx);
     echo_can_adaption_mode(ctx, ECHO_CAN_USE_ADAPTION);
     signal_restart(&local_css, 0.0f);
-    
+
     /* Test 2B (a) - Convergence test with NLP disabled */
 
     /* Converge the canceller */
@@ -863,17 +863,17 @@ static int perform_test_2ca(void)
     print_test_title("Performing test 2C(a) - Convergence with background noise present\n");
     ctx = echo_can_init(TEST_EC_TAPS, 0);
     awgn_init_dbm0(&far_noise_source, 7162534, -50.0f);
-    
+
     echo_can_flush(ctx);
     echo_can_adaption_mode(ctx, ECHO_CAN_USE_ADAPTION);
-    
+
     /* Converge a canceller */
     signal_restart(&local_css, 0.0f);
     run_test(ctx, silence, silence, 200);
-    
+
     awgn_init_dbm0(&far_noise_source, 7162534, -40.0f);
     run_test(ctx, local_css_signal, far_hoth_noise_signal, 5000);
-    
+
     /* Now freeze adaption, and measure the echo. */
     echo_can_adaption_mode(ctx, 0);
     level_measurements_reset_peaks();
@@ -901,18 +901,18 @@ static int perform_test_3a(void)
 
     echo_can_flush(ctx);
     echo_can_adaption_mode(ctx, ECHO_CAN_USE_ADAPTION);
-    
+
     run_test(ctx, silence, silence, 200);
     signal_restart(&local_css, 0.0f);
     signal_restart(&far_css, -20.0f);
 
     /* Apply double talk, with a weak far end signal */
     run_test(ctx, local_css_signal, far_css_signal, 5000);
-    
+
     /* Now freeze adaption. */
     echo_can_adaption_mode(ctx, 0);
     run_test(ctx, local_css_signal, silence, 500);
-    
+
     /* Now measure the echo */
     level_measurements_reset_peaks();
     run_test(ctx, local_css_signal, silence, 5000);
@@ -943,20 +943,20 @@ static int perform_test_3ba(void)
     run_test(ctx, silence, silence, 200);
     signal_restart(&local_css, 0.0f);
     signal_restart(&far_css, 0.0f);
-    
+
     /* Converge the canceller */
     run_test(ctx, local_css_signal, silence, 5000);
-    
+
     /* Apply double talk */
     run_test(ctx, local_css_signal, far_css_signal, 5000);
-    
+
     /* Now freeze adaption. */
     echo_can_adaption_mode(ctx, 0);
     run_test(ctx, local_css_signal, far_css_signal, 1000);
-    
+
     /* Turn off the double talk. */
     run_test(ctx, local_css_signal, silence, 500);
-    
+
     /* Now measure the echo */
     level_measurements_reset_peaks();
     run_test(ctx, local_css_signal, silence, 5000);
@@ -983,20 +983,20 @@ static int perform_test_3bb(void)
     run_test(ctx, silence, silence, 200);
     signal_restart(&local_css, 0.0f);
     signal_restart(&far_css, -15.0f);
-    
+
     /* Converge the canceller */
     run_test(ctx, local_css_signal, silence, 5000);
-    
+
     /* Apply double talk */
     run_test(ctx, local_css_signal, far_css_signal, 5000);
-    
+
     /* Now freeze adaption. */
     echo_can_adaption_mode(ctx, 0);
     run_test(ctx, local_css_signal, silence, 1000);
-    
+
     /* Turn off the double talk. */
     run_test(ctx, local_css_signal, silence, 500);
-    
+
     /* Now measure the echo */
     level_measurements_reset_peaks();
     run_test(ctx, local_css_signal, silence, 5000);
@@ -1082,7 +1082,7 @@ static int perform_test_4(void)
 static int perform_test_5(void)
 {
     echo_can_state_t *ctx;
-    
+
     /* Test 5 - Infinite return loss convergence test */
     print_test_title("Performing test 5 - Infinite return loss convergence test\n");
     ctx = echo_can_init(TEST_EC_TAPS, 0);
@@ -1261,8 +1261,8 @@ static int perform_test_9(void)
 
     echo_can_flush(ctx);
     echo_can_adaption_mode(ctx,
-                           ECHO_CAN_USE_ADAPTION 
-                         | ECHO_CAN_USE_NLP 
+                           ECHO_CAN_USE_ADAPTION
+                         | ECHO_CAN_USE_NLP
                          | ECHO_CAN_USE_CNG);
 
     /* Test 9 part 1 - matching */
@@ -1492,7 +1492,7 @@ static void simulate_ec(char *argv[], int two_channel_file, int mode)
     if (two_channel_file)
     {
         txfile = sf_open_telephony_read(argv[0], 1);
-        rxfile = sf_open_telephony_read(argv[1], 1);      
+        rxfile = sf_open_telephony_read(argv[1], 1);
         ecfile = sf_open_telephony_write(argv[2], 1);
     }
     else
@@ -1524,7 +1524,7 @@ static void simulate_ec(char *argv[], int two_channel_file, int mode)
                 exit(2);
             }
             if ((nrx = sf_readf_short(rxfile, &sin, 1)) < 0)
-            {           
+            {
                 fprintf(stderr, "    Error reading rx sound file\n");
                 exit(2);
             }
index a62e8971ee8150c26a084f41aa95b13f6d38f107..37792a9f2bb1b0d21ffd8a40f2a281967ffa142f 100644 (file)
@@ -139,7 +139,7 @@ static void print_frame(const char *io, const uint8_t *fr, int frlen)
     const char *country;
     const char *vendor;
     const char *model;
-    
+
     fprintf(stderr, "%s %s:", io, t30_frametype(fr[2]));
     for (i = 2;  i < frlen;  i++)
         fprintf(stderr, " %02x", fr[i]);
@@ -545,7 +545,7 @@ int main(int argc, char *argv[])
         fprintf(stderr, "Failed to init\n");
         exit(0);
     }
-        
+
     for (;;)
     {
         len = sf_readf_short(inhandle, amp, SAMPLES_PER_CHUNK);
index 7767a2d544e83c7a0a4cebe5380ac1212c4d5385..d42ea3a07495529e3a946007751e824a1748ad70 100644 (file)
@@ -102,7 +102,7 @@ static void hdlc_underflow_handler(void *user_data)
     uint8_t buf[400];
 
     s = (faxtester_state_t *) user_data;
-    
+
     if (s->image_buffer)
     {
         /* We are sending an ECM image */
@@ -172,7 +172,7 @@ static void tone_detected(void *user_data, int tone, int level, int delay)
                  SPAN_LOG_FLOW,
                  "Tone was on for %fs\n",
                  (float) (s->timer - s->tone_on_time)/SAMPLE_RATE + 0.55);
-    }    
+    }
     s->tone_state = tone;
     if (tone == MODEM_CONNECT_TONES_NONE)
         front_end_step_complete(s);
@@ -336,7 +336,7 @@ int faxtester_rx(faxtester_state_t *s, int16_t *amp, int len)
 int faxtester_tx(faxtester_state_t *s, int16_t *amp, int max_len)
 {
     int len;
-    
+
     len = 0;
     if (s->transmit)
     {
@@ -350,7 +350,7 @@ int faxtester_tx(faxtester_state_t *s, int16_t *amp, int max_len)
                 {
                     /* Pad to the requested length with silence */
                     memset(amp + len, 0, (max_len - len)*sizeof(int16_t));
-                    len = max_len;        
+                    len = max_len;
                 }
                 break;
             }
@@ -362,7 +362,7 @@ int faxtester_tx(faxtester_state_t *s, int16_t *amp, int max_len)
         {
             /* Pad to the requested length with silence */
             memset(amp, 0, max_len*sizeof(int16_t));
-            len = max_len;        
+            len = max_len;
         }
     }
     return len;
index cf285009054e8d68a8bbd5810dc5f5edc0d1b8d6..02c840974a52240e2a47fe8151acbfad3e719e50 100644 (file)
@@ -343,7 +343,7 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
     int i;
     t30_stats_t t;
     char tag[20];
-    
+
     i = (int) (intptr_t) user_data;
     snprintf(tag, sizeof(tag), "%c: Phase E", i + 'A');
     printf("%c: Phase E handler - (%d) %s\n", i + 'A', result, t30_completion_code_to_str(result));
@@ -363,7 +363,7 @@ static void real_time_frame_handler(t30_state_t *s,
                                     int len)
 {
     int i;
-    
+
     i = (intptr_t) user_data;
     printf("%c: Real time frame handler - %s, %s, length = %d\n",
            i + 'A',
@@ -376,7 +376,7 @@ static void real_time_frame_handler(t30_state_t *s,
 static int document_handler(t30_state_t *s, void *user_data, int event)
 {
     int i;
-    
+
     i = (intptr_t) user_data;
     printf("%c: Document handler - event %d\n", i + 'A', event);
     return FALSE;
@@ -400,7 +400,7 @@ static void real_time_gateway_frame_handler(t38_gateway_state_t *s,
                                             int len)
 {
     int i;
-    
+
     i = (intptr_t) user_data;
     printf("%c: Real time gateway frame handler - %s, %s, length = %d\n",
            i + 'A',
@@ -674,7 +674,7 @@ int main(int argc, char *argv[])
         }
     }
     memset(silence, 0, sizeof(silence));
+
     srand48(0x1234567);
     /* Set up the nodes */
     input_wave_handle = NULL;
@@ -858,6 +858,7 @@ int main(int argc, char *argv[])
                                     | T30_SUPPORT_300_600_RESOLUTION
                                     | T30_SUPPORT_400_800_RESOLUTION
                                     | T30_SUPPORT_600_1200_RESOLUTION);
+        //t30_set_rx_encoding(t30_state[i], T4_COMPRESSION_ITU_T85);
         t30_set_ecm_capability(t30_state[i], use_ecm);
         if (use_ecm)
         {
@@ -1096,7 +1097,7 @@ int main(int argc, char *argv[])
             exit(2);
         }
     }
-    
+
     /* Check how many pages should have been transferred */
     expected_pages = get_tiff_total_pages(input_tiff_file_name);
     if (end_page >= 0  &&  expected_pages > end_page + 1)
index b3068559656a898df0527af25d23d7c207978824..b6f075da6d45886008c182978df3d10405fa36db 100644 (file)
@@ -41,7 +41,7 @@
 void fax_log_tx_parameters(t30_state_t *s, const char *tag)
 {
     const char *u;
-    
+
     if ((u = t30_get_tx_ident(s)))
         printf("%s: Local ident '%s'\n", tag, u);
     if ((u = t30_get_tx_sub_address(s)))
index 22ee5ab3c6ae5fe244427e352b14c48032783fd2..9cd69f586588be7866c888f554f1d9e7467e905b 100644 (file)
@@ -174,7 +174,7 @@ int main(int argc, char *argv[])
     int16_t out_amp[2*BLOCK_LEN];
     SNDFILE *inhandle;
     SNDFILE *outhandle;
-    int outframes;    
+    int outframes;
     int i;
     int j;
     int samples;
@@ -350,14 +350,14 @@ int main(int argc, char *argv[])
         }
         off_at = i;
         printf("Carrier on at %d, off at %d\n", on_at, off_at);
-        if (on_at < -29  ||  on_at > -26  
+        if (on_at < -29  ||  on_at > -26
             ||
             off_at < -35  ||  off_at > -31)
         {
             printf("Tests failed.\n");
             exit(2);
         }
-                
+
         printf("Test with BERT\n");
         test_bps = preset_fsk_specs[modem_under_test_1].baud_rate;
         if (modem_under_test_1 >= 0)
@@ -426,7 +426,7 @@ int main(int argc, char *argv[])
                 out_amp[2*i + 1] = answerer_model_amp[i];
             for (  ;  i < BLOCK_LEN;  i++)
                 out_amp[2*i + 1] = 0;
-        
+
             if (log_audio)
             {
                 outframes = sf_writef_short(outhandle, out_amp, BLOCK_LEN);
@@ -468,7 +468,7 @@ int main(int argc, char *argv[])
                     }
                     break;
                 }
-    
+
                 /* Put a little silence between the chunks in the file. */
                 memset(out_amp, 0, sizeof(out_amp));
                 if (log_audio)
index cf4453c4a2983908a0c138bf9af8cd1155dae6be..bb0956d677bf793fcbde3141157c9b3766064c9d 100644 (file)
@@ -173,7 +173,7 @@ static void compliance_tests(int log_audio)
         printf("Tests failed\n");
         exit(2);
     }
-    
+
     printf("Cyclic conversion repeatability tests.\n");
     /* Find what happens to every possible linear value after a round trip. */
     for (i = 0;  i < 65536;  i++)
@@ -200,7 +200,7 @@ static void compliance_tests(int log_audio)
             exit(2);
         }
     }
-    
+
     printf("Reference power level tests.\n");
     power_meter_init(&power_meter, 7);
 
@@ -274,7 +274,7 @@ static void compliance_tests(int log_audio)
             }
         }
     }
-    
+
     enc_state = g711_init(NULL, G711_ALAW);
     transcode = g711_init(NULL, G711_ALAW);
     dec_state = g711_init(NULL, G711_ULAW);
index 28688999b1dd32359c42194e9a702b3c5edbaa2e..dff1b959d240436abbcb06f9010b782f3e7517cd 100644 (file)
@@ -136,7 +136,7 @@ static const char *decode_test_files[] =
     TESTDATA_DIR "T3L3.RC2",
     TESTDATA_DIR "T3L3.RC3",
     TESTDATA_DIR "T3H3.RC0",
-    
+
     NULL
 };
 
@@ -197,13 +197,13 @@ static int get_test_vector(const char *file, uint16_t buf[], int max_len)
     int octets;
     int i;
     FILE *infile;
-    
+
     if ((infile = fopen(file, "r")) == NULL)
     {
         fprintf(stderr, "    Failed to open '%s'\n", file);
         exit(2);
     }
-    octets = 0;  
+    octets = 0;
     while ((i = get_vector(infile, buf + octets)) > 0)
         octets += i;
     fclose(infile);
@@ -232,7 +232,7 @@ static void itu_compliance_tests(void)
     for (file = 0;  encode_test_files[file];  file += 2)
     {
         printf("Testing %s -> %s\n", encode_test_files[file], encode_test_files[file + 1]);
-    
+
         /* Get the input data */
         len_data = get_test_vector(encode_test_files[file], (uint16_t *) itu_data, MAX_TEST_VECTOR_LEN);
 
@@ -322,7 +322,7 @@ static void itu_compliance_tests(void)
             len = j - i;
             for (k = 0;  k < len;  k++)
                 compressed[k] = itu_data[k + i] >> ((mode == 3)  ?  10  :  (mode == 2)  ?  9  :  8);
-        
+
             dec_state = g722_decode_init(NULL, (mode == 3)  ?  48000  :  (mode == 2)  ?  56000  :  64000, 0);
             dec_state->itu_test_mode = TRUE;
             len2 = g722_decode(dec_state, decompressed, compressed, len);
index 369a8860edcf0612bbd3362678a591c4961dc1a0..4fba66021e06e3ad73e78c7925e0ec6b38636e16 100644 (file)
@@ -157,7 +157,7 @@ Algorithm   Input   Intermediate    Output      Input   Intermediate    Output
                     HN40FA.I        HN40FX.O            HV40FA.I        HV40FX.O
 */
 
-#define        G726_ENCODING_NONE          9999
+#define G726_ENCODING_NONE          9999
 
 typedef struct
 {
@@ -1043,13 +1043,13 @@ static int get_test_vector(const char *file, uint8_t buf[], int max_len)
     int i;
     int sum;
     FILE *infile;
-    
+
     if ((infile = fopen(file, "r")) == NULL)
     {
         fprintf(stderr, "    Failed to open '%s'\n", file);
         exit(2);
     }
-    octets = 0;  
+    octets = 0;
     while ((i = get_vector(infile, buf + octets)) > 0)
         octets += i;
     fclose(infile);
@@ -1253,7 +1253,7 @@ int main(int argc, char *argv[])
         printf("ADPCM packing is %d\n", packing);
         g726_init(&enc_state, bit_rate, G726_ENCODING_LINEAR, packing);
         g726_init(&dec_state, bit_rate, G726_ENCODING_LINEAR, packing);
-            
+
         while ((frames = sf_readf_short(inhandle, amp, 159)))
         {
             adpcm = g726_encode(&enc_state, adpcmdata, amp, frames);
index 6b41a33b07b3eedd384f11b960eb9ccb7500fb0f..9993a39260dcfe3789f1448e3a8c85d0bbeb54aa 100644 (file)
@@ -92,7 +92,7 @@ copied to etsitests/gsm0610/unpacked so the files are arranged in the following
 ./fr_sync_A:
     Seqsync_A.inp
     Sync000_A.cod   --to--          Sync159_A.cod
-    
+
 ./fr_sync_L:
     Bitsync.inp
     Seqsync.inp
@@ -153,7 +153,7 @@ static int get_test_vector(int full, int disk, const char *name)
     int in;
     int len;
     int i;
-    
+
     if (full)
     {
         sprintf(buf, "%s%c/%s.inp", TESTDATA_DIR, 'L', name);
@@ -189,7 +189,7 @@ static int get_test_vector(int full, int disk, const char *name)
     {
         vector_len = len;
     }
-    
+
     sprintf(buf, "%s%c/%s.cod", TESTDATA_DIR, 'L', name);
     if ((in = open(buf, O_RDONLY)) < 0)
     {
@@ -221,9 +221,9 @@ static int get_law_test_vector(int full, int law, const char *name)
     int len;
     int i;
     int law_uc;
-    
+
     law_uc = toupper(law);
-    
+
     if (full)
     {
         sprintf(buf, "%s%c/%s-%c.inp", TESTDATA_DIR, law_uc, name, law_uc);
@@ -286,7 +286,7 @@ static int get_law_test_vector(int full, int law, const char *name)
     len /= sizeof(int16_t);
     for (i = 0;  i < len;  i++)
         decoder_code_vector[i] = code_vector_buf[i];
-    
+
     return len;
 }
 /*- End of function --------------------------------------------------------*/
@@ -368,7 +368,7 @@ static int perform_law_test(int full, int law, const char *name)
         printf("Performing A-law test '%s'\n", name);
     else
         printf("Performing u-law test '%s'\n", name);
-        
+
     get_law_test_vector(full, law, name);
 
     if (full)
@@ -448,9 +448,9 @@ static int repack_gsm0610_voip_to_wav49(uint8_t c[], const uint8_t d[])
 {
     gsm0610_frame_t frame[2];
     int n;
-       n = gsm0610_unpack_voip(&frame[0], d);
-       gsm0610_unpack_voip(&frame[1], d + n);
+
+    n = gsm0610_unpack_voip(&frame[0], d);
+    gsm0610_unpack_voip(&frame[1], d + n);
     n = gsm0610_pack_wav49(c, frame);
     return n;
 }
@@ -479,7 +479,7 @@ static int perform_pack_unpack_test(void)
     printf("Performing packing/unpacking tests (not part of the ETSI conformance tests).\n");
     /* Try trans-packing a lot of random data looking for before/after mismatch. */
     for (j = 0;  j < 1000;  j++)
-    {        
+    {
         for (i = 0;  i < 65;  i++)
             a[i] = rand();
         repack_gsm0610_wav49_to_voip(b, a);
@@ -583,13 +583,13 @@ int main(int argc, char *argv[])
             fprintf(stderr, "    Cannot create audio file '%s'\n", OUT_FILE_NAME);
             exit(2);
         }
-    
+
         if ((gsm0610_enc_state = gsm0610_init(NULL, packing)) == NULL)
         {
             fprintf(stderr, "    Cannot create encoder\n");
             exit(2);
         }
-            
+
         if ((gsm0610_dec_state = gsm0610_init(NULL, packing)) == NULL)
         {
             fprintf(stderr, "    Cannot create decoder\n");
@@ -602,7 +602,7 @@ int main(int argc, char *argv[])
             gsm0610_decode(gsm0610_dec_state, post_amp, gsm0610_data, bytes);
             sf_writef_short(outhandle, post_amp, frames);
         }
-    
+
         if (sf_close_telephony(inhandle))
         {
             fprintf(stderr, "    Cannot close audio file '%s'\n", IN_FILE_NAME);
index a4a35dcf3c964f0d608ec895af2c7145c31be7c7..70df13425ce700866753deadfb257d0c8da60c03 100644 (file)
@@ -818,7 +818,7 @@ static void decode_bitstream(const char *in_file_name)
     int num;
     hdlc_rx_state_t rx;
     FILE *in;
-    
+
     if ((in = fopen(in_file_name, "r")) == NULL)
     {
         fprintf(stderr, "Failed to open '%s'\n", in_file_name);
index c335f6179b6918136c881939c5025eb1010c542a..dcf2a6a4cb1bc3a72c7629e8d3823333a8b7df8f 100644 (file)
@@ -136,7 +136,7 @@ int main(int argc, char *argv[])
         fprintf(stderr, "    Cannot create encoder\n");
         exit(2);
     }
-        
+
     if ((ima_dec_state = ima_adpcm_init(NULL, variant, enc_chunk_size)) == NULL)
     {
         fprintf(stderr, "    Cannot create decoder\n");
@@ -203,7 +203,7 @@ int main(int argc, char *argv[])
         printf("Tests failed.\n");
         exit(2);
     }
-    
+
     printf("Tests passed.\n");
     return 0;
 }
index 5fb68c7042b92a24fc7338c58e59a50904911487..cd4195f7da809c76fc936345eae92b793b61e94a 100644 (file)
@@ -196,7 +196,7 @@ static int test_dithered_50_by_50(int row, int width, uint8_t buf[])
         " 46:  @ @ @ @ @ @ @@ @ @ @@ @@ @@ @@@@@ @ @@ @@@@@@@@@@",
         " 47: @ @ @ @ @ @@ @ @ @@@@ @@@@ @@@@@ @@@@@@@@@@@ @@@@@",
         " 48:  @ @ @ @@ @ @@ @@ @ @@ @ @@@ @ @@@@@ @@@@@@@@@@@@@",
-        " 49: @ @ @ @ @ @@ @@ @@ @@ @@@@ @@@@@@@ @@@@@@ @@@@@@@@" 
+        " 49: @ @ @ @ @ @@ @@ @@ @@ @@@@ @@@@@@@ @@@@@@ @@@@@@@@"
     };
     int i;
     int match;
index 133782e9fa1af2105632d10b161f972a6c7bed1b..0cb065783d3b39dbe3a2ac7979391c6daf016f8e 100644 (file)
@@ -241,7 +241,7 @@ int main(int argc, char *argv[])
     pk = peak(noise_sound, 8192);
     ms = rms(noise_sound, 8192);
     printf("Filtered noise level = %.2fdB, crest factor = %.2fdB\n", rms_to_dbm0(ms), rms_to_db(pk/ms));
-    
+
     for (i = 0;  i < 8192;  i++)
         silence_sound[i] = 0.0;
 
index 52b1f8d94007fdc02dab260be17967fb060212cd..fd7f104992608f4a9ce8c368392e661c41d841fb 100644 (file)
@@ -130,7 +130,7 @@ static int preamble_get_bit(void *user_data)
 {
     static int bit_no = 0;
     int bit;
-    
+
     /* Generate a section of HDLC flag octet preamble. Then generate some random
        bits, which should not look like preamble. */
     if (++preamble_count < 255)
index 4f042b9fcdfd071e3e331fe27a138ffbfceee1ff..c6ce135a027b98380dac44cfec9c1a301acdea77 100644 (file)
 \section modem_echo_can_tests_page_sec_1 What does it do?
 Currently the echo cancellation tests only provide simple exercising of the
 cancellor in the way it might be used for line echo cancellation. The test code
-is in echotests.c. 
+is in echotests.c.
 
 The goal is to test the echo cancellor again the G.16X specs. Clearly, that also
 means the goal for the cancellor itself is to comply with those specs. Right
 now, the only aspect of these tests implemented is the line impulse response
-models in g168tests.c. 
+models in g168tests.c.
 
 \section modem_echo_can_tests_page_sec_2 How does it work?
 The current test consists of feeding an audio file of real speech to the echo
@@ -42,7 +42,7 @@ real speech is also used to simulate a signal received form the far end of the
 line. This is gated so it is only placed for one second every 10 seconds,
 simulating the double talk condition. The resulting echo cancelled signal can
 either be store in a file for further analysis, or played back as the data is
-processed. 
+processed.
 
 A number of modified versions of this test have been performed. The signal level
 of the two speech sources has been varied. Several simple models of the
@@ -53,7 +53,7 @@ is very loud (with earlier versions, well, ....:) ). The lack of saturating
 arithmetic in general purpose CPUs is a huge disadvantage here, as software
 saturation logic would cause a major slow down. Floating point would be good,
 but is not usable in the Linux kernel. Anyway, the bottom line seems to be the
-current design is genuinely useful, if imperfect. 
+current design is genuinely useful, if imperfect.
 
 \section modem_echo_can_tests_page_sec_2 How do I use it?
 
@@ -69,7 +69,7 @@ echo_tests.c is commented out with a \#if. If this is enabled, detailed
 information about the results of the echo cancellation will be written to
 stdout. By saving this into a file, Grace (recommended), GnuPlot, or some other
 plotting package may be used to graphically display the functioning of the
-cancellor.  
+cancellor.
 */
 
 #if defined(HAVE_CONFIG_H)
@@ -266,7 +266,7 @@ int main(int argc, char *argv[])
 #if defined(ENABLE_GUI)
     int16_t amp[2];
 #endif
-    
+
     line_model_no = 0;
     use_gui = FALSE;
     for (i = 1;  i < argc;  i++)
@@ -305,7 +305,7 @@ int main(int argc, char *argv[])
 
     power_meter_init(&power_before, 5);
     power_meter_init(&power_after, 5);
-    
+
     /* Measure the echo power before adaption */
     modem_echo_can_adaption_mode(ctx, FALSE);
     for (i = 0;  i < 8000*5;  i++)
@@ -319,7 +319,7 @@ int main(int argc, char *argv[])
     unadapted_output_power = power_meter_current_dbm0(&power_before);
     unadapted_echo_power = power_meter_current_dbm0(&power_after);
     printf("Pre-adaption: output power %10.5fdBm0, echo power %10.5fdBm0\n", unadapted_output_power, unadapted_echo_power);
-    
+
     /* Converge the canceller */
     signal_restart(&local_css);
     modem_echo_can_adaption_mode(ctx, TRUE);
@@ -364,7 +364,7 @@ int main(int argc, char *argv[])
     adapted_output_power = power_meter_current_dbm0(&power_before);
     adapted_echo_power = power_meter_current_dbm0(&power_after);
     printf("Post-adaption: output power %10.5fdBm0, echo power %10.5fdBm0\n", adapted_output_power, adapted_echo_power);
-    
+
     if (fabsf(adapted_output_power - unadapted_output_power) > 0.1f
         ||
         adapted_echo_power > unadapted_echo_power - 30.0f)
index 568c916682f5eb88a82f73402080575e9e81034e..0c7ee99bbf456b2027e29312751fffdfa457de01 100644 (file)
@@ -202,7 +202,7 @@ int main (int argc, char *argv[])
             exit(2);
         }
     }
-    
+
     quality = 7;
     printf("Generating Hoth noise at -15dBOv to file\n");
     level = -15;
@@ -224,7 +224,7 @@ int main (int argc, char *argv[])
         fprintf(stderr, "    Cannot close audio file '%s'\n", OUT_FILE_NAME);
         exit(2);
     }
-    
+
     printf("Tests passed.\n");
     return 0;
 }
index 2571dc7cbf5fdc27e597f9f6cb7e417647c84d9c..d9c68700294235bcf82759415082bec2857d86bf 100644 (file)
@@ -79,7 +79,7 @@ struct iphdr
     uint32_t daddr;
     /*The options start here. */
 };
-   
+
 #endif
 
 /* We define our own structures for Ethernet Header and IPv6 Header as they are not available on CYGWIN.
@@ -287,6 +287,9 @@ int pcap_scan_pkts(const char *file,
             fprintf(stderr, "Truncated packet - total len = %d, captured len = %d\n", pkthdr->len, pkthdr->caplen);
             exit(2);
         }
+#if 0
+        printf("%d:%d -> %d:%d\n", ntohl(iphdr->saddr), ntohs(udphdr->source), ntohl(iphdr->daddr), ntohs(udphdr->dest));
+#endif
         body = (const uint8_t *) udphdr;
         body += sizeof(struct udphdr);
         body_len = pktlen - sizeof(struct udphdr);
index acdbd8ed1c2276cae91c01400ac9e2d0a3f870e9..a5180eafdfe5a08e462403a4b004f707e3a68f99 100644 (file)
@@ -260,7 +260,7 @@ static void static_buffer_tests(void)
                               fr,
                               type,
                               len,
-                              next_scheduled_send, 
+                              next_scheduled_send,
                               next_actual_receive);
             switch (ret)
             {
index 9dc6b3e4af2e897bd723bb91c7627d730c41aee5..0dd04c74248c26ee821ae49216d91dd7d9f2d4ac 100644 (file)
@@ -101,7 +101,7 @@ static int power_surge_detector_tests(void)
             if (prev_signal_present != signal_present)
             {
                 signal_power = power_surge_detector_current_dbm0(sig);
-                if (signal_present) 
+                if (signal_present)
                 {
                     if (ok == 0  &&  i >= 0  &&  i < 25)
                         ok = 1;
@@ -120,7 +120,7 @@ static int power_surge_detector_tests(void)
                     if (extremes[3] < i)
                         extremes[3] = i;
                     printf("Off at %f (%fdBm0)\n", (sample + i)/8000.0, signal_power);
-                }                    
+                }
                 prev_signal_present = signal_present;
             }
             amp_out[2*i] = amp[i];
index 4e208db946e2453b615a6554af716bae0b7d592d..d01aa60ec9a58b83543f5c9046e7db6edb24d6cd 100644 (file)
@@ -546,7 +546,7 @@ static void functional_message_tests(void)
     uint8_t buf[MSG_LEN];
     int i;
     int len;
-    
+
     total_in = 0;
     total_out = 0;
 
index 66f6526e32b9b98ef1126cbf0b993bfd597ab1fa..6fb9b0781dbf8bc52d369276f3d1417c27e8be80 100644 (file)
@@ -149,7 +149,7 @@ static void my_mf_gen_init(float low_fudge,
 {
     const mf_digit_tones_t *tone;
     int i;
-    
+
     for (i = 0;  i < 15;  i++)
     {
         if (fwd)
@@ -190,7 +190,7 @@ static void codec_munge(int16_t amp[], int len)
 {
     int i;
     uint8_t alaw;
-    
+
     for (i = 0;  i < len;  i++)
     {
         alaw = linear_to_alaw (amp[i]);
@@ -245,15 +245,15 @@ static int test_a_tone_set(int fwd)
     /* Test 1: Mitel's test 1 isn't really a test. Its a calibration step,
        which has no meaning here. */
 
-    printf ("Test 1: Calibration\n");
-    printf ("    Passed\n");
+    printf("Test 1: Calibration\n");
+    printf("    Passed\n");
 
     /* Test 2: Decode check
        This is a sanity check, that all digits are reliably detected
        under ideal conditions.  Each possible digit is repeated 10 times,
        with 68ms bursts. The level of each tone is about 6dB down from clip */
 
-    printf ("Test 2: Decode check\n");
+    printf("Test 2: Decode check\n");
     my_mf_gen_init(0.0, -3, 0.0, -3, 68, fwd);
     s = r2_mf_tone_codes;
     while (*s)
@@ -267,14 +267,14 @@ static int test_a_tone_set(int fwd)
             actual = r2_mf_rx_get(mf_state);
             if (actual != digit)
             {
-                printf ("    Sent     '%c'\n", digit);
-                printf ("    Received 0x%X\n", actual);
-                printf ("    Failed\n");
-                exit (2);
+                printf("    Sent     '%c'\n", digit);
+                printf("    Received 0x%X\n", actual);
+                printf("    Failed\n");
+                exit(2);
             }
         }
     }
-    printf ("    Passed\n");
+    printf("    Passed\n");
 
     /* Test 3: Recognition bandwidth and channel centre frequency check.
        Use all digits. Each digit types requires four tests to complete
@@ -297,14 +297,14 @@ static int test_a_tone_set(int fwd)
             RRB% = (N+ + N-)/10
        Receiver Center Frequency Offset (RCFO) is calculated as follows:
             RCFO% = X + (N+ - N-)/20
-            
+
        Note that this test doesn't test what it says it is testing at all,
        and the results are quite inaccurate, if not a downright lie! However,
        it follows the Mitel procedure, so how can it be bad? :)
-       
+
        The spec calls for +-4 +-10Hz (ie +-14Hz) of bandwidth. */
 
-    printf ("Test 3: Recognition bandwidth and channel centre frequency check\n");
+    printf("Test 3: Recognition bandwidth and channel centre frequency check\n");
     s = r2_mf_tone_codes;
     j = 0;
     while (*s)
@@ -330,17 +330,17 @@ static int test_a_tone_set(int fwd)
         }
         rrb = (float) (nplus + nminus)/10.0;
         rcfo = (float) (nplus - nminus)/10.0;
-        printf ("    %c (low)  rrb = %5.2f%%, rcfo = %5.2f%%, max -ve = %5.2f, max +ve = %5.2f\n",
-                digit,
-                rrb,
-                rcfo,
-                (float) nminus/10.0,
-                (float) nplus/10.0);
+        printf("    %c (low)  rrb = %5.2f%%, rcfo = %5.2f%%, max -ve = %5.2f, max +ve = %5.2f\n",
+               digit,
+               rrb,
+               rcfo,
+               (float) nminus/10.0,
+               (float) nplus/10.0);
 
         if (rrb < rcfo + (2.0*100.0*14.0/r2_mf_fwd_tones[j].f1)  ||  rrb >= 15.0 + rcfo)
         {
-            printf ("    Failed\n");
-            exit (2);
+            printf("    Failed\n");
+            exit(2);
         }
 
         for (nplus = 0, i = 1;  i <= 60;  i++)
@@ -363,27 +363,27 @@ static int test_a_tone_set(int fwd)
         }
         rrb = (float) (nplus + nminus)/10.0;
         rcfo = (float) (nplus - nminus)/10.0;
-        printf ("    %c (high) rrb = %5.2f%%, rcfo = %5.2f%%, max -ve = %5.2f, max +ve = %5.2f\n",
-                digit,
-                rrb,
-                rcfo,
-                (float) nminus/10.0,
-                (float) nplus/10.0);
+        printf("    %c (high) rrb = %5.2f%%, rcfo = %5.2f%%, max -ve = %5.2f, max +ve = %5.2f\n",
+               digit,
+               rrb,
+               rcfo,
+               (float) nminus/10.0,
+               (float) nplus/10.0);
         if (rrb < rcfo + (2.0*100.0*14.0/r2_mf_fwd_tones[j].f2)  ||  rrb >= 15.0 + rcfo)
         {
-            printf ("    Failed\n");
-            exit (2);
+            printf("    Failed\n");
+            exit(2);
         }
         j++;
     }
-    printf ("    Passed\n");
+    printf("    Passed\n");
 
     /* Test 4: Acceptable amplitude ratio (twist).
        Twist all digits in both directions, and check the maximum twist
        we can accept. The way this is done is styled after the Mitel DTMF
        test, and has good and bad points. */
 
-    printf ("Test 4: Acceptable amplitude ratio (twist)\n");
+    printf("Test 4: Acceptable amplitude ratio (twist)\n");
     s = r2_mf_tone_codes;
     while (*s)
     {
@@ -398,11 +398,11 @@ static int test_a_tone_set(int fwd)
             if (r2_mf_rx_get(mf_state) == digit)
                 nplus++;
         }
-        printf ("    %c normal twist  = %.2fdB\n", digit, (float) nplus/10.0);
+        printf("    %c normal twist  = %.2fdB\n", digit, (float) nplus/10.0);
         if (nplus < 70)
         {
-            printf ("    Failed\n");
-            exit (2);
+            printf("    Failed\n");
+            exit(2);
         }
         for (nminus = 0, i = -50;  i >= -250;  i--)
         {
@@ -414,21 +414,21 @@ static int test_a_tone_set(int fwd)
             if (r2_mf_rx_get(mf_state) == digit)
                 nminus++;
         }
-        printf ("    %c reverse twist = %.2fdB\n", digit, (float) nminus/10.0);
+        printf("    %c reverse twist = %.2fdB\n", digit, (float) nminus/10.0);
         if (nminus < 70)
         {
-            printf ("    Failed\n");
-            exit (2);
+            printf("    Failed\n");
+            exit(2);
         }
     }
-    printf ("    Passed\n");
+    printf("    Passed\n");
 
     /* Test 5: Dynamic range
-       This test sends all possible digits, with gradually increasing 
+       This test sends all possible digits, with gradually increasing
        amplitude. We determine the span over which we achieve reliable
        detection. */
-       
-    printf ("Test 5: Dynamic range\n");
+
+    printf("Test 5: Dynamic range\n");
     for (nplus = nminus = -1000, i = -50;  i <= 3;  i++)
     {
         s = r2_mf_tone_codes;
@@ -458,19 +458,19 @@ static int test_a_tone_set(int fwd)
                 nminus = i;
         }
     }
-    printf ("    Dynamic range = %ddB to %ddB\n", nplus, nminus - 1);
+    printf("    Dynamic range = %ddB to %ddB\n", nplus, nminus - 1);
     if (nplus > -35  ||  nminus <= -5)
     {
         printf("    Failed\n");
         exit(2);
     }
-    printf ("    Passed\n");
+    printf("    Passed\n");
 
     /* Test 6: Guard time
-       This test sends all possible digits, with a gradually reducing 
+       This test sends all possible digits, with a gradually reducing
        duration. */
 
-    printf ("Test 6: Guard time\n");
+    printf("Test 6: Guard time\n");
     for (i = 30;  i < 62;  i++)
     {
         s = r2_mf_tone_codes;
@@ -493,19 +493,19 @@ static int test_a_tone_set(int fwd)
         if (j == 500)
             break;
     }
-    printf ("    Guard time = %dms\n", i);
+    printf("    Guard time = %dms\n", i);
     if (i > 61)
     {
         printf("    Failed\n");
         exit(2);
     }
-    printf ("    Passed\n");
+    printf("    Passed\n");
 
     /* Test 7: Acceptable signal to noise ratio
        We send all possible digits at -6dBm from clip, mixed with AWGN.
        We gradually reduce the noise until we get clean detection. */
 
-    printf ("Test 7: Acceptable signal to noise ratio\n");
+    printf("Test 7: Acceptable signal to noise ratio\n");
     my_mf_gen_init(0.0, -3, 0.0, -3, 68, fwd);
     for (i = -3;  i > -50;  i--)
     {
@@ -563,7 +563,7 @@ static int test_a_tone_set(int fwd)
     if (!callback_ok)
     {
         printf("    Failed\n");
-       exit (2);
+        exit(2);
     }
     printf("    Passed\n");
 
@@ -571,7 +571,7 @@ static int test_a_tone_set(int fwd)
        meaningless for R2 MF. However the decoder's tolerance of
        out of band noise is significant. */
     /* TODO: add a OOB tolerance test. */
-    
+
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
@@ -587,7 +587,7 @@ int main(int argc, char *argv[])
     printf("R2 backward tones\n");
     test_a_tone_set(FALSE);
     duration = time(NULL) - now;
-    printf ("Tests passed in %lds\n", duration);
+    printf("Tests passed in %lds\n", duration);
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
index 2a88f24637e3d38001644d60e95d80fc415b9d0f..2c2700fc4443f1e2dfe8b6a10d11e14fe7b46b8f 100644 (file)
@@ -183,7 +183,7 @@ int main(int argc, char *argv[])
         if ((len = rfc2198_sim_put(s, put_pkt, put_pkt_len, i, (double) i*0.001*PACKET_INTERVAL)) > 0)
             packets_really_put++;
         packets_put++;
-#if 0        
+#if 0
         if (i == 5)
             rfc2198_sim_queue_dump(s);
 #endif
index 419020cd1b9afdf9f2e5b30363e7b3109f35230d..793cff9dd9042f2d5c3c1a5dd824a0433343700a 100644 (file)
@@ -287,7 +287,7 @@ int main(int argc, char *argv[])
         ||
         saturated_mul16_32(32767, 32767) != 2147352578
         ||
-        saturated_mul16_32(-32768, -32768) != -2147483648)
+        saturated_mul16_32(-32768, -32768) != INT32_MAX)
     {
         printf("Test failed.\n");
         exit(2);
index f1b19bc946fa71b9034c0c068d8d2d4b2a36fad5..e3aca335bc2365abe238afca0a3be8ea1a7d0d89 100644 (file)
@@ -94,7 +94,7 @@ int main(int argc, char *argv[])
     when1 = span_schedule_time(&sched) + 500000;
     when2 = span_schedule_time(&sched) + 550000;
     //span_schedule_del(&sched, id);
-    
+
     for (i = 0;  i < 100000000;  i += 20000)
         span_schedule_update(&sched, 20000);
     when = span_schedule_time(&sched);
index 2aa30a98f1657cdc9f62c5fc482d9b8be28d2541..4288891e5788e9560c60d7b6ad74cc6198718375 100644 (file)
@@ -88,12 +88,12 @@ static int use_gui = FALSE;
 static void plot_frequency_response(void)
 {
     FILE *gnucmd;
-    
+
     if ((gnucmd = popen("gnuplot", "w")) == NULL)
     {
         exit(2);
     }
-    
+
     fprintf(gnucmd, "set autoscale\n");
     fprintf(gnucmd, "unset log\n");
     fprintf(gnucmd, "unset label\n");
@@ -175,7 +175,7 @@ static void tx_handler(void *user_data, int what, int level, int duration)
 #endif
         {0, 0}
     };
-    
+
     s = (sig_tone_tx_state_t *) user_data;
     tx_handler_callbacks++;
     //printf("What - %d, duration - %d\n", what, duration);
@@ -268,7 +268,7 @@ static void map_frequency_response(sig_tone_rx_state_t *s, template_t template[]
     double gain;
     int template_entry;
     FILE *file;
-    
+
     /* Things like noise don't highlight the frequency response of the high Q notch
        very well. We use a slowly swept frequency to check it. */
     printf("Frequency response test\n");
@@ -650,7 +650,7 @@ int main(int argc, char *argv[])
         sequence_tests(&tx_state, &rx_state, munge);
     }
     /*endfor*/
-    
+
     printf("Tests completed.\n");
     return 0;
 }
index 718960463bf11f1234dc061a3c08691297978b5f..d090d7cce022812c0a6a6884fa8eb6df73ae7e11 100644 (file)
@@ -58,7 +58,7 @@
 #define IN_FILE_NAME    "super_tone.wav"
 
 #define MITEL_DIR       "../test-data/mitel/"
-#define BELLCORE_DIR   "../test-data/bellcore/"
+#define BELLCORE_DIR    "../test-data/bellcore/"
 
 const char *bellcore_files[] =
 {
@@ -270,7 +270,7 @@ static void get_tone_set(super_tone_rx_descriptor_t *desc, const char *tone_file
     xmlValidCtxt valid;
 #endif
     xmlChar *x;
-    
+
     ns = NULL;
     xmlKeepBlanksDefault(0);
     xmlCleanupParser();
@@ -334,7 +334,7 @@ static void get_tone_set(super_tone_rx_descriptor_t *desc, const char *tone_file
 static void super_tone_rx_fill_descriptor(super_tone_rx_descriptor_t *desc)
 {
     int tone_id;
-    
+
     tone_id = super_tone_rx_add_tone(desc);
     super_tone_rx_add_element(desc, tone_id, 400, 0, 700, 0);
     tone_names[tone_id] = "XXX";
@@ -390,12 +390,12 @@ static int talk_off_tests(super_tone_rx_state_t *super)
                 x = super_tone_rx(super, amp + sample, frames - sample);
                 sample += x;
             }
-       }
+        }
         if (sf_close_telephony(inhandle))
-       {
-           printf("    Cannot close speech file '%s'\n", bellcore_files[j]);
+        {
+            printf("    Cannot close speech file '%s'\n", bellcore_files[j]);
             exit(2);
-       }
+        }
     }
     return 0;
 }
index ff465193f79ea43786773cf7b32b1fcf31b9e6f2..561b333c36ba5b2f8f1ad595f1e63b04357b5384 100644 (file)
@@ -212,7 +212,7 @@ static void get_tone_set(const char *tone_file, const char *set_id)
 #endif
     xmlChar *x;
 
-    ns = NULL;    
+    ns = NULL;
     xmlKeepBlanksDefault(0);
     xmlCleanupParser();
     doc = xmlParseFile(tone_file);
index c216a901c17c0fd67b6ea3185b850dbe259552b4..da32c80c9fefd43a97a118845de01d0f24188fd8 100644 (file)
@@ -70,9 +70,9 @@
 
 typedef enum
 {
-       MODEM_POLL_READ = (1 << 0),
-       MODEM_POLL_WRITE = (1 << 1),
-       MODEM_POLL_ERROR = (1 << 2)
+    MODEM_POLL_READ = (1 << 0),
+    MODEM_POLL_WRITE = (1 << 1),
+    MODEM_POLL_ERROR = (1 << 2)
 } modem_poll_t;
 
 g1050_state_t *path_a_to_b;
@@ -139,8 +139,8 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
 static int at_tx_handler(at_state_t *s, void *user_data, const uint8_t *buf, size_t len)
 {
 #if defined(WIN32)
-       DWORD res;
-       OVERLAPPED o;
+    DWORD res;
+    OVERLAPPED o;
 #else
     int res;
 #endif
@@ -155,16 +155,16 @@ printf("\n");
 
     modem = (modem_t *) user_data;
 #if defined(WIN32)
-       o.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
-       /* Initialize the rest of the OVERLAPPED structure to zero. */
-       o.Internal = 0;
-       o.InternalHigh = 0;
-       o.Offset = 0;
-       o.OffsetHigh = 0;
-       assert(o.hEvent);
-       if (!WriteFile(modem->master, buf, (DWORD) len, &res, &o))
-               GetOverlappedResult(modem->master, &o, &res, TRUE);
-       CloseHandle(o.hEvent);
+    o.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+    /* Initialize the rest of the OVERLAPPED structure to zero. */
+    o.Internal = 0;
+    o.InternalHigh = 0;
+    o.Offset = 0;
+    o.OffsetHigh = 0;
+    assert(o.hEvent);
+    if (!WriteFile(modem->master, buf, (DWORD) len, &res, &o))
+        GetOverlappedResult(modem->master, &o, &res, TRUE);
+    CloseHandle(o.hEvent);
 #else
     res = write(modem->master, buf, len);
 #endif
@@ -172,7 +172,7 @@ printf("\n");
     {
         printf("Failed to write the whole buffer to the device. %d bytes of %d written: %s\n", res, (int) len, strerror(errno));
 
-               if (res == -1)
+        if (res == -1)
             res = 0;
 #if !defined(WIN32)
         if (tcflush(modem->master, TCOFLUSH))
@@ -300,7 +300,7 @@ static int modem_wait_sock(modem_t *modem, int ms, modem_poll_t flags)
     HANDLE arHandles[2];
 
     ret = MODEM_POLL_ERROR;
-       arHandles[0] = modem->threadAbort;
+    arHandles[0] = modem->threadAbort;
 
     o.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
     arHandles[1] = o.hEvent;
@@ -322,7 +322,7 @@ static int modem_wait_sock(modem_t *modem, int ms, modem_poll_t flags)
         }
         else
         {
-               /* IO is pending, wait for it to finish */
+            /* IO is pending, wait for it to finish */
             dwWait = WaitForMultipleObjects(2, arHandles, FALSE, INFINITE);
             if (dwWait == WAIT_OBJECT_0 + 1  &&  !modem->block_read)
                 ret = MODEM_POLL_READ;
@@ -341,37 +341,37 @@ static int modem_wait_sock(modem_t *modem, int ms, modem_poll_t flags)
 #else
 static int modem_wait_sock(int sock, uint32_t ms, modem_poll_t flags)
 {
-       struct pollfd pfds[2] = {{0}};
-       int s;
+    struct pollfd pfds[2] = {{0}};
+    int s;
     int ret;
 
-       pfds[0].fd = sock;
+    pfds[0].fd = sock;
 
-       if ((flags & MODEM_POLL_READ))
-               pfds[0].events |= POLLIN;
-       if ((flags & MODEM_POLL_WRITE))
-               pfds[0].events |= POLLOUT;
-       if ((flags & MODEM_POLL_ERROR))
-               pfds[0].events |= POLLERR;
+    if ((flags & MODEM_POLL_READ))
+        pfds[0].events |= POLLIN;
+    if ((flags & MODEM_POLL_WRITE))
+        pfds[0].events |= POLLOUT;
+    if ((flags & MODEM_POLL_ERROR))
+        pfds[0].events |= POLLERR;
 
-       s = poll(pfds, (modem->block_read)  ?  0  :  1, ms);
+    s = poll(pfds, (modem->block_read)  ?  0  :  1, ms);
 
     ret = 0;
-       if (s < 0)
+    if (s < 0)
     {
-               ret = s;
-       }
+        ret = s;
+    }
     else if (s > 0)
     {
-               if ((pfds[0].revents & POLLIN))
-                       ret |= MODEM_POLL_READ;
-               if ((pfds[0].revents & POLLOUT))
-                       ret |= MODEM_POLL_WRITE;
-               if ((pfds[0].revents & POLLERR))
-                       ret |= MODEM_POLL_ERROR;
-       }
+        if ((pfds[0].revents & POLLIN))
+            ret |= MODEM_POLL_READ;
+        if ((pfds[0].revents & POLLOUT))
+            ret |= MODEM_POLL_WRITE;
+        if ((pfds[0].revents & POLLERR))
+            ret |= MODEM_POLL_ERROR;
+    }
 
-       return ret;
+    return ret;
 
 }
 /*- End of function --------------------------------------------------------*/
@@ -407,8 +407,8 @@ static int t30_tests(int t38_mode, int use_ecm, int use_gui, int log_audio, int
     SNDFILE *in_handle;
     at_state_t *at_state;
 #if defined(WIN32)
-       DWORD read_bytes;
-       OVERLAPPED o;
+    DWORD read_bytes;
+    OVERLAPPED o;
 #endif
 
     /* Test the T.31 modem against the full FAX machine in spandsp */
@@ -606,18 +606,18 @@ printf("ZZZ\n");
         if ((ret & MODEM_POLL_READ))
         {
 #if defined(WIN32)
-                       o.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
-
-                       /* Initialize the rest of the OVERLAPPED structure to zero. */
-                       o.Internal = 0;
-                       o.InternalHigh = 0;
-                       o.Offset = 0;
-                       o.OffsetHigh = 0;
-                       assert(o.hEvent);
-                       if (!ReadFile(modem->master, buf, avail, &read_bytes, &o))
-                               GetOverlappedResult(modem->master, &o, &read_bytes, TRUE);
-                       CloseHandle (o.hEvent);
-                       if ((len = read_bytes))
+            o.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+
+            /* Initialize the rest of the OVERLAPPED structure to zero. */
+            o.Internal = 0;
+            o.InternalHigh = 0;
+            o.Offset = 0;
+            o.OffsetHigh = 0;
+            assert(o.hEvent);
+            if (!ReadFile(modem->master, buf, avail, &read_bytes, &o))
+                GetOverlappedResult(modem->master, &o, &read_bytes, TRUE);
+            CloseHandle (o.hEvent);
+            if ((len = read_bytes))
 #else
             if ((len = read(modem[0].master, buf, 1024)))
 #endif
index f0a27f38f7197458eb1bf61358a5af9915b7b96c..b7047d2ad6b93171981ca5a9e9536817574d54eb 100644 (file)
@@ -219,7 +219,7 @@ static int test_cycle(const char *test_id,
        down the image, will only succeed if a new chunk is started afterwards. */
     if (comment)
         t85_encode_comment(t85_enc, comment, strlen((const char *) comment) + 1);
-    
+
     testbuf_len = 0;
     max_len = 100;
     while ((len = t85_encode_get(t85_enc, &testbuf[testbuf_len], max_len)) > 0)
@@ -321,7 +321,7 @@ static int test_cycle(const char *test_id,
     free(decoded_image);
     t85_decode_release(t85_dec);
     printf("Test passed\n");
-    
+
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
index d5e01fb109679ecf7bfdbed864b18f0c7b3457fa..54b7c4e8284b1209a2176aed15c471e4593fb10d 100644 (file)
@@ -79,7 +79,7 @@ int main(int argc, char *argv[])
             break;
         sf_writef_short(outhandle, amp, len);
     }
-    
+
     /* Try a different tone pair */
     tone_gen_descriptor_init(&tone_desc,
                              350,
@@ -211,7 +211,7 @@ int main(int argc, char *argv[])
             break;
         sf_writef_short(outhandle, amp, len);
     }
-    
+
     /* Try an AM modulated tone at maximum modulation level (100%) */
     tone_gen_descriptor_init(&tone_desc,
                              425,
@@ -233,7 +233,7 @@ int main(int argc, char *argv[])
             break;
         sf_writef_short(outhandle, amp, len);
     }
-    
+
     if (sf_close_telephony(outhandle))
     {
         fprintf(stderr, "    Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
index 96071da55d6554c3b071bf39f3d094fd0ac174f5..96f2c251627a01f949da5a0c5b70f8fb60787c79 100644 (file)
@@ -7,7 +7,7 @@
  *
  * Written by Steve Underwood <steveu@coppice.org>
  *
- * Copyright (C) 2005 Steve Underwood
+ * Copyright (C) 2005, 2009, 2012 Steve Underwood
  *
  * All rights reserved.
  *
@@ -381,6 +381,8 @@ int udptl_build_packet(udptl_state_t *s, uint8_t buf[], const uint8_t msg[], int
     int len;
     int limit;
     int high_tide;
+    int len_before_entries;
+    int previous_len;
 
     /* UDPTL cannot cope with zero length messages, and our buffering for redundancy limits their
        maximum length. */
@@ -425,16 +427,28 @@ int udptl_build_packet(udptl_state_t *s, uint8_t buf[], const uint8_t msg[], int
             entries = s->error_correction_entries;
         else
             entries = s->tx_seq_no;
+        len_before_entries = len;
         /* The number of entries will always be small, so it is pointless allowing
            for the fragmented case here. */
         if (encode_length(buf, &len, entries) < 0)
             return -1;
         /* Encode the elements */
-        for (i = 0;  i < entries;  i++)
+        for (m = 0;  m < entries;  m++)
         {
-            j = (entry - i - 1) & UDPTL_BUF_MASK;
+            previous_len = len;
+            j = (entry - m - 1) & UDPTL_BUF_MASK;
             if (encode_open_type(buf, &len, s->tx[j].buf, s->tx[j].buf_len) < 0)
                 return -1;
+
+            /* If we have exceeded the far end's max datagram size, don't include this last chunk,
+               and stop trying to add more. */
+            if (len > s->far_max_datagram_size)
+            {
+                len = previous_len;
+                if (encode_length(buf, &len_before_entries, m) < 0)
+                    return -1;
+                break;
+            }
         }
         break;
     case UDPTL_ERROR_CORRECTION_FEC:
@@ -455,9 +469,11 @@ int udptl_build_packet(udptl_state_t *s, uint8_t buf[], const uint8_t msg[], int
         buf[len++] = span;
         /* The number of entries is defined as a length, but will only ever be a small
            value. Treat it as such. */
+        len_before_entries = len;
         buf[len++] = entries;
         for (m = 0;  m < entries;  m++)
         {
+            previous_len = len;
             /* Make an XOR'ed entry the maximum length */
             limit = (entry + m) & UDPTL_BUF_MASK;
             high_tide = 0;
@@ -479,6 +495,15 @@ int udptl_build_packet(udptl_state_t *s, uint8_t buf[], const uint8_t msg[], int
             }
             if (encode_open_type(buf, &len, fec, high_tide) < 0)
                 return -1;
+
+            /* If we have exceeded the far end's max datagram size, don't include this last chunk,
+               and stop trying to add more. */
+            if (len > s->far_max_datagram_size)
+            {
+                len = previous_len;
+                buf[len_before_entries] = (uint8_t) m;
+                break;
+            }
         }
         break;
     }
index f084cdeecbf46c732c21526cee73f8a9ef4cc676..23efd7ae3c61011ea6bee4d963e39809c14e3585 100644 (file)
 
 int log_audio = FALSE;
 SNDFILE *outhandle = NULL;
+char result[1024];
+int unexpected_echo = FALSE;
 
 char *decode_test_file = NULL;
 
 int good_message_received;
 
+both_ways_line_model_state_t *model;
+int rbs_pattern = 0;
+float noise_level = -70.0f;
+int line_model_no = 0;
+int channel_codec = MUNGE_CODEC_NONE;
+v18_state_t *v18[2];
+
 const char *qbf_tx = "The quick Brown Fox Jumps Over The Lazy dog 0123456789!@#$%^&*()'";
 const char *qbf_rx = "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG 0123456789!X$$/'+.()'";
 const char *full_baudot_rx =
@@ -79,43 +88,61 @@ static void put_text_msg(void *user_data, const uint8_t *msg, int len)
 
 static void basic_tests(int mode)
 {
-    int16_t amp[SAMPLES_PER_CHUNK];
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
     int outframes;
-    int len;
+    int samples;
     int push;
     int i;
-    v18_state_t *v18_a;
-    v18_state_t *v18_b;
-    logging_state_t *logging;
+    int j;
 
     printf("Testing %s\n", v18_mode_to_str(mode));
-    v18_a = v18_init(NULL, TRUE, mode, put_text_msg, NULL);
-    logging = v18_get_logging_state(v18_a);
+    v18[0] = v18_init(NULL, TRUE, mode, put_text_msg, NULL);
+    logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
     span_log_set_tag(logging, "A");
-    v18_b = v18_init(NULL, FALSE, mode, put_text_msg, NULL);
-    logging = v18_get_logging_state(v18_b);
+    v18[1] = v18_init(NULL, FALSE, mode, put_text_msg, NULL);
+    logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
     span_log_set_tag(logging, "B");
 
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
     /* Fake an OK condition for the first message test */
     good_message_received = TRUE;
     push = 0;
-    if (v18_put(v18_a, qbf_tx, -1) != strlen(qbf_tx))
+    if (v18_put(v18[0], qbf_tx, -1) != strlen(qbf_tx))
     {
         printf("V.18 put failed\n");
         exit(2);
     }
-    for (i = 0;  i < 100000;  i++)
+
+    for (i = 0;  i < 10000;  i++)
     {
         if (push == 0)
         {
-            if ((len = v18_tx(v18_a, amp, SAMPLES_PER_CHUNK)) == 0)
+            if ((samples = v18_tx(v18[0], amp[0], SAMPLES_PER_CHUNK)) == 0)
                 push = 10;
         }
         else
         {
-            len = 0;
+            samples = 0;
             /* Push a little silence through, to flush things out */
             if (--push == 0)
             {
@@ -125,36 +152,71 @@ static void basic_tests(int mode)
                     exit(2);
                 }
                 good_message_received = FALSE;
-                if (v18_put(v18_a, qbf_tx, -1) != strlen(qbf_tx))
+                if (v18_put(v18[0], qbf_tx, -1) != strlen(qbf_tx))
                 {
                     printf("V.18 put failed\n");
                     exit(2);
                 }
             }
         }
-        if (len < SAMPLES_PER_CHUNK)
+        if (samples < SAMPLES_PER_CHUNK)
+        {
+            vec_zeroi16(&amp[0][samples], SAMPLES_PER_CHUNK - samples);
+            samples = SAMPLES_PER_CHUNK;
+        }
+        if ((samples = v18_tx(v18[1], amp[1], SAMPLES_PER_CHUNK)) == 0)
+            push = 10;
+        if (samples < SAMPLES_PER_CHUNK)
         {
-            memset(&amp[len], 0, sizeof(int16_t)*(SAMPLES_PER_CHUNK - len));
-            len = SAMPLES_PER_CHUNK;
+            vec_zeroi16(&amp[1][samples], SAMPLES_PER_CHUNK - samples);
+            samples = SAMPLES_PER_CHUNK;
         }
         if (log_audio)
         {
-            outframes = sf_writef_short(outhandle, amp, len);
-            if (outframes != len)
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
             {
                 fprintf(stderr, "    Error writing audio file\n");
                 exit(2);
             }
         }
-        v18_rx(v18_b, amp, len);
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
     }
-    v18_free(v18_a);
-    v18_free(v18_b);
+    v18_free(v18[0]);
+    v18_free(v18[1]);
 }
 /*- End of function --------------------------------------------------------*/
 
 static int test_misc_01(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.1.1     No disconnection test
         Purpose:        To verify that the DCE does not initiate a disconnection.
@@ -165,6 +227,73 @@ static int test_misc_01(void)
                         TUT should continue to probe until the test is terminated.
         Comments:       This feature should also be verified by observation during the automoding tests.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -172,6 +301,17 @@ static int test_misc_01(void)
 
 static int test_misc_02(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.1.2     Automatic resumption of automoding
         Purpose:        To ensure that the DCE can be configured to automatically re-assume the automode
@@ -182,10 +322,77 @@ static int test_misc_02(void)
                         The tester will then transmit silence for 11 seconds followed by a 1300Hz tone for
                         5 seconds (i.e. V.23).
         Pass criteria:  1) Ten seconds after dropping the carrier the TUT should return to state Monitor 1.
-                        2) After 2.7±0.3 seconds the TUT should select V.23 mode and send a 390Hz tone.
+                        2) After 2.7+-0.3 seconds the TUT should select V.23 mode and send a 390Hz tone.
         Comments:       The TUT should indicate that carrier has been lost at some time after the 1650Hz
                         signal is lost.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -193,6 +400,17 @@ static int test_misc_02(void)
 
 static int test_misc_03(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.1.3     Retention of selected mode on loss of signal
         Purpose:        To ensure that the DCE stays in the selected transmission mode if it is not
@@ -207,6 +425,73 @@ static int test_misc_03(void)
         Comments:       The TUT should indicate that carrier has been lost at some time after the carrier
                         signal is removed and not disconnect.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -214,6 +499,17 @@ static int test_misc_03(void)
 
 static int test_misc_04(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.1.4     Detection of BUSY tone
         Purpose:        To ensure that the DCE provides the call progress indication "BUSY" in presence of
@@ -227,6 +523,73 @@ static int test_misc_04(void)
                         automatically hang up when busy tone is detected. PABX busy tones may differ in
                         frequency and cadence from national parameters.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -234,6 +597,17 @@ static int test_misc_04(void)
 
 static int test_misc_05(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.1.5     Detection of RINGING
         Purpose:        To ensure that the DCE provides the call progress indication "RINGING" in
@@ -244,6 +618,73 @@ static int test_misc_05(void)
         Pass criteria:  The RINGING condition should be visually indicated by the TUT.
         Comments:       This test should be repeated across a range of valid timings and ring voltages.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -251,6 +692,17 @@ static int test_misc_05(void)
 
 static int test_misc_06(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.1.6     "LOSS OF CARRIER" indication
         Purpose:        To ensure that the DCE provides the call progress indication "LOSS OF CARRIER"
@@ -264,6 +716,73 @@ static int test_misc_06(void)
                         mode. There may be other cases, e.g. where the V.18 DCE is used in a gateway,
                         when automatic disconnection is required.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -271,6 +790,17 @@ static int test_misc_06(void)
 
 static int test_misc_07(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.1.7     Call progress indication
         Purpose:        To ensure that the DCE provides the call progress indication "CONNECT(x)" upon
@@ -282,6 +812,73 @@ static int test_misc_07(void)
                         However, this may possibly not be indicated by the DTE.
         Comments:       The possible modes are: V.21, V.23, Baudot 45, Baudot 50, EDT, Bell 103, DTMF.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -289,6 +886,17 @@ static int test_misc_07(void)
 
 static int test_misc_08(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.1.8     Circuit 135 Test
         Purpose:        To ensure that the DCE implements circuit 135 or an equivalent way of indicating
@@ -301,15 +909,93 @@ static int test_misc_08(void)
         Comment:        The response times and signal level thresholds of Circuit 135 are not specified in
                         ITU-T V.18 or V.24 and therefore the pattern indicated may vary.
      */
-    printf("Test not yet implemented\n");
-    return 1;
-}
-/*- End of function --------------------------------------------------------*/
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
 
-static int test_misc_09(void)
-{
-    /*
-        III.5.4.1.9     Connection procedures
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
+    printf("Test not yet implemented\n");
+    return 1;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int test_misc_09(void)
+{
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
+    /*
+        III.5.4.1.9     Connection procedures
         Purpose:        To ensure that the TUT implements the call connect procedure described in
                         clause 6.
         Preamble:       N/A
@@ -317,6 +1003,73 @@ static int test_misc_09(void)
         Pass criteria:  TBD
         Comment:        TBD
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -324,6 +1077,17 @@ static int test_misc_09(void)
 
 static int test_org_01(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.2.1     CI and XCI signal coding and cadence
         Purpose:        To verify that TUT correctly emits the CI and XCI signals with the ON/OFF
@@ -342,6 +1106,73 @@ static int test_org_01(void)
                         8) The whole sequence should be repeated until the call is cleared.
                         9) When V.18 to V.18, the XCI must not force V.23 or Minitel mode.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -349,6 +1180,17 @@ static int test_org_01(void)
 
 static int test_org_02(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.2.2     ANS signal detection
         Purpose:        To verify that TUT correctly detects the ANS (2100Hz) signal during the
@@ -362,6 +1204,73 @@ static int test_org_02(void)
                         2) The TUT should reply with transmission of TXP as defined in 5.1.2.
                         3) Verify that TXP sequence has correct bit pattern.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -369,6 +1278,17 @@ static int test_org_02(void)
 
 static int test_org_03(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.2.3     End of ANS signal detection
         Purpose:        The TUT should stop sending TXP at the end of the current sequence when the ANS
@@ -379,6 +1299,73 @@ static int test_org_03(void)
         Pass criteria:  The TUT should stop sending TXP at the end of the current sequence when ANS
                         tone ceases.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -386,6 +1373,17 @@ static int test_org_03(void)
 
 static int test_org_04(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.2.4     ANS tone followed by TXP
         Purpose:        To check correct detection of V.18 modem.
@@ -400,6 +1398,73 @@ static int test_org_04(void)
                            with the V.18 operational requirements.
         Comments:       The TUT should indicate that V.18 mode has been selected.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -407,6 +1472,17 @@ static int test_org_04(void)
 
 static int test_org_05(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.2.5     ANS tone followed by 1650Hz
         Purpose:        To check correct detection of V.21 modem upper channel when preceded by answer
@@ -422,6 +1498,73 @@ static int test_org_05(void)
                         examination of TUT. If there is no visual indication, verify by use of ITU-T T.50 for
                         ITU-T V.21 as opposed to UTF-8 coded ISO 10646 character set for ITU-T V.18.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -429,6 +1572,17 @@ static int test_org_05(void)
 
 static int test_org_06(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.2.6     ANS tone followed by 1300Hz
         Purpose:        To check correct detection of V.23 modem upper channel when preceded by answer
@@ -443,6 +1597,73 @@ static int test_org_06(void)
                            by the TUT to comply with Annex E.
         Comments:       The TUT should indicate that V.23 mode has been selected.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -450,7 +1671,18 @@ static int test_org_06(void)
 
 static int test_org_07(void)
 {
-    /*
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
+    /*
         III.5.4.2.7     ANS tone followed by no tone
         Purpose:        To confirm that TUT does not lock up under this condition.
         Preamble:       Tests ORG-02 and ORG-03 should be successfully completed prior to this test.
@@ -464,6 +1696,73 @@ static int test_org_07(void)
                         literally. It may however, occur when connected to certain Swedish textphones if the
                         handset is lifted just after the start of an automatically answered incoming call.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -471,16 +1770,94 @@ static int test_org_07(void)
 
 static int test_org_08(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.2.8     Bell 103 (2225Hz signal) detection
         Purpose:        To verify that the TUT correctly detects the Bell 103 upper channel signal during
                         the 2-second interval between transmission of CI sequences.
         Preamble:       N/A
         Method:         The tester waits for a CI and then sends a 2225Hz signal for 5 seconds.
-        Pass criteria:  1) The TUT should respond with a 1270Hz tone in 0.5±0.1 seconds.
+        Pass criteria:  1) The TUT should respond with a 1270Hz tone in 0.5+-0.1 seconds.
                         2) Data should be transmitted and received at 300 bit/s to comply with Annex D.
         Comments:       The TUT should indicate that Bell 103 mode has been selected.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -488,16 +1865,94 @@ static int test_org_08(void)
 
 static int test_org_09(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.2.9     V.21 (1650Hz signal) detection
         Purpose:        To verify that the TUT correctly detects the V.21 upper channel signal during the
                         2-second interval between transmission of CI sequences.
         Preamble:       N/A
         Method:         The tester waits for a CI and then sends a 1650Hz signal for 5 seconds.
-        Pass criteria:  1) The TUT should respond with a 980Hz tone in 0.5±0.1 seconds.
+        Pass criteria:  1) The TUT should respond with a 980Hz tone in 0.5+-0.1 seconds.
                         2) Data should be transmitted and received at 300 bit/s to comply with Annex F.
         Comments:       The TUT should indicate that V.21 mode has been selected.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -505,17 +1960,95 @@ static int test_org_09(void)
 
 static int test_org_10(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.2.10    V.23 (1300Hz signal) detection
         Purpose:        To verify that the TUT correctly detects the V.23 upper channel signal during the
                         2-second interval between transmission of CI sequences.
         Preamble:       N/A
         Method:         The tester waits for a CI and then sends a 1300Hz signal for 5 seconds.
-        Pass criteria:  1) The TUT should respond with a 390Hz tone in 1.7±0.1 seconds.
+        Pass criteria:  1) The TUT should respond with a 390Hz tone in 1.7+-0.1 seconds.
                         2) Data should be transmitted and received at 75 bit/s and 1200 bit/s respectively
                            by the TUT to comply with Annex E.
         Comments:       The TUT should indicate that V.23 mode has been selected.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -523,6 +2056,17 @@ static int test_org_10(void)
 
 static int test_org_11(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.2.11    V.23 (390Hz signal) detection
         Purpose:        To confirm correct selection of V.23 reverse mode during sending of XCI.
@@ -537,6 +2081,73 @@ static int test_org_11(void)
         Comments:       The TUT should indicate that V.23 mode has been selected at least 3 seconds after
                         the start of the 390Hz tone.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -544,6 +2155,17 @@ static int test_org_11(void)
 
 static int test_org_12(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.2.12    5 bit mode (Baudot) detection tests
         Purpose:        To confirm detection of Baudot modulation at various bit rates that may be
@@ -563,6 +2185,73 @@ static int test_org_12(void)
                         automode answer state. The TUT may then select either 45.45 or 50 bit/s for the
                         transmission.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -570,6 +2259,17 @@ static int test_org_12(void)
 
 static int test_org_13(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.2.13    DTMF signal detection
         Purpose:        To verify whether the TUT correctly recognizes DTMF signals during the 2-second
@@ -583,6 +2283,73 @@ static int test_org_13(void)
                         TUT should comply with ITU-T Q.24 for the Danish Administration while
                         receiving for best possible performance.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -590,6 +2357,17 @@ static int test_org_13(void)
 
 static int test_org_14(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.2.14    EDT rate detection
         Purpose:        To confirm detection of EDT modems by detecting the transmission rate of received
@@ -605,40 +2383,263 @@ static int test_org_14(void)
                         the number lost should be minimal. The data bits and parity are specified in
                         Annex C.
      */
-    printf("Test not yet implemented\n");
-    return 1;
-}
-/*- End of function --------------------------------------------------------*/
-
-static int test_org_15(void)
-{
-    /*
-        III.5.4.2.15    Rate detection test
-        Purpose:        To verify the presence of 980/1180Hz at a different signalling rate than 110 bit/s
-                        returns the TUT modem to the "monitor A" state.
-        Preamble:       N/A
-        Method:         The tester transmits 980/1180Hz signals at 300 bit/s for 2 seconds.
-        Pass criteria:  The TUT should not select EDT or any other mode and should continue to transmit
-                        the CI signal.
-        Comments:       Echoes of the CI sequences may be detected at 300 bit/s.
-     */
-    printf("Test not yet implemented\n");
-    return 1;
-}
-/*- End of function --------------------------------------------------------*/
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
 
-static int test_org_16(void)
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
+    printf("Test not yet implemented\n");
+    return 1;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int test_org_15(void)
+{
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
+    /*
+        III.5.4.2.15    Rate detection test
+        Purpose:        To verify the presence of 980/1180Hz at a different signalling rate than 110 bit/s
+                        returns the TUT modem to the "monitor A" state.
+        Preamble:       N/A
+        Method:         The tester transmits 980/1180Hz signals at 300 bit/s for 2 seconds.
+        Pass criteria:  The TUT should not select EDT or any other mode and should continue to transmit
+                        the CI signal.
+        Comments:       Echoes of the CI sequences may be detected at 300 bit/s.
+     */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
+    printf("Test not yet implemented\n");
+    return 1;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int test_org_16(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.2.16    980Hz detection
         Purpose:        To confirm correct selection of V.21 reverse mode.
         Preamble:       N/A
         Method:         The tester sends 980Hz to TUT for 5 seconds.
-        Pass criteria:  1) TUT should respond with 1650Hz tone after 1.5±0.1 seconds after start of
+        Pass criteria:  1) TUT should respond with 1650Hz tone after 1.5+-0.1 seconds after start of
                            980Hz tone.
                         2) Data should be transmitted and received at 300 bit/s complying with Annex F.
         Comments:       The TUT should indicate that V.21 mode has been selected.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -646,6 +2647,17 @@ static int test_org_16(void)
 
 static int test_org_17(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.2.17    Loss of signal after 980Hz
         Purpose:        To confirm that TUT returns to the Monitor 1 state if 980Hz signal disappears.
@@ -654,6 +2666,73 @@ static int test_org_17(void)
         Pass criteria:  TUT should not respond to the 980Hz tone and resume sending CI signals after a
                         maximum of 2.4 seconds from the end of the 980Hz tone.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -661,16 +2740,94 @@ static int test_org_17(void)
 
 static int test_org_18(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.2.18    Tr timer
         Purpose:        To confirm that TUT returns to the Monitor 1 state if Timer Tr expires.
         Preamble:       N/A
         Method:         The tester sends 980Hz to TUT for 1.2 seconds followed by 1650Hz for 5 seconds
                         with no pause.
-        Pass criteria:  TUT should respond with 980Hz after 1.3±0.1 seconds of 1650Hz.
+        Pass criteria:  TUT should respond with 980Hz after 1.3+-0.1 seconds of 1650Hz.
         Comments:       This implies timer Tr has expired 2 seconds after the start of the 980Hz tone and
                         then 1650Hz has been detected for 0.5 seconds.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -678,15 +2835,93 @@ static int test_org_18(void)
 
 static int test_org_19(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.2.19    Bell 103 (1270Hz signal) detection
         Purpose:        To confirm correct selection of Bell 103 reverse mode.
         Preamble:       N/A
         Method:         The tester sends 1270Hz to TUT for 5 seconds.
-        Pass criteria:  1) TUT should respond with 2225Hz tone after 0.7±0.1 s.
+        Pass criteria:  1) TUT should respond with 2225Hz tone after 0.7+-0.1 s.
                         2) Data should be transmitted and received at 300 bit/s complying with Annex D.
         Comments:       The TUT should indicate that Bell 103 mode has been selected.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -694,6 +2929,17 @@ static int test_org_19(void)
 
 static int test_org_20(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.2.20    Immunity to network tones
         Purpose:        To ensure that the TUT does not interpret network tones as valid signals.
@@ -710,6 +2956,73 @@ static int test_org_20(void)
                         presence and cadence of the tones for instance by a flashing light. The TUT may
                         disconnect on reception of tones indicating a failed call attempt.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -717,6 +3030,17 @@ static int test_org_20(void)
 
 static int test_org_21(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.2.21    Immunity to non-textphone modems
         Purpose:        To ensure that the TUT does not interpret modem tones not supported by V.18 as
@@ -729,6 +3053,73 @@ static int test_org_21(void)
         Comments:       Some high speed modems may fall back to a compatibility mode, e.g. V.21 or V.23
                         that should be correctly detected by the TUT.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -736,6 +3127,17 @@ static int test_org_21(void)
 
 static int test_org_22(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.2.22    Immunity to fax tones
         Purpose:        To ensure that the TUT will not interpret a called fax machine as being a textphone.
@@ -747,6 +3149,73 @@ static int test_org_22(void)
         Comments:       Ideally the TUT should detect the presence of a fax machine and report it back to
                         the user.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -754,6 +3223,17 @@ static int test_org_22(void)
 
 static int test_org_23(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.2.23    Immunity to voice
         Purpose:        To ensure that the TUT does not misinterpret speech as a valid textphone signal.
@@ -765,6 +3245,73 @@ static int test_org_23(void)
         Comments:       Ideally the TUT should report the presence of speech back to the user, e.g. via
                         circuit 135.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -772,6 +3319,17 @@ static int test_org_23(void)
 
 static int test_org_24(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.2.24    ANSam signal detection
         Purpose:        To verify that TUT correctly detects the ANSam (2100Hz modulated) signal during
@@ -785,6 +3343,73 @@ static int test_org_24(void)
                         2) The TUT should reply with transmission of CM as defined in 5.2.13.
                         3) Verify that CM sequence has correct bit pattern.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -792,6 +3417,17 @@ static int test_org_24(void)
 
 static int test_org_25(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.2.25    V.8 calling procedure
         Purpose:        To verify that TUT correctly performs a V.8 call negotiation.
@@ -800,6 +3436,73 @@ static int test_org_25(void)
         Method:         The Test System waits for the TUT to start transmitting V.21 carrier (1).
         Pass criteria:  The TUT should connect by sending V.21 carrier (1).
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -807,6 +3510,17 @@ static int test_org_25(void)
 
 static int test_ans_01(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.1     Ta timer
         Purpose:        To ensure that on connecting the call, the DCE starts timer Ta (3 seconds) and on
@@ -816,6 +3530,73 @@ static int test_ans_01(void)
                         answers the call. It will then monitor for any signal.
         Pass criteria:  The TUT should start probing 3 seconds after answering the call.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -823,6 +3604,17 @@ static int test_ans_01(void)
 
 static int test_ans_02(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.2     CI signal detection
         Purpose:        To confirm the correct detection and response to the V.18 CI signal.
@@ -830,10 +3622,77 @@ static int test_ans_02(void)
         Method:         The tester will transmit 2 sequences of 4 CI patterns separated by 2 seconds. It will
                         monitor for ANS and measure duration.
         Pass criteria:  1) The TUT should respond after either the first or second CI with ANSam tone.
-                        2) ANSam tone should remain for 3 seconds Â±0.5 s followed by silence.
+                        2) ANSam tone should remain for 3 seconds +-0.5 s followed by silence.
         Comments:       The ANSam tone is a modulated 2100Hz tone. It may have phase reversals. The
                         XCI signal is tested in a separate test.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -841,6 +3700,17 @@ static int test_ans_02(void)
 
 static int test_ans_03(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.3     Early termination of ANSam tone
         Purpose:        To confirm that the TUT will respond correctly to TXP signals, i.e. by stopping
@@ -849,13 +3719,80 @@ static int test_ans_03(void)
         Method:         The tester will transmit 2 sequences of 4 CI patterns separated by 2 seconds. On
                         reception of the ANSam tone the tester will wait 0.5 seconds and then begin
                         transmitting the TXP signal in V.21 (1) mode.
-        Pass criteria:  1) On reception of the TXP signal, the TUT should remain silent for 75±5 ms.
+        Pass criteria:  1) On reception of the TXP signal, the TUT should remain silent for 75+-5 ms.
                         2) The TUT should then transmit 3 TXP sequences in V.21(2) mode.
                         3) The 3 TXPs should be followed by continuous 1650Hz.
                         4) Correct transmission and reception of T.140 data should be verified after the
                            V.18 mode connection is completed.
         Comments:       The TUT should indicate V.18 mode.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -863,6 +3800,17 @@ static int test_ans_03(void)
 
 static int test_ans_04(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.4     Tt timer
         Purpose:        To ensure that after detection of ANSam the TUT will return to Monitor A after
@@ -872,6 +3820,73 @@ static int test_ans_04(void)
         Pass criteria:  The TUT should start probing 3 seconds after ANSam disappears.
         Comments:       It is assumed that timer Ta is restarted on return to Monitor A.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -879,6 +3894,17 @@ static int test_ans_04(void)
 
 static int test_ans_05(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.5     ANS tone followed by 980Hz
         Purpose:        To check correct detection of V.21 modem lower channel when preceded by answer
@@ -886,9 +3912,76 @@ static int test_ans_05(void)
         Preamble:       N/A
         Method:         Tester transmits ANS for 2.5 seconds followed by 75 ms of no tone then transmits
                         980Hz and starts a 1 s timer.
-        Pass criteria:  TUT should respond with 1650Hz within 400±100 ms of start of 980Hz.
+        Pass criteria:  TUT should respond with 1650Hz within 400+-100 ms of start of 980Hz.
         Comments:       The TUT should indicate that V.21 mode has been selected.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -896,6 +3989,17 @@ static int test_ans_05(void)
 
 static int test_ans_06(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.6     ANS tone followed by 1300Hz
         Purpose:        To check correct detection of V.23 modem upper channel when preceded by answer
@@ -906,6 +4010,73 @@ static int test_ans_06(void)
         Pass criteria:  TUT should respond with 390Hz after 1.7(+0.2-0.0) seconds of start of 1300Hz.
         Comments:       The TUT should indicate that V.23 mode has been selected.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -913,6 +4084,17 @@ static int test_ans_06(void)
 
 static int test_ans_07(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.7     ANS tone followed by 1650Hz
         Purpose:        To check correct detection of V.21 modem upper channel when preceded by answer
@@ -920,9 +4102,76 @@ static int test_ans_07(void)
         Preamble:       N/A
         Method:         Tester transmits ANS for 2.5 seconds followed by 75 ms of no tone then transmits
                         1650Hz and starts a 1-second timer.
-        Pass criteria:  TUT should respond with 980Hz within 400±100 ms of start of 1650Hz.
+        Pass criteria:  TUT should respond with 980Hz within 400+-100 ms of start of 1650Hz.
         Comments:       The TUT should indicate that V.21 mode has been selected.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -930,6 +4179,17 @@ static int test_ans_07(void)
 
 static int test_ans_08(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.8     980Hz followed by 1650Hz
         Purpose:        To ensure the correct selection of V.21 modem channel when certain types of
@@ -942,6 +4202,73 @@ static int test_ans_08(void)
         Comments:       The TUT should indicate a V.21 connection. The time for which each frequency is
                         transmitted is random and varies between 0.64 and 2.56 seconds.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -949,6 +4276,17 @@ static int test_ans_08(void)
 
 static int test_ans_09(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.9     980Hz calling tone detection
         Purpose:        To confirm correct detection of 980Hz calling tones as defined in V.25.
@@ -960,6 +4298,73 @@ static int test_ans_09(void)
                            700 ms followed by 1 second of silence.
         Comments:       The probe sent by the TUT will depend on the country setting.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -967,15 +4372,93 @@ static int test_ans_09(void)
 
 static int test_ans_10(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.10    V.21 detection by timer
         Purpose:        To confirm correct selection of V.21 calling modem when the received signal is not
                         modulated, i.e. there is no 1180Hz.
         Preamble:       N/A
         Method:         The tester sends 980Hz to TUT for 2 seconds.
-        Pass criteria:  The TUT should respond with a 1650Hz tone in 1.5±0.1 seconds.
+        Pass criteria:  The TUT should respond with a 1650Hz tone in 1.5+-0.1 seconds.
         Comments:       The TUT should indicate that V.21 mode has been selected.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -983,6 +4466,17 @@ static int test_ans_10(void)
 
 static int test_ans_11(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.11    EDT detection by rate
         Purpose:        To confirm detection of EDT modems by detecting the transmission rate of received
@@ -996,6 +4490,73 @@ static int test_ans_11(void)
                         be lost during the detection process. However, the number lost should be minimal.
                         The data bits and parity are specified in Annex C.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -1003,6 +4564,17 @@ static int test_ans_11(void)
 
 static int test_ans_12(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.12    V.21 Detection by rate
         Purpose:        To confirm detection of V.21 modem low channel by detecting the transmission rate
@@ -1017,6 +4589,73 @@ static int test_ans_12(void)
                         (1650Hz) probe. However, it is catered for in V.18. It is more likely that this is
                         where CI or TXP characters would be detected (see test ANS-02).
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -1024,6 +4663,17 @@ static int test_ans_12(void)
 
 static int test_ans_13(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.13    Tr timer
         Purpose:        To ensure that the TUT returns to the Monitor A state on expiry of timer Tr
@@ -1031,12 +4681,79 @@ static int test_ans_13(void)
         Preamble:       N/A
         Method:         The tester will transmit 980Hz for 200 ms followed by alternating 980Hz/1180Hz
                         at 110 bit/s for 100 ms followed by 980Hz for 1 second.
-        Pass criteria:  The TUT should begin probing 4±0.5 seconds after the 980Hz signal is removed.
+        Pass criteria:  The TUT should begin probing 4+-0.5 seconds after the 980Hz signal is removed.
         Comments:       It is not possible to be precise on timings for this test since the definition of a
                         "modulated signal" as in 5.2.4.4 is not specified. Therefore it is not known exactly
                         when timer Tr will start. It is assumed that timer Ta is restarted on re-entering the
                         Monitor A state.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -1044,16 +4761,94 @@ static int test_ans_13(void)
 
 static int test_ans_14(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.14    Te timer
         Purpose:        To ensure that the TUT returns to the Monitor A on expiry of timer Te
                         (2.7 seconds). Timer Te is started when a 980Hz signal is detected.
         Preamble:       N/A
         Method:         The tester will transmit 980Hz for 200 ms followed silence for 7 s.
-        Pass criteria:  The TUT should begin probing 5.5±0.5 seconds after the 980Hz signal is removed.
+        Pass criteria:  The TUT should begin probing 5.5+-0.5 seconds after the 980Hz signal is removed.
         Comments:       It is assumed that timer Ta (3 seconds) is restarted on re-entering the Monitor A
                         state.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -1061,6 +4856,17 @@ static int test_ans_14(void)
 
 static int test_ans_15(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.15 5  Bit mode (Baudot) detection tests
         Purpose:        To confirm detection of Baudot modulation at various bit rates that may be
@@ -1081,6 +4887,73 @@ static int test_ans_15(void)
                         automode answer state. The TUT may then select either 45.45 or 50 bit/s for the
                         transmission.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -1088,6 +4961,17 @@ static int test_ans_15(void)
 
 static int test_ans_16(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.16    DTMF signal detection
         Purpose:        To verify whether the TUT correctly recognizes DTMF signals.
@@ -1099,6 +4983,73 @@ static int test_ans_16(void)
         Comments:       The TUT should indicate that it has selected DTMF mode. The DTMF capabilities
                         of the TUT should comply with ITU-T Q.24 for the Danish Administration.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -1106,14 +5057,92 @@ static int test_ans_16(void)
 
 static int test_ans_17(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.17    Bell 103 (1270Hz signal) detection
         Purpose:        To ensure correct detection and selection of Bell 103 modems.
         Preamble:       N/A
         Method:         The tester sends 1270Hz to TUT for 5 seconds.
-        Pass criteria:  TUT should respond with 2225Hz tone after 0.7±0.1 s.
+        Pass criteria:  TUT should respond with 2225Hz tone after 0.7+-0.1 s.
         Comments:       The TUT should indicate that Bell 103 mode has been selected.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -1121,15 +5150,93 @@ static int test_ans_17(void)
 
 static int test_ans_18(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.18    Bell 103 (2225Hz signal) detection
         Purpose:        To ensure correct detection and selection of Bell 103 modems in reverse mode.
         Preamble:       N/A
         Method:         The tester sends 2225Hz to TUT for 5 seconds.
-        Pass criteria:  The TUT should respond with 1270Hz after 1±0.2 seconds.
+        Pass criteria:  The TUT should respond with 1270Hz after 1+-0.2 seconds.
         Comments:       The TUT should indicate that Bell 103 mode has been selected. Bell 103 modems
                         use 2225Hz as both answer tone and higher frequency of the upper channel.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -1137,14 +5244,92 @@ static int test_ans_18(void)
 
 static int test_ans_19(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.19    V.21 Reverse mode (1650Hz) detection
         Purpose:        To ensure correct detection and selection of V.21 reverse mode.
         Preamble:       N/A
         Method:         The tester sends 1650Hz to TUT for 5 seconds.
-        Pass criteria:  The TUT should respond with 980Hz after 0.4±0.2 seconds.
+        Pass criteria:  The TUT should respond with 980Hz after 0.4+-0.2 seconds.
         Comments:       The TUT should indicate that V.21 mode has been selected.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -1152,6 +5337,17 @@ static int test_ans_19(void)
 
 static int test_ans_20(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.20    1300Hz calling tone discrimination
         Purpose:        To confirm correct detection of 1300Hz calling tones as defined in ITU-T V.25.
@@ -1163,6 +5359,73 @@ static int test_ans_20(void)
                            700 ms followed by 1 second of silence.
         Comments:       The probe sent by the TUT will depend on the country setting.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -1170,14 +5433,92 @@ static int test_ans_20(void)
 
 static int test_ans_21(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.21    V.23 Reverse mode (1300Hz) detection
         Purpose:        To ensure correct detection and selection of V.23 reverse mode.
         Preamble:       N/A
         Method:         The tester sends 1300Hz only, with no XCI signals, to TUT for 5 seconds.
-                        Pass criteria: The TUT should respond with 390Hz after 1.7±0.1 seconds.
+                        Pass criteria: The TUT should respond with 390Hz after 1.7+-0.1 seconds.
         Comments:       The TUT should indicate that V.23 mode has been selected.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -1185,6 +5526,17 @@ static int test_ans_21(void)
 
 static int test_ans_22(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.22    1300Hz with XCI test
         Purpose:        To ensure correct detection of the XCI signal and selection of V.18 mode.
@@ -1193,6 +5545,73 @@ static int test_ans_22(void)
                         silent for 500 ms then transmit the TXP signal in V.21 (1) mode.
         Pass criteria:  The TUT should respond with TXP using V.21 (2) and select V.18 mode.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -1200,6 +5619,17 @@ static int test_ans_22(void)
 
 static int test_ans_23(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.23    Stimulate mode country settings
         Purpose:        To ensure that the TUT steps through the probes in the specified order for the
@@ -1211,6 +5641,73 @@ static int test_ans_23(void)
         Pass criteria:  The TUT should use the orders described in Appendix I.
         Comments:       The order of the probes is not mandatory.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -1218,6 +5715,17 @@ static int test_ans_23(void)
 
 static int test_ans_24(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.24    Stimulate carrierless mode probe message
         Purpose:        To ensure that the TUT sends the correct probe message for each of the carrierless
@@ -1229,6 +5737,73 @@ static int test_ans_24(void)
                         modes followed by a pause of Tm (default 3) seconds.
         Comments:       The carrierless modes are those described in Annexes A, B and C.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -1236,6 +5811,17 @@ static int test_ans_24(void)
 
 static int test_ans_25(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.25    Interrupted carrierless mode probe
         Purpose:        To ensure that the TUT continues probing from the point of interruption a maximum
@@ -1247,6 +5833,73 @@ static int test_ans_25(void)
         Pass criteria:  The TUT should transmit silence on detecting the 1270Hz tone and then continue
                         probing starting with the V.23 probe 20 seconds after the end of the 1270Hz signal.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -1254,6 +5907,17 @@ static int test_ans_25(void)
 
 static int test_ans_26(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.26    Stimulate carrier mode probe time
         Purpose:        To ensure that the TUT sends each carrier mode for time Tc (default 6 seconds)
@@ -1262,9 +5926,76 @@ static int test_ans_26(void)
         Method:         The tester will call the TUT, wait for Ta to expire and then monitor the probes sent
                         by the TUT.
         Pass criteria:  The TUT should send the ANS tone (2100Hz) for 1 second followed by silence for
-                        75±5 ms and then the 1650Hz, 1300Hz and 2225Hz probes for time Tc.
+                        75+-5 ms and then the 1650Hz, 1300Hz and 2225Hz probes for time Tc.
         Comments:       The carrier modes are those described in Annexes D, E, and F.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -1272,6 +6003,17 @@ static int test_ans_26(void)
 
 static int test_ans_27(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.27    V.23 mode (390Hz) detection
         Purpose:        To confirm correct selection of V.23 mode.
@@ -1287,6 +6029,73 @@ static int test_ans_27(void)
                         390Hz. When the 1300Hz probe is not being transmitted, a 390Hz tone may be
                         interpreted as a 400Hz network tone.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -1294,6 +6103,17 @@ static int test_ans_27(void)
 
 static int test_ans_28(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.28    Interrupted carrier mode probe
         Purpose:        To ensure that the TUT continues probing from the point of interruption a maximum
@@ -1307,6 +6127,73 @@ static int test_ans_28(void)
         Comments:       It is most likely that the TUT will return to probing time Ta (3 seconds) after the
                         1270Hz tone ceases. This condition needs further clarification.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -1314,6 +6201,17 @@ static int test_ans_28(void)
 
 static int test_ans_29(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.29    Stimulate mode response during probe
         Purpose:        To ensure that the TUT is able to detect an incoming signal while transmitting a
@@ -1326,6 +6224,73 @@ static int test_ans_29(void)
         Comments:       The TUT may not respond to any signals while a carrierless mode probe is being
                         sent since these modes are half duplex.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -1333,6 +6298,17 @@ static int test_ans_29(void)
 
 static int test_ans_30(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.30    Immunity to network tones
         Purpose:        To ensure that the TUT does not interpret network tones as valid signals.
@@ -1347,6 +6323,73 @@ static int test_ans_30(void)
                         tones may be ignored. Some devices may only provide a visual indication of the
                         presence and cadence of the tones for instance by a flashing light.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -1354,6 +6397,17 @@ static int test_ans_30(void)
 
 static int test_ans_31(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.31    Immunity to fax calling tones
         Purpose:        To determine whether the TUT can discriminate fax calling tones.
@@ -1365,6 +6419,73 @@ static int test_ans_31(void)
         Comments:       This is an optional test as detection of the fax calling tone is not required by
                         ITU-T V.18.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -1372,6 +6493,17 @@ static int test_ans_31(void)
 
 static int test_ans_32(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.32    Immunity to voice
         Purpose:        To ensure that the TUT does not misinterpret speech as a valid textphone signal.
@@ -1383,6 +6515,73 @@ static int test_ans_32(void)
         Comments:       Ideally the TUT should report the presence of speech back to the user. This is an
                         optional test.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -1390,6 +6589,17 @@ static int test_ans_32(void)
 
 static int test_ans_33(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.3.33    CM detection and V.8 answering
         Purpose:        To confirm that the TUT will respond correctly to CM signals and connect
@@ -1406,6 +6616,73 @@ static int test_ans_33(void)
                            V.18 mode connection is completed.
         Comments:       The TUT should indicate V.18 mode.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -1420,6 +6697,17 @@ static int test_mon_01(void)
 
 static int test_mon_21(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.4.1     Automode monitor Ta timer test
         Purpose:        To ensure that on entering monitor mode, timer Ta (3 seconds) is not active and that
@@ -1429,6 +6717,73 @@ static int test_mon_21(void)
                         for 1 minute.
         Pass criteria:  The TUT should not start probing.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -1436,6 +6791,17 @@ static int test_mon_21(void)
 
 static int test_mon_22(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.4.2     Automode monitor 1300Hz calling tone discrimination
         Purpose:        To confirm correct detection and reporting of 1300Hz calling tones as defined in
@@ -1449,6 +6815,73 @@ static int test_mon_22(void)
         Comments:       In automode answer, the 1300Hz calling causes the DCE to start probing. In
                         monitor mode it should only report detection to the DTE.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -1456,6 +6889,17 @@ static int test_mon_22(void)
 
 static int test_mon_23(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.4.3     Automode monitor 980Hz calling tone discrimination
         Purpose:        To confirm correct detection and reporting of 980Hz calling tones as defined in
@@ -1469,13 +6913,101 @@ static int test_mon_23(void)
         Comments:       In automode answer, the 980Hz calling causes the DCE to start probing. In monitor
                         mode it should only report detection to the DTE.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
 /*- End of function --------------------------------------------------------*/
 
+static void x_01_put_text_msg(void *user_data, const uint8_t *msg, int len)
+{
+printf("1-1 %d '%s'\n", len, msg);
+    if (user_data == NULL)
+        strcat(result, (const char *) msg);
+    else
+        v18_put(v18[1], "abcdefghij", 10);
+}
+/*- End of function --------------------------------------------------------*/
+
 static int test_x_01(void)
 {
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+    const char *ref;
+
     /*
         III.5.4.5.1     Baudot carrier timing and receiver disabling
         Purpose:        To verify that the TUT sends unmodulated carrier for 150 ms before a new character
@@ -1490,13 +7022,96 @@ static int test_x_01(void)
                         3) The tester will confirm that 1 start bit and at least 1.5 stop bits are used.
         Comments:       The carrier should be maintained during the 300 ms after a character.
      */
-    printf("Test not yet implemented\n");
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_5BIT_45, x_01_put_text_msg, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_5BIT_45, x_01_put_text_msg, (void *) (intptr_t) 1);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    v18_put(v18[0], "z", 1);
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
+    ref = "cdefghij";
+    printf("Result:\n%s\n", result);
+    printf("Reference result:\n%s\n", ref);
+    if (unexpected_echo  ||  strcmp(result, ref) != 0)
+        return -1;
     return 1;
 }
 /*- End of function --------------------------------------------------------*/
 
 static int test_x_02(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.5.2     Baudot bit rate confirmation
         Purpose:        To verify that the TUT uses the correct bit rates in the Baudot mode.
@@ -1506,6 +7121,73 @@ static int test_x_02(void)
                         transmit the string "abcdef" at each rate.
         Pass criteria:  The tester will measure the bit timings and confirm the rates.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_5BIT_45, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_5BIT_45, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
@@ -1513,6 +7195,17 @@ static int test_x_02(void)
 
 static int test_x_03(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.5.3     Baudot probe bit rate confirmation
         Purpose:        To verify that the TUT uses the correct bit rates in the Baudot mode probe during
@@ -1525,21 +7218,104 @@ static int test_x_03(void)
         Comments:       The probe message must be long enough for the tester to establish the bit rate. "GA"
                         may not be sufficient.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_5BIT_45, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_5BIT_45, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 1;
 }
 /*- End of function --------------------------------------------------------*/
 
+static void x_04_put_echo_text_msg(void *user_data, const uint8_t *msg, int len)
+{
+    printf("Unexpected ECHO received (%d) '%s'\n", len, msg);
+    unexpected_echo = TRUE;
+}
+/*- End of function --------------------------------------------------------*/
+
+static void x_04_put_text_msg(void *user_data, const uint8_t *msg, int len)
+{
+printf("1-1 %d '%s'\n", len, msg);
+    strcat(result, (const char *) msg);
+}
+/*- End of function --------------------------------------------------------*/
+
 static int test_x_04(void)
 {
-    char result[1024];
-    char *t;
-    int ch;
-    int xx;
-    int yy;
-    int i;
-    v18_state_t *v18_state;
+    char msg[1024];
+    v18_state_t *v18[2];
     logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int i;
+    int j;
 
     /*
         III.5.4.5.4     5 Bit to T.50 character conversion
@@ -1560,56 +7336,202 @@ static int test_x_04(void)
                         assumed that the character conversion is the same for Baudot at 50 bit/s and any
                         other supported speed.
      */
-    v18_state = v18_init(NULL, TRUE, V18_MODE_5BIT_45, NULL, NULL);
-    logging = v18_get_logging_state(v18_state);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_5BIT_45, x_04_put_echo_text_msg, NULL);
+    logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "");
-    printf("Original:\n");
-    t = result;
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_5BIT_45, x_04_put_text_msg, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    result[0] = '\0';
+    unexpected_echo = FALSE;
     for (i = 0;  i < 127;  i++)
+        msg[i] = i + 1;
+    msg[127] = '\0';
+    v18_put(v18[0], msg, 127);
+
+    for (i = 0;  i < 1000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK);
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
+    printf("Result:\n%s\n", result);
+    printf("Reference result:\n%s\n", full_baudot_rx);
+    if (unexpected_echo  ||  strcmp(result, full_baudot_rx) != 0)
+        return -1;
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static void x_05_put_text_msg(void *user_data, const uint8_t *msg, int len)
+{
+    if (user_data == NULL)
+        strcat(result, (const char *) msg);
+    else
+        v18_put(v18[1], "behknqtwz", 9);
+}
+/*- End of function --------------------------------------------------------*/
+
+static int test_x_05(void)
+{
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+    const char *ref;
+
+    /*
+        III.5.4.5.5     DTMF receiver disabling
+        Purpose:        To verify that the TUT disables its DTMF receiver for 300 ms when a character is
+                        transmitted.
+        Preamble:       Establish a call between the tester and TUT in DTMF mode.
+        Method:         The operator should send a single "e" character from the TUT which will result in
+                        sending a single DTMF tone to the tester. The tester will immediately start sending a
+                        unique character sequence using single DTMF tones. Examination of the TUT
+                        display will show when its receiver is re-enabled.
+        Pass criteria:  The receiver should be re-enabled after 300 ms.
+     */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, x_05_put_text_msg, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, x_05_put_text_msg, (void *) (intptr_t) 1);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    result[0] = '\0';
+    v18_put(v18[0], "e", 1);
+
+    for (i = 0;  i < 1000;  i++)
     {
-        ch = i;
-        printf("%c", ch);
-        xx = v18_encode_baudot(v18_state, ch);
-        if (xx)
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
         {
-            if ((xx & 0x3E0))
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
             {
-                yy = v18_decode_baudot(v18_state, (xx >> 5) & 0x1F);
-                if (yy)
-                    *t++ = yy;
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
             }
-            yy = v18_decode_baudot(v18_state, xx & 0x1F);
-            if (yy)
-                *t++ = yy;
         }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
     }
-    printf("\n");
-    *t = '\0';
-    v18_free(v18_state);
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
+    ref = "knqtwz";
     printf("Result:\n%s\n", result);
-    printf("Reference result:\n%s\n", full_baudot_rx);
-    if (strcmp(result, full_baudot_rx) != 0)
+    printf("Reference result:\n%s\n", ref);
+    if (strcmp(result, ref) != 0)
         return -1;
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
 
-static int test_x_05(void)
+static void x_06_put_text_msg(void *user_data, const uint8_t *msg, int len)
 {
-    /*
-        III.5.4.5.5     DTMF receiver disabling
-        Purpose:        To verify that the TUT disables its DTMF receiver for 300 ms when a character is
-                        transmitted.
-        Preamble:       Establish a call between the tester and TUT in DTMF mode.
-        Method:         The operator should send a single "e" character from the TUT which will result in
-                        sending a single DTMF tone to the tester. The tester will immediately start sending a
-                        unique character sequence using single DTMF tones. Examination of the TUT
-                        display will show when its receiver is re-enabled.
-        Pass criteria:  The receiver should be re-enabled after 300 ms.
-     */
-    printf("Test not yet implemented\n");
-    return 0;
+    strcat(result, (const char *) msg);
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -1617,9 +7539,17 @@ static int test_x_06(void)
 {
     char msg[128];
     char dtmf[1024];
-    char result[1024];
     const char *ref;
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
     int i;
+    int j;
 
     /*
         III.5.4.5.6     DTMF character conversion
@@ -1635,22 +7565,89 @@ static int test_x_06(void)
                         receiving character from the TUT. It is assumed that the echo delay in the test
                         system is negligible.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, x_06_put_text_msg, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    result[0] = '\0';
     for (i = 0;  i < 127;  i++)
         msg[i] = i + 1;
     msg[127] = '\0';
-    printf("%s\n", msg);
+    printf("Original:\n%s\n", msg);
 
     v18_encode_dtmf(NULL, dtmf, msg);
-    printf("%s\n", dtmf);
-
+    printf("DTMF:\n%s\n", dtmf);
     v18_decode_dtmf(NULL, result, dtmf);
 
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
     ref = "\b \n\n\n?\n\n\n  %+().+,-.0123456789:;(=)"
           "?XABCDEFGHIJKLMNOPQRSTUVWXYZ\xC6\xD8\xC5"
           " abcdefghijklmnopqrstuvwxyz\xE6\xF8\xE5 \b";
 
     printf("Result:\n%s\n", result);
     printf("Reference result:\n%s\n", ref);
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     if (strcmp(result, ref) != 0)
         return -1;
     return 0;
@@ -1659,6 +7656,17 @@ static int test_x_06(void)
 
 static int test_x_07(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.5.7     EDT carrier timing and receiver disabling
         Purpose:        To verify that the TUT sends unmodulated carrier for 300 ms before a character and
@@ -1673,6 +7681,73 @@ static int test_x_07(void)
                         3) The tester will confirm that 1 start bit and at least 1.5 stop bits are used.
         Comments:       The carrier should be maintained during the 300 ms after a character.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 0;
 }
@@ -1680,6 +7755,17 @@ static int test_x_07(void)
 
 static int test_x_08(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.5.8     EDT bit rate and character structure
         Purpose:        To verify that the TUT uses the correct bit rate and character structure in the EDT
@@ -1690,6 +7776,73 @@ static int test_x_08(void)
                         2) The tester should confirm that 1 start bit, 7 data bits, 1 even parity bit and 2 stop
                            bits are used.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 0;
 }
@@ -1697,6 +7850,17 @@ static int test_x_08(void)
 
 static int test_x_09(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.5.9     V.23 calling mode character format
         Purpose:        To verify that the TUT uses the correct character format in the V.23 calling mode.
@@ -1710,6 +7874,73 @@ static int test_x_09(void)
                            that there are no duplicate characters on the TUT display.
                         3) The received string should be correctly displayed despite the incorrect parity.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 0;
 }
@@ -1717,6 +7948,17 @@ static int test_x_09(void)
 
 static int test_x_10(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.5.10    V.23 answer mode character format
         Purpose:        To verify that the TUT uses the correct character format in the V.23 answer mode.
@@ -1733,6 +7975,73 @@ static int test_x_10(void)
         Comments:       This test is only applicable to Minitel Dialogue terminals. Prestel and Minitel
                         Normal terminals cannot operate in this mode.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 0;
 }
@@ -1740,6 +8049,17 @@ static int test_x_10(void)
 
 static int test_x_11(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.5.11    V.21 character structure
         Purpose:        To verify that the TUT uses the character structure in the V.21 mode.
@@ -1754,6 +8074,73 @@ static int test_x_11(void)
                         4) The last five characters on the TUT display should be "12345" (no "6")
                            correctly displayed despite the incorrect parity.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 0;
 }
@@ -1761,6 +8148,17 @@ static int test_x_11(void)
 
 static int test_x_12(void)
 {
+    v18_state_t *v18[2];
+    logging_state_t *logging;
+    int16_t amp[2][SAMPLES_PER_CHUNK];
+    int16_t model_amp[2][SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+    int outframes;
+    int samples;
+    int push;
+    int i;
+    int j;
+
     /*
         III.5.4.5.12    V.18 mode
         Purpose:        To verify that the TUT uses the protocol defined in ITU-T T.140.
@@ -1772,6 +8170,73 @@ static int test_x_12(void)
         Pass criteria:  The tester should confirm UTF8 encoded UNICODE characters are used with the
                         controls specified in ITU-T T.140.
      */
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[0]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "A");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL);
+    logging = v18_get_logging_state(v18[1]);
+    span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+    span_log_set_tag(logging, "B");
+
+    if ((model = both_ways_line_model_init(line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           line_model_no,
+                                           (float) noise_level,
+                                           -15.0f,
+                                           -15.0f,
+                                           channel_codec,
+                                           rbs_pattern)) == NULL)
+    {
+        fprintf(stderr, "    Failed to create line model\n");
+        exit(2);
+    }
+
+    for (i = 0;  i < 10000;  i++)
+    {
+        for (j = 0;  j < 2;  j++)
+        {
+            if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
+                push = 10;
+            if (samples < SAMPLES_PER_CHUNK)
+            {
+                vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
+                samples = SAMPLES_PER_CHUNK;
+            }
+        }
+        if (log_audio)
+        {
+            for (j = 0;  j < samples;  j++)
+            {
+                out_amp[2*j + 0] = amp[0][j];
+                out_amp[2*j + 1] = amp[1][j];
+            }
+            outframes = sf_writef_short(outhandle, out_amp, samples);
+            if (outframes != samples)
+            {
+                fprintf(stderr, "    Error writing audio file\n");
+                exit(2);
+            }
+        }
+#if 1
+        both_ways_line_model(model,
+                             model_amp[0],
+                             amp[0],
+                             model_amp[1],
+                             amp[1],
+                             samples);
+#else
+        vec_copyi16(model_amp[0], amp[0], samples);
+        vec_copyi16(model_amp[1], amp[1], samples);
+#endif
+        v18_rx(v18[0], model_amp[1], samples);
+        v18_rx(v18[1], model_amp[0], samples);
+    }
+
+    v18_free(v18[0]);
+    v18_free(v18[1]);
     printf("Test not yet implemented\n");
     return 0;
 }
@@ -1829,7 +8294,7 @@ const struct
 } test_list[] =
 {
     {"III.3.2.1 Operational requirements tests", NULL},
-    {"MISC-01         4 (1)       No Disconnection Test", test_misc_01},
+    {"MISC-01         4 (1)       No disconnection test", test_misc_01},
     {"MISC-02         4 (2)       Automatic resumption of automoding", test_misc_02},
     {"MISC-03         4 (2)       Retention of selected mode on loss of signal", test_misc_03},
     {"MISC-04         4 (4)       Detection of BUSY tone", test_misc_04},
@@ -1837,81 +8302,81 @@ const struct
     {"MISC-06         4 (4)       LOSS OF CARRIER indication", test_misc_06},
     {"MISC-07         4 (4)       Call progress indication", test_misc_07},
     {"MISC-08         4 (5)       Circuit 135 test", test_misc_08},
-    {"MISC-09         4 (6)       Connection Procedures", test_misc_09},
+    {"MISC-09         4 (6)       Connection procedures", test_misc_09},
 
     {"III.3.2.2 Automode originate tests", NULL},
-    {"ORG-01          5.1.1       CI & XCI Signal coding and cadence", test_org_01},
-    {"ORG-02          5.1.3       ANS Signal Detection", test_org_02},
+    {"ORG-01          5.1.1       CI & XCI signal coding and cadence", test_org_01},
+    {"ORG-02          5.1.3       ANS signal detection", test_org_02},
     {"ORG-03          5.2.3.1     End of ANS signal detection", test_org_03},
     {"ORG-04          5.1.3.2     ANS tone followed by TXP", test_org_04},
     {"ORG-05          5.1.3.3     ANS tone followed by 1650Hz", test_org_05},
     {"ORG-06          5.1.3.4     ANS tone followed by 1300Hz", test_org_06},
     {"ORG-07          5.1.3       ANS tone followed by no tone", test_org_07},
-    {"ORG-08          5.1.4       Bell 103 (2225Hz Signal) Detection", test_org_08},
-    {"ORG-09          5.1.5       V.21 (1650Hz Signal) Detection", test_org_09},
-    {"ORG-10          5.1.6       V.23 (1300Hz Signal) Detection", test_org_10},
-    {"ORG-11          5.1.7       V.23 (390Hz Signal) Detection", test_org_11},
-    {"ORG-12a to d    5.1.8       5 Bit Mode (Baudot) Detection Tests", test_org_12},
+    {"ORG-08          5.1.4       Bell 103 (2225Hz signal) detection", test_org_08},
+    {"ORG-09          5.1.5       V.21 (1650Hz signal) detection", test_org_09},
+    {"ORG-10          5.1.6       V.23 (1300Hz signal) detection", test_org_10},
+    {"ORG-11          5.1.7       V.23 (390Hz signal) detection", test_org_11},
+    {"ORG-12a to d    5.1.8       5 Bit Mode (baudot) detection Tests", test_org_12},
     {"ORG-13          5.1.9       DTMF signal detection", test_org_13},
-    {"ORG-14          5.1.10      EDT Rate Detection", test_org_14},
-    {"ORG-15          5.1.10.1    Rate Detection Test", test_org_15},
-    {"ORG-16          5.1.10.2    980Hz Detection", test_org_16},
+    {"ORG-14          5.1.10      EDT rate detection", test_org_14},
+    {"ORG-15          5.1.10.1    Rate detection test", test_org_15},
+    {"ORG-16          5.1.10.2    980Hz detection", test_org_16},
     {"ORG-17          5.1.10.3    Loss of signal after 980Hz", test_org_17},
     {"ORG-18          5.1.10.3    Tr Timer", test_org_18},
-    {"ORG-19          5.1.11      Bell 103 (1270Hz Signal) Detection", test_org_19},
-    {"ORG-20                      Immunity to Network Tones", test_org_20},
+    {"ORG-19          5.1.11      Bell 103 (1270Hz signal) detection", test_org_19},
+    {"ORG-20                      Immunity to network tones", test_org_20},
     {"ORG-21a to b                Immunity to other non-textphone modems", test_org_21},
-    {"ORG-22                      Immunity to Fax Tones", test_org_22},
-    {"ORG-23                      Immunity to Voice", test_org_23},
+    {"ORG-22                      Immunity to Fax tones", test_org_22},
+    {"ORG-23                      Immunity to voice", test_org_23},
     {"ORG-24          5.1.2       ANSam detection", test_org_24},
     {"ORG-25          6.1         V.8 originate call", test_org_25},
 
     {"III.3.2.3 Automode answer tests", NULL},
     {"ANS-01          5.2.1       Ta timer", test_ans_01},
-    {"ANS-02          5.2.2       CI Signal Detection", test_ans_02},
-    {"ANS-03          5.2.2.1     Early Termination of ANS tone", test_ans_03},
+    {"ANS-02          5.2.2       CI signal detection", test_ans_02},
+    {"ANS-03          5.2.2.1     Early termination of ANS tone", test_ans_03},
     {"ANS-04          5.2.2.2     Tt Timer", test_ans_04},
     {"ANS-05          5.2.3.2     ANS tone followed by 980Hz", test_ans_05},
     {"ANS-06          5.2.3.2     ANS tone followed by 1300Hz", test_ans_06},
     {"ANS-07          5.2.3.3     ANS tone followed by 1650Hz", test_ans_07},
     {"ANS-08          5.2.4.1     980Hz followed by 1650Hz", test_ans_08},
     {"ANS-09a to d    5.2.4.2     980Hz calling tone detection", test_ans_09},
-    {"ANS-10          5.2.4.3     V.21 Detection by Timer", test_ans_10},
-    {"ANS-11          5.2.4.4.1   EDT Detection by Rate", test_ans_11},
-    {"ANS-12          5.2.4.4.2   V.21 Detection by Rate", test_ans_12},
+    {"ANS-10          5.2.4.3     V.21 detection by timer", test_ans_10},
+    {"ANS-11          5.2.4.4.1   EDT detection by rate", test_ans_11},
+    {"ANS-12          5.2.4.4.2   V.21 detection by rate", test_ans_12},
     {"ANS-13          5.2.4.4.3   Tr Timer", test_ans_13},
     {"ANS-14          5.2.4.5     Te Timer", test_ans_14},
-    {"ANS-15a to d    5.2.5       5 Bit Mode (Baudot) Detection Tests", test_ans_15},
-    {"ANS-16          5.2.6       DTMF Signal Detection", test_ans_16},
+    {"ANS-15a to d    5.2.5       5 bit mode (Baudot) detection tests", test_ans_15},
+    {"ANS-16          5.2.6       DTMF signal detection", test_ans_16},
     {"ANS-17          5.2.7       Bell 103 (1270Hz signal) detection", test_ans_17},
     {"ANS-18          5.2.8       Bell 103 (2225Hz signal) detection", test_ans_18},
-    {"ANS-19          5.2.9       V.21 Reverse Mode (1650Hz) Detection", test_ans_19},
-    {"ANS-20a to d    5.2.10      1300Hz Calling Tone Discrimination", test_ans_20},
-    {"ANS-21          5.2.11      V.23 Reverse Mode (1300Hz) Detection", test_ans_21},
+    {"ANS-19          5.2.9       V.21 reverse mode (1650Hz) detection", test_ans_19},
+    {"ANS-20a to d    5.2.10      1300Hz calling tone discrimination", test_ans_20},
+    {"ANS-21          5.2.11      V.23 reverse mode (1300Hz) detection", test_ans_21},
     {"ANS-22                      1300Hz with XCI Test", test_ans_22},
-    {"ANS-23          5.2.12      Stimulate Mode Country Settings", test_ans_23},
-    {"ANS-24          5.2.12.1    Stimulate Carrierless Mode Probe Message", test_ans_24},
-    {"ANS-25          5.2.12.1.1  Interrupted Carrierless Mode Probe", test_ans_25},
-    {"ANS-26          5.2.12.2    Stimulate Carrier Mode Probe Time", test_ans_26},
-    {"ANS-27          5.2.12.2.1  V.23 Mode (390Hz) Detection", test_ans_27},
-    {"ANS-28          5.2.12.2.2  Interrupted Carrier Mode Probe", test_ans_28},
-    {"ANS-29          5.2.12.2.2  Stimulate Mode Response During Probe", test_ans_29},
-    {"ANS-30                      Immunity to Network Tones", test_ans_30},
-    {"ANS-31                      Immunity to Fax Calling Tones", test_ans_31},
-    {"ANS-32                      Immunity to Voice", test_ans_32},
-    {"ANS-33          5.2.2.1     V.8 CM detection and V.8 Answering", test_ans_33},
+    {"ANS-23          5.2.12      Stimulate mode country settings", test_ans_23},
+    {"ANS-24          5.2.12.1    Stimulate carrierless mode probe message", test_ans_24},
+    {"ANS-25          5.2.12.1.1  Interrupted carrierless mode probe", test_ans_25},
+    {"ANS-26          5.2.12.2    Stimulate carrier mode probe time", test_ans_26},
+    {"ANS-27          5.2.12.2.1  V.23 mode (390Hz) detection", test_ans_27},
+    {"ANS-28          5.2.12.2.2  Interrupted carrier mode probe", test_ans_28},
+    {"ANS-29          5.2.12.2.2  Stimulate mode response during probe", test_ans_29},
+    {"ANS-30                      Immunity to network tones", test_ans_30},
+    {"ANS-31                      Immunity to Fax calling tones", test_ans_31},
+    {"ANS-32                      Immunity to voice", test_ans_32},
+    {"ANS-33          5.2.2.1     V.8 CM detection and V.8 answering", test_ans_33},
 
     {"III.3.2.4 Automode monitor tests", NULL},
     {"MON-01 to -20   5.3         Repeat all answer mode tests excluding tests ANS-01, ANS-20 and ANS-23 to ANS-29", test_mon_01},
-    {"MON-21          5.3         Automode Monitor Ta timer", test_mon_21},
-    {"MON-22a to d    5.3         Automode Monitor 1300Hz Calling Tone Discrimination", test_mon_22},
-    {"MON-23a to d    5.3         Automode Monitor 980Hz Calling Tone Discrimination", test_mon_23},
+    {"MON-21          5.3         Automode monitor Ta timer", test_mon_21},
+    {"MON-22a to d    5.3         Automode monitor 1300Hz calling tone discrimination", test_mon_22},
+    {"MON-23a to d    5.3         Automode monitor 980Hz calling tone discrimination", test_mon_23},
 
     {"III.3.2.5 ITU-T V.18 annexes tests", NULL},
     {"X-01            A.1         Baudot carrier timing and receiver disabling", test_x_01},
     {"X-02            A.2         Baudot bit rate confirmation", test_x_02},
     {"X-03            A.3         Baudot probe bit rate confirmation", test_x_03},
-    {"X-04            A.4         5 Bit to T.50 Character Conversion", test_x_04},
+    {"X-04            A.4         5 Bit to T.50 character conversion", test_x_04},
     {"X-05            B.1         DTMF receiver disabling", test_x_05},
     {"X-06            B.2         DTMF character conversion", test_x_06},
     {"X-07            C.1         EDT carrier timing and receiver disabling", test_x_07},
@@ -1967,7 +8432,7 @@ int main(int argc, char *argv[])
     outhandle = NULL;
     if (log_audio)
     {
-        if ((outhandle = sf_open_telephony_write(OUTPUT_FILE_NAME, 1)) == NULL)
+        if ((outhandle = sf_open_telephony_write(OUTPUT_FILE_NAME, 2)) == NULL)
         {
             fprintf(stderr, "    Cannot create audio file '%s'\n", OUTPUT_FILE_NAME);
             exit(2);
index 82722e25569cd5f07475b5786477fac60bae4f1f..aade32c726d0de20d18e7023f0ef936d2273074c 100644 (file)
@@ -373,7 +373,6 @@ int main(int argc, char *argv[])
         bert_set_report(&endpoint[i].bert_rx, 10000, reporter, &endpoint[i]);
     }
 
-
 #if defined(ENABLE_GUI)
     if (use_gui)
     {