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 <device> \t sound device (eg: /dev/dsp)\n");
printf("-r <file> \t record to <file>\n");
printf("-p <file> \t play from <file>\n");
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;
mode|=PLAY;
strcpy(play_file,argv[++i]);
break;
+ case 'R':
+ mode|=REVERSED;
+ break;
case 's':
set.channel=STEREO;
break;
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<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);
+ }
}
}
/* write_fds */
FD_SET(sfile_fd,&write_fds);
FD_SET(audio_fd,&write_fds);
- fds_tv.tv_sec=0;
- fds_tv.tv_usec=1000;
while(c!='q') {
+ fds_tv.tv_sec=0;
+ fds_tv.tv_usec=1000;
k=select(sfile_fd+1,&read_fds,&write_fds,NULL,&fds_tv);
if(k==0) printf("itz zZzero :p\n");
if(k) {
+ printf("returned after %ld usecs\n",1000-fds_tv.tv_usec);
if(FD_ISSET(0,&read_fds)) {
- puts("reading from stdin");
read(0,&c,1);
}
if(FD_ISSET(pfile_fd,&read_fds)) {
- puts("read from sound file");
read(pfile_fd,buf2,set.bufsize);
}
if(FD_ISSET(audio_fd,&read_fds)) {
- puts("reading from audio device");
read(audio_fd,buf,set.bufsize);
}
if(FD_ISSET(sfile_fd,&write_fds)) {
- puts("writing to file");
write(sfile_fd,buf,set.bufsize);
}
if(FD_ISSET(audio_fd,&write_fds)) {
- puts("writing to audio device");
write(audio_fd,buf2,set.bufsize);
}
}