- sounds in the menu are working now.

Since the in-game sound is paused in the menu these sounds need the CHAN_UI flag to play.
This commit is contained in:
Christoph Oelckers 2019-12-16 08:19:57 +01:00
parent 9b9c009de9
commit 938db6d35d
8 changed files with 26 additions and 25 deletions

View file

@ -479,6 +479,7 @@ int RunGame()
M_Init();
SetDefaultStrings();
if (g_gameType & GAMEFLAG_RR) InitRREndMap(); // this needs to be done better later
C_DoCommand("stat sounddebug");
return gi->app_main();
}

View file

@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define actors_c_
#include "duke3d.h"
#include "sounds.h"
BEGIN_DUKE_NS
@ -1527,7 +1528,7 @@ ACTOR_STATIC void G_MoveFX(void)
goto next_sprite;
}
#endif
A_PlaySound(pSprite->lotag,spriteNum, true);
A_PlaySound(pSprite->lotag,spriteNum, CHAN_LOOP);
T1(spriteNum) = 1; // AMBIENT_SFX_PLAYING
}
else if (playerDist >= spriteHitag && T1(spriteNum) == 1)

View file

@ -364,7 +364,7 @@ int32_t Anim_Play(const char *fn)
if (sound == -1)
FX_StopAllSounds();
else
S_PlaySound(sound);
S_PlaySound(sound, CHAN_UI);
soundidx++;
}
@ -378,7 +378,7 @@ int32_t Anim_Play(const char *fn)
if (sound == -1)
FX_StopAllSounds();
else
S_PlaySound(sound);
S_PlaySound(sound, CHAN_UI);
soundidx++;
}
@ -536,7 +536,7 @@ int32_t Anim_Play(const char *fn)
if (sound == -1)
FX_StopAllSounds();
else
S_PlaySound(sound);
S_PlaySound(sound, CHAN_UI);
soundidx++;
}

View file

@ -481,15 +481,15 @@ void GameInterface::MenuSound(EMenuSounds snd)
switch (snd)
{
case CursorSound:
S_PlaySound(KICK_HIT);
S_PlaySound(KICK_HIT, CHAN_UI);
break;
case AdvanceSound:
S_PlaySound(PISTOL_BODYHIT);
S_PlaySound(PISTOL_BODYHIT, CHAN_UI);
break;
case CloseSound:
S_PlaySound(EXITMENUSOUND);
S_PlaySound(EXITMENUSOUND, CHAN_UI);
break;
default:

View file

@ -172,8 +172,7 @@ enum gametokens
static void gameTimerHandler(void)
{
MUSIC_Update();
S_Update();
G_HandleSpecialKeys();
}
@ -4492,7 +4491,7 @@ void G_HandleLocalKeys(void)
{
if (G_ChangeHudLayout(1))
{
S_PlaySound(THUD);
S_PlaySound(THUD, CHAN_UI);
}
}
else
@ -4511,7 +4510,7 @@ void G_HandleLocalKeys(void)
{
if (G_ChangeHudLayout(-1))
{
S_PlaySound(THUD);
S_PlaySound(THUD, CHAN_UI);
}
}
else
@ -6159,7 +6158,6 @@ MAIN_LOOP_RESTART:
&& (myplayer.gm & MODE_GAME))
{
G_MoveLoop();
S_Update();
}
if (totalclock - moveClock >= (TICSPERFRAME>>1))

View file

@ -4125,7 +4125,7 @@ badindex:
if (S_CheckSoundPlaying(soundNum))
S_StopSound((int16_t)soundNum);
dispatch();
case CON_SCREENSOUND: S_PlaySound(soundNum); dispatch();
case CON_SCREENSOUND: S_PlaySound(soundNum, CHAN_UI); dispatch();
}
}
dispatch();

View file

