ncmixer

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

commit 4467d76f3e607b64e5bcba38c80acfbe143f1df4
parent 1dbad1ae29c1aaa1faecce0d77d8dc65f27510f3
Author: sin <sin@2f30.org>
Date:   Sat, 11 Jun 2016 10:52:45 +0100

Add support for leveling inputs

Diffstat:
ncmixer.c | 31+++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/ncmixer.c b/ncmixer.c @@ -63,9 +63,10 @@ struct input { short attenuated_buf[NSAMPLES]; int nsamples; int monitor; + float level; } inputs[] = { - { .listenfd = -1, .clifd = -1 }, - { .listenfd = -1, .clifd = -1 } + { .listenfd = -1, .clifd = -1, .level = 1.0f }, + { .listenfd = -1, .clifd = -1, .level = 1.0f } }; struct output { @@ -207,6 +208,18 @@ key_cb(int fd) case '2': inputs[1].monitor = !inputs[1].monitor; break; + case 'q': + inputs[0].level = MAX(inputs[0].level - 0.125f, 0.0f); + break; + case 'w': + inputs[0].level = MIN(inputs[0].level + 0.125f, 1.0f); + break; + case 'o': + inputs[1].level = MAX(inputs[1].level - 0.125f, 0.0f); + break; + case 'p': + inputs[1].level = MIN(inputs[1].level + 0.125f, 1.0f); + break; } return 0; } @@ -226,6 +239,18 @@ consume(struct input *in) } void +level(struct input *in) +{ + short *ch0 = (short *)in->buf; + int i; + + for (i = 0; i < in->nsamples; i++) { + *ch0 *= in->level; + ch0++; + } +} + +void attenuate(struct input *in, float factor) { short *ch0 = (short *)in->buf; @@ -448,6 +473,8 @@ loop(void) pfd[in->clifd].events = 0; close(in->clifd); in->clifd = -1; + } else { + level(in); } } }