0
0

I cannot get my program to set a sound’s position using FSOUND_3D_SetAttributes, I’ve tried placing it in a number of different places but the sound will follow my camera around as if it isn’t a 3D sound.
Here is a snippet of the code that I am using.
I know in the FSOUND_Sample_Load I am using FSOUND_2D but if I put in FSOUND_HW3D I get no sounds at all.
It’s probably something simple, as I’m new to using fmod so any advice will be greatly appreciated.

[code:182fcdkr]void Sound::listenerPosition(float x, float y, float z, float atx, float aty, float atz, float upx, float upy, float upz)
{
float listenerPos[]={x,y,z};
float listenerVel[]={0.0,0.0,0.0};

FSOUND_3D_Listener_SetAttributes(listenerPos, listenerVel, atx, aty, atz, upx, upy, upz); 

}

//——————————————————————————————–

void Sound::createSound(char filename[40], int volume, float x, float y, float z)
{
float soundPos[]={x, y, z};
float soundVel[]={0.0f, 0.0f, 0.0f};

channel = FSOUND_FREE;
sound=FSOUND_Sample_Load (channel, filename, FSOUND_2D | FSOUND_LOOP_NORMAL, 0, 0);
FSOUND_Sample_SetMinMaxDistance(sound, 1.0f, 5.0f);   
FSOUND_3D_SetAttributes(channel, soundPos, soundVel);
FSOUND_SetVolume (channel, volume);

}

//——————————————————————————————–

void Sound::playSound()
{
channel = FSOUND_PlaySoundEx(channel,sound, NULL, false);
}[/code:182fcdkr]

  • You must to post comments
0
0

Well 2d means not 3d, so obviously that is your first thing to change.

Next you shouldnt just ignore a sound not playing, it probably means you didnt check any error codes. For example you will get an error if you try to play a stereo sound as 3d. Check the return values.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.