ncmixer

ncurses audio mixer with cross-fade support
git clone git://git.2f30.org/ncmixer.git
Log | Files | Refs | README | LICENSE

commit bf3bce37aade59912035f0214b8796073a6f309e
parent 9413f4fc2d436144a39293ea7de996fda9a438c4
Author: lostd <lostd@2f30.org>
Date:   Tue Jun  7 02:06:56 +0100

Draw the crossfader bar

Diffstat:
ncmixer.c | 32++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+), 0 deletions(-)
diff --git a/ncmixer.c b/ncmixer.c @@ -21,6 +21,7 @@ #define MIN(x, y) ((x) < (y) ? (x) : (y)) #undef MAX #define MAX(x, y) ((x) > (y) ? (x) : (y)) +#define ISODD(x) ((x) & 1) #define CONTROL(c) ((c) ^ 0x40) #define SA struct sockaddr #define CH0_NAME "/tmp/ch0" @@ -339,6 +340,35 @@ server_listen(char *name) } void +draw_xfader(void) +{ + int i, start, end, len, center; + float pos; + + if (COLS < strlen(" -|+|- ")) + return; + + start = 2; + end = ISODD(COLS) ? COLS - 2 : COLS - 3; + len = end - start; + center = start + (len - 1) / 2; + move(getcury(stdscr), start); + for (i = 0; i < len; i++) + printw("-"); + + pos = xfpos + 1.0; /* make it positive */ + pos /= 2.0; /* scale it */ + i = start + (len - 1) * pos; + move(getcury(stdscr), i - 1); + printw("|||"); + + if (i != center - 1 && i != center + 1) { + move(getcury(stdscr), center); + printw("+"); + } +} + +void draw(void) { move(0, 0); @@ -359,6 +389,8 @@ draw(void) default: printw("direction: none\n"); } + printw("\n"); + draw_xfader(); refresh(); }