commit d5ed2c61244b5ee0a65da6d265953268d8b6f4dc
parent 89d1c6e31941dce7d2a950613c8adf737b201448
Author: lostd <lostd@2f30.org>
Date: Wed, 8 Jun 2016 22:35:06 +0100
Add keys for changing the step amount
Diffstat:
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/README b/README
@@ -1,12 +1,14 @@
visual:
- pos: -1.0000
+ step: 0.062500
+ pos: -1.000000
|||------------+--------------
movement:
h,l -- move crossfader left/right by one step
+ j,k -- halve/double the step amount
^H,^L -- snap to leftmost, center, rightmost positions
monitor control:
diff --git a/ncmixer.c b/ncmixer.c
@@ -33,8 +33,6 @@
#define RATE 44100
#define CHANS 2
#define NSAMPLES 2048
-#define STEP 0.0625f
-#define ROUND(xfpos) ((int)((xfpos) / STEP) * STEP)
#ifdef DEBUG
#define DEBUG_FD 8
@@ -49,6 +47,7 @@
/* mixer state */
float xfpos = 0.; /* values in [-1.0, 1.0] */
+float step = 0.0625f;
/* forward decls */
struct input;
@@ -196,10 +195,16 @@ key_cb(int fd)
DPRINTF_D(c);
switch (c) {
case 'h':
- xfpos = MAX(ROUND(xfpos) - STEP, -1.0f);
+ xfpos = MAX(xfpos - step, -1.0f);
break;
case 'l':
- xfpos = MIN(ROUND(xfpos) + STEP, 1.0f);
+ xfpos = MIN(xfpos + step, 1.0f);
+ break;
+ case 'j':
+ step = MAX(step / 2, 0.015625f);
+ break;
+ case 'k':
+ step = MIN(step * 2, 0.25f);
break;
case CONTROL('H'):
if (xfpos > 0.)
@@ -345,7 +350,8 @@ draw(void)
printw("ch1_monitor: %d\n", inputs[1].monitor);
printw("ch0_connected: %d\n", inputs[0].clifd != -1);
printw("ch1_connected: %d\n", inputs[1].clifd != -1);
- printw("pos: %0.4f\n", xfpos);
+ printw("step: %0.6f\n", step);
+ printw("pos: %0.6f\n", xfpos);
printw("\n");
draw_xfader();
refresh();