diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 6c548f400..9749d635c 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -1764,7 +1764,7 @@ void S_SetSoundPaused (int state) S_ResumeSound(true); if (GSnd != NULL) { - GSnd->SetInactive(false); + GSnd->SetInactive(SoundRenderer::INACTIVE_Active); } if (!netgame #ifdef _DEBUG @@ -1783,7 +1783,9 @@ void S_SetSoundPaused (int state) S_PauseSound(false, true); if (GSnd != NULL) { - GSnd->SetInactive(true); + GSnd->SetInactive(gamestate == GS_LEVEL ? + SoundRenderer::INACTIVE_Complete : + SoundRenderer::INACTIVE_Mute); } if (!netgame #ifdef _DEBUG diff --git a/src/sound/fmodsound.cpp b/src/sound/fmodsound.cpp index b01754324..5abb67e76 100644 --- a/src/sound/fmodsound.cpp +++ b/src/sound/fmodsound.cpp @@ -672,6 +672,7 @@ bool FMODSoundRenderer::Init() PrevEnvironment = DefaultEnvironments[0]; DSPClock.AsOne = 0; ChannelGroupTargetUnit = NULL; + ChannelGroupTargetUnitOutput = NULL; SfxReverbHooked = false; SfxReverbPlaceholder = NULL; OutputPlugin = 0; @@ -1155,6 +1156,15 @@ bool FMODSoundRenderer::Init() { ChannelGroupTargetUnit = NULL; } + else + { + FMOD::DSP *dontcare; + result = ChannelGroupTargetUnit->getOutput(0, &dontcare, &ChannelGroupTargetUnitOutput); + if (result != FMOD_OK) + { + ChannelGroupTargetUnitOutput = NULL; + } + } } } @@ -2123,11 +2133,33 @@ void FMODSoundRenderer::SetSfxPaused(bool paused, int slot) // //========================================================================== -void FMODSoundRenderer::SetInactive(bool inactive) +void FMODSoundRenderer::SetInactive(SoundRenderer::EInactiveState inactive) { + float mix; + bool active; + + if (inactive == INACTIVE_Active) + { + mix = 1; + active = true; + } + else if (inactive == INACTIVE_Complete) + { + mix = 1; + active = false; + } + else // inactive == INACTIVE_Mute + { + mix = 0; + active = true; + } + if (ChannelGroupTargetUnitOutput != NULL) + { + ChannelGroupTargetUnitOutput->setMix(mix); + } if (ChannelGroupTargetUnit != NULL) { - ChannelGroupTargetUnit->setActive(!inactive); + ChannelGroupTargetUnit->setActive(active); } } diff --git a/src/sound/fmodsound.h b/src/sound/fmodsound.h index e00b2ed27..99d627e5f 100644 --- a/src/sound/fmodsound.h +++ b/src/sound/fmodsound.h @@ -49,7 +49,7 @@ public: void SetSfxPaused (bool paused, int slot); // Pauses or resumes *every* channel, including environmental reverb. - void SetInactive (bool inactive); + void SetInactive (EInactiveState inactive); // Updates the position of a sound channel. void UpdateSoundParams3D (SoundListener *listener, FISoundChannel *chan, bool areasound, const FVector3 &pos, const FVector3 &vel); @@ -107,6 +107,7 @@ private: FMOD::ChannelGroup *MusicGroup; FMOD::DSP *WaterLP, *WaterReverb; FMOD::DSPConnection *SfxConnection; + FMOD::DSPConnection *ChannelGroupTargetUnitOutput; FMOD::DSP *ChannelGroupTargetUnit; FMOD::DSP *SfxReverbPlaceholder; bool SfxReverbHooked; diff --git a/src/sound/i_sound.cpp b/src/sound/i_sound.cpp index 27c00e93f..0fe68a25c 100644 --- a/src/sound/i_sound.cpp +++ b/src/sound/i_sound.cpp @@ -199,7 +199,7 @@ public: } // Pauses or resumes *every* channel, including environmental reverb. - void SetInactive(bool inactive) + void SetInactive(SoundRenderer::EInactiveState inactive) { } diff --git a/src/sound/i_sound.h b/src/sound/i_sound.h index 660e47166..c905678ad 100644 --- a/src/sound/i_sound.h +++ b/src/sound/i_sound.h @@ -126,7 +126,13 @@ public: virtual void SetSfxPaused (bool paused, int slot) = 0; // Pauses or resumes *every* channel, including environmental reverb. - virtual void SetInactive(bool inactive) = 0; + enum EInactiveState + { + INACTIVE_Active, // sound is active + INACTIVE_Complete, // sound is completely paused + INACTIVE_Mute // sound is only muted + }; + virtual void SetInactive(EInactiveState inactive) = 0; // Updates the volume, separation, and pitch of a sound channel. virtual void UpdateSoundParams3D (SoundListener *listener, FISoundChannel *chan, bool areasound, const FVector3 &pos, const FVector3 &vel) = 0;