ncmixer

ncurses audio mixer for DJ'ing
git clone git://git.2f30.org/ncmixer
Log | Files | Refs | README | LICENSE

commit ff8dede675556cc10eec9bd45943ab80802129bb
parent b86601468f91193eccd553d759cf5a37ab5d03d2
Author: lostd <lostd@2f30.org>
Date:   Sat, 11 Jun 2016 11:22:27 +0100

Make level step a variable and draw both levels

Diffstat:
Mncmixer.c | 30++++++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/ncmixer.c b/ncmixer.c @@ -48,6 +48,7 @@ /* mixer state */ float xfpos = 0.; /* values in [-1.0, 1.0] */ float step = 0.0625f; +float level_step = 0.125f; /* forward decls */ struct input; @@ -209,16 +210,16 @@ key_cb(int fd) inputs[1].monitor = !inputs[1].monitor; break; case 'q': - inputs[0].level = MAX(inputs[0].level - 0.125f, 0.0f); + inputs[0].level = MAX(inputs[0].level - level_step, 0.0f); break; case 'w': - inputs[0].level = MIN(inputs[0].level + 0.125f, 1.0f); + inputs[0].level = MIN(inputs[0].level + level_step, 1.0f); break; case 'o': - inputs[1].level = MAX(inputs[1].level - 0.125f, 0.0f); + inputs[1].level = MAX(inputs[1].level - level_step, 0.0f); break; case 'p': - inputs[1].level = MIN(inputs[1].level + 0.125f, 1.0f); + inputs[1].level = MIN(inputs[1].level + level_step, 1.0f); break; } return 0; @@ -345,6 +346,26 @@ draw_status(void) } void +draw_levels(void) +{ + int start, end, len, nsteps, i; + + start = 2; + end = ISODD(COLS) ? COLS - 2 : COLS - 3; + len = 1.0f / level_step; + + move(getcury(stdscr), start); + nsteps = inputs[0].level / level_step; + for (i = 0; i < nsteps; i++) + printw("|"); + nsteps = inputs[1].level / level_step; + move(getcury(stdscr), end - len); + for (i = 0; i < nsteps; i++) + printw("|"); + printw("\n"); +} + +void draw_xfader(void) { int start, end, len, center, pos, i; @@ -387,6 +408,7 @@ draw(void) erase(); draw_status(); draw_xfader(); + draw_levels(); refresh(); }