From cceaa25630a7a50b73e0dee0aee17e82237827eb Mon Sep 17 00:00:00 2001 From: hackbard Date: Thu, 21 Aug 2003 03:11:30 +0000 Subject: [PATCH] - --- hdrec.c | 43 +++++++++++++++++++++++++++++++++---------- hdrec.h | 1 + 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/hdrec.c b/hdrec.c index 77b222b..c6945f5 100644 --- a/hdrec.c +++ b/hdrec.c @@ -25,6 +25,7 @@ int usage(void) { printf("usage:\n\n"); printf("-h \t\t print this help\n"); printf("-i \t\t use/print file info\n"); + printf("-R \t\t play reversed :)\n"); printf("-d \t sound device (eg: /dev/dsp)\n"); printf("-r \t record to \n"); printf("-p \t play from \n"); @@ -55,6 +56,7 @@ int main(int argc,char **argv) { unsigned char info[8]; int info_int; int tmp; + char is_wav=0; fd_set read_fds,write_fds; struct timeval fds_tv; char c; @@ -83,6 +85,9 @@ int main(int argc,char **argv) { mode|=PLAY; strcpy(play_file,argv[++i]); break; + case 'R': + mode|=REVERSED; + break; case 's': set.channel=STEREO; break; @@ -197,10 +202,32 @@ int main(int argc,char **argv) { if((mode&PLAY) && (!(mode&RECORD))) { printf("playing file %s ...\n",play_file); + if(mode&REVERSED) printf("but we do it reversed!\n"); rw=1; - while(rw) { - rw=read(pfile_fd,buf,set.bufsize); - write(audio_fd,buf,set.bufsize); + if(!(mode&REVERSED)) { + while(rw) { + rw=read(pfile_fd,buf,set.bufsize); + write(audio_fd,buf,set.bufsize); + } + } else { + i=0; + read(pfile_fd,info,4); + if(!strncmp(info,"RIFF",4)) { + is_wav=1; + printf("\nassuming wav file according to header ...\n"); + i=44; + } + lseek(pfile_fd,0,SEEK_SET); + tmp=lseek(pfile_fd,0,SEEK_END); + // if(set.format==AFMT_U8) i=set.channel; + // if(set.format==AFMT_S16_LE) i=set.channel*2; + for(j=0;j<(tmp-i);j++) { + for(k=0;k