0
0

First things first: what a great API!!

I was checking out the 3d/doppler functionality with the code below, and it sounded pretty damn good. I noticed though, that when the distance between the listener and a source is >= 255, there is no sound. The documentation says that ‘volume for a sample will scale at 1 / distance’. I might have missed some other mentionings about this in the docs, or my code is not set up correctly – any ideas? I tried moving the source along different axes, and with different front/up vectors for the listener, and in some cases the sound cut off when the source-to-listener distance was >= 127. (It seems like the longest axis of the source-to-listener vector is important somehow…)


[size=75:3pwkx0fw]#include <windows.h>

include <stdio.h>

include <stdlib.h>

include <conio.h>

include <math.h>

include “api/inc/fmod.h”

include “api/inc/fmod_errors.h”

int main(int argc, char* argv[]) {

if (!FSOUND_Init(44100, 32, 0)) {
    printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));
    exit(1);
}   

FSOUND_SAMPLE* ss = NULL;

if (!(ss = FSOUND_Sample_Load(0, "xfw3.wav", FSOUND_HW3D | FSOUND_LOOP_NORMAL, 0))) {
    printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));
    exit(1);
}   

float listenerPos[3] = {0,0,0}, listenerVel[3] = {0,0,0};
FSOUND_3D_Listener_SetAttributes(listenerPos, listenerVel, 1,0,0, 0,1,0);

FSOUND_PlaySound(0, ss);
float sourcePos[3] = {10,10,-300}, sourceVel[3] = {0,0,100};

while (sourcePos[2] &lt; 300) {
    sourcePos[2] += 2;
    FSOUND_3D_SetAttributes(0, sourcePos, sourceVel);
    FSOUND_3D_Update();
    Sleep(20);
    printf("%f\n", sourcePos[2]);
}

FSOUND_Close();

return 0;

}[/size:3pwkx0fw]

  • You must to post comments
0
0

Hi,
I see now that it’s just doing integer division for speed, if I listen carefully I can hear other slight volume step-ups as the source approaches. Well nobody does that when they’re playing a game, so no problem there. I am still curious though about why sometimes the cutoff distance is not the same. In the above code, sound plays when -255 < sourceZ < 127.

  • You must to post comments
0
0

It is the same without FSOUND_HW3D… but I needed to alter the rolloff factor to less than 1 anyway which fixes the problem for me.

FWIW, I tried on two soundcards, both vanilla onboard types, Crystal SoundFusion and Yamaha XG, both on Win2000pro, one with DX8.0 one with DX8.1, same results.

  • You must to post comments
0
0

ahh… the pan balance will be what it is – it does seem like some kind of integer rounding/division precision thing. My ‘amp’ is not on 10 but I am listening very carefully with a good pair of earphones… just to harass you 😉
So now I will assume there should be no sound from sources further than 127 away, and scale that with SetRolloffFactor to give me my necessary range of about 500 ‘metres’, and everything will be fine.

By the way I had the source velocity at 100 just because it sounded mega-cool. When I first put my looping engine sound sample through the code above I couldn’t believe my ears – it was indistinguishable from a real p51 flyby!! Did I mention that I like this API?

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.