@ -386,7 +386,7 @@ void S_Update(void)
//
//==========================================================================
int S_PlaySound3D(int num, int spriteNum, const vec3_t* pos, bool looped)
int S_PlaySound3D(int num, int spriteNum, const vec3_t* pos, int flags)
{
int32_t j = VM_OnEventWithReturn(EVENT_SOUND, spriteNum, screenpeek, num);
@ -470,8 +470,8 @@ int S_PlaySound3D(int num, int spriteNum, const vec3_t* pos, bool looped)
// Now
float attenuation = (userflags & (SF_GLOBAL | SF_DTAG)) == SF_GLOBAL ? ATTN_NONE : ATTN_NORM;
auto chflg = ((userflags & SF_LOOP) || looped) ? CHAN_AUTO | CHAN_LOOP : CHAN_AUTO;
auto chan = soundEngine->StartSound(SOURCE_Actor, &sprite[spriteNum], &sndpos, chflg, sndnum+1, 1.f, attenuation, nullptr, S_ConvertPitch(pitch));
if (userflags & SF_LOOP) flags |= CHAN_LOOP;
auto chan = soundEngine->StartSound(SOURCE_Actor, &sprite[spriteNum], &sndpos, flags, sndnum+1, 1.f, attenuation, nullptr, S_ConvertPitch(pitch));
if (!chan) return -1;
return 0;
}
@ -482,7 +482,7 @@ int S_PlaySound3D(int num, int spriteNum, const vec3_t* pos, bool looped)
//
//==========================================================================
int S_PlaySound(int num, bool looped)
int S_PlaySound(int num, int flags)
{
int sndnum = VM_OnEventWithReturn(EVENT_SOUND, g_player[screenpeek].ps->i, screenpeek, num);
@ -494,8 +494,8 @@ int S_PlaySound(int num, bool looped)
int const pitch = S_GetPitch(sndnum);
auto chflg = ((userflags & SF_LOOP) || looped) ? CHAN_AUTO | CHAN_LOOP : CHAN_AUTO;
soundEngine->StartSound(SOURCE_None, nullptr, nullptr, chflg, sndnum + 1, 1.f, ATTN_NONE, nullptr, S_ConvertPitch(pitch));
if (userflags & SF_LOOP) flags |= CHAN_LOOP;
soundEngine->StartSound(SOURCE_None, nullptr, nullptr, flags, sndnum + 1, 1.f, ATTN_NONE, nullptr, S_ConvertPitch(pitch));
/* for reference. May still be needed for balancing later.
: FX_Play3D(snd.ptr, snd.siz, FX_ONESHOT, pitch, 0, 255 - LOUDESTVOLUME, snd.pr, snd.volume,
(num * MAXSOUNDINSTANCES) + sndnum);
@ -509,10 +509,10 @@ int S_PlaySound(int num, bool looped)
//
//==========================================================================
int A_PlaySound(int soundNum, int spriteNum, bool looped)
int A_PlaySound(int soundNum, int spriteNum, int flags)
{
return (unsigned)spriteNum >= MAXSPRITES ? S_PlaySound(soundNum, looped) :
S_PlaySound3D(soundNum, spriteNum, &sprite[spriteNum].pos, looped);
return (unsigned)spriteNum >= MAXSPRITES ? S_PlaySound(soundNum, flags) :
S_PlaySound3D(soundNum, spriteNum, &sprite[spriteNum].pos, flags);
}
void S_StopEnvSound(int sndNum, int sprNum)

View file

@ -30,6 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define sounds_public_h_
#include "sounds_common.h"
#include "sound/s_soundinternal.h"
#include "z_music.h"
BEGIN_DUKE_NS
@ -45,7 +46,7 @@ typedef struct
} sound_t;
int A_CheckSoundPlaying(int spriteNum,int soundNum);
int A_PlaySound(int soundNum, int spriteNum, bool looped = false);
int A_PlaySound(int soundNum, int spriteNum, int flags = 0);
void S_Callback(intptr_t num);
int A_CheckAnySoundPlaying(int spriteNum);
int S_CheckSoundPlaying(int soundNum);
@ -58,8 +59,8 @@ void S_PlayLevelMusicOrNothing(unsigned int);
int S_TryPlaySpecialMusic(unsigned int);
void S_PlaySpecialMusicOrNothing(unsigned int);
void S_ContinueLevelMusic(void);
int S_PlaySound(int num, bool looped = false);
int S_PlaySound3D(int num, int spriteNum, const vec3_t *pos, bool looped = false);
int S_PlaySound(int num, int flags = 0);
int S_PlaySound3D(int num, int spriteNum, const vec3_t *pos, int flags = 0);
void S_StopEnvSound(int sndNum,int sprNum);
void S_StopAllSounds(void);
void S_Update(void);