Sign in to follow this  

OpenAL favoring one channel too heavily

This topic is 2488 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 [url="http://www.gamedev.net/topic/533317-openal-and-source-position/page__p__4447806__hl__openal__fromsearch__1#entry4447806"]here[/url]:

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:
[code]
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);
[/code]

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

This topic is 2488 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this