This is stripnextsnd.c in view mode; [Download] [Up]
/* * Strips the header off NeXT sound files for play on the Sparc * * Copyright (c) 1990, Keith Edwards * May be freely used, modified, distributed, or copied as long as * this notice stays intact. * * Keith Edwards * Georgia Tech / SERC / Multimedia Group * April 5, 1990 * <keith@dali.gatech.edu> */ /************************************************************************* stripnextsnd.c: If no args, reads from stdin and writes to stdout. If one arg, opens that file and writes to stdout. If two args, uses arg one as input and arg 2 as output. *************************************************************************/ #include <stdio.h> #include <fcntl.h> #include <errno.h> #include <sys/types.h> #include <sys/uio.h> #include "next_soundstruct.h" #define BUFSIZE 1024 main( argc, argv, envp ) int argc; char *argv[], *envp[]; { int in, out; unsigned char buf[BUFSIZE]; SNDSoundStruct sndStruct; if (argc > 3) { fprintf( stderr, "Usage: %s [infile [outfile]]\n", argv[0] ); exit( 1 ); } if (argc >= 2) { if ((in = open( argv[1], O_RDONLY, NULL )) == -1) { perror( argv[1] ); exit( 2 ); } close( 0 ); dup2( in, 0 ); } if (argc == 3) { if ((out = open( argv[2], (O_WRONLY | O_CREAT), NULL )) == -1){ perror( argv[2] ); exit( 2 ); } close( 1 ); dup2( out, 1 ); } read( 0, (char *) &sndStruct, sizeof( SNDSoundStruct )); if (sndStruct.magic != SND_MAGIC) { fprintf( stderr, "%s: bad magic number on sound input\n", argv[0] ); exit( 3 ); } if (sndStruct.dataFormat != SND_FORMAT_MULAW_8) { fprintf( stderr, "%s: bad format on sound input (can only read 8-bit mulaw)\n", argv[0] ); exit( 4 ); } if (sndStruct.samplingRate != (int) SND_RATE_CODEC) fprintf( stderr, "%s: warning: sampling rate not CODEC\n", argv[0] ); if (sndStruct.channelCount != 1) fprintf( stderr, "%s: warning: channel count not 1\n", argv[0] ); while (read( 0, buf, BUFSIZE ) == BUFSIZE) write( 1, buf, BUFSIZE ); write( 1, buf, BUFSIZE ); close( in ) ; close( out ); exit( 0 ); }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.