+ 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<tmp/set.bufsize;j++) {
+ i=read(pfile_fd,buf,set.bufsize);
+ k=write(sfile_fd,buf,set.bufsize);
+ printf("read %d, wrote %d\n",i,k);
+ }
+ printf("\ndone ...\n");
+ }
+