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

  1. /* volume.c - change the volume of a sound file
  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.     float scale;
  25.     double atof();
  26.     int c, lc;
  27.  
  28.     if ( argc < 2 || argc > 3 )
  29.     {
  30.     fprintf( stderr, "usage:  %s <factor> [<file>]\n", argv[0] );
  31.     exit( 1 );
  32.     }
  33.  
  34.     scale = atof( argv[1] );
  35.     if ( scale == 0.0 )
  36.     {
  37.     fprintf( stderr, "%s: scale factor required\n", argv[0] );
  38.     exit( 1 );
  39.     }
  40.  
  41.     if ( argc == 2 )
  42.     f = stdin;
  43.     else if ( argc == 3 )
  44.     {
  45.     f = fopen( argv[2], "r" );
  46.     if ( f == NULL )
  47.         {
  48.         perror( argv[2] );
  49.         exit( 1 );
  50.         }
  51.     }
  52.     setbuffer( stdout, mybuf, MYBUFSIZ );
  53.  
  54.     while ( (c = getc( f )) != EOF )
  55.     {
  56.     lc = st_ulaw_to_linear( c ) * scale;
  57.     LINCLIP( lc );
  58.     putchar( st_linear_to_ulaw( lc ) );
  59.     }
  60.  
  61.     exit( 0 );
  62.     }
  63.