Fix drop in volume when shooting into a Brains power screen.

If too many of these sounds are started in one frame (for example if the
player shoots with the super shotgun into the power screen of a Brain)
things get too loud and OpenAL is forced to scale the volume of several
other sounds and the background music down. That leads to a noticable
and annoying drop in the overall volume.

Work around that by limiting the number of sounds started. 16 was
choosen by empirical testing.
This commit is contained in:
Yamagi Burmeister 2017-11-30 08:26:39 +01:00
parent e30f824944
commit e3e5bd1bdd
3 changed files with 32 additions and 1 deletions

View file

@ -92,6 +92,11 @@ centity_t cl_entities[MAX_EDICTS];
entity_state_t cl_parse_entities[MAX_PARSE_ENTITIES]; entity_state_t cl_parse_entities[MAX_PARSE_ENTITIES];
/*Evil hack against too many power screen and power
shield impact sounds. For example if the player
fires his shotgun onto a Brain. */
int num_power_sounds;
extern cvar_t *allow_download; extern cvar_t *allow_download;
extern cvar_t *allow_download_players; extern cvar_t *allow_download_players;
extern cvar_t *allow_download_models; extern cvar_t *allow_download_models;
@ -733,6 +738,9 @@ CL_Frame(int packetdelta, int renderdelta, int timedelta, qboolean packetframe,
cls.netchan.last_received = Sys_Milliseconds(); cls.netchan.last_received = Sys_Milliseconds();
} }
// Reset power shield / power screen sound counter.
num_power_sounds = 0;
if (!cl_timedemo->value) if (!cl_timedemo->value)
{ {
// Don't throttle too much when connecting / loading. // Don't throttle too much when connecting / loading.

View file

@ -24,7 +24,9 @@
* ======================================================================= * =======================================================================
*/ */
#include <SDL2/SDL_scancode.h>
#include "header/client.h" #include "header/client.h"
#include "sound/header/local.h"
typedef enum typedef enum
{ {
@ -716,7 +718,23 @@ CL_ParseTEnt(void)
CL_ParticleEffect(pos, dir, 0xb0, 40); CL_ParticleEffect(pos, dir, 0xb0, 40);
} }
num_power_sounds++;
/* If too many of these sounds are started in one frame (for
* example if the player shoots with the super shotgun into
* the power screen of a Brain) things get too loud and OpenAL
* is forced to scale the volume of several other sounds and
* the background music down. That leads to a noticable and
* annoying drop in the overall volume.
*
* Work around that by limiting the number of sounds started.
* 16 was choosen by empirical testing.
*/
if (sound_started == SS_OAL && num_power_sounds < 16)
{
S_StartSound(pos, 0, 0, cl_sfx_lashit, 1, ATTN_NORM, 0); S_StartSound(pos, 0, 0, cl_sfx_lashit, 1, ATTN_NORM, 0);
}
break; break;
case TE_SHOTGUN: /* bullet hitting wall */ case TE_SHOTGUN: /* bullet hitting wall */

View file

@ -249,6 +249,11 @@ typedef struct
extern client_static_t cls; extern client_static_t cls;
/*Evil hack against too many power screen and power
shield impact sounds. For example if the player
fires his shotgun onto a Brain. */
extern int num_power_sounds;
/* cvars */ /* cvars */
extern cvar_t *gl_stereo_separation; extern cvar_t *gl_stereo_separation;
extern cvar_t *gl_stereo_convergence; extern cvar_t *gl_stereo_convergence;