diff --git a/music_visualizer.c b/music_visualizer.c index 443b9f8..eed3478 100755 --- a/music_visualizer.c +++ b/music_visualizer.c @@ -13,15 +13,48 @@ #define N_SAMPLES 1024 /*FPS FREQ/N_SAMPLES*/ +void process_mpd (int fifo) { + uint16_t buf[N_SAMPLES]; + unsigned int *fftBuf, *fftAvg; + int maxR, maxC, correction; //curses + + + getmaxyx(stdscr, maxR, maxC); + + while(read(fifo, (uint16_t*)buf, 2*N_SAMPLES) != 0){ + /*usleep(45000);*/ + if(wgetch(stdscr)=='q'){ + break; + } + + fftBuf = fast_fft(N_SAMPLES, (uint16_t*)buf); + fftAvg = average_signal(fftBuf, N_SAMPLES, maxC); + free(fftBuf); + + erase(); + correction = 0; + for(i=correction; i maxR || fftAvg[i] < 0){ + fftAvg[i] = 1; + } + print_col(i-correction, fftAvg[i], maxR, atoi(argv[1])); + /*print_col(i-correction+1, fftAvg[i], maxR);*/ + } + refresh(); + free(fftAvg); + } +} + int main(int argc, char *argv[]) { int fifo, i, j; WINDOW *mainwin; - int maxR, maxC, correction; //curses - uint16_t buf[N_SAMPLES]; - unsigned int *fftBuf, *fftAvg; + if (strcmp (argv[2], "--alsa") == 0) { + + } while((fifo = open(MPD_FIFO, O_RDONLY)) == -1); if (argc != 2){