0
0

Please can anyone help im trying yo add FMOD’s positioned sound into my gaming engine as currently all sounds are just played no position nothing like that

Can anyone who can help contact me please…

Quadrant@PlanetQuake.com

http://www.planetquake.com/quadkill/quadengine/

  • You must to post comments
0
0

Hi im not sure ive not played about with it like this before ive only played sounds direct before,, but now i want to try to use the 3d stuff here is a quick test i put together maybe you can help thx,,

//[QBS] TESTING
float listenerpos[3] = { 0,0,0 }; // Location of player
float lastpos[3] = { 0,0,0 };
float pos[3] = { -10.0f, -0.0f, 0.0f };
float vel[3] = { 0,0,0 };

define INTERFACE_UPDATETIME 50 // 50ms update for interface

void Play_Explode_Sound (void)
{
// COORDINATE SYSTEM : X = right, Y = up, Z = forwards. (Left handed)
extern float listenerpos[3]; // Location of player
extern float lastpos[3];

    extern  float pos[3];
    extern  float vel[3];

FSOUND_STREAM   *explode_sound = NULL;
explode_sound  = NULL;

if (!sound_inited)return;
explode_sound = FSOUND_Stream_OpenFile("sound/fx/rockex.mp3", FSOUND_NORMAL | FSOUND_2D,0);//[QBS] FSOUND_LOOP_NORMAL added 0
/*
"freq" frequency in hz to play sound at. -1 will use streams default frequency.

"vol" volume to play sound at (0-255). -1 will use streams default volume.

"pan" pan position to play sound at (0-255, FSOUND_STEREOPAN). -1 will use streams default pan.

"pos" Pointer to a position vector (xyz float triplet), of the listener in world space, measured in distance units.
This can be NULL to ignore it. (especially if the sound is 2D!)

"vel" Pointer to a velocity vector (xyz float triplet), of the listener measured in distance units PER SECOND.
This can be NULL to ignore it. (especially if the sound is 2D!)

*/
vel[0] = (listenerpos[0]-lastpos[0]) * (1000 / INTERFACE_UPDATETIME);
vel[1] = (listenerpos[1]-lastpos[1]) * (1000 / INTERFACE_UPDATETIME);
vel[2] = (listenerpos[2]-lastpos[2]) * (1000 / INTERFACE_UPDATETIME);

        // store pos for next time
        lastpos[0] = listenerpos[0];
        lastpos[1] = listenerpos[1];
        lastpos[2] = listenerpos[2];

// // //

FSOUND_3D_Listener_SetAttributes(&listenerpos[0], &vel[0], 0, 0, 1.0f, 0, 1.0f, 0);

FSOUND_Stream_Play3DAttrib(FSOUND_FREE, explode_sound,-1,-1,-1,pos,vel);

listenerpos[0] += 1.0f;
if (listenerpos[0] > 30)
listenerpos[0] = -35;
FSOUND_3D_Update();

Sleep(INTERFACE_UPDATETIME-1); // -2 for printf etc
}
//[QBS]TESTING END

  • You must to post comments
0
0

As far as I can see, you are using FSOUND_2D when loading the sample.
You should use FSOUND_HW3D when you want to play the sound positioned.

  • You must to post comments
0
0

Thank you very much i over looked that so i had done it right after all :smile:

THANK YOU
& HAPPY NEW YEAR TO YOU…

Im [QBS]Quadrant by the way
http://www.planetquake.com/quadkill/quadengine
is the project thx…

  • You must to post comments
0
0

[QBS]Quadrant

Im not sure im doing this correctly how do i use £ dimentional sound ???

My player ie (Camera)
ie is this correct
X -X left to +X right
Y -Y back to +Y forward
Z -Z down to +Z up
//[QBS] Set SND listener position to Camera
for(i=-0;i<2;i++) //[QBS] count 0 to 2
{
X[i]=C->ToWorld[i][0]; //X right
Y[i]=C->ToWorld[i][1]; //Y up
Z[i]=C->ToWorld[i][2]; //Z forward
}

