aboutsummaryrefslogtreecommitdiffstats
path: root/src/jake2/sound/joal
diff options
context:
space:
mode:
authorCarsten Weisse <[email protected]>2005-05-08 13:37:46 +0000
committerCarsten Weisse <[email protected]>2005-05-08 13:37:46 +0000
commit06d4d63e21a0771bae2932e3284e2d90fd25a9cf (patch)
treee853b18b41d4dff07525228243e51d04ad539184 /src/jake2/sound/joal
parent360ca724c3f1ddab3483426f4c864b91eb154b0d (diff)
handles different source volumes (e.g. explosions far away)
Diffstat (limited to 'src/jake2/sound/joal')
-rw-r--r--src/jake2/sound/joal/Channel.java25
-rw-r--r--src/jake2/sound/joal/PlaySound.java6
2 files changed, 19 insertions, 12 deletions
diff --git a/src/jake2/sound/joal/Channel.java b/src/jake2/sound/joal/Channel.java
index 502906c..596a838 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.3 2005-04-27 12:39:23 cawe Exp $
+ * $Id: Channel.java,v 1.4 2005-05-08 13:37:28 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -69,25 +69,27 @@ public class Channel {
private int entchannel;
private int bufferId;
private int sourceId;
- // private float volume;
+ private float volume;
private float rolloff;
private float[] origin = {0, 0, 0};
// update flags
- private boolean autosound = false;
- private boolean active = false;
- private boolean modified = false;
- private boolean bufferChanged = false;
+ private boolean autosound;
+ private boolean active;
+ private boolean modified;
+ private boolean bufferChanged;
+ private boolean volumeChanged;
private Channel(int sourceId) {
this.sourceId = sourceId;
clear();
+ this.volumeChanged = false;
+ this.volume = 1.0f;
}
private void clear() {
entnum = entchannel = bufferId = -1;
bufferChanged = false;
- // volume = 1.0f;
rolloff = 0;
autosound = false;
active = false;
@@ -180,8 +182,9 @@ public class Channel {
ch.entchannel = ps.entchannel;
ch.bufferChanged = (ch.bufferId != ps.bufferId);
ch.bufferId = ps.bufferId;
+ ch.volumeChanged = (ch.volume != ps.volume);
+ ch.volume = ps.volume;
ch.rolloff = ps.attenuation * 2;
- //ch.volume = ps.volume;
ch.active = true;
ch.modified = true;
return true;
@@ -197,6 +200,8 @@ public class Channel {
ch.entchannel = 0;
ch.bufferChanged = (ch.bufferId != bufferId);
ch.bufferId = bufferId;
+ ch.volumeChanged = (ch.volume < 1.0f);
+ ch.volume = 1.0f;
ch.rolloff = attenuation * 2;
ch.active = true;
ch.modified = true;
@@ -236,7 +241,9 @@ public class Channel {
if (ch.bufferChanged) {
al.alSourcei(sourceId, AL.AL_BUFFER, ch.bufferId);
}
- // al.alSourcef (sourceId, AL.AL_GAIN, ch.volume);
+ if (ch.volumeChanged) {
+ 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/PlaySound.java b/src/jake2/sound/joal/PlaySound.java
index f21a6c2..7683d7f 100644
--- a/src/jake2/sound/joal/PlaySound.java
+++ b/src/jake2/sound/joal/PlaySound.java
@@ -3,7 +3,7 @@
*
* Copyright (C) 2003
*
- * $Id: PlaySound.java,v 1.2 2004-12-22 23:53:05 cawe Exp $
+ * $Id: PlaySound.java,v 1.3 2005-05-08 13:37:28 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -59,7 +59,7 @@ public class PlaySound {
int entnum;
int entchannel;
int bufferId;
- // float volume;
+ float volume;
float attenuation;
float[] origin = {0,0,0};
@@ -158,7 +158,7 @@ public class PlaySound {
ps.entnum = entnum;
ps.entchannel = entchannel;
ps.bufferId = bufferId;
- // ps.volume = volume;
+ ps.volume = volume;
ps.attenuation = attenuation;
ps.beginTime = Globals.cl.time + (long)(timeoffset * 1000);
PlaySound.add(ps);