Jump to content
  • Advertisement
Sign in to follow this  

OpenAL favoring one channel too heavily

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

If you intended to correct an error in the post then please contact us.

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);
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.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!