mirror of
https://github.com/ericonr/sndio.git
synced 2024-02-18 04:45:21 -06:00
make clipping less ugly
This commit is contained in:
parent
af674f331b
commit
638b66d498
@ -616,7 +616,7 @@ mix_badd(struct abuf *ibuf, struct abuf *obuf)
|
|||||||
unsigned cmin, cmax;
|
unsigned cmin, cmax;
|
||||||
unsigned i, j, cc, istart, inext, onext, ostart;
|
unsigned i, j, cc, istart, inext, onext, ostart;
|
||||||
unsigned scount, icount, ocount;
|
unsigned scount, icount, ocount;
|
||||||
int vol;
|
int vol, s;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (debug_level >= 4) {
|
if (debug_level >= 4) {
|
||||||
@ -673,7 +673,12 @@ mix_badd(struct abuf *ibuf, struct abuf *obuf)
|
|||||||
idata += istart;
|
idata += istart;
|
||||||
for (i = scount; i > 0; i--) {
|
for (i = scount; i > 0; i--) {
|
||||||
for (j = cc; j > 0; j--) {
|
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++;
|
idata++;
|
||||||
odata++;
|
odata++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user