diff --git a/src/fft.c b/src/fft.c index 7703a7e..739e944 100644 --- a/src/fft.c +++ b/src/fft.c @@ -115,14 +115,18 @@ { int i, j, step, k=0; unsigned int avg; + int maxfreq = 0; + // N_SAMPLES / maximum number of columns step = inLen/max; for(i=0; i maxfreq) { + maxfreq = fftBuf[i+j]; + } } - fftAvg[k++] = avg/step; //the 80 is a correction for the display + fftAvg[k++] = maxfreq-step; //the 80 is a correction for the display } } diff --git a/src/music_visualizer.c b/src/music_visualizer.c index b82d842..bdc200e 100644 --- a/src/music_visualizer.c +++ b/src/music_visualizer.c @@ -99,7 +99,7 @@ fftAvg[i] = 1; } // print the column fftAvg[i] - print_col(i-X_CORRECTION, fftAvg[i], maxR, maxC, pattern); + print_col(i-X_CORRECTION, fftAvg[i], maxR, maxC, pattern, (int)fftAvg[i]); } } @@ -151,7 +151,7 @@ if ((c = wgetch(stdscr)) == 'q') { over = true; } else if (c == ' ') { - pattern = (pattern + 1) % 4; + pattern = (pattern + 1) % 5; } else if (c == KEY_UP) { statusHeight -= 1; } else if (c == KEY_DOWN) { diff --git a/src/settings.h b/src/settings.h index 62f31dd..9c0ec12 100644 --- a/src/settings.h +++ b/src/settings.h @@ -1,7 +1,7 @@ /* **** MPD options */ -static char defHost[] = "localhost"; +static char defHost[] = "192.168.1.131"; static unsigned int defPort = 6600; diff --git a/src/utils_curses.c b/src/utils_curses.c index ea4f0fc..ce31ce7 100644 --- a/src/utils_curses.c +++ b/src/utils_curses.c @@ -39,8 +39,9 @@ } void -print_pattern(int col, int row, int l, const int maxR, PATTERN pattern) +print_pattern(int col, int row, int l, const int maxR, const int maxC, PATTERN pattern, int seed) { + bool randc; switch(pattern) { case CURVE: if (row > maxR-l && row < maxR-l/3) { // center of the screen @@ -72,6 +73,20 @@ mvaddch(row, col, EMPTY); } break; + case RANDOM: + srand(seed+row*row*row); + row = rand() % maxR; + if(seed > 28) { + mvaddch(row,col,FULL); + } else if (seed < 28 && seed > 24) { + mvaddch(row,col,EMPTY); + } else if (seed < 14 && seed > 10) { + mvaddch(row,col,EMPTY); + } else if (seed < 10) { + mvaddch(row,col,FULL); + } else { + mvaddch(row,col,' '); + } default: break; } @@ -81,7 +96,7 @@ // while doing so, perform a rotation of the color // modify here to change color output void -print_col(int col, int l, const int maxR, const int maxC, PATTERN pattern) +print_col(int col, int l, const int maxR, const int maxC, PATTERN pattern, int seed) { int row; int color = 5; @@ -91,7 +106,7 @@ if (col < maxC) { color = (color+1) % 6; color_set(color, NULL); - print_pattern(col, row, l, maxR, pattern); + print_pattern(col, row, l, maxR, maxC, pattern, seed); } } } diff --git a/src/utils_curses.h b/src/utils_curses.h index 81b05b2..177f0ac 100644 --- a/src/utils_curses.h +++ b/src/utils_curses.h @@ -4,11 +4,11 @@ #include "utils_mpd.h" -typedef enum {CURVE=0, MOUTH=1, MOUTH_REV=2, LINE=3} PATTERN; +typedef enum {CURVE=0, MOUTH=1, MOUTH_REV=2, LINE=3, RANDOM=4} PATTERN; void init_color_pairs(); WINDOW* curses_init(); -void print_col(int col, int length, const int maxR, const int maxC, PATTERN pattern); +void print_col(int col, int length, const int maxR, const int maxC, PATTERN pattern, int seed); void print_rate_info(const int rate, const int nsamples, const int maxC, int seed, int amplitude, int beat); void print_help(const int maxR, const int maxC);