home *** CD-ROM | disk | FTP | other *** search
/ ftp.ee.lbl.gov / 2014.05.ftp.ee.lbl.gov.tar / ftp.ee.lbl.gov / sst.tar.Z / sst.tar / sst / voxexit.c < prev   
C/C++ Source or Header  |  1990-01-10  |  1KB  |  44 lines

  1. /* voxexit.c - exit when sound is heard
  2. **
  3. ** Copyright (C) 1989 by Jef Poskanzer.
  4. **
  5. ** Permission to use, copy, modify, and distribute this software and its
  6. ** documentation for any purpose and without fee is hereby granted, provided
  7. ** that the above copyright notice appear in all copies and that both that
  8. ** copyright notice and this permission notice appear in supporting
  9. ** documentation.  This software is provided "as is" without express or
  10. ** implied warranty.
  11. */
  12.  
  13. #include <stdio.h>
  14. #include "libst.h"
  15.  
  16. #define abs(a) ((a) >= 0 ? (a) : -(a))
  17.  
  18. #define Q_DELTA 1000
  19. #define MYBUFSIZ 256
  20.  
  21. main( argc, argv )
  22. int argc;
  23. char *argv[];
  24.     {
  25.     char mybuf[MYBUFSIZ];
  26.     int c, lc, plc, pplc;
  27.  
  28.     if ( argc != 1 )
  29.     {
  30.     fprintf( stderr, "usage:  %s\n", argv[0] );
  31.     exit( 1 );
  32.     }
  33.     setbuffer( stdout, mybuf, MYBUFSIZ );
  34.  
  35.     for ( pplc = plc = 0; (c = getc( stdin )) != EOF; pplc = plc, plc = lc )
  36.     {
  37.     lc = st_ulaw_to_linear( c );
  38.     if ( abs( pplc - lc ) > Q_DELTA )
  39.         break;
  40.     }
  41.  
  42.     exit( 0 );
  43.     }
  44.