Skip to content

Commit

Permalink
Sfx: Cleanups and update after game tics
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Dec 6, 2011
1 parent dae7835 commit 6e36822
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions doomsday/engine/portable/src/s_sfx.c
Expand Up @@ -465,8 +465,7 @@ void Sfx_ChannelUpdate(sfxchannel_t* ch)
}
else
{
normdist = (dist - soundMinDist) /
(soundMaxDist - soundMinDist);
normdist = (dist - soundMinDist) / (soundMaxDist - soundMinDist);

// Apply the linear factor so that at max distance there
// really is silence.
Expand Down Expand Up @@ -505,8 +504,7 @@ void Sfx_ChannelUpdate(sfxchannel_t* ch)
}
}

iSFX->Set(buf, SFXBP_VOLUME,
ch->volume * dist * sfxVolume / 255.0f);
iSFX->Set(buf, SFXBP_VOLUME, ch->volume * dist * sfxVolume / 255.0f);
iSFX->Set(buf, SFXBP_PAN, pan);
}
}
Expand All @@ -532,8 +530,7 @@ void Sfx_ListenerUpdate(void)
// Orientation. (0,0) will produce front=(1,0,0) and up=(0,0,1).
vec[VX] = listener->angle / (float) ANGLE_MAX *360;

vec[VY] =
listener->dPlayer ? LOOKDIR2DEG(listener->dPlayer->lookDir) : 0;
vec[VY] = (listener->dPlayer? LOOKDIR2DEG(listener->dPlayer->lookDir) : 0);
iSFX->Listenerv(SFXLP_ORIENTATION, vec);

// Velocity. The unit is world distance units per second.
Expand Down Expand Up @@ -839,7 +836,7 @@ int Sfx_StartSound(sfxsample_t* sample, float volume, float freq,
if(play3D)
{
// Init the buffer's min/max distances.
// This is only done once, when the sound is started (i.e. here).
// This is only done once, when the sound is started (i.e., here).
iSFX->Set(selCh->buffer, SFXBP_MIN_DISTANCE,
(selCh->flags & SFXCF_NO_ATTENUATION)? 10000 :
soundMinDist);
Expand Down Expand Up @@ -895,9 +892,6 @@ void Sfx_StartFrame(void)
{
static int old16Bit = false;
static int oldRate = 11025;
static double lastUpdate = 0;

double nowTime = Sys_GetSeconds();

if(!sfxAvail)
return;
Expand All @@ -911,7 +905,7 @@ void Sfx_StartFrame(void)
// Check that the rate is valid.
if(sfxSampleRate != 11025 && sfxSampleRate != 22050 && sfxSampleRate != 44100)
{
Con_Message("sound-rate corrected to 11025.\n");
Con_Message("Sfx_StartFrame: sound-rate corrected to 11025.\n");
sfxSampleRate = 11025;
}

Expand All @@ -925,19 +919,22 @@ void Sfx_StartFrame(void)

// Should we purge the cache (to conserve memory)?
Sfx_PurgeCache();
}

void Sfx_EndFrame(void)
{
static double lastUpdate = 0;
double nowTime = Sys_GetSeconds();

if(!sfxAvail)
return;

// Is it time to do a channel update?
if(nowTime - lastUpdate >= UPDATE_TIME)
{
lastUpdate = nowTime;
Sfx_Update();
}
}

void Sfx_EndFrame(void)
{
if(!sfxAvail)
return;

// The sound frame ends.
audioDriver->Event(SFXEV_END);
Expand Down

0 comments on commit 6e36822

Please sign in to comment.