Re: [AD] Allegro's mixer

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Wednesday 17 March 2004 17:12, Chris wrote:
> Ben Davis wrote:
> >Anyway, yeah, I welcome the changes - although perhaps we should go
> > flat-out for 32-bit mixing if we're doing final-stage conversion at all?
>
> Currently volumes use 16-bit precision, any sample size above 16-bit
> would potentially cause an overflow of the 32-bit registers (x-bit *
> y-bit == (x+y)-bit). You could change to use 8-bit volume precision then
> you could do 24-bit streams, but that's about it. You can't use 64-bit
> or floating-point math, since the mixer is run in a timer, and according
> to scale64() in digmid.c: "it is impossible to reliably lock the
> compiler helpers that implement a 64 bit divide, and it isn't safe to
> use the i386 FPU stack in an interrupt context."

DUMB manages to combine 24-bit samples with a 16-bit volume:

#define MULSC(a, b) ((int)((LONG_LONG)((a) << 4) * ((b) << 12) >> 32))

a is the 24-bit value and b is the 16-bit value. GCC does the two shifts and 
then uses a multiply into EDX:EAX and uses the value in EDX. DUMB's mixer 
seems to be just as fast as ModPlugXMMS (in mono; in stereo there's an 
unrelated difference that makes it slower).

Took me ages to come up with the idea for that macro. :)

Ben




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/