there is a new event api ...
[sound-tools/hdrec.git] / resample.c
1 /* resample.c -- resample audio file (just raw) */
2
3 /* hackbard@hackdaworld.dyndns.org */
4
5 #include <stdio.h>
6 #include <sys/types.h>
7 #include <sys/stat.h>
8 #include <fcntl.h>
9 #include <unistd.h>
10
11 int usage() {
12         puts("usage: resample <src> <dst>");
13         return 1;
14 }
15
16 int main(int argc,char **argv) {
17         int src_fd,dst_fd;
18         int i;
19         unsigned char buf[2];
20         
21
22         if(argc!=3) {
23                 usage();
24                 return -1;
25         }
26
27         src_fd=open(argv[1],O_RDONLY);
28         if(src_fd<0) {
29                 printf("can't open %s\n",argv[1]);
30                 return -1;
31         }
32
33         dst_fd=open(argv[2],O_WRONLY|O_CREAT);
34         if(dst_fd<0) {
35                 printf("can't open %s\n",argv[2]);
36                 return -1;
37         }
38
39         i=1;
40         while(i) {
41                 i=read(src_fd,buf,2);
42                 write(dst_fd,buf,2);
43                 write(dst_fd,buf,2);
44         }
45
46         return 1;
47 }