summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Weisse <[email protected]>2005-04-27 12:39:23 +0000
committerCarsten Weisse <[email protected]>2005-04-27 12:39:23 +0000
commitc3dc694a595fc216152ea4d9801a9fbf973241b6 (patch)
tree6c509256ff898a751125010327ced9b13708d9f1
parentbfc3531d5dbb13ee9fe8fba0d4302d481c3670db (diff)
change the master volume (listener) only on Update not per source
-rw-r--r--src/jake2/sound/joal/Channel.java29
-rw-r--r--src/jake2/sound/joal/JOALSoundImpl.java15
2 files changed, 27 insertions, 17 deletions
diff --git a/src/jake2/sound/joal/Channel.java b/src/jake2/sound/joal/Channel.java
index 08aa584..502906c 100644
--- a/src/jake2/sound/joal/Channel.java
+++ b/src/jake2/sound/joal/Channel.java
@@ -3,7 +3,7 @@
*
* Copyright (C) 2003
*
- * $Id: Channel.java,v 1.2 2004-10-27 16:51:32 cawe Exp $
+ * $Id: Channel.java,v 1.3 2005-04-27 12:39:23 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -26,18 +26,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jake2.sound.joal;
-import java.util.*;
-
-import net.java.games.joal.AL;
import jake2.Defines;
import jake2.Globals;
import jake2.client.CL_ents;
import jake2.game.entity_state_t;
-import jake2.qcommon.Com;
import jake2.sound.sfx_t;
import jake2.sound.sfxcache_t;
import jake2.util.Math3D;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+
+import net.java.games.joal.AL;
+
/**
* Channel
*
@@ -92,7 +94,7 @@ public class Channel {
modified = false;
}
- static int init(AL al, int[] buffers, float masterVolume) {
+ static int init(AL al, int[] buffers) {
Channel.al = al;
Channel.buffers = buffers;
// create channels
@@ -112,12 +114,12 @@ public class Channel {
numChannels++;
// set default values for AL sources
- al.alSourcef (sourceId, AL.AL_GAIN, masterVolume);
+ al.alSourcef (sourceId, AL.AL_GAIN, 1.0f);
al.alSourcef (sourceId, AL.AL_PITCH, 1.0f);
al.alSourcei (sourceId, AL.AL_SOURCE_ABSOLUTE, AL.AL_TRUE);
al.alSourcefv(sourceId, AL.AL_VELOCITY, NULLVECTOR);
al.alSourcei (sourceId, AL.AL_LOOPING, AL.AL_FALSE);
- al.alSourcef (sourceId, AL.AL_REFERENCE_DISTANCE, 300.0f);
+ al.alSourcef (sourceId, AL.AL_REFERENCE_DISTANCE, 200.0f);
al.alSourcef (sourceId, AL.AL_MIN_GAIN, 0.0005f);
al.alSourcef (sourceId, AL.AL_MAX_GAIN, 1.0f);
}
@@ -204,9 +206,11 @@ public class Channel {
return null;
}
- static void playAllSounds(float[] listenerOrigin, float masterVolume) {
- float[] sourceOrigin = {0, 0, 0};
- float[] entityOrigin = {0, 0, 0};
+ // stack variables
+ private static float[] entityOrigin = {0, 0, 0};
+ private static float[] sourceOrigin = {0, 0, 0};
+
+ static void playAllSounds(float[] listenerOrigin) {
Channel ch;
int sourceId;
int state;
@@ -232,8 +236,7 @@ public class Channel {
if (ch.bufferChanged) {
al.alSourcei(sourceId, AL.AL_BUFFER, ch.bufferId);
}
-// al.alSourcef (sourceId, AL.AL_GAIN, masterVolume * ch.volume);
- al.alSourcef (sourceId, AL.AL_GAIN, masterVolume);
+ // al.alSourcef (sourceId, AL.AL_GAIN, ch.volume);
al.alSourcef (sourceId, AL.AL_ROLLOFF_FACTOR, ch.rolloff);
al.alSourcefv(sourceId, AL.AL_POSITION, sourceOrigin);
al.alSourcePlay(sourceId);
diff --git a/src/jake2/sound/joal/JOALSoundImpl.java b/src/jake2/sound/joal/JOALSoundImpl.java
index 69e8683..1b6f722 100644
--- a/src/jake2/sound/joal/JOALSoundImpl.java
+++ b/src/jake2/sound/joal/JOALSoundImpl.java
@@ -2,7 +2,7 @@
* JOALSoundImpl.java
* Copyright (C) 2004
*
- * $Id: JOALSoundImpl.java,v 1.12 2005-04-26 22:39:34 cawe Exp $
+ * $Id: JOALSoundImpl.java,v 1.13 2005-04-27 12:39:23 cawe Exp $
*/
package jake2.sound.joal;
@@ -93,9 +93,11 @@ public final class JOALSoundImpl implements Sound {
Com.DPrintf(e.getMessage() + '\n');
return false;
}
- al.alGenBuffers(MAX_SFX, buffers);
+ // set the master volume
s_volume = Cvar.Get("s_volume", "0.7", Defines.CVAR_ARCHIVE);
- int count = Channel.init(al, buffers, s_volume.value);
+
+ al.alGenBuffers(MAX_SFX, buffers);
+ int count = Channel.init(al, buffers);
Com.Printf("... using " + count + " channels\n");
al.alDistanceModel(AL.AL_INVERSE_DISTANCE_CLAMPED);
Cmd.AddCommand("play", new xcommand_t() {
@@ -266,6 +268,9 @@ public final class JOALSoundImpl implements Sound {
Channel.convertOrientation(forward, up, listenerOrientation);
al.alListenerfv(AL.AL_ORIENTATION, listenerOrientation);
+ // set the listener (master) volume
+ al.alListenerf(AL.AL_GAIN, s_volume.value);
+
if (eax != null) {
// workaround for environment initialisation
if (currentEnv == -1) {
@@ -289,13 +294,15 @@ public final class JOALSoundImpl implements Sound {
Channel.addLoopSounds();
Channel.addPlaySounds();
- Channel.playAllSounds(listenerOrigin, s_volume.value);
+ Channel.playAllSounds(listenerOrigin);
}
/* (non-Javadoc)
* @see jake2.sound.SoundImpl#StopAllSounds()
*/
public void StopAllSounds() {
+ // mute the listener (master)
+ al.alListenerf(AL.AL_GAIN, 0);
PlaySound.reset();
Channel.reset();
}