From 075c5d872dd93cc6c44978b6ce0594372576f21d Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 22 Jun 2014 22:22:45 -0700 Subject: [PATCH] Always use the pitch multiplier when underwater --- src/sound/oalsound.cpp | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/src/sound/oalsound.cpp b/src/sound/oalsound.cpp index 0353b17bb..8bb4be5bc 100644 --- a/src/sound/oalsound.cpp +++ b/src/sound/oalsound.cpp @@ -1083,9 +1083,8 @@ FISoundChannel *OpenALSoundRenderer::StartSound(SoundHandle sfx, float vol, int alSource3i(source, AL_AUXILIARY_SEND_FILTER, 0, 0, AL_FILTER_NULL); } alSourcef(source, AL_ROOM_ROLLOFF_FACTOR, 0.f); - alSourcef(source, AL_PITCH, PITCH(pitch)); } - else if(WasInWater && !(chanflags&SNDF_NOREVERB)) + if(WasInWater && !(chanflags&SNDF_NOREVERB)) alSourcef(source, AL_PITCH, PITCH(pitch)*PITCH_MULT); else alSourcef(source, AL_PITCH, PITCH(pitch)); @@ -1258,9 +1257,8 @@ FISoundChannel *OpenALSoundRenderer::StartSound3D(SoundHandle sfx, SoundListener alSource3i(source, AL_AUXILIARY_SEND_FILTER, 0, 0, AL_FILTER_NULL); } alSourcef(source, AL_ROOM_ROLLOFF_FACTOR, 0.f); - alSourcef(source, AL_PITCH, PITCH(pitch)); } - else if(WasInWater && !(chanflags&SNDF_NOREVERB)) + if(WasInWater && !(chanflags&SNDF_NOREVERB)) alSourcef(source, AL_PITCH, PITCH(pitch)*PITCH_MULT); else alSourcef(source, AL_PITCH, PITCH(pitch)); @@ -1519,8 +1517,7 @@ void OpenALSoundRenderer::UpdateListener(SoundListener *listener) const_cast(env)->Modified = false; } - // NOTE: Moving into and out of water will undo pitch variations on sounds - // if either snd_waterreverb or EFX are disabled. + // NOTE: Moving into and out of water will undo pitch variations on sounds. if(listener->underwater || env->SoftwareWater) { if(!WasInWater) @@ -1530,13 +1527,11 @@ void OpenALSoundRenderer::UpdateListener(SoundListener *listener) if(EnvSlot != 0 && *snd_waterreverb) { // Find the "Underwater" reverb environment - env = Environments; - while(env && env->ID != 0x1600) - env = env->Next; + env = S_FindEnvironment(0x1600); LoadReverb(env ? env : DefaultEnvironments[0]); - alFilterf(EnvFilters[0], AL_LOWPASS_GAIN, 0.1f); - alFilterf(EnvFilters[0], AL_LOWPASS_GAINHF, 1.f); + alFilterf(EnvFilters[0], AL_LOWPASS_GAIN, 1.f); + alFilterf(EnvFilters[0], AL_LOWPASS_GAINHF, 0.125f); alFilterf(EnvFilters[1], AL_LOWPASS_GAIN, 1.f); alFilterf(EnvFilters[1], AL_LOWPASS_GAINHF, 1.f); @@ -1547,11 +1542,9 @@ void OpenALSoundRenderer::UpdateListener(SoundListener *listener) alSource3i(*i, AL_AUXILIARY_SEND_FILTER, EnvSlot, 0, EnvFilters[1]); } } - else - { - foreach(ALuint, i, ReverbSfx) - alSourcef(*i, AL_PITCH, PITCH_MULT); - } + + foreach(ALuint, i, ReverbSfx) + alSourcef(*i, AL_PITCH, PITCH_MULT); getALError(); } } @@ -1573,11 +1566,9 @@ void OpenALSoundRenderer::UpdateListener(SoundListener *listener) alSource3i(*i, AL_AUXILIARY_SEND_FILTER, EnvSlot, 0, EnvFilters[1]); } } - else - { - foreach(ALuint, i, ReverbSfx) - alSourcef(*i, AL_PITCH, 1.f); - } + + foreach(ALuint, i, ReverbSfx) + alSourcef(*i, AL_PITCH, 1.f); getALError(); } }