]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
independent volume control for the 8 entity channels
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 6 Aug 2008 06:32:58 +0000 (06:32 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 6 Aug 2008 06:32:58 +0000 (06:32 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8437 d7cf8633-e32d-0410-b094-e92efae38249

snd_main.c

index 46600ca7b013ccfdcf2369705110b81a31553319..3d9ae194b75677a98cfd7fa8f57f3c5af29360e6 100644 (file)
@@ -179,6 +179,14 @@ cvar_t snd_swapstereo = {CVAR_SAVE, "snd_swapstereo", "0", "swaps left/right spe
 extern cvar_t v_flipped;
 cvar_t snd_channellayout = {0, "snd_channellayout", "0", "channel layout. Can be 0 (auto - snd_restart needed), 1 (standard layout), or 2 (ALSA layout)"};
 cvar_t snd_mutewhenidle = {CVAR_SAVE, "snd_mutewhenidle", "1", "whether to disable sound output when game window is inactive"};
+cvar_t snd_entchannel0volume = {CVAR_SAVE, "snd_entchannel0volume", "1", "volume multiplier of the auto-allocate entity channel"};
+cvar_t snd_entchannel1volume = {CVAR_SAVE, "snd_entchannel1volume", "1", "volume multiplier of the 1st entity channel"};
+cvar_t snd_entchannel2volume = {CVAR_SAVE, "snd_entchannel2volume", "1", "volume multiplier of the 2nd entity channel"};
+cvar_t snd_entchannel3volume = {CVAR_SAVE, "snd_entchannel3volume", "1", "volume multiplier of the 3rd entity channel"};
+cvar_t snd_entchannel4volume = {CVAR_SAVE, "snd_entchannel4volume", "1", "volume multiplier of the 4th entity channel"};
+cvar_t snd_entchannel5volume = {CVAR_SAVE, "snd_entchannel5volume", "1", "volume multiplier of the 5th entity channel"};
+cvar_t snd_entchannel6volume = {CVAR_SAVE, "snd_entchannel6volume", "1", "volume multiplier of the 6th entity channel"};
+cvar_t snd_entchannel7volume = {CVAR_SAVE, "snd_entchannel7volume", "1", "volume multiplier of the 7th entity channel"};
 
 // Local cvars
 static cvar_t nosound = {0, "nosound", "0", "disables sound"};
@@ -738,6 +746,14 @@ void S_Init(void)
        Cvar_RegisterVariable(&volume);
        Cvar_RegisterVariable(&bgmvolume);
        Cvar_RegisterVariable(&snd_staticvolume);
+       Cvar_RegisterVariable(&snd_entchannel0volume);
+       Cvar_RegisterVariable(&snd_entchannel1volume);
+       Cvar_RegisterVariable(&snd_entchannel2volume);
+       Cvar_RegisterVariable(&snd_entchannel3volume);
+       Cvar_RegisterVariable(&snd_entchannel4volume);
+       Cvar_RegisterVariable(&snd_entchannel5volume);
+       Cvar_RegisterVariable(&snd_entchannel6volume);
+       Cvar_RegisterVariable(&snd_entchannel7volume);
 
        Cvar_RegisterVariable(&snd_speed);
        Cvar_RegisterVariable(&snd_width);
@@ -1176,9 +1192,25 @@ void SND_Spatialize(channel_t *ch, qboolean isstatic)
        }
 
        mastervol = ch->master_vol;
+
        // Adjust volume of static sounds
        if (isstatic)
                mastervol *= snd_staticvolume.value;
+       else if(!(ch->flags & CHANNELFLAG_FULLVOLUME)) // same as SND_PaintChannel uses
+       {
+               switch(ch->entchannel)
+               {
+                       case 0: mastervol *= snd_entchannel0volume.value; break;
+                       case 1: mastervol *= snd_entchannel1volume.value; break;
+                       case 2: mastervol *= snd_entchannel2volume.value; break;
+                       case 3: mastervol *= snd_entchannel3volume.value; break;
+                       case 4: mastervol *= snd_entchannel4volume.value; break;
+                       case 5: mastervol *= snd_entchannel5volume.value; break;
+                       case 6: mastervol *= snd_entchannel6volume.value; break;
+                       case 7: mastervol *= snd_entchannel7volume.value; break;
+                       default:                                          break;
+               }
+       }
 
        // anything coming from the view entity will always be full volume
        // LordHavoc: make sounds with ATTN_NONE have no spatialization