Panning between Left and Right speakers

Started by paulscode, May 15, 2008, 19:06:42

Previous topic - Next topic

paulscode

Does anyone know how to control the volume of a source out of each speaker?

wolf_m

I'll assume that you've got a prerendered stereo audio file that you're playing back.

The easiest and most reliable way in that case is to split your stereo source into two mono sources (left and right) with audacity or whatever tool you prefer. Then you can change the volumes of the sources.

The downside is that you've got an extra source.

For individual 3D sources, OpenAL is supposed to control the panning of the sources for you as they move. Stereo sources do not provide that feature.
So in that case you have to manipulate the source positions to get panning, but again, that only works for mono sources, at least that was the case the last time I checked.

I'd love to hear of a way to control the listener's overall panning via OpenAL.

wolf_m

Here's a related quote for you:
http://www.openal.org/oalspecs-specs/x44.html
Quote
OpenAL is foremost a means to generate audio in a simulated three-dimensional space. Consequently, legacy audio concepts such as panning and left/right channels are not directly supported.

paulscode

Yeh, I thought of using two mono sources, but I was wondering if it could be done with a single source.  Guess it isn't possible, according to that quote.  Seems odd that OpenAL doesn't have this ability.  Even the buggy old Javasound library allows panning.

My experience with OpenAL's built-in 3D panning of mono sources, is that it doesn't work very well.  I can only hear the panning when the source is really close to the listener, like distance <= 1.  Further distances do not seem to pan, regardless of their position in relation to the listener.  I don't know if it is just my soundcard, or what.  You wouldn't happen to have any experience with this, would you?  I'm thinking maybe there are some AL settings I have to change or something to get OpenAL's built-in panning to work for far-away mono sources.

wolf_m

Maybe your sources are omnidirectional? Then you need to change that. You need to use a cone.

See OpenAL 1.1 docs, section 4.3.2, Direction and Cone and OpenAL 1.0 docs - Source Attributes - Direction and Cone. I'm not sure which version lwjgl is using (I think it's OAL1.0), but it operates in the same way in both versions.

OpenAL's 3D panning of mono sources works, the problem is that if you've got an omnidirectional source, you will almost always hear the output left and right.

I don't have experience with that though, so you'll have to wrestle with it by yourself. Feel free to enlighten us after you've got it.

paulscode

Hmm.  That seems rather unrealistic.  Many sources in real life are omnidirectional, but if a sound is to you right, regardless of how far away it is, you're going to hear it out of your right ear louder than your left one.

So how does that work, do I make every source directional, pointed at the listener, or what?

bobjob

cant you just use openAL with a mono sound. and change its 3d position relative to the listener, depending on how loud u want it?

paulscode

Quote from: bobjob on May 19, 2008, 03:01:02
cant you just use openAL with a mono sound. and change its 3d position relative to the listener, depending on how loud u want it?

The "loudness" part is working fine (far away sounds are quiet, closer ones louder), and yes I am using mono sounds.  The problem is the panning between left and right speaker only works when the sound is very close (honestly this seems like a bug to me).  I am talking about a source that is to the right of the listener should play louder out of the right speaker, and a source that is to the left of the listener should play louder out of the left speaker.  This works the way I would expect when the source is close, but when a source is further away, then the source plays equal volume out of both speakers (getting quieter with distance, but not panning between left and right speakers depending on 3D position).  I am using omnidirectional sources as mentioned, and I haven't had a chance to try the directional sources yet.  When I get some time to work on this again, I will try it and post whether or not this corrects the problem.  Also, I am going create a simple example to demonstrate the problem, and I'll post the source.

-- EDIT--
In creating the demonstration applet, I discovered that it doesn't have the problem I described above.  Means there is a bug in my original coding, so this question is no longer relevant.  This is the third time I've asked about a lwjgl problem, then solved it myself while trying to demonstrate it to other people.  Oh, well - as long as I can keep solving the problems as they pop up!

;D Thanks for the help!

bobjob

then i guess 1 way 2 get it working the way you'd like is by always keeping the sound close, and manually adjusting the gain.
AL10.alSourcef(source, AL10.AL_GAIN , (float)gain);

paulscode

That is a great idea.  Looks like I won't have to now, but thanks!