diff --git a/src/beat_track.c b/src/beat_track.c index a47fed8..7708e4a 100644 --- a/src/beat_track.c +++ b/src/beat_track.c @@ -32,6 +32,10 @@ } else { cb->count++; } + if(cb->tail > cb->capacity) { + cb->head -= cb->capacity; + cb->tail -= cb->capacity; + } } double cb_avg(cebuffer *cb) @@ -76,7 +80,7 @@ bool beat = false; // compute the avg of the circular buffer up to now - double mult = (double)9/8; + double mult = (double)17/16; double et = mult*cb_avg(cb); if(item > et) { diff --git a/src/music_visualizer.c b/src/music_visualizer.c index ec6a90e..832569f 100644 --- a/src/music_visualizer.c +++ b/src/music_visualizer.c @@ -101,7 +101,7 @@ int statusHeight = 0; int statusCol = 0; bool toggleStatus = true; - bool subWindow = false; + bool subWindow = true; short cnt_over = 0; // in case no data is available for too much unsigned int energyThreshold = 0; bool beat = false; @@ -216,7 +216,7 @@ print_rate_info(sampleRate, nsamples, maxC, status->song->duration_sec, beat); cnt_over = 0; } - print_mpd_status(status, maxC, statusHeight+maxR/6, statusCol); + print_mpd_status(status, maxC, maxR/2-statusHeight-2, statusCol); } #endif // refresh screen @@ -224,14 +224,14 @@ wrefresh(mainwin); if(subWindow) { - print_subw(sub, beat, maxR/2, maxC/2); + print_subw(sub, beat, maxR/10, maxC); box(sub, 0, 0); wrefresh(sub); // refresh sub window - wresize(sub, maxR/2, maxC/2); - mvwin(sub, maxR/4, maxC/4); + wresize(sub, maxR/10, maxC); + mvwin(sub, maxR*9/10+1, 0); } getmaxyx(stdscr, maxR, maxC); @@ -282,7 +282,7 @@ nodelay(stdscr, TRUE); // space invaders window - WINDOW* sub = subwin(mainwin, maxR/2, maxC/2, maxR/4, maxC/4); + WINDOW* sub = subwin(mainwin, maxR/10, maxC, maxR*9/10+1, 0); // call the fifo processor int res = main_event(fifo, mainwin, sub); diff --git a/src/utils_curses.c b/src/utils_curses.c index c01b09f..c59fa24 100644 --- a/src/utils_curses.c +++ b/src/utils_curses.c @@ -130,13 +130,16 @@ int row, col; int color = 5; - int rr = genrand_int32() % maxR; + int rr = genrand_int32() % maxR/3; + + rr += maxR/3; for (row=0; row= rr-maxR/4 ) { - mvwaddch(sub, row, col, '#'); + if(beat) { // && + /* row <= rr+maxR/4 && row >= rr-maxR/4 && */ + /* col >= maxC/3 && col <= maxC*2/3) { */ + mvwaddch(sub, row, col, '|'); } else { if(col % 2 == 0) { mvwaddch(sub, row, col, '.'); @@ -146,7 +149,9 @@ } } } - if(beat) mvprintw(maxR/2, maxC/2, "* CLAP *"); + mvwprintw(sub, 1, maxC/2-6, " ---------- "); + mvwprintw(sub, 2, maxC/2-6, " || BEAT || "); + mvwprintw(sub, 3, maxC/2-6, " ---------- "); } @@ -165,9 +170,10 @@ mvprintw(7, 0, "* Move status panel (if built with libmpdclient): up / down / left / right keys"); mvprintw(8, 0, "* Reset status panel position: r"); mvprintw(9, 0, "* Toggle status display: t"); - mvprintw(10, 0, "* Print this help: h"); + mvprintw(10, 0, "* Toggle beat display: s"); + mvprintw(11, 0, "* Print this help: h"); color_set(1, NULL); - mvprintw(11, 0, "--> Press any key to continue."); + mvprintw(12, 0, "--> Press any key to continue."); timeout(-1); getch(); timeout(0); @@ -193,9 +199,6 @@ mvprintw(0, center, " -------------------------------- ", rate, nsamples); mvprintw(2, center, " ------------[mvc]--------------- ", rate, nsamples); } - if(beat) { - mvprintw(3, center, " ============ *BEAT ============== ", rate, nsamples); - } }