+ if(!(mode&REVERSED)) {
+ while(rw) {
+ /* read samples */
+ rw=read(pfile_fd,buf,set.bufsize);
+ /* do fourier trafo */
+ for(sample=0;sample<fourier.data_len[0];sample++) fourier.data[sample].r=*((signed short *)buf+(set.format&AFMT_S16_LE?2:1)*sample);
+ fourier_dft_1d(&fourier);
+ /* print graph */
+ primary->Clear(primary,0,0,0,0xff);
+ a_f=dx*fourier.data_len[0]*440/set.freq;
+ primary->DrawLine(primary,a_f,height,a_f,0);
+ for(sample=0;sample<fourier.data_len[0]/8;sample++) primary->FillRectangle(primary,sample*dx,0,dx,height*sqrt(fourier.ftdata[sample].r*fourier.ftdata[sample].r+fourier.ftdata[sample].i*fourier.ftdata[sample].i)/0x7fff);
+ primary->Flip(primary,NULL,DSFLIP_WAITFORSYNC);
+ //fcount=0;
+
+ //}
+
+ 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<set.bufsize;k++) {
+ lseek(pfile_fd,tmp-(j+1)*set.bufsize+k,SEEK_SET);
+ read(pfile_fd,buf+k,1);
+ }
+ write(audio_fd,buf,set.bufsize);
+ }