]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
new cvar: mastervolume (controlling both volume and bgmvolume)
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 6 May 2010 06:45:32 +0000 (06:45 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 6 May 2010 06:45:32 +0000 (06:45 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10173 d7cf8633-e32d-0410-b094-e92efae38249

cd_shared.c
snd_3dras.c
snd_main.c
snd_mix.c
snd_null.c
sound.h

index 5ac76832bc53dfc7fc8683b76e14f794331476a3..7ca41ed60079493485e6ad7db7323fdf94f30e32 100644 (file)
@@ -605,7 +605,7 @@ void CDAudio_SetVolume (float newvol)
                if (faketrack != -1)
                        S_SetChannelVolume (faketrack, newvol);
                else
                if (faketrack != -1)
                        S_SetChannelVolume (faketrack, newvol);
                else
-                       CDAudio_SysSetVolume (newvol);
+                       CDAudio_SysSetVolume (newvol * mastervolume.value);
        }
 
        cdvolume = newvol;
        }
 
        cdvolume = newvol;
index 18860a5d76568aef4a2e6a70a1f700346ad3aae8..8b71d2798082b59b00829a0d0632024ff376edca 100644 (file)
@@ -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)"};
 #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"};
 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);
                        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);
 
                        Cvar_RegisterVariable(&snd_staticvolume);
                        Cvar_RegisterVariable(&snd_precache);
 
index 87c223a44585c38ee0b66bab3a3ac28d3658df1f..ce04f8051d93f901a78e01ebbff919b910139bf7 100644 (file)
@@ -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)"};
 
 // 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)"};
 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(&volume);
        Cvar_RegisterVariable(&bgmvolume);
+       Cvar_RegisterVariable(&mastervolume);
        Cvar_RegisterVariable(&snd_staticvolume);
        Cvar_RegisterVariable(&snd_entchannel0volume);
        Cvar_RegisterVariable(&snd_entchannel1volume);
        Cvar_RegisterVariable(&snd_staticvolume);
        Cvar_RegisterVariable(&snd_entchannel0volume);
        Cvar_RegisterVariable(&snd_entchannel1volume);
index 79e6e0738803091e83f3ad084e286bc46c5fcb6f..6bba3c1ad8870912efc8788ce3aa45c693a13939 100644 (file)
--- 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)
 
        // If this channel manages its own volume
        if (ch->flags & CHANNELFLAG_FULLVOLUME)
-               snd_vol = 256;
+               snd_vol = (int)(mastervolume.value * 256);
        else
        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
 
        // calculate mixing volumes based on channel volumes and volume cvar
        // also limit the volumes to values that won't clip
index 7362dc5693324e08d350a727581b6666470f638c..bc71a4f30835082a6164a480c8c333bcccdd7817 100755 (executable)
@@ -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)"};
 #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"};
 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);
 void S_Init (void)
 {
        Cvar_RegisterVariable(&bgmvolume);
+       Cvar_RegisterVariable(&mastervolume);
        Cvar_RegisterVariable(&volume);
        Cvar_RegisterVariable(&snd_staticvolume);
        Cvar_RegisterVariable(&snd_initialized);
        Cvar_RegisterVariable(&volume);
        Cvar_RegisterVariable(&snd_staticvolume);
        Cvar_RegisterVariable(&snd_initialized);
diff --git a/sound.h b/sound.h
index fa435c8806e5285746a35bd52d1d6dbffbf4e7bd..37e53b06f1e541983304a6a8e68603ca43184759 100644 (file)
--- 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;
 
 
 typedef struct sfx_s sfx_t;
 
+extern cvar_t mastervolume;
 extern cvar_t bgmvolume;
 extern cvar_t volume;
 extern cvar_t snd_initialized;
 extern cvar_t bgmvolume;
 extern cvar_t volume;
 extern cvar_t snd_initialized;