about summary refs log tree commit diff
path: root/src/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/client/snd.c27
-rw-r--r--src/engine/config_variables.h1
-rw-r--r--src/engine/interface.h3
3 files changed, 14 insertions, 17 deletions
diff --git a/src/engine/client/snd.c b/src/engine/client/snd.c
index f2b7f9a4..603683f7 100644
--- a/src/engine/client/snd.c
+++ b/src/engine/client/snd.c
@@ -207,17 +207,21 @@ static void mix(short *final_out, unsigned frames)
 	/* release the lock */
 	lock_release(sound_lock);
 
-	/* clamp accumulated values */
-	/* TODO: this seams slow */
-	for(i = 0; i < frames; i++)
 	{
-		int j = i<<1;
-		int vl = mix_buffer[j]>>8;
-		int vr = mix_buffer[j+1]>>8;
+		int master_vol = config.snd_volume;
+		
+		/* clamp accumulated values */
+		/* TODO: this seams slow */
+		for(i = 0; i < frames; i++)
+		{
+			int j = i<<1;
+			int vl = ((mix_buffer[j]*master_vol)/101)>>8;
+			int vr = ((mix_buffer[j+1]*master_vol)/101)>>8;
 
-		final_out[j] = int2short(vl);
-		final_out[j+1] = int2short(vr);
-	}	
+			final_out[j] = int2short(vl);
+			final_out[j+1] = int2short(vr);
+		}
+	}
 }
 
 static int pacallback(const void *in, void *out, unsigned long frames, const PaStreamCallbackTimeInfo* time, PaStreamCallbackFlags status, void *user)
@@ -425,11 +429,6 @@ int snd_load_wv(const char *filename)
 	return sid;
 }
 
-void snd_set_master_volume(float vol)
-{
-	/*master_vol = vol;*/
-}
-
 void snd_set_listener_pos(float x, float y)
 {
 	center_x = (int)x;
diff --git a/src/engine/config_variables.h b/src/engine/config_variables.h
index e67e87c9..49f2a0d9 100644
--- a/src/engine/config_variables.h
+++ b/src/engine/config_variables.h
@@ -27,6 +27,7 @@ MACRO_CONFIG_INT(b_max_requests, 10, 0, 1000)
 
 MACRO_CONFIG_INT(snd_rate, 48000, 0, 0)
 MACRO_CONFIG_INT(snd_enable, 1, 0, 1)
+MACRO_CONFIG_INT(snd_volume, 100, 0, 100)
 
 MACRO_CONFIG_INT(gfx_screen_width, 800, 0, 0)
 MACRO_CONFIG_INT(gfx_screen_height, 600, 0, 0)
diff --git a/src/engine/interface.h b/src/engine/interface.h
index 1a4b7d73..ae6362fe 100644
--- a/src/engine/interface.h
+++ b/src/engine/interface.h
@@ -372,9 +372,6 @@ void gfx_quads_text(float x, float y, float size, const char *text);
 /* sound (client) */
 int snd_init();
 
-float snd_get_master_volume();
-void snd_set_master_volume(float val);
-
 void snd_set_channel(int cid, float vol, float pan);
 
 int snd_load_wv(const char *filename);