From fb74d9b1ecc264f5d1b986c52a4c5c9765b96084 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Wed, 4 Nov 2009 02:07:39 +0000 Subject: [PATCH] - Added virtual status and audibility to the noise debug display. SVN r1961 (trunk) --- docs/rh-log.txt | 1 + src/s_sound.cpp | 29 +++++++++++++++++++++++++++-- src/s_sound.h | 1 + src/sound/fmodsound.cpp | 34 +++++++++++++++++++++++++++++----- src/sound/fmodsound.h | 3 +++ src/sound/i_sound.cpp | 6 ++++++ src/sound/i_sound.h | 4 ++++ src/sound/i_soundinternal.h | 1 - 8 files changed, 71 insertions(+), 8 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index a3492e313..fdb2dcbd1 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,5 @@ November 3, 2009 +- Added virtual status and audibility to the noise debug display. - Added a command line option -warpwipe to perform the screen wipe if you start with -warp or +map. diff --git a/src/s_sound.cpp b/src/s_sound.cpp index e294b6efb..ffacab9e6 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -164,6 +164,7 @@ void S_NoiseDebug (void) screen->DrawText (SmallFont, CR_GOLD, 300, y, "chan", TAG_DONE); screen->DrawText (SmallFont, CR_GOLD, 340, y, "pri", TAG_DONE); screen->DrawText (SmallFont, CR_GOLD, 380, y, "flags", TAG_DONE); + screen->DrawText (SmallFont, CR_GOLD, 460, y, "aud", TAG_DONE); y += 8; if (Channels == NULL) @@ -236,7 +237,7 @@ void S_NoiseDebug (void) screen->DrawText(SmallFont, color, 340, y, temp, TAG_DONE); // Flags - mysnprintf(temp, countof(temp), "%s3%sZ%sU%sM%sN%sA%sL%sE", + mysnprintf(temp, countof(temp), "%s3%sZ%sU%sM%sN%sA%sL%sE%sV", (chan->ChanFlags & CHAN_IS3D) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK, (chan->ChanFlags & CHAN_LISTENERZ) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK, (chan->ChanFlags & CHAN_UI) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK, @@ -244,9 +245,14 @@ void S_NoiseDebug (void) (chan->ChanFlags & CHAN_NOPAUSE) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK, (chan->ChanFlags & CHAN_AREA) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK, (chan->ChanFlags & CHAN_LOOP) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK, - (chan->ChanFlags & CHAN_EVICTED) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK); + (chan->ChanFlags & CHAN_EVICTED) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK, + (chan->ChanFlags & CHAN_VIRTUAL) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK); screen->DrawText(SmallFont, color, 380, y, temp, TAG_DONE); + // Audibility + mysnprintf(temp, countof(temp), "%.2g", GSnd->GetAudibility(chan)); + screen->DrawText(SmallFont, color, 460, y, temp, TAG_DONE); + y += 8; if (chan->PrevChan == &Channels) { @@ -2003,6 +2009,25 @@ void S_ChannelEnded(FISoundChannel *ichan) } } +//========================================================================== +// +// S_ChannelVirtualChanged (callback for sound interface code) +// +//========================================================================== + +void S_ChannelVirtualChanged(FISoundChannel *ichan, bool is_virtual) +{ + FSoundChan *schan = static_cast(ichan); + if (is_virtual) + { + schan->ChanFlags |= CHAN_VIRTUAL; + } + else + { + schan->ChanFlags &= ~CHAN_VIRTUAL; + } +} + //========================================================================== // // S_StopChannel diff --git a/src/s_sound.h b/src/s_sound.h index ad0f3c61b..638baf5e5 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -262,6 +262,7 @@ void S_Sound (fixed_t x, fixed_t y, fixed_t z, int channel, FSoundID sfxid, floa #define CHAN_FORGETTABLE 4 // internal: Forget channel data when sound stops. #define CHAN_JUSTSTARTED 512 // internal: Sound has not been updated yet. #define CHAN_ABSTIME 1024// internal: Start time is absolute and does not depend on current time. +#define CHAN_VIRTUAL 2048// internal: Channel is currently virtual // sound attenuation values #define ATTN_NONE 0.f // full volume the entire level diff --git a/src/sound/fmodsound.cpp b/src/sound/fmodsound.cpp index 2a1ad2b9c..724d701fe 100644 --- a/src/sound/fmodsound.cpp +++ b/src/sound/fmodsound.cpp @@ -1846,6 +1846,27 @@ unsigned int FMODSoundRenderer::GetPosition(FISoundChannel *chan) return pos; } +//========================================================================== +// +// FMODSoundRenderer :: GetAudibility +// +// Returns the audible volume of the channel, after rollof and any other +// factors are applied. +// +//========================================================================== + +float FMODSoundRenderer::GetAudibility(FISoundChannel *chan) +{ + float aud; + + if (chan == NULL || chan->SysChannel == NULL) + { + return 0; + } + ((FMOD::Channel *)chan->SysChannel)->getAudibility(&aud); + return aud; +} + //========================================================================== // // FMODSoundRenderer :: SetSfxPaused @@ -2284,16 +2305,19 @@ unsigned int FMODSoundRenderer::GetSampleLength(SoundHandle sfx) FMOD_RESULT F_CALLBACK FMODSoundRenderer::ChannelCallback (FMOD_CHANNEL *channel, FMOD_CHANNEL_CALLBACKTYPE type, void *data1, void *data2) { - if (type != FMOD_CHANNEL_CALLBACKTYPE_END) - { - return FMOD_OK; - } FMOD::Channel *chan = (FMOD::Channel *)channel; FISoundChannel *schan; if (chan->getUserData((void **)&schan) == FMOD_OK && schan != NULL) { - S_ChannelEnded(schan); + if (type == FMOD_CHANNEL_CALLBACKTYPE_END) + { + S_ChannelEnded(schan); + } + else if (type == FMOD_CHANNEL_CALLBACKTYPE_VIRTUALVOICE) + { + S_ChannelVirtualChanged(schan, data1 != 0); + } } return FMOD_OK; } diff --git a/src/sound/fmodsound.h b/src/sound/fmodsound.h index 5febda3e2..78ba8aa86 100644 --- a/src/sound/fmodsound.h +++ b/src/sound/fmodsound.h @@ -36,6 +36,9 @@ public: // Returns position of sound on this channel, in samples. unsigned int GetPosition(FISoundChannel *chan); + // Gets a channel's audibility (real volume). + float GetAudibility(FISoundChannel *chan); + // Synchronizes following sound startups. void Sync (bool sync); diff --git a/src/sound/i_sound.cpp b/src/sound/i_sound.cpp index 3370bd92f..c4b0c63e0 100644 --- a/src/sound/i_sound.cpp +++ b/src/sound/i_sound.cpp @@ -175,6 +175,12 @@ public: return 0; } + // Gets a channel's audibility (real volume). + float GetAudibility(FISoundChannel *chan) + { + return 0; + } + // Synchronizes following sound startups. void Sync (bool sync) { diff --git a/src/sound/i_sound.h b/src/sound/i_sound.h index b402fa3d2..1ff535d93 100644 --- a/src/sound/i_sound.h +++ b/src/sound/i_sound.h @@ -112,6 +112,9 @@ public: // Returns position of sound on this channel, in samples. virtual unsigned int GetPosition(FISoundChannel *chan) = 0; + // Gets a channel's audibility (real volume). + virtual float GetAudibility(FISoundChannel *chan) = 0; + // Synchronizes following sound startups. virtual void Sync (bool sync) = 0; @@ -142,6 +145,7 @@ void I_InitSound (); void I_ShutdownSound (); void S_ChannelEnded(FISoundChannel *schan); +void S_ChannelVirtualChanged(FISoundChannel *schan, bool is_virtual); float S_GetRolloff(FRolloffInfo *rolloff, float distance, bool logarithmic); FISoundChannel *S_GetChannel(void *syschan); diff --git a/src/sound/i_soundinternal.h b/src/sound/i_soundinternal.h index 9f6fe6d87..157c9c87b 100644 --- a/src/sound/i_soundinternal.h +++ b/src/sound/i_soundinternal.h @@ -96,7 +96,6 @@ struct FISoundChannel // callback that can't be passed a sound channel pointer FRolloffInfo Rolloff; float DistanceScale; - };