Hello Guest

Panning between Left and Right speakers

  • 9 Replies
  • 20487 Views
Panning between Left and Right speakers
« on: May 15, 2008, 19:06:42 »
Does anyone know how to control the volume of a source out of each speaker?

Re: Panning between Left and Right speakers
« Reply #1 on: May 15, 2008, 22:18:25 »
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.

Re: Panning between Left and Right speakers
« Reply #2 on: May 15, 2008, 22:23:15 »
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.

Re: Panning between Left and Right speakers
« Reply #3 on: May 16, 2008, 00:28:21 »
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.
« Last Edit: May 16, 2008, 00:49:00 by paulscode »

Re: Panning between Left and Right speakers
« Reply #4 on: May 18, 2008, 16:36:27 »
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.

Re: Panning between Left and Right speakers
« Reply #5 on: May 18, 2008, 19:28:15 »
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?

*

Offline bobjob

  • ****
  • 394
  • LWJGL: WOW SO GOOD
Re: Panning between Left and Right speakers
« Reply #6 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?

Re: Panning between Left and Right speakers
« Reply #7 on: May 19, 2008, 11:34:45 »
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!
« Last Edit: May 20, 2008, 03:04:03 by paulscode »

*

Offline bobjob

  • ****
  • 394
  • LWJGL: WOW SO GOOD
Re: Panning between Left and Right speakers
« Reply #8 on: May 21, 2008, 05:27:11 »
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);

Re: Panning between Left and Right speakers
« Reply #9 on: May 21, 2008, 23:09:50 »
That is a great idea.  Looks like I won't have to now, but thanks!