diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mixer.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/src/mixer.c b/src/mixer.c index 60233de..8b41152 100644 --- a/src/mixer.c +++ b/src/mixer.c @@ -7,57 +7,55 @@ #include <xas/audio.h> #include <xas/mixer.h> +struct params { + float gain, + bias_l, + bias_r; +}; + static void mixer_apply_mono_to_mono(int16_t *dest, int16_t *src, size_t count, - float gain, - float bias_l, - float bias_r) { + struct params params) { size_t i; for (i=0; i<count; i++) { - dest[i] += gain * src[i]; + dest[i] += params.gain * src[i]; } } static void mixer_apply_mono_to_stereo(int16_t *dest, int16_t *src, size_t count, - float gain, - float bias_l, - float bias_r) { + struct params params) { size_t i; for (i=0; i<count; i++) { - dest[i*2] += gain * bias_l * src[i]; - dest[i*2+1] += gain * bias_r * src[i]; + dest[i*2] += params.gain * params.bias_l * src[i]; + dest[i*2+1] += params.gain * params.bias_r * src[i]; } } static void mixer_apply_stereo_to_stereo(int16_t *dest, int16_t *src, size_t count, - float gain, - float bias_l, - float bias_r) { + struct params params) { size_t i; for (i=0; i<count; i++) { - dest[i*2] += gain * bias_l * src[i*2]; - dest[i*2+1] += gain * bias_r * src[i*2+1]; + dest[i*2] += params.gain * params.bias_l * src[i*2]; + dest[i*2+1] += params.gain * params.bias_r * src[i*2+1]; } } static void mixer_apply_stereo_to_mono(int16_t *dest, int16_t *src, size_t count, - float gain, - float bias_l, - float bias_r) { + struct params params) { size_t i; for (i=0; i<count; i++) { - dest[i] += gain * ((src[i*2] + src[i*2+1]) / 2); + dest[i] += params.gain * ((src[i*2] + src[i*2+1]) / 2); } } @@ -69,15 +67,19 @@ static ssize_t mixer_fill(xas_mixer *mixer, xas_audio_stream *output = mixer->output; xas_mixer_input *input = mixer->inputs; + struct params params = { + .gain = input->gain, + .bias_l = input->bias_l, + .bias_r = input->bias_r + }; + xas_audio_zero(output->format, mixer->buf, 0, mixer->buffer_size); while (input) { void (*mixer_apply)(int16_t *, int16_t *, size_t, - float, - float, - float); + struct params); xas_mixer_input *next = input->next; int16_t *buf; @@ -108,9 +110,7 @@ static ssize_t mixer_fill(xas_mixer *mixer, mixer_apply((int16_t *)(mixer->buf), buf, readlen, - input->gain, - input->bias_l, - input->bias_r); + params); if (total < readlen) { total = readlen; @@ -148,7 +148,7 @@ static int set_gain(xas_mixer *mixer, float gain) { return 0; } -static int noop(xas_mixer *mixer) { +static int noop() { return 0; } |