summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorXANTRONIX Development2022-01-31 23:33:12 -0500
committerXANTRONIX Development2022-01-31 23:33:12 -0500
commit617cac672b997ffde087caafbbbf54f7a6c46714 (patch)
treedf6b83cc5ba48acede8e4b9ecabe1e397ecf8bbf /src
parent918a7f459a2bebb178efa269afaab43fadb6fdb6 (diff)
downloadxas-617cac672b997ffde087caafbbbf54f7a6c46714.tar.gz
xas-617cac672b997ffde087caafbbbf54f7a6c46714.tar.bz2
xas-617cac672b997ffde087caafbbbf54f7a6c46714.zip
Ensure gain is factored into mixer input sources
Diffstat (limited to 'src')
-rw-r--r--src/mixer.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/mixer.c b/src/mixer.c
index 001c765..0f3b5b1 100644
--- a/src/mixer.c
+++ b/src/mixer.c
@@ -10,50 +10,54 @@
static void mixer_apply_mono_to_mono(int16_t *dest,
int16_t *src,
size_t count,
+ float gain,
float bias_l,
float bias_r) {
size_t i;
for (i=0; i<count; i++) {
- dest[i] += src[i];
+ dest[i] += 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) {
size_t i;
for (i=0; i<count; i++) {
- dest[i*2] += bias_l * src[i];
- dest[i*2+1] += bias_r * src[i];
+ dest[i*2] += gain * bias_l * src[i];
+ dest[i*2+1] += gain * 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) {
size_t i;
for (i=0; i<count; i++) {
- dest[i*2] += bias_l * src[i*2];
- dest[i*2+1] += bias_r * src[i*2+1];
+ dest[i*2] += gain * bias_l * src[i*2];
+ dest[i*2+1] += gain * 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) {
size_t i;
for (i=0; i<count; i++) {
- dest[i] += (src[i*2] + src[i*2+1]) / 2;
+ dest[i] += gain * ((src[i*2] + src[i*2+1]) / 2);
}
}
@@ -74,6 +78,7 @@ static ssize_t mixer_fill(xas_mixer *mixer,
int16_t *,
size_t,
float,
+ float,
float);
xas_mixer_input *next = input->next;
@@ -102,6 +107,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);