From 638b66d498c05dee38f7c910fc7f5c8478706878 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Thu, 26 May 2011 09:45:07 +0200 Subject: [PATCH] make clipping less ugly --- aucat/aproc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/aucat/aproc.c b/aucat/aproc.c index de82a4f..f202356 100644 --- a/aucat/aproc.c +++ b/aucat/aproc.c @@ -616,7 +616,7 @@ mix_badd(struct abuf *ibuf, struct abuf *obuf) unsigned cmin, cmax; unsigned i, j, cc, istart, inext, onext, ostart; unsigned scount, icount, ocount; - int vol; + int vol, s; #ifdef DEBUG if (debug_level >= 4) { @@ -673,7 +673,12 @@ mix_badd(struct abuf *ibuf, struct abuf *obuf) idata += istart; for (i = scount; i > 0; i--) { for (j = cc; j > 0; j--) { - *odata += ADATA_MUL(*idata, vol); + s = *odata + ADATA_MUL(*idata, vol); + if (s >= ADATA_UNIT) + s = ADATA_UNIT - 1; + else if (s < -ADATA_UNIT) + s = -ADATA_UNIT; + *odata = s; idata++; odata++; }