commit d61e8d87c1dc34dc82ea82fb9870abc335399bee
parent 4716fde1bf500ad77a203c4c9c95c3ccd492a4d9
Author: Lazaros Koromilas <lostd@2f30.org>
Date: Sat, 16 Jul 2016 12:28:31 +0100
Avoid clipping when mixing.
Always divide by two to give enough headroom.
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ncmixer.c b/ncmixer.c
@@ -277,7 +277,7 @@ mix_master(struct output *out, struct input *in0, struct input *in1)
out->nsamples = MAX(in0->nsamples, in1->nsamples);
for (i = 0; i < out->nsamples; i++) {
- *buf = *ch0 * 0.707 + *ch1 * 0.707;
+ *buf = *ch0 * 0.5 + *ch1 * 0.5;
ch0++, ch1++, buf++;
}
return out->nsamples;
@@ -295,7 +295,7 @@ mix_monitor(struct output *out, struct input *in0, struct input *in1)
for (i = 0; i < out->nsamples; i++) {
*ch0 *= in0->monitor;
*ch1 *= in1->monitor;
- *buf = *ch0 * 0.707 + *ch1 * 0.707;
+ *buf = *ch0 * 0.5 + *ch1 * 0.5;
ch0++, ch1++, buf++;
}
return out->nsamples;