From 32510c922fbcaad22056befd2018ea9066c1f138 Mon Sep 17 00:00:00 2001 From: divverent Date: Thu, 6 May 2010 06:45:32 +0000 Subject: [PATCH] new cvar: mastervolume (controlling both volume and bgmvolume) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10173 d7cf8633-e32d-0410-b094-e92efae38249 --- cd_shared.c | 2 +- snd_3dras.c | 2 ++ snd_main.c | 2 ++ snd_mix.c | 4 ++-- snd_null.c | 2 ++ sound.h | 1 + 6 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cd_shared.c b/cd_shared.c index 5ac76832..7ca41ed6 100644 --- a/cd_shared.c +++ b/cd_shared.c @@ -605,7 +605,7 @@ void CDAudio_SetVolume (float newvol) if (faketrack != -1) S_SetChannelVolume (faketrack, newvol); else - CDAudio_SysSetVolume (newvol); + CDAudio_SysSetVolume (newvol * mastervolume.value); } cdvolume = newvol; diff --git a/snd_3dras.c b/snd_3dras.c index 18860a5d..8b71d279 100644 --- a/snd_3dras.c +++ b/snd_3dras.c @@ -5,6 +5,7 @@ #include "snd_3dras.h" cvar_t bgmvolume = {CVAR_SAVE, "bgmvolume", "1", "volume of background music (such as CD music or replacement files such as sound/cdtracks/track002.ogg)"}; +cvar_t mastervolume = {CVAR_SAVE, "mastervolume", "1", "master volume"}; cvar_t volume = {CVAR_SAVE, "volume", "0.7", "volume of sound effects"}; cvar_t snd_staticvolume = {CVAR_SAVE, "snd_staticvolume", "1", "volume of ambient sound effects (such as swampy sounds at the start of e1m2)"}; cvar_t snd_initialized = { CVAR_READONLY, "snd_initialized", "0", "indicates the sound subsystem is active"}; @@ -367,6 +368,7 @@ void S_Init (void){ Con_Printf ("Version %i found\n",ras_version); Cvar_RegisterVariable(&volume); Cvar_RegisterVariable(&bgmvolume); + Cvar_RegisterVariable(&mastervolume); Cvar_RegisterVariable(&snd_staticvolume); Cvar_RegisterVariable(&snd_precache); diff --git a/snd_main.c b/snd_main.c index 87c223a4..ce04f805 100644 --- a/snd_main.c +++ b/snd_main.c @@ -157,6 +157,7 @@ spatialmethod_t spatialmethod; // Cvars declared in sound.h (part of the sound API) cvar_t bgmvolume = {CVAR_SAVE, "bgmvolume", "1", "volume of background music (such as CD music or replacement files such as sound/cdtracks/track002.ogg)"}; +cvar_t mastervolume = {CVAR_SAVE, "mastervolume", "0.7", "master volume"}; cvar_t volume = {CVAR_SAVE, "volume", "0.7", "volume of sound effects"}; cvar_t snd_initialized = { CVAR_READONLY, "snd_initialized", "0", "indicates the sound subsystem is active"}; cvar_t snd_staticvolume = {CVAR_SAVE, "snd_staticvolume", "1", "volume of ambient sound effects (such as swampy sounds at the start of e1m2)"}; @@ -771,6 +772,7 @@ void S_Init(void) { Cvar_RegisterVariable(&volume); Cvar_RegisterVariable(&bgmvolume); + Cvar_RegisterVariable(&mastervolume); Cvar_RegisterVariable(&snd_staticvolume); Cvar_RegisterVariable(&snd_entchannel0volume); Cvar_RegisterVariable(&snd_entchannel1volume); diff --git a/snd_mix.c b/snd_mix.c index 79e6e073..6bba3c1a 100644 --- a/snd_mix.c +++ b/snd_mix.c @@ -189,9 +189,9 @@ static qboolean SND_PaintChannel (channel_t *ch, portable_sampleframe_t *paint, // If this channel manages its own volume if (ch->flags & CHANNELFLAG_FULLVOLUME) - snd_vol = 256; + snd_vol = (int)(mastervolume.value * 256); else - snd_vol = (int)(volume.value * 256); + snd_vol = (int)(mastervolume.value * volume.value * 256); // calculate mixing volumes based on channel volumes and volume cvar // also limit the volumes to values that won't clip diff --git a/snd_null.c b/snd_null.c index 7362dc56..bc71a4f3 100755 --- a/snd_null.c +++ b/snd_null.c @@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "quakedef.h" cvar_t bgmvolume = {CVAR_SAVE, "bgmvolume", "1", "volume of background music (such as CD music or replacement files such as sound/cdtracks/track002.ogg)"}; +cvar_t mastervolume = {CVAR_SAVE, "mastervolume", "1", "master volume"}; cvar_t volume = {CVAR_SAVE, "volume", "0.7", "volume of sound effects"}; cvar_t snd_staticvolume = {CVAR_SAVE, "snd_staticvolume", "1", "volume of ambient sound effects (such as swampy sounds at the start of e1m2)"}; cvar_t snd_initialized = { CVAR_READONLY, "snd_initialized", "0", "indicates the sound subsystem is active"}; @@ -31,6 +32,7 @@ cvar_t snd_mutewhenidle = {CVAR_SAVE, "snd_mutewhenidle", "1", "whether to disab void S_Init (void) { Cvar_RegisterVariable(&bgmvolume); + Cvar_RegisterVariable(&mastervolume); Cvar_RegisterVariable(&volume); Cvar_RegisterVariable(&snd_staticvolume); Cvar_RegisterVariable(&snd_initialized); diff --git a/sound.h b/sound.h index fa435c88..37e53b06 100644 --- a/sound.h +++ b/sound.h @@ -45,6 +45,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. typedef struct sfx_s sfx_t; +extern cvar_t mastervolume; extern cvar_t bgmvolume; extern cvar_t volume; extern cvar_t snd_initialized; -- 2.39.2