Cannot get sound to change by moving the Listeners position in OpenAL?

Started by
4 comments, last by kburkhart84 19 years, 1 month ago
My problem is that i cannot get the sound to get louder or softer by moving the position of the Listener away from or to the source. What puzzles me is the Source works fine. I can move its position all around and the sound will change accordingly. I am using the default distance model. I use this function to set the Listeners position to the cameras position. float cameraPos[3]; alListenerfv(AL_POSITION, cameraPos); Am I not doing something right before I set the Listeners position or do I have to set something up for it to recognize when the listeners position has moved or am i not using the correct function to set the position? Why does it work when the Sources postion moves and doesnt when the Listeners position moves? Can anyone help.
Advertisement
With the code you gave below ... all I can get is you are not initializing the cameraPos array. If that doesnt work then try ...

alListener3f (AL_POSITION, X, Y, Z);

where X, Y & Z are the Listener's value on X, Y & Z Axis.

Hope that helps.
[edit] First try The Lion King's post, I think he/she is correct. I didn't see that till later [embarrass]. Make sure to set: cameraPos[0], cameraPos[1], and cameraPos[2] to valid numbers! If that does not work, try mine, but the King's suggestion should fix it for you.

Quote:Original post by codyc
Why does it work when the Sources postion moves and doesnt when the Listeners position moves?
Can anyone help.


The last time that I helped someone with this exact problem, they did not have the updated sound drivers for their computer. They were relucant to update, but finally gave in and it fixed their problem. I would suggest that you try the same thing as well as make sure you have the most recent OpenAL runtime installed.

- Drew
Thanks for the try but thats not it. I didnt put the code in there that initializes the cameraPos. I put the cameraPos in there to show what i was passing in for the other parameter of the function. I did think that was the problem at first too and checked it. The Listener is actually getting the position when i set it but for some reason it doesnt make a difference. I also checked to see if the Sources position was somehow following the Listeners but its not.
Well ... there are other means of setting up the listener position. See the documentation for it. If even that doesnt work ... then I would suggest that get updated sound drivers and get a working dll from someone who has done that.

The current one in OpenAl.org is buggy and deosnt do a couple of things I am sure about. There are a few bugs in it.

This can be one too. One in the old one was that the pause didnt work.

You will have to check it ... cause things get pretty frustrated when you work with OpenAL :)
Besides the file/driver update, I can only think that maybe this. I know that the listener and the source position/rotation/whatever must be set before playing the sound when you want to see the difference. If you are looping the sound then changing the listener pos, it won't work. You have to play each time you move the listener. I had this problem and I fixed it this way. That may be it.


This topic is closed to new replies.

Advertisement