From: Carsten W. <ca...@us...> - 2005-04-27 12:39:52
|
Update of /cvsroot/jake2/jake2/src/jake2/sound/joal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21252/src/jake2/sound/joal Modified Files: JOALSoundImpl.java Channel.java Log Message: change the master volume (listener) only on Update not per source Index: Channel.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sound/joal/Channel.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Channel.java 27 Oct 2004 16:51:32 -0000 1.2 --- Channel.java 27 Apr 2005 12:39:23 -0000 1.3 *************** *** 27,42 **** 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; /** * Channel --- 27,44 ---- package jake2.sound.joal; import jake2.Defines; import jake2.Globals; import jake2.client.CL_ents; import jake2.game.entity_state_t; 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 *************** *** 93,97 **** } ! static int init(AL al, int[] buffers, float masterVolume) { Channel.al = al; Channel.buffers = buffers; --- 95,99 ---- } ! static int init(AL al, int[] buffers) { Channel.al = al; Channel.buffers = buffers; *************** *** 113,122 **** // set default values for AL sources ! al.alSourcef (sourceId, AL.AL_GAIN, masterVolume); 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_MIN_GAIN, 0.0005f); al.alSourcef (sourceId, AL.AL_MAX_GAIN, 1.0f); --- 115,124 ---- // set default values for AL sources ! 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, 200.0f); al.alSourcef (sourceId, AL.AL_MIN_GAIN, 0.0005f); al.alSourcef (sourceId, AL.AL_MAX_GAIN, 1.0f); *************** *** 205,211 **** } ! static void playAllSounds(float[] listenerOrigin, float masterVolume) { ! float[] sourceOrigin = {0, 0, 0}; ! float[] entityOrigin = {0, 0, 0}; Channel ch; int sourceId; --- 207,215 ---- } ! // 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; *************** *** 233,238 **** 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_ROLLOFF_FACTOR, ch.rolloff); al.alSourcefv(sourceId, AL.AL_POSITION, sourceOrigin); --- 237,241 ---- al.alSourcei(sourceId, AL.AL_BUFFER, ch.bufferId); } ! // al.alSourcef (sourceId, AL.AL_GAIN, ch.volume); al.alSourcef (sourceId, AL.AL_ROLLOFF_FACTOR, ch.rolloff); al.alSourcefv(sourceId, AL.AL_POSITION, sourceOrigin); Index: JOALSoundImpl.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sound/joal/JOALSoundImpl.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** JOALSoundImpl.java 26 Apr 2005 22:39:34 -0000 1.12 --- JOALSoundImpl.java 27 Apr 2005 12:39:23 -0000 1.13 *************** *** 94,100 **** return false; } ! al.alGenBuffers(MAX_SFX, buffers); s_volume = Cvar.Get("s_volume", "0.7", Defines.CVAR_ARCHIVE); ! int count = Channel.init(al, buffers, s_volume.value); Com.Printf("... using " + count + " channels\n"); al.alDistanceModel(AL.AL_INVERSE_DISTANCE_CLAMPED); --- 94,102 ---- return false; } ! // set the master volume s_volume = Cvar.Get("s_volume", "0.7", Defines.CVAR_ARCHIVE); ! ! al.alGenBuffers(MAX_SFX, buffers); ! int count = Channel.init(al, buffers); Com.Printf("... using " + count + " channels\n"); al.alDistanceModel(AL.AL_INVERSE_DISTANCE_CLAMPED); *************** *** 267,270 **** --- 269,275 ---- 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 *************** *** 290,294 **** Channel.addLoopSounds(); Channel.addPlaySounds(); ! Channel.playAllSounds(listenerOrigin, s_volume.value); } --- 295,299 ---- Channel.addLoopSounds(); Channel.addPlaySounds(); ! Channel.playAllSounds(listenerOrigin); } *************** *** 297,300 **** --- 302,307 ---- */ public void StopAllSounds() { + // mute the listener (master) + al.alListenerf(AL.AL_GAIN, 0); PlaySound.reset(); Channel.reset(); |