nausea

curses audio visualizer
git clone git://git.2f30.org/nausea
Log | Files | Refs | README | LICENSE

commit 46130eb508efa681b2a0bce7a76f1c9661ee6fea
parent b48d4d078f8ad33a7d1d61011c1e78cfd4981c2b
Author: lostd <lostd@2f30.org>
Date:   Mon, 15 Sep 2014 23:33:52 +0100

Bounce mode

Diffstat:
Mnausea.1 | 6+++++-
Mnausea.c | 28++++++++++++++++++++++++----
2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/nausea.1 b/nausea.1 @@ -6,7 +6,7 @@ .Nd curses audio visualizer .Sh SYNOPSIS .Nm nausea -.Op Fl hcpkl +.Op Fl hcpklb .Op Fl d Ar num .Op Ar fifo .Sh DESCRIPTION @@ -34,6 +34,8 @@ Enable falling peaks in the spectrum visualization. Keep state in the fountain visualization. .It Fl l Go left in the fountain visualization. +.It Fl b +Enable bounce mode in the fountain visualization. .El .Pp Exposed runtime options: @@ -52,4 +54,6 @@ Toggle falling peaks. Toggle keep state. .It l Toggle direction. +.It b +Toggle bounce mode. .El diff --git a/nausea.c b/nausea.c @@ -24,6 +24,7 @@ static int colors; static int peaks; static int keep; static int left; +static int bounce; static int die; struct frame { @@ -399,11 +400,24 @@ draw_fountain(struct frame *fr) } } + /* current column bounces back */ + if (bounce) + if (left) + if (col == 0) + left = 0; + else + col--; + else + if (col == fr->width - 1) + left = 1; + else + col++; /* current column wraps around */ - if (left) - col = (col == 0) ? fr->width - 1 : col - 1; else - col = (col == fr->width - 1) ? 0 : col + 1; + if (left) + col = (col == 0) ? fr->width - 1 : col - 1; + else + col = (col == fr->width - 1) ? 0 : col + 1; attroff(A_BOLD); refresh(); @@ -425,7 +439,7 @@ initcolors(void) static void usage(void) { - fprintf(stderr, "usage: %s [-hcpkl] [-d num] [fifo]\n", argv0); + fprintf(stderr, "usage: %s [-hcpklb] [-d num] [fifo]\n", argv0); fprintf(stderr, "default fifo path is `/tmp/audio.fifo'\n"); exit(1); } @@ -469,6 +483,9 @@ main(int argc, char *argv[]) case 'l': left = 1; break; + case 'b': + bounce = 1; + break; case 'h': /* fall-through */ default: @@ -519,6 +536,9 @@ main(int argc, char *argv[]) case 'l': left = !left; break; + case 'b': + bounce = !bounce; + break; case '1': draw = draw_spectrum; break;