//[QBS] copy camera location to listener position in 3D space
listener_pos_x[i]=X[i];//x -X left to +X right
listener_pos_y[i]=Y[i];//y -Y down to +Y up
listener_pos_z[i]=Z[i];//z -Z back to +Z forward

//vel

// Ok now update 3D
FSOUND_3D_Update(); //UPDATE EVERY FRAME OF CAMERA

ok next if we go into the playing of a sound

//[QBS] TESTING
float listenerpos[3] = { 0,0,0 }; // Init player as 0
float lastpos[3] = { 0,0,0 }; // and his last position
float pos[3] = { -10.0f, -0.0f, 0.0f };
float vel[3] = { 0,0,0 };

define INTERFACE_UPDATETIME 50 // 50ms update for interface

void Play_Explode_Sound (float *c)
{
// COORDINATE SYSTEM : X = right, Y = up, Z = forwards. (Left handed)
extern float listener_pos[3]; // Location of listener
extern float listener_vel[3]; // Location of listener

    extern  float last_pos[3]; // old location of listener
    extern  float last_vel[3]; // old location of listener

    extern  float pos[3];// from sound object
    extern  float vel[3];// from sound object

FSOUND_STREAM   *explode_sound = NULL;
FSOUND_MATERIAL *material = NULL;
explode_sound  = NULL;

if (!sound_inited)return;

explode_sound = FSOUND_Stream_OpenFile(“sound/fx/rockex.mp3”, FSOUND_NORMAL | FSOUND_HW3D,0);
if (!explode_sound)
{
printf(“explode_sound ERROR: %sn”, FMOD_ErrorString(FSOUND_GetError()));
}

        vel[0] = (listener_vel[0]-last_vel[0]) * (1000 / INTERFACE_UPDATETIME);
        vel[1] = (listener_vel[1]-last_vel[1]) * (1000 / INTERFACE_UPDATETIME);
        vel[2] = (listener_vel[2]-last_vel[2]) * (1000 / INTERFACE_UPDATETIME);

// COORDINATE SYSTEM : X = right, Y = up, Z = forwards. (Left handed)
// store pos for next time
last_vel[0] = listener_vel[0];
last_vel[1] = listener_vel[1];
last_vel[2] = listener_vel[2];

        pos[0] = pob.c[0];
        pos[1] = pob.c[1];
        pos[2] = pob.c[2];

// Update camera position
// if (DoCameraSync)
SyncCamera(C,cl);

// No world bsp!
if (!cl->MainBSP) return;

//[QBS] Set sound to its world location
for(i=-0;i<2;i++) //[QBS] count 0 to 2
{
X[i]=C->ToWorld[i][0]; //X right
Y[i]=C->ToWorld[i][1]; //Y up
Z[i]=C->ToWorld[i][2]; //Z forward
}

//[QBS] position in 3D space
listener_pos_x[i]=X[i];//x -X left to +X right
listener_pos_y[i]=Y[i];//y -Y down to +Y up
listener_pos_z[i]=Z[i];//z -Z back to +Z forward

// COORDINATE SYSTEM : X = right, Y = up, Z = forwards. (Left handed)
// store pos for next time
last_pos[0] = listener_pos[0];//X -X left to +X right
last_pos[1] = listener_pos[1];//Y -Y down to +Y up
last_pos[2] = listener_pos[2];//Z -Z back to +Z forward

FSOUND_3D_SetAttributes(FSOUND_FREE,pos,vel);// the sound

FSOUND_Stream_Play3DAttrib(FSOUND_FREE, explode_sound,-1,-1,-1,pos,vel);
FSOUND_3D_Listener_SetAttributes(listener_pos,vel, listener_pos_x,listener_pos_y,listener_pos_z,listener_vel_x,listener_vel_y,listener_vel_z); // the listener

}

AM i doing this anywhere near correct its making me pooly trying to work it out :sad:

  • You must to post comments
0
0

[QBS]Quadrant

Ive got it all working now i will post a tutorial for others to help them soon, I had to do a total rewrite of my code to get it to work in my engine in 3D

  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.