add a configurable same sound limit
inspired by dsda-doom in alot of cases the game may play a crapton of the same sound at once, becoming unbearably loud
This commit is contained in:
1 parent
a42e6f24a3
commit
6a17bb052c
3 files changed
+39
-6
No files matched your search
+9
-6
@@ -1138,14 +1138,16 @@ static menuitem_t OP_SoundAdvancedMenu[] =
|
||||
|
||||
{IT_HEADER, NULL, "Misc", NULL, 45},
|
||||
|
||||
{IT_STRING | IT_CVAR, NULL, "Grow Music", &cv_growmusic, 55},
|
||||
{IT_STRING | IT_CVAR, NULL, "Invulnerability Music", &cv_supermusic, 60},
|
||||
{IT_STRING | IT_CVAR, NULL, "Same Sound Limit", &cv_samesoundlimit, 55},
|
||||
|
||||
{IT_STRING | IT_CVAR, NULL, "Keep Map Music", &cv_keepmusic, 70},
|
||||
{IT_STRING | IT_CVAR, NULL, "Skip Intro Music", &cv_skipintromusic, 75},
|
||||
{IT_STRING | IT_CVAR, NULL, "Grow Music", &cv_growmusic, 65},
|
||||
{IT_STRING | IT_CVAR, NULL, "Invulnerability Music", &cv_supermusic, 70},
|
||||
|
||||
{IT_STRING | IT_CVAR, NULL, "Audio Buffer Size", &cv_audbuffersize, 80},
|
||||
{IT_DISABLED, NULL, "", NULL, 90}, // dummy text
|
||||
{IT_STRING | IT_CVAR, NULL, "Keep Map Music", &cv_keepmusic, 80},
|
||||
{IT_STRING | IT_CVAR, NULL, "Skip Intro Music", &cv_skipintromusic, 85},
|
||||
|
||||
{IT_STRING | IT_CVAR, NULL, "Audio Buffer Size", &cv_audbuffersize, 90},
|
||||
{IT_DISABLED, NULL, "", NULL, 100}, // dummy text
|
||||
};
|
||||
|
||||
static const char* OP_SoundAdvancedTooltips[] =
|
||||
@@ -1161,6 +1163,7 @@ static const char* OP_SoundAdvancedTooltips[] =
|
||||
"How far should the four channels in .mod be panned?",
|
||||
#endif
|
||||
NULL,
|
||||
"How many times is the same sound allowed to play at once?\nIf 0 theres no limit.",
|
||||
"Should the Grow music be on or off?",
|
||||
"Should the Invulnerability music be on or off?",
|
||||
"Should music be kept when restarting the map?",
|
||||
|
||||
@@ -81,6 +81,9 @@ consvar_t cv_midimusicvolume = {"midimusicvolume", "18", CV_SAVE, soundvolume_co
|
||||
// number of channels available
|
||||
consvar_t cv_numChannels = {"snd_channels", "64", CV_SAVE|CV_CALL, CV_Unsigned, SetChannelsNum, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
static CV_PossibleValue_t samesoundlimit_cons_t[] = {{0, "MIN"}, {64, "MAX"}, {0, NULL}};
|
||||
consvar_t cv_samesoundlimit = {"samesoundlimit", "0", CV_SAVE, samesoundlimit_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
//consvar_t cv_resetmusic = {"resetmusic", "No", CV_SAVE|CV_NOSHOWHELP, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
// Sound system toggles, saved into the config
|
||||
@@ -282,6 +285,8 @@ void S_RegisterSoundStuff(void)
|
||||
CV_RegisterVar(&cv_gamemidimusic);
|
||||
#endif
|
||||
|
||||
CV_RegisterVar(&cv_samesoundlimit);
|
||||
|
||||
// bird music stuff
|
||||
CV_RegisterVar(&cv_playmusicifunfocused);
|
||||
CV_RegisterVar(&cv_playsoundifunfocused);
|
||||
@@ -427,6 +432,25 @@ static INT32 S_ScaleVolumeWithSplitscreen(INT32 volume)
|
||||
return FixedDiv(volume * FRACUNIT, root) / FRACUNIT;
|
||||
}
|
||||
|
||||
static boolean S_CheckSameSoundLimit(sfxenum_t sfx_id)
|
||||
{
|
||||
INT32 cnum, scount = 0;
|
||||
|
||||
if (!cv_samesoundlimit.value)
|
||||
return true;
|
||||
|
||||
for (cnum = 0; cnum < numofchannels; cnum++)
|
||||
if ((size_t)(channels[cnum].sfxinfo - S_sfx) == (size_t)sfx_id)
|
||||
scount++;
|
||||
|
||||
//CONS_Printf("same sound count: %d for sfx: %d\n", scount, sfx_id);
|
||||
|
||||
if (scount >= cv_samesoundlimit.value)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume)
|
||||
{
|
||||
const mobj_t *origin = (const mobj_t *)origin_p;
|
||||
@@ -449,6 +473,10 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume)
|
||||
if (sfx_id == sfx_None)
|
||||
return;
|
||||
|
||||
// reached same sound limit?
|
||||
if (!S_CheckSameSoundLimit(sfx_id))
|
||||
return;
|
||||
|
||||
for (i = 0; i <= splitscreen; i++)
|
||||
{
|
||||
player_t *player = &players[displayplayers[i]];
|
||||
|
||||
@@ -32,6 +32,8 @@ extern consvar_t stereoreverse;
|
||||
extern consvar_t cv_soundvolume, cv_digmusicvolume;//, cv_midimusicvolume;
|
||||
extern consvar_t cv_numChannels;
|
||||
|
||||
extern consvar_t cv_samesoundlimit;
|
||||
|
||||
extern consvar_t cv_audbuffersize;
|
||||
//extern consvar_t cv_resetmusic;
|
||||
extern consvar_t cv_gamedigimusic;
|
||||
|
||||
Reference in new issue
Block a user