Jump to content
  • Advertisement
Sign in to follow this  

OpenAL setting listener position

This topic is 3447 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

Hi everyone, I've found a couple people who had a similar problem, but so far no solutions. I am using OpenAL to play sounds in 3D space. I can set up a sound to play, and play it fine. I can set the listener position and orientation (at least no errors occur) and play, pause, stop, etc. However when I use
Al.alListenerfv(Al.AL_POSITION, Position.ToFloat());

there is no effect. So when I pan to the left, the sounds do not move to the right. It seems like the audio is coming from everywhere all the time. However:
Al.alListenerfv(Al.AL_ORIENTATION, Orientation.ToFloat());

does work as expected. Even more curious... If I move the source instead of the listener it works! I've ensured that my source is a mono wave file loaded using Alut. I've initialized Alut successfully. I'm at a loss as to what to try next. By default the sound should *not* be relative to the listener, and I've ensured that by using
Al.alSourcei(s_source[0], Al.AL_SOURCE_RELATIVE, Al.AL_FALSE);

Code that loads the buffer and sets the position.
            s_buffer[0] = Alut.alutCreateBufferFromFile(ResourceFile);
            if (s_buffer[0] == Al.AL_NONE)
                throw new UnableToLoadException("Could not load sound " + ResourceFile + ".");
            Al.alGenSources(1, s_source);
            Al.alSourcef(s_source[0], Al.AL_PITCH, 1.2f);
            Al.alSourcef(s_source[0], Al.AL_GAIN, 1.0f);
            Al.alSourcefv(s_source[0], Al.AL_POSITION, Vector3.Zero.ToFloat());
            Al.alSourcefv(s_source[0], Al.AL_VELOCITY, Vector3.Zero.ToFloat());
            Al.alSourcei(s_source[0], Al.AL_BUFFER, s_buffer[0]);
            Al.alSourcei(s_source[0], Al.AL_LOOPING, Al.AL_TRUE);
            Al.alSourcei(s_source[0], Al.AL_SOURCE_RELATIVE, Al.AL_FALSE);

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!