Sign in to follow this  

OpenAL setting listener position

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

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