about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJoel de Vahl <joel@stalverk80.se>2007-07-21 17:44:24 +0000
committerJoel de Vahl <joel@stalverk80.se>2007-07-21 17:44:24 +0000
commit978b4bf7d7a4216c73556b5ea3a3b28cc717fc25 (patch)
treea347fd6728658797860162b5ba7a69d1c9433772 /src
parentd3986a36a74ce7afd86397e428fd4abd3047f669 (diff)
downloadzcatch-978b4bf7d7a4216c73556b5ea3a3b28cc717fc25.tar.gz
zcatch-978b4bf7d7a4216c73556b5ea3a3b28cc717fc25.zip
Master volume affect playing sounds.
Diffstat (limited to 'src')
-rw-r--r--src/engine/client/snd.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/engine/client/snd.cpp b/src/engine/client/snd.cpp
index 23e20d4c..a4ed957c 100644
--- a/src/engine/client/snd.cpp
+++ b/src/engine/client/snd.cpp
@@ -12,6 +12,7 @@ static const int NUM_FRAMES_LERP = 512;
 static const float NUM_FRAMES_LERP_INV = 1.0f/(float)NUM_FRAMES_LERP;
 
 static const float GLOBAL_VOLUME_SCALE = 0.75f;
+static float master_volume = 1.0f;
 
 static const int64 GLOBAL_SOUND_DELAY = 1000;
 
@@ -69,7 +70,7 @@ public:
 		for(unsigned long i = 0; i < frames; i++)
 		{
 			float p = (1.0f-(c->pan+1.0f)*0.5f);
-			int val = (int)(p*c->vol * c->data->data[c->tick]);
+			int val = (int)(p*c->vol * master_volume * c->data->data[c->tick]);
 			out[i<<1] += (short)val;
 			out[(i<<1)+1] += (short)val;
 			c->tick++;
@@ -84,8 +85,8 @@ public:
 		{
 			float pl = c->pan<0.0f?-c->pan:1.0f;
 			float pr = c->pan>0.0f?1.0f-c->pan:1.0f;
-			int vl = (int)(pl*c->vol * c->data->data[c->tick]);
-			int vr = (int)(pr*c->vol * c->data->data[c->tick + 1]);
+			int vl = (int)(pl*c->vol * master_volume * c->data->data[c->tick]);
+			int vr = (int)(pr*c->vol * master_volume * c->data->data[c->tick + 1]);
 			out[i<<1] += (short)vl;
 			out[(i<<1)+1] += (short)vr;
 			c->tick += 2;
@@ -195,7 +196,6 @@ struct sound_holder
 static const int MAX_SOUNDS = 1024;
 static sound_holder sounds[MAX_SOUNDS];
 static int first_free_sound;
-static float master_volume = 1.0f;
 
 bool snd_init()
 {
@@ -408,7 +408,7 @@ int snd_play(int id, int loop, float vol, float pan)
 
 	dbg_assert(sounds[id].sound.data != 0, "null sound");
 	dbg_assert(sounds[id].next == -1, "sound isn't allocated");
-	return mixer.play(&sounds[id].sound, loop, master_volume * vol, pan);
+	return mixer.play(&sounds[id].sound, loop, vol, pan);
 }
 
 void snd_stop(int id)