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 / lintoulaw.c < prev    next >
C/C++ Source or Header  |  1990-01-10  |  1KB  |  54 lines

  1. /* lintoulaw.c - convert linear to ulaw
  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 MYBUFSIZ 256
  17.  
  18. main( argc, argv )
  19. int argc;
  20. char *argv[];
  21.     {
  22.     FILE *f;
  23.     char mybuf[MYBUFSIZ];
  24.     double atof();
  25.     int c;
  26.     float lc;
  27.  
  28.     if ( argc == 1 )
  29.     f = stdin;
  30.     else if ( argc == 2 )
  31.     {
  32.     f = fopen( argv[1], "r" );
  33.     if ( f == NULL )
  34.         {
  35.         perror( argv[1] );
  36.         exit( 1 );
  37.         }
  38.     }
  39.     else
  40.     {
  41.     fprintf( stderr, "usage:  %s [<file>]\n", argv[0] );
  42.     exit( 1 );
  43.     }
  44.     setbuffer( stdout, mybuf, MYBUFSIZ );
  45.  
  46.     while ( fscanf( f, "%g", &lc ) == 1 )
  47.     {
  48.     c = st_linear_to_ulaw( (int) lc );
  49.     putchar( c );
  50.     }
  51.  
  52.     exit( 0 );
  53.     }
  54.