From 71dd0d0269d37facfd45ddb873a44780230c251d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 18 Sep 2008 21:00:12 +0000 Subject: [PATCH] - another #include fix for Linux. - Added a 'logarithmic' parameter to S_GetRolloff. SVN r1235 (trunk) --- src/s_sound.cpp | 22 ++++++++++++++++++---- src/sdl/i_main.cpp | 3 +++ src/sound/fmodsound.cpp | 4 ++-- src/sound/i_sound.h | 2 +- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 31f2ca2519..665f3f6d3c 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -1778,7 +1778,7 @@ static void S_SetListener(SoundListener &listener, AActor *listenactor) // //========================================================================== -float S_GetRolloff(FRolloffInfo *rolloff, float distance) +float S_GetRolloff(FRolloffInfo *rolloff, float distance, bool logarithmic) { if (rolloff == NULL) { @@ -1803,13 +1803,27 @@ float S_GetRolloff(FRolloffInfo *rolloff, float distance) { volume = S_SoundCurve[int(S_SoundCurveSize * (1 - volume))] / 127.f; } - if (rolloff->RolloffType == ROLLOFF_Linear) + if (logarithmic) { - return volume; + if (rolloff->RolloffType == ROLLOFF_Linear) + { + return volume; + } + else + { + return float((pow(10.f, volume) - 1.) / 9.); + } } else { - return (powf(10.f, volume) - 1.f) / 9.f; + if (rolloff->RolloffType == ROLLOFF_Linear) + { + return float(log10(9. * volume + 1.)); + } + else + { + return volume; + } } } diff --git a/src/sdl/i_main.cpp b/src/sdl/i_main.cpp index f49c9bbd16..2f9d483372 100644 --- a/src/sdl/i_main.cpp +++ b/src/sdl/i_main.cpp @@ -54,6 +54,9 @@ #include "errors.h" #include "version.h" #include "w_wad.h" +#include "g_level.h" +#include "r_state.h" +#include "cmdlib.h" // MACROS ------------------------------------------------------------------ diff --git a/src/sound/fmodsound.cpp b/src/sound/fmodsound.cpp index 6179b7bebc..9946edafa9 100644 --- a/src/sound/fmodsound.cpp +++ b/src/sound/fmodsound.cpp @@ -2040,11 +2040,11 @@ float F_CALLBACK FMODSoundRenderer::RolloffCallback(FMOD_CHANNEL *channel, float if (GRolloff != NULL) { - return S_GetRolloff(GRolloff, distance * GDistScale); + return S_GetRolloff(GRolloff, distance * GDistScale, true); } else if (chan->getUserData((void **)&schan) == FMOD_OK && schan != NULL) { - return S_GetRolloff(&schan->Rolloff, distance * schan->DistanceScale); + return S_GetRolloff(&schan->Rolloff, distance * schan->DistanceScale, true); } else { diff --git a/src/sound/i_sound.h b/src/sound/i_sound.h index d7c071290e..6844a75452 100644 --- a/src/sound/i_sound.h +++ b/src/sound/i_sound.h @@ -141,7 +141,7 @@ void I_InitSound (); void I_ShutdownSound (); void S_ChannelEnded(FISoundChannel *schan); -float S_GetRolloff(FRolloffInfo *rolloff, float distance); +float S_GetRolloff(FRolloffInfo *rolloff, float distance, bool logarithmic); FISoundChannel *S_GetChannel(void *syschan); extern ReverbContainer *DefaultEnvironments[26];