0
0

This is the problem i have: (OS: Windows, FMODEx)
A 3D sound can be heard level wide, even after setting:
set3DMinMaxDistance(min * DISTANCEFACTOR, max*DISTANCEFACTOR);

When i get within the min-max distance the sound gets louder and louder, however once i get out of the min-max distance, it stays at a very low but audible volume level.

This is my code for the listener and soundemitter classes
SoundEmitter (This class is cut down)
[code:3lo0kr1d]
const float DISTANCEFACTOR = 1.0f; // Units per meter. I.e feet would = 3.28. centimeters would = 100.

SoundEmitter::SoundEmitter(int id, FMOD::System *system, const char *soundPath, bool levelSound, bool loop, float posX, float posY, float posZ, float velX, float velY, float velZ)
{
this->id = id; //gives this instance its unique identifying number, used to destroy itself.
staticSound = levelSound;
createSound(system, soundPath, loop);

tempSystem = system;

}

void SoundEmitter::createSound(FMOD::System *system, const char *soundPath, bool loop)
{
result = system->createSound(soundPath, FMOD_SOFTWARE | FMOD_3D | FMOD_LOOP_OFF, 0, &sound);
setAudibleDistance();

error = ERRCHECK(result);

}

void SoundEmitter::playSound(float posX, float posY, float posZ, float velX, float velY, float velZ)
{
FMOD::Channel *channel;
result = tempSystem->playSound(FMOD_CHANNEL_FREE, this->sound, true, &channel);
ERRCHECK(result);

SetPosition(channel,posX, posY, posZ, velX, velY, velZ);

result = channel->setPaused(false);
ERRCHECK(result);

}

void SoundEmitter::SetPosition(FMOD::Channel * channel, float posX, float posY, float posZ, float velX, float velY, float velZ)
{
sPos.x = posX;
sPos.y = posY;
sPos.z = posZ;

    sVel.x = velX;
    sVel.y = velY;
    sVel.z = velZ;

    result = channel->set3DAttributes(&sPos, &sVel);
    ERRCHECK(result);

}

void SoundEmitter::setAudibleDistance(float min, float max)
{
result = sound->set3DMinMaxDistance(min * DISTANCEFACTOR, max*DISTANCEFACTOR);
ERRCHECK(result);
}
[/code:3lo0kr1d]

Code for Listener Class (cut down version)
[code:3lo0kr1d]
SoundListener::SoundListener(FMOD::System *system, float posX, float posY, float posZ, float velX, float velY, float velZ)
{
this->system = system;
SetPosition(posX, posY, posZ, velX, velY, velZ);
}

void SoundListener::SetPosition(float posX, float posY, float posZ, float velX, float velY, float velZ)
{
sListenerPos.x = posX;
sListenerPos.y = posY;
sListenerPos.z = posZ;

sVel.x = velX;
sVel.y = velY;
sVel.z = velZ;

result = system->set3DListenerAttributes(0, &sListenerPos, &sVel, &sForward, &sUp);
ERRCHECK(result);

}
[/code:3lo0kr1d]

Anybody see anything wrong with any of this code? I suspect the SoundEmitter is doing something wrong, i just cant see where its wrong

  • You must to post comments
0
0

The maxdistance parameter is not the distance at which the sound stops being audible. It is the maximum distance for attenuation, so the attenuation will stop at that distance, but depending on the type of rolloff the sound may still be audible beyond that distance.

From FMOD Documentation:
[quote:18lho5vu] MaxDistance is the distance a sound stops attenuating at. Beyond this point it will stay at the volume it would be at maxdistance units from the listener and will not attenuate any more… Some people have the confusion that maxdistance is the point the sound will fade out to, this is not the case.[/quote:18lho5vu]

From FMOD Documentation:
[quote:18lho5vu]
FMOD_3D_LOGROLLOFF
This sound will follow the standard logarithmic rolloff model where mindistance = full volume, maxdistance = where sound stops attenuating, and rolloff is fixed according to the global rolloff factor. (DEFAULT)

FMOD_3D_LINEARROLLOFF
This sound will follow a linear rolloff model where mindistance = full volume, maxdistance = silence. Rolloffscale is ignored.
[/quote:18lho5vu]

If you use linear rolloff you should get the expected behaviour of silence beyond the ‘maxdistance’ value.

  • You must to post comments
0
0

Thanks a lot for the explanation!

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.