aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Weisse <[email protected]>2005-04-27 12:21:24 +0000
committerCarsten Weisse <[email protected]>2005-04-27 12:21:24 +0000
commitbfc3531d5dbb13ee9fe8fba0d4302d481c3670db (patch)
tree82ad279d1f3a462eefd804baa40118f7d20d78cd
parent696d1c5a364a00be29952e8b75086baadccbfccf (diff)
change the master volume (listener) only on Update not per source
-rw-r--r--src/jake2/sound/lwjgl/Channel.java19
-rw-r--r--src/jake2/sound/lwjgl/LWJGLSoundImpl.java22
2 files changed, 27 insertions, 14 deletions
diff --git a/src/jake2/sound/lwjgl/Channel.java b/src/jake2/sound/lwjgl/Channel.java
index 722668f..a4d0f38 100644
--- a/src/jake2/sound/lwjgl/Channel.java
+++ b/src/jake2/sound/lwjgl/Channel.java
@@ -3,7 +3,7 @@
*
* Copyright (C) 2003
*
- * $Id: Channel.java,v 1.3 2005-04-25 22:50:25 cawe Exp $
+ * $Id: Channel.java,v 1.4 2005-04-27 12:21:24 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -37,7 +37,9 @@ import jake2.util.Math3D;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
-import java.util.*;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
import org.lwjgl.openal.AL10;
@@ -96,7 +98,7 @@ public class Channel {
private static IntBuffer tmp = Lib.newIntBuffer(1);
- static int init(IntBuffer buffers, float masterVolume) {
+ static int init(IntBuffer buffers) {
Channel.buffers = buffers;
// create channels
int sourceId;
@@ -114,7 +116,7 @@ public class Channel {
numChannels++;
// set default values for AL sources
- AL10.alSourcef (sourceId, AL10.AL_GAIN, masterVolume);
+ AL10.alSourcef (sourceId, AL10.AL_GAIN, 1.0f);
AL10.alSourcef (sourceId, AL10.AL_PITCH, 1.0f);
AL10.alSourcei (sourceId, AL10.AL_SOURCE_ABSOLUTE, AL10.AL_TRUE);
AL10.nalSourcefv(sourceId, AL10.AL_VELOCITY, NULLVECTOR, 0);
@@ -208,8 +210,10 @@ public class Channel {
private static FloatBuffer sourceOriginBuffer = Lib.newFloatBuffer(3);
- static void playAllSounds(FloatBuffer listenerOrigin, float masterVolume) {
- float[] entityOrigin = {0, 0, 0};
+ //stack variable
+ private static float[] entityOrigin = {0, 0, 0};
+
+ static void playAllSounds(FloatBuffer listenerOrigin) {
FloatBuffer sourceOrigin = sourceOriginBuffer;
Channel ch;
int sourceId;
@@ -238,8 +242,7 @@ public class Channel {
if (ch.bufferChanged) {
AL10.alSourcei(sourceId, AL10.AL_BUFFER, ch.bufferId);
}
-// AL10.alSourcef (sourceId, AL10.AL_GAIN, masterVolume * ch.volume);
- AL10.alSourcef (sourceId, AL10.AL_GAIN, masterVolume);
+ // AL10.alSourcef (sourceId, AL10.AL_GAIN, ch.volume);
AL10.alSourcef (sourceId, AL10.AL_ROLLOFF_FACTOR, ch.rolloff);
AL10.nalSourcefv(sourceId, AL10.AL_POSITION, sourceOrigin, 0);
AL10.alSourcePlay(sourceId);
diff --git a/src/jake2/sound/lwjgl/LWJGLSoundImpl.java b/src/jake2/sound/lwjgl/LWJGLSoundImpl.java
index aeaaddc..0259a82 100644
--- a/src/jake2/sound/lwjgl/LWJGLSoundImpl.java
+++ b/src/jake2/sound/lwjgl/LWJGLSoundImpl.java
@@ -2,7 +2,7 @@
* LWJGLSoundImpl.java
* Copyright (C) 2004
*
- * $Id: LWJGLSoundImpl.java,v 1.6 2005-04-26 22:34:17 cawe Exp $
+ * $Id: LWJGLSoundImpl.java,v 1.7 2005-04-27 12:21:24 cawe Exp $
*/
package jake2.sound.lwjgl;
@@ -14,11 +14,15 @@ import jake2.sound.*;
import jake2.util.Lib;
import jake2.util.Vargs;
-import java.nio.*;
+import java.nio.ByteBuffer;
+import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
import org.lwjgl.LWJGLException;
import org.lwjgl.openal.*;
-import org.lwjgl.openal.eax.*;
+import org.lwjgl.openal.eax.EAX;
+import org.lwjgl.openal.eax.EAX20;
+import org.lwjgl.openal.eax.EAXListenerProperties;
/**
* LWJGLSoundImpl
@@ -60,9 +64,10 @@ public final class LWJGLSoundImpl implements Sound {
return false;
}
- AL10.alGenBuffers(buffers);
+ // set the listerner (master) volume
s_volume = Cvar.Get("s_volume", "0.7", Defines.CVAR_ARCHIVE);
- int count = Channel.init(buffers, s_volume.value);
+ AL10.alGenBuffers(buffers);
+ int count = Channel.init(buffers);
Com.Printf("... using " + count + " channels\n");
AL10.alDistanceModel(AL10.AL_INVERSE_DISTANCE_CLAMPED);
Cmd.AddCommand("play", new xcommand_t() {
@@ -239,6 +244,9 @@ public final class LWJGLSoundImpl implements Sound {
Channel.convertOrientation(forward, up, listenerOrientation);
AL10.nalListenerfv(AL10.AL_ORIENTATION, listenerOrientation, 0);
+ // set the master volume
+ AL10.alListenerf(AL10.AL_GAIN, s_volume.value);
+
if (hasEAX){
if ((GameBase.gi.pointcontents.pointcontents(origin)& Defines.MASK_WATER)!= 0) {
changeEnvironment(EAX20.EAX_ENVIRONMENT_UNDERWATER);
@@ -249,7 +257,7 @@ public final class LWJGLSoundImpl implements Sound {
Channel.addLoopSounds();
Channel.addPlaySounds();
- Channel.playAllSounds(listenerOrigin, s_volume.value);
+ Channel.playAllSounds(listenerOrigin);
}
private IntBuffer eaxEnv = Lib.newIntBuffer(1);
@@ -266,6 +274,8 @@ public final class LWJGLSoundImpl implements Sound {
* @see jake2.sound.SoundImpl#StopAllSounds()
*/
public void StopAllSounds() {
+ // mute the listener (master)
+ AL10.alListenerf(AL10.AL_GAIN, 0);
PlaySound.reset();
Channel.reset();
}