So, I have a little app (interfacing with the FMOD DLL)since its written in Python. My problem is this:
When the app starts, it loads some sounds, and begins playback of a random sound at (20, 0, 0). The orientation is set to (sin(theta), cos(theta), 0) for forward and (0, 0, 1) for upwards. When the application listens for events and receives a press of either the left or right arrow keys, it increases the theta by 15 or decreases it by 15, respectively, and recalculates the orientation. Here’s the code for that:

if event.type==sdl2.SDL_KEYUP and event.key.keysym.sym==sdl2.SDLK_RIGHT:
if theta+15.0>359.0:
theta=0.0
else:
theta+=15.0
forward_orientation = FMOD_VECTOR()
forward_orientation.x=math.sin(theta)
forward_orientation.y=math.cos(theta)
forward_orientation.z=0.0
upward_orientation = FMOD_VECTOR()
upward_orientation.x=0.0
upward_orientation.y=0.0
upward_orientation.z=1.0
res = fmod.FMOD_System_Set3DListenerAttributes(system, 0, None, None, ctypes.byref(forward_orientation), ctypes.byref(upward_orientation))
That’s for the increase. The decrease is similar. (I also do error checking, as well, below that.) The problem is, though the attributes are set, the sounds position doesn’t change at all. It does not seem to “orient”/“rotate” depending on where the listener is facing. I do call FMOD_System_Update(), as well, at the start of the loop. I’ve tried initializing the system object with both right-handed and default coordinate systems,and get the same result for both. What exactly am I doing wrong?

OK, so nothing I’ve tried has worked. I’ve significantly altered the code, and am now getting the error that the vectors aren’t perpendicular or of unit length when trying to set the listeners orientation. The code in my first post no longer functions as it did. This is what I’ve tried so far:

getting the cross product of the current orientation of the listener as a vector and the cross product of the sine and cosine of theta and the current orientation’s z, i.e.: getting the cross product of (current orientation x, current orientation y, current orientation z) and (sine of theta, cosine of theta, current orientation z)

The same, but instead of the sine and cosine, the sine and cosine in degrees, i.e. cross product of (current orientation x, current orientation y, current orientation z) and (sine of theta in degrees, cosine of theta in degrees, current orientation z);

Setting the forward orientations (x, y, z) vectors to (sin(thetapi/180), cos(thetapi/180), current orientation z); and

setting the (x, y, z) of the forward orientation to (sin(thetapi/180)0.01100, cos(thetapi/180)0.01100, current orientation z)

None of this has worked, in either left-handed or right-handed coordinates. I’m trying to make it so I can make a sound orient itself to the listeners position (for turning in a game I’m aiding in the development of, and we’re considering switching to FMOD). So, my main question:

How can I get an adapting forward orientation? I don’t care about upwards orientation right now, though info on how to adapt that orientation as well would be nice. For example, if the listener turns towards or away from the sound, and the sound is at the same Z axis as the listener, how do I get the sound to pan around the player so that, for example, the sound would sound behind the listener, and would appear to move across the 3D space when the listeners orientation changes?

What do the docs mean by “perpendicular”? Traditionally, in 3D space a “perpendicular” vector is the cross product of two vectors, and whether the vectors are perpendicular can be checked by getting the dot product of the vectors.

I hope the info above is correct; all the research I’ve done points to that being the case. Clearly, either FMOD does not follow the traditional method of getting perpendicular vectors, and determining the perpendicular status of two vectors via the dot product, or I am entirely misunderstanding my research and the docs.

I apologize for quad-posting. Or double-posting. I don’t mean to be rude, but this makes ti easier for me (at least) to separate my problem solving out into stages so people can easily figure out what part each post is at. Feel free to disallow this or to merge my posts, or to post in between (this issue still is unresolved). So, here’s my current status:

Turning now fully works; I don’t get any errors.

The sound in 3D space is set to (20, 0, 0) still.

I’ve tried setting the Doppler level. The 3D level is set to maximum; when the app starts, I can here the sound off to my right.

However, when I use the arrow keys to turn, which alters the forward orientation of the master 3D listener, the sounds position does not change at all.

I’ll paste the update loop that runs since that’s where the problem is:

while True:
# this code works
event=sdl2.SDL_Event()
sdl2.SDL_PollEvent(event)
res = fmod.FMOD_System_Update(system)
if res!=0:
raise RuntimeError(ErrorString(res))
angle=ctypes.c_float(0.0)
res = fmod.FMOD_Channel_Get3DSpread(channel, ctypes.byref(angle))
if res!=0:
raise RuntimeError(ErrorString(res))
oldorientation=FMOD_VECTOR()
res = fmod.FMOD_System_Get3DListenerAttributes(system, 0, None, None, ctypes.byref(oldorientation), None)
if res!=0:
raise RuntimeError(ErrorString(res))
# but this orientation code does not
if event.type==sdl2.SDL_KEYUP and event.key.keysym.sym==sdl2.SDLK_RIGHT:
theta+=15.0
if theta>360.0: theta=0.0
elif theta<0.0: theta=360.0
forward_orientation = FMOD_VECTOR()
forward_orientation.x=math.sin(theta*math.pi/180)
forward_orientation.y=oldorientation.y
forward_orientation.z=math.cos(theta*math.pi/180)
res = fmod.FMOD_System_Set3DListenerAttributes(system, 0, 0, 0, ctypes.byref(forward_orientation), 0)
if res!=0:
raise RuntimeError(Errorstring(res))
if event.type==sdl2.SDL_KEYUP and event.key.keysym.sym==sdl2.SDLK_LEFT:
theta-=15.0
if theta>359.0: theta=0.0
elif theta<0.0: theta=359.0
forward_orientation = FMOD_VECTOR()
forward_orientation.x=math.sin(theta*math.pi/180)
forward_orientation.y=oldorientation.y
forward_orientation.z=math.cos(theta*math.pi/180)
res = fmod.FMOD_System_Set3DListenerAttributes(system, 0, 0, 0, ctypes.byref(forward_orientation), 0)
if res!=0:
raise RuntimeError(ErrorString(res))

I’ll stop double-posting and let you guys read all of this (I hope it was readable, I’m visually impaired).