Advertisement

Directional sound depending on camera movement in openAL

Started by April 14, 2020 09:20 PM
1 comment, last by ChimDev 4 years, 7 months ago

I'm trying to get directional sound to work correctly in openAL. I'm getting sound, and it IS directional, but I'll explain the problem. The game is a 3d first person game, and if I move the character around an audio source the audio behaves as expected and seems to rotate appropriately, BUT the rotation of the player camera has no effect. Below is my current code, which is just a test, changing the -1 to 1 for example has zero effect in how the audio is perceived. The method is called every frame in the game, so it's not that. Anyone have a clue about what the issue could be?

To reiterate, setting AL_ORIENTATION has zero effect for me, whatever I set the values to.

		float[] playerOrientation = new float[6]; 
		
		// direction-vector
		playerOrientation[0] = 0; // x
		playerOrientation[1] = 0; // y
		playerOrientation[2] = -1; // z

		// up-vector
		playerOrientation[3] = 0; // x
		playerOrientation[4] = 1; // y
		playerOrientation[5] = 0; // z
		
		alListenerf(AL_ORIENTATION, playerOrientation[0]); 

Solved, it was a simple mistake, I should have used alListenerfv instead of alListenerf, and not use playerOrientation[0], just playerOrientation

This topic is closed to new replies.

Advertisement