Menu

#26 DirectX Sound Panning Bug

closed
nobody
Windows (54)
7
2012-10-09
2001-07-14
Anonymous
No

The DirectX sound panning code is still incorrect in
Allegro 3.9.37. I submitted this to an 'Allegro bugs
mailing list,' but it was ignored.

The problem is: DirectX sound playback locks the
panning to Left/Center/Right, rather than making
sounds pan smoothly from one speaker to another. This
is due to DirectX's decibel panning attenuation, which
does not have a linear relationship with Allegro's
integer panning values. It is easy to fix:

src/win/wdsound.c

Under linear_to_millibel (line 148), place the
following declaration:

static float pan_attenuation[256];

Initialize the panning array (line 422) inside
digi_directsound_init(int, int):

/ setup allegro panning to decibal speaker
attenuation table
/
for (v = 0; v < 256; v++) {
double pan = v;
if (pan > 127) {
pan = 255 - pan;
if (pan != 0) {
double mul = pan / 128.0;
pan = -log10(mul) * 1000;
if (pan > DSBPAN_RIGHT) { pan = DSBPAN_RIGHT; }
} else {
pan = DSBPAN_RIGHT;
}
} else {
if (pan != 0) {
double mul = pan / 128.0;
pan = log10(mul) * 1000;
if (pan < DSBPAN_LEFT) { pan = DSBPAN_LEFT; }
} else {
pan = DSBPAN_LEFT;
}
}
pan_attenuation[v] = (float) pan;
}

Under digi_directsound_set_pan(int, int) (line 968),
change ds_pan = DSBPAN_LEFT... to the following line:

int ds_pan = pan_attenuation[pan];


Now DirectX sound should pan smoothly from one speaker
to another, as it is supposed to do.

Thanks for fixing this,
Connelly Barnes

"This is the Eternal Kingdom of Zeal, where dreams can
come true! But at what price?"

Discussion

  • Nobody/Anonymous

    Logged In: NO

    Oh, looks like Sourceforce butchered the code indentation.

    Sorry.

     
  • Eric Botcazou

    Eric Botcazou - 2001-07-25

    Logged In: YES
    user_id=113920

    I didn't see your post on the [AD] or the [AL] lists: it
    was likely rejected by the server because you're not a
    subscriber to the lists.

    I'll have a look at the bug as soon as I can. Could you
    give me any mean to contact you ?

     

Log in to post a comment.