0
0

I was trying to pause the channel, so i can play with the attributes. But somehow when my MainGameLoop starts, there’s still a milisecond of the sound being playing played, before it stop and changes the position and volume. Whey is the sound played even when I paused the channel and setting the volume to 0?

Someone advise please.

[code:1oz13k32]void CAudioEngine::PlaySound()
{

FMOD_VECTOR pos = { 0.0f, 0.0f, 0.0f };



result = system->playSound(FMOD_CHANNEL_FREE, sound, true, &channel);

ERRCHECK(result);


//channel->set3DMinMaxDistance(1,2);
result = channel->set3DAttributes(&pos, 0);
ERRCHECK(result);
channel->setVolume(0.0);
channel->setPaused(false);

}

void CAudioEngine::ChangeListenerPos(CCamera * cam, CVECTOR playerPos)
{

CVECTOR campos = cam->getPosition();
FMOD_VECTOR fcampos = {campos.fX, campos.fY, campos.fZ};

CVECTOR camforward = playerPos - campos;


static FMOD_VECTOR lastpos = { 0.0f, 0.0f, 0.0f };
FMOD_VECTOR forward        = { camforward.fX, camforward.fY, camforward.fZ };
//FMOD_VECTOR up             = { 0.0f, 1.0f, 0.0f };
//FMOD_VECTOR vel;

FMOD_VECTOR oldPos = {0, 0, 0};

channel->get3DAttributes(&oldPos, 0);

CVECTOR cOldPos;
cOldPos.fX = oldPos.x;
cOldPos.fY = oldPos.y;
cOldPos.fZ = oldPos.z;

CVECTOR cCamPos;
cCamPos.fX = campos.fX;
cCamPos.fY = campos.fY;
cCamPos.fZ = campos.fZ;

float mag = (cCamPos - cOldPos).Magnitude();
//cout << "Magnitude: " << mag << "\n";

float newVol;
if (mag > 2000.0f) {
    newVol = 0.0f;
} else {
    newVol = 1.0 - ((mag / 2000.0f) * 1.0);
}

channel->setVolume(newVol);
result = system->set3DListenerAttributes(0, &fcampos, 0, &forward, 0);

ERRCHECK(result);

system->update();

}[/code:1oz13k32]

  • You must to post comments
0
0

Are you using the latest version of fmod. Try and repro that in any fmod example and it wont make any noise if you set values before unpausing.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.