playraw.c
1017 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "playraw.h"
#define BSIZE 1024
#define DEF_FS 44100
char usage[] = "[-h -s -f rate] <infile";
main(int argc, char *argv[])
{
extern char *optarg;
extern int optind, opterr;
int c; /* Required for getopt(); */
char *progname = argv[0];
int lin_buffer[BSIZE], rin_buffer[BSIZE], eof, i, channels;
int fs = DEF_FS;
channels = 1;
while ((c=getopt(argc,argv,"hsf:"))!=-1)
switch (c) {
case 'h':
fprintf(stderr,"%s %s\n",progname,usage);
exit(1);
break;
case 's':
channels = 2;
break;
case 'f':
if (sscanf(optarg,"%f",&fs)!=1)
fs = DEF_FS;
break;
}
initaudio(channels,fs);
eof = 0;
while(eof==0){
switch (channels) {
case 1:
eof = getmonodata(stdin, eof, BSIZE, lin_buffer);
break;
case 2:
eof = getstereodata(stdin, eof, BSIZE, lin_buffer, rin_buffer);
break;
}
writeout(NULL, BSIZE, lin_buffer, rin_buffer, channels);
}
clearaudio();
}