Skip to content

Commit

Permalink
Add function docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
hemebond committed Mar 4, 2024
1 parent 82eb6d6 commit c44943f
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions snd_mix.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,46 +309,56 @@ static void S_ConvertPaintBuffer(portable_sampleframe_t *painted_ptr, void *rb_p
}
}



/*
===============================================================================
UNDERWATER EFFECT
Muffles the intensity of sounds when the player is underwater
===============================================================================
*/



static struct {
float intensity;
float alpha;
float accum[SND_LISTENERS];
} underwater = {0.f, 1.f, {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f}};

void S_SetUnderwaterIntensity(void)
{


void S_SetUnderwaterIntensity(void) {
float host_frametime = cl.realframetime;
float target = cl.view_underwater ? 1.f : 0.f;

if (snd_waterfx.value < 0.f)
if (snd_waterfx.value < 0.f) {
target *= 0.f;
else if (snd_waterfx.value > 2.f)
}
else if (snd_waterfx.value > 2.f) {
target *= 2.f;
else
}
else {
target *= snd_waterfx.value;
}

if (underwater.intensity < target)
{
if (underwater.intensity < target) {
underwater.intensity += host_frametime * 4.f;
underwater.intensity = min(underwater.intensity, target);
}
else if (underwater.intensity > target)
{
else if (underwater.intensity > target) {
underwater.intensity -= host_frametime * 4.f;
underwater.intensity = max(underwater.intensity, target);
}

underwater.alpha = exp(-underwater.intensity * log(12.f));
}



static void S_UnderwaterFilter(int endtime)
{
int i;
Expand All @@ -369,6 +379,8 @@ static void S_UnderwaterFilter(int endtime)
}
}



/*
===============================================================================
Expand Down

0 comments on commit c44943f

Please sign in to comment.