[Openal-devel] new panning algorithm

Christian Borss christian.borss at rub.de
Mon Jan 19 02:17:51 PST 2009


Am 19. Jan. 2009 um 10:39 Uhr schrieb Christian Borss:

>But you are right, it would be a more clean implementation to avoid a
>division by zero.

How about:

static __inline ALint aluCart2LUTpos(ALfloat re, ALfloat im)
{
    ALint pos;
    ALfloat denum;

    denum = aluFabs(re) + aluFabs(im);
    if (denum == 0.0)
        return 0;
    pos = round(QUADRANT_NUM * aluFabs(im) / denum);
    if (re < 0.0)
        pos = 2 * QUADRANT_NUM - pos;
    if (im < 0.0)
        pos = LUT_NUM - pos;
    return pos % LUT_NUM;
}


Ciao,
Christian
-- 
Christian Borß, Dipl.-Ing.          ||   Institut für Kommunikationsakustik
http://www.ika.ruhr-uni-bochum.de   ||   Ruhr-Universität Bochum
Tel.: +49-(0)234-32-22470           ||   Universitätsstr. 150, IC1/33
Fax.: +49-(0)234-32-14165           ||   D-44780 Bochum (Germany)


More information about the Openal-devel mailing list