From: hackbard Date: Sun, 6 Jul 2003 20:39:35 +0000 (+0000) Subject: added print info option (still in dev) X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=378d09ab71532d175538ef40bb70432e76c75057;p=sound-tools%2Fhdrec.git added print info option (still in dev) --- diff --git a/hdrec b/hdrec index bb3f97a..9bfc05f 100755 Binary files a/hdrec and b/hdrec differ diff --git a/hdrec.c b/hdrec.c index ac6348e..58cb670 100644 --- a/hdrec.c +++ b/hdrec.c @@ -22,6 +22,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 record to \n"); printf("-p \t play from \n"); printf("-s \t\t stereo\n"); @@ -45,6 +46,9 @@ int main(int argc,char **argv) { char play_file[MAX_C_FILE]; dsp_set set; unsigned char *buf; + unsigned char print_info=0; + unsigned char info[8]; + int info_int; /* defaults */ strcpy(device,""); @@ -59,6 +63,9 @@ int main(int argc,char **argv) { case 'h': usage(); return 1; + case 'i': + print_info=1; + break; case 'r': mode=RECORD; strcpy(record_file,argv[++i]); @@ -119,6 +126,33 @@ int main(int argc,char **argv) { } } + if(print_info) { + if(mode&PLAY) { + printf("file info:\n"); + lseek(pfile_fd,4,SEEK_SET); + read(pfile_fd,&info_int,4); + printf("file size: %d\n",info_int); + lseek(pfile_fd,8,SEEK_CUR); + read(pfile_fd,&info_int,4); + printf("fmtsize: %d\n",info_int); + read(pfile_fd,&info_int,4); + printf("format tag: %d\n",(info_int>>16)&1<<16); + printf("channels: %d\n",info_int&1<<16); + read(pfile_fd,&info_int,4); + printf("samples/sec: %d\n",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); + lseek(pfile_fd,4,SEEK_CUR); + read(pfile_fd,&info_int,4); + printf("datasize: %d\n\n",info_int); + /* return to start */ + lseek(pfile_fd,0,SEEK_SET); + } + } + /* set dsp and get capabilities */ if(get_dsp_cap(audio_fd,&set,1)==-1) { printf("unable to get capabilities :(\n"); @@ -135,7 +169,7 @@ int main(int argc,char **argv) { perror("malloc"); return -1; } - + if(mode&PLAY) { printf("playing file %s ...\n",play_file); rw=1;