« Return to Thread: new panning algorithm

Re: new panning algorithm

by Christian Borss :: Rate this Message:

Reply to Author | View in Thread

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)
_______________________________________________
Openal-devel mailing list
Openal-devel@...
http://opensource.creative.com/mailman/listinfo/openal-devel

 « Return to Thread: new panning algorithm