I’m trying to code a 3D sound effect (.wav) for a room that measures, -3 to 3 units on the x-axis and -3 to 3 units on the z-axis. The sound effect is centered on the origin (0,0,0), but I’m having difficulty calculating the front vector (at least I think it’s that, my 3D maths isn’t all that good).

With the current code I’ve written so far, the sound is demonstrating signs of being in a 3D space but at certain angles it cuts out or the output is coming out the wrong speaker (i.e. if I directly face the effect along the z-axis no sound occurs).

Can anyone see if I’m doing something wrong or offer advice as to what might be going wrong if I’m actually calculating the front vector properly?


  • Bill


// Angle, y-rotation, 0 degrees is vector (0,0,1)

void Update(float x_pos, float z_pos, float angle)

float lPos[3], x_foward, z_foward;

lPos[0] = x_pos;
lPos[1] = 0;
lPos[2] = z_pos;

x_foward = -sin((angle) * 0.0174532925);
z_foward = cos((angle) * 0.0174532925);

FSOUND_3D_Listener_SetAttributes(&lPos[0], NULL, x_foward, 0.0f, z_foward ,0.0f , 1.0f, 0.0f);


  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.