diff --git a/README.md b/README.md index 45659a7..90b2e20 100644 --- a/README.md +++ b/README.md @@ -33,11 +33,13 @@ ## Usage -Simply run: +Simply run in your terminal: ``` -mvc +mvc [color] ``` -The keypress 'q' at anytime quits the program and restores the terminal. +[color] is the number of a color in your terminal colorscheme. + +The keypress '**q**'' at anytime **quits** the program and restores the terminal. Note that an instance of MPD must be running for mvc to work, otherwise the fifo file doesn't exist. diff --git a/makefile b/makefile index cc33fd0..df521e1 100644 --- a/makefile +++ b/makefile @@ -1,7 +1,7 @@ ALL = fft.c utils_curses.c music_visualizer.c LOCPATH = ./bin INSTALLPATH = /usr/local -LFLAGS = -lm -lcurses +LFLAGS = -lm -lcurses -ldl -ltinfo DEBFLAGS = -g -Wall NAME = mvc diff --git a/music_visualizer.c b/music_visualizer.c index f4ddec0..9382245 100755 --- a/music_visualizer.c +++ b/music_visualizer.c @@ -8,6 +8,7 @@ #include "utils_curses.h" #include "time.h" +#define MPD_FIFO "/tmp/mpd.fifo" /*FREQ 44100*/ #define N_SAMPLES 512 /*FPS FREQ/N_SAMPLES*/ @@ -21,7 +22,12 @@ uint16_t buf[N_SAMPLES]; unsigned int *fftBuf, *fftAvg; - while((fifo = open("/tmp/mpd.fifo", O_RDONLY)) == -1); + while((fifo = open(MPD_FIFO, O_RDONLY)) == -1); + + if (argc != 2){ + fprintf(stderr, "Usage: mvc [color number]\n"); + exit(EXIT_FAILURE); + } if((mainwin = curses_init()) == NULL){ @@ -34,9 +40,8 @@ while(read(fifo, (uint16_t*)buf, 2*N_SAMPLES) != 0){ /*usleep(45000);*/ - if(wgetch(stdscr)=='q'){ - break; + break; } fftBuf = fast_fft(N_SAMPLES, (uint16_t*)buf); @@ -46,13 +51,7 @@ erase(); correction = 0; for(i=correction; iavgLen*2/3){*/ - /*color_set(2, NULL); */ - /*} else {*/ - /*color_set(3, NULL);*/ - /*}*/ + color_set(atoi(argv[1]), NULL); for(j=0; j<1; j++){ if(fftAvg[i] > maxR || fftAvg[i] < 0){ fftAvg[i] = 1; diff --git a/utils_curses.c b/utils_curses.c index 7fc47a2..6af334f 100755 --- a/utils_curses.c +++ b/utils_curses.c @@ -32,10 +32,8 @@ void print_col(int col, int length, int maxR) { - int row, l; - + int row, l; l = maxR - length; - /*l -= 5;*/ for(row=maxR; row>l; row--){ mvaddch(row, col, SHARP); }