From 9894394f33f4aee3cafbaf91c076cdd13f4fc1c6 Mon Sep 17 00:00:00 2001 From: hackbard Date: Mon, 7 Jul 2003 23:20:09 +0000 Subject: [PATCH] removed binary - added convert function --- hdrec | Bin 10446 -> 0 bytes hdrec.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++------ hdrec.h | 1 + 3 files changed, 58 insertions(+), 6 deletions(-) delete mode 100755 hdrec diff --git a/hdrec b/hdrec deleted file mode 100755 index 9bfc05fed12ef339e20968c70b4effc07a6d787b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10446 zcmcgyeRN#Kb)Q`=W-UZk{(urN<^fV-POP=(Ol zZOg@p%xX&(SqF#KIi$7IKu!oreOkAnj&s08U@&$MZ5*GRQxYKM!{zKoN{&lyFtv*M z`^~(Oo@AV~{UftycJ6QPojZ5#+?n^@y!W-{mgOFgN9g1g6@qAP!RMcka`$zLGhY~D zl9(lK5HnB;LEiix$RH1ZX1)yBhg^YtmKi+eX`q?Oqwdk(z!S*BR|~<+_M%$xW!=-@ zAV@^C$7mp=#+k@Fu zaGv5pwX|);n)RSmKa#-T6enMyD^Su7X%osSx*$u8_BR|B;4`uvMfPDRcmZvwvE!SyKPzJzmAgl8sz7J7dp5JB4L?71PviBLSA3X6EwvK|oIGBMi{87mZ_rX*FFtJb1@B$hODSt|l% z>pXHR6Zy%Esq++-;tOjh|VJ3BQZx3r7O!l z5_3e+1;lBIIkM;y;`=1#2%{^BTP5a5qpieCB<6^t8;Ivh%#la$BQ_+a2cjHMxf&Ry zsQ=BD;yd}%XIk6WMc@7gxHSmkyY7zeDf;}SjSxD!XAk_<)>@+U#$87ry-A3^JeNmd z!1j)u?Atti;^>~yqC~5BR>zx{*_(tlZ$S%P8(S zakTiMYX9VEh(P~UhuH>1)vLZ5)|F=LxbRVNX!B@~QvRA^?tEXasPWiZeMZp z*}g5l;-Z>jdyW6qrW)U6t-gWMKYubZvLw*^YiL}!#b?(RH`Vx{){j+M+6CTWx~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Aoqe6a`6yGa;%zFycXEiP?IcWOgVxPLx>(s?o8m@km)1FD%TKwr_SyX3w_tiCpYZ?K;ztQ2q`QdsrC{YGImL)=#shG9thKB>ZaBhP(8@wo%4`z?iK zwY(2gn4?hZTVZuS%yq0VcLeo4gu-g&a9t|QyF?_eKcouhD*&!Dh1FYst|x`nD%ba8 z74ptd2(Aysmv6HL*MY)nXJ@=C%)1?Rf2pv#>y+;gQBfhVxLv7Y+>S*)g3^^L1cJqt zDg=VUl`6*VJZwM1#U;Le0-iZ87JcGBMx^166fsA{y9!o$u@l|w@K}%^M5+DZ!KTJ< z0JJ|mxYF^)L;KT%NaVKz+CLuLZQl>@jVK=izei#r9zezm?NiARC=fv>+M`9AQOulxM# zW&0}eca-P*Z=`CB_XsfGr$3IR%l=;iK7jVGOL-yw4fr71&v)AY7Fe%01M~ec@bi#g z=*VAzEk&=_srVXa3h-;-Yk%DY{H6=f18znCw>tXo0CwBA44Bsyu;IU}#0KE`F8enF z54rRufzQAnx40FHex~>>t$_&-Z|JGC=SRnfu$A6BGEa1CRSQ zhIhHauwcQPT##WLWVk+55#fxTwR4@FV3}rP``UG8%c{0^(*$Z7hniQK%hxTvv)NqM zykgZFDX_Y6R633CTyP7FgA|+`;@QwNBPp{hp6Uq2O?ks?hH~45yrVWFxkLh=)~Mc^ z*EEfFrh)26BX*HB0YY)u_Jj zS+Zp8!yI|SroP^BSDT$_GrGT2)gin(M4YzUDPg{$|WNvPLc#4T%5M*<0rQ)^y48%e(2<` zX4h^kKV>p864R2;LFS5am}{3W$9b*UzI0hjGh)L^M$~6k?zT9#qkHtnQ*PEp p-%+`2HCJyn*I8XLo;x \t 1=8bit - 2=16bit (le)\n"); printf("-F \t frequency\n"); + printf("-c \t converts raw to wav (specify f/m,s/F)\n"); return 1; } @@ -49,6 +50,7 @@ int main(int argc,char **argv) { unsigned char print_info=0; unsigned char info[8]; int info_int; + int tmp; /* defaults */ strcpy(device,""); @@ -91,6 +93,11 @@ int main(int argc,char **argv) { case 'd': strncpy(device,argv[++i],MAX_C_DEVICE-1); break; + case 'c': + mode=CONVERT; + strcpy(play_file,argv[++i]); + strcpy(record_file,argv[++i]); + break; default: usage(); return -1; @@ -113,13 +120,13 @@ int main(int argc,char **argv) { } /* file fd's */ - if(mode&PLAY) { + if((mode&PLAY) || (mode&CONVERT)) { if((pfile_fd=open_file(play_file,O_RDONLY))==-1) { printf("unable to open file %s for reading\n",play_file); return -1; } } - if(mode&RECORD) { + if((mode&RECORD) || (mode&CONVERT)) { if((sfile_fd=open_file(record_file,O_CREAT|O_WRONLY))==-1) { printf("unable to open file %s for writing\n",record_file); return -1; @@ -135,16 +142,20 @@ int main(int argc,char **argv) { lseek(pfile_fd,8,SEEK_CUR); read(pfile_fd,&info_int,4); printf("fmtsize: %d\n",info_int); + if(info_int==16) set.format=AFMT_S16_LE; + if(info_int==8) set.format=AFMT_U8; read(pfile_fd,&info_int,4); - printf("format tag: %d\n",(info_int>>16)&1<<16); - printf("channels: %d\n",info_int&1<<16); + printf("format tag: %d\n",info_int&0xffff); + printf("channels: %d\n",(info_int>>16)&0xffff); + set.channel=(info_int>>16)&0xffff; read(pfile_fd,&info_int,4); printf("samples/sec: %d\n",info_int); + set.freq=info_int; read(pfile_fd,&info_int,4); printf("bytes/sec: %d\n",info_int); read(pfile_fd,&info_int,4); - printf("block allign: %d\n",(info_int>>16)&1<<16); - printf("bits/sample: %d\n",info_int&1<<16); + printf("block allign: %d\n",info_int&0xffff); + printf("bits/sample: %d\n",(info_int>>16)&0xffff); lseek(pfile_fd,4,SEEK_CUR); read(pfile_fd,&info_int,4); printf("datasize: %d\n\n",info_int); @@ -188,5 +199,45 @@ int main(int argc,char **argv) { } } + if(mode&CONVERT) { + if((tmp=lseek(pfile_fd,0,SEEK_END))==-1) { + printf("cannot determine filesize :(\n"); + perror("lseek"); + return -1; + } + lseek(pfile_fd,0,SEEK_SET); + strcpy(info,"RIFF"); + write(sfile_fd,info,4); + info_int=tmp+36; + write(sfile_fd,&info_int,4); + strcpy(info,"WAVEfmt "); + write(sfile_fd,info,8); + if(set.format==AFMT_S16_LE) info_int=16; + if(set.format==AFMT_U8) info_int=8; + write(sfile_fd,&info_int,4); + info_int=set.channel<<16; + info_int|=1; + write(sfile_fd,&info_int,4); + info_int=set.freq; + write(sfile_fd,&info_int,4); + info_int=set.freq*set.channel; + if(set.format==AFMT_S16_LE) info_int*=2; + write(sfile_fd,&info_int,4); + info_int=(set.channel*8)<<16; + info_int|=set.channel; + write(sfile_fd,&info_int,4); + strcpy(info,"data"); + write(sfile_fd,info,4); + info_int=tmp; + write(sfile_fd,&info_int,4); + /* write data now ... */ + for(j=0;j