if(bytes==-1){//if no bytes read sleep 10ms and zero
nanosleep(&req,NULL);
t++;
if(t>10){
for(i=0;i<M;i++)shared[i]=0;
t=0;
}
}else{//if bytes read go ahead
t=0;
for(q=0;q<(size/4);q++){
for(q=0;q<(size/4);q++){
//printf("%d, %d\n",buf[q],buf[q+1]);
tempr=(buf[size-4*q-1]<<2);
tempr=(buf[size-4*q-1]<<2);
lo=(buf[size-4*q]>>6);
lo=(buf[size-4*q]>>6);
//printf("%d\n",buf[4*q+1]);
if(lo<0)lo=lo+4;
if(lo<0)lo=lo+4;
if(tempr>=0)tempr=tempr+lo;
if(tempr>=0)tempr=tempr+lo;
if(tempr<0)tempr=tempr-lo;
if(tempr<0)tempr=tempr-lo;
@ -194,14 +215,14 @@ fifomusic(void* data)
if(templ>=0)templ=templ+lo;
if(templ>=0)templ=templ+lo;
elsetempl=templ-lo;
elsetempl=templ-lo;
//printf("%d\n",((tempr+templ)/2));
shared[n]=(tempr+templ)/2;
shared[n]=(tempr+templ)/2;
n++;
n++;
if(n==M-1)n=0;
if(n==M-1)n=0;
}
}
}
}
fclose(fp);
}
close(fd);
}
}
intmain(intargc,char**argv)
intmain(intargc,char**argv)
@ -246,7 +267,7 @@ int main(int argc, char **argv)
structtimespecreq={.tv_sec=0,.tv_nsec=0};
structtimespecreq={.tv_sec=0,.tv_nsec=0};
char*usage=
char*usage=
"\nUsage : ./cava [options]\n\nOptions:\n\t-b 1..(console columns/2-1) or 200\t number of bars in the spectrum (default 25 + fills up the console), program wil auto adjust to maxsize if input is to high)\n\n\t-i 'input method'\t\t\t method used for listnening to audio, supports 'alsa' and 'fifo'\n\n\t-d 'alsa device'\t\t\t name of alsa capture device (default 'hw:1,1')\n\n\t-p 'fifo path'\t\t\t\t path to fifo (default '/tmp/mpd.fifo')\n\n\t-c color\t\t\t\t suported colors: red, green, yellow, magenta, cyan, white, blue, black (default: cyan)\n\n\t-C backround color\t\t\t supported colors: same as above (default: no change) \n\n\t-s sensitivity %\t\t\t sensitivity in percent, 0 means no respons 100 is normal 50 half 200 double and so forth\n\n\t-f framerate \t\t\t\t max frames per second to be drawn, if you are experiencing high CPU usage, try redcing this (default: 60)\n\n";
"\nUsage : ./cava [options]\n\nOptions:\n\t-b 1..(console columns/2-1) or 200\t number of bars in the spectrum (default 25 + fills up the console), program wil auto adjust to maxsize if input is to high)\n\n\t-i 'input method'\t\t\t method used for listnening to audio, supports 'alsa' and 'fifo'\n\n\t-d 'alsa device'\t\t\t name of alsa capture device (default 'hw:1,1')\n\n\t-p 'fifo path'\t\t\t\t path to fifo (default '/tmp/mpd.fifo')\n\n\t-c color\t\t\t\t suported colors: red, green, yellow, magenta, cyan, white, blue, black (default: cyan)\n\n\t-C backround color\t\t\t supported colors: same as above (default: no change) \n\n\t-s sensitivity %\t\t\t sensitivity in percent, 0 means no respons 100 is normal 50 half 200 double and so forth\n\n\t-f framerate \t\t\t\t max frames per second to be drawn, if you are experiencing high CPU usage, try redcing this (default: 60)\n\n";