On Sat, 14 May 2011 17:55:06 +0200 Alexandre Ratchov <a...@caoua.org> wrote:
> On Sat, May 14, 2011 at 06:26:57PM +0300, Sviatoslav Chagaev wrote: > > > > Then the only thing that remains -- is to add clipping in mix_badd(). > > Yes, if the other diff goes in, handling clipping makes sense. > > > This will give aucat all the bits and pieces to meet the requirements > > of all kinds of users. > > > > (Tested on i386 and amd64 with 16 and 24 bits ADATA) > > > > > > Index: aproc.c > > =================================================================== > > RCS file: /cvs/src/usr.bin/aucat/aproc.c,v > > retrieving revision 1.64 > > diff -u -p -r1.64 aproc.c > > --- aproc.c 28 Apr 2011 07:20:03 -0000 1.64 > > +++ aproc.c 14 May 2011 14:42:58 -0000 > > @@ -617,6 +617,11 @@ mix_badd(struct abuf *ibuf, struct abuf > > unsigned i, j, cc, istart, inext, onext, ostart; > > unsigned scount, icount, ocount; > > int vol; > > +#if ADATA_BITS <= 16 > > + register int data; > > +#else > > + register long long data; > > +#endif > > > > it's ok this to be an int in both cases, since ints are 32-bit > an samples are at most 24-bit. > > > #ifdef DEBUG > > if (debug_level >= 4) { > > @@ -673,7 +678,13 @@ mix_badd(struct abuf *ibuf, struct abuf > > idata += istart; > > for (i = scount; i > 0; i--) { > > for (j = cc; j > 0; j--) { > > - *odata += ADATA_MUL(*idata, vol); > > + data = *odata; > > + data += ADATA_MUL(*idata, vol); > > + if (data < -ADATA_UNIT) > > + data = -ADATA_UNIT; > > + else if (data > (ADATA_UNIT-2)) > > + data = (ADATA_UNIT-2); > ^^^^^^^^^^^^^^ > ADATA_UNIT - 1 > > samles are in the -ADATA_UNIT .. (ADATA_UNIT - 1) range Sorry =( > > > > + *odata = (adata_t) data; > > idata++; > > odata++; > > } > -- Alexandre