diff options
author | Carsten Weisse <[email protected]> | 2005-05-08 13:37:46 +0000 |
---|---|---|
committer | Carsten Weisse <[email protected]> | 2005-05-08 13:37:46 +0000 |
commit | 06d4d63e21a0771bae2932e3284e2d90fd25a9cf (patch) | |
tree | e853b18b41d4dff07525228243e51d04ad539184 /src/jake2 | |
parent | 360ca724c3f1ddab3483426f4c864b91eb154b0d (diff) |
handles different source volumes (e.g. explosions far away)
Diffstat (limited to 'src/jake2')
-rw-r--r-- | src/jake2/sound/joal/Channel.java | 25 | ||||
-rw-r--r-- | src/jake2/sound/joal/PlaySound.java | 6 | ||||
-rw-r--r-- | src/jake2/sound/lwjgl/Channel.java | 27 | ||||
-rw-r--r-- | src/jake2/sound/lwjgl/PlaySound.java | 6 |
4 files changed, 39 insertions, 25 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); diff --git a/src/jake2/sound/lwjgl/Channel.java b/src/jake2/sound/lwjgl/Channel.java index ffa2f8b..daed9db 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.5 2005-04-27 12:41:47 cawe Exp $ + * $Id: Channel.java,v 1.6 2005-05-08 13:37:46 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -71,25 +71,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(); + volumeChanged = false; + volume = 1.0f; } private void clear() { entnum = entchannel = bufferId = -1; bufferChanged = false; - // volume = 1.0f; rolloff = 0; autosound = false; active = false; @@ -183,7 +185,8 @@ public class Channel { ch.bufferChanged = (ch.bufferId != ps.bufferId); ch.bufferId = ps.bufferId; ch.rolloff = ps.attenuation * 2; - //ch.volume = ps.volume; + ch.volumeChanged = (ch.volume != ps.volume); + ch.volume = ps.volume; ch.active = true; ch.modified = true; return true; @@ -199,7 +202,9 @@ public class Channel { ch.entchannel = 0; ch.bufferChanged = (ch.bufferId != bufferId); ch.bufferId = bufferId; - ch.rolloff = attenuation * 2; + ch.volumeChanged = (ch.volume != 1.0f); + ch.volume = 1.0f; + ch.rolloff = attenuation * 2; ch.active = true; ch.modified = true; return ch; @@ -242,7 +247,9 @@ public class Channel { if (ch.bufferChanged) { AL10.alSourcei(sourceId, AL10.AL_BUFFER, ch.bufferId); } - // AL10.alSourcef (sourceId, AL10.AL_GAIN, ch.volume); + if (ch.volumeChanged) { + 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/PlaySound.java b/src/jake2/sound/lwjgl/PlaySound.java index 703e80c..1e3c4f8 100644 --- a/src/jake2/sound/lwjgl/PlaySound.java +++ b/src/jake2/sound/lwjgl/PlaySound.java @@ -3,7 +3,7 @@ * * Copyright (C) 2003 * - * $Id: PlaySound.java,v 1.1 2004-12-23 00:52:12 cawe Exp $ + * $Id: PlaySound.java,v 1.2 2005-05-08 13:37:46 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); |