# OpenAL favoring one channel too heavily

This topic is 2561 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm attempting to use OpenAL, and have encountered the following problem, also mentioned but not adequately solved here:

The closer the listener and source Z location values are to each other, the more the sound will be played exclusively out of one speaker or the other when the X values don't match. Obviously this is a desired behaviour to a point, but OpenAL takes it to extremes depending on the Z values. It is worst when the Z values exactly match- then if the X values aren't identical, 100% of the sound will come out of one speaker only, depending on which side the sound is on. So there's an enormous discontinuity when crossing from -x to +x: it goes from 100% L 0% R to 0%L 100%R, or vice versa, complete with a nasty little pop. The attenuation still works fine, but the degree to which it favors one channel is problematic, especially with headphones- hearing a sound through only one ear is both unpleasant and unnatural.

The post linked above mentioned just artificially setting the Z values to something different, and yes, that works to some degree, but as the X distance between listener and source increases, it will still eventually be favoring one speaker over the other more than sounds pleasant on headphones. Increasing the Z difference linearly with the X difference + a constant works for a single listener+source pair, but gets more math intensive for multiple sources than seems like should be necessary. At that point I might as well do the attenuation and balance calculations myself too, and then what exactly is OpenAL doing for me, besides possibly a bunch of redundant math?

I assume ALUT's special "hello world" sound is mono, and I'm certain engine.wav is. The behaviour is the same for both.

I find it hard to believe this is deliberate behaviour. Am I doing something wrong? Most of this is straight out of the most basic ALUT example.

A sample which will play 100% of the sound out of only one speaker:
 ALuint helloBuffer, helloSource; alutInit (&argc, argv); helloBuffer = alutCreateBufferHelloWorld (); // helloBuffer = alutCreateBufferFromFile("sounds/engine.wav"); alGenSources (1, &helloSource); alSourcei (helloSource, AL_BUFFER, helloBuffer); alSourcef(helloSource,AL_REFERENCE_DISTANCE,500); alSourcei(helloSource,AL_LOOPING,AL_TRUE); alSource3f(helloSource,AL_POSITION,-10,0,0); alListener3f(AL_POSITION,0,0,0); alSourcePlay (helloSource); 

It's a 2D game, so I can kind of solve the problem by setting all X listener and source values to 0, and pretending my X values are Z values instead- that at least gives me proper distance attenuation in all directions, so it's what I'll do if it ends up this is all intentional behaviour, but it also gives me zero stereo effect. I'd like to have some, but not have it go nuts with matching Z values.

I'm using mingw on win7, if that's relevant.