add: EAX support done - needs some cleaning, and possibly refactoring of constants...

This commit is contained in:
Brian Matzon 2002-09-02 22:06:13 +00:00
parent a7d1580aa3
commit 4ebe09b5d2
4 changed files with 1238 additions and 5 deletions

View file

@ -40,5 +40,273 @@ package org.lwjgl.openal.eax;
* @version $Revision$
*/
public interface BaseEAXConstants {
//add some...
public static final int DSPROPERTY_EAXLISTENER_NONE = 0;
public static final int DSPROPERTY_EAXLISTENER_ALLPARAMETERS = 1;
public static final int DSPROPERTY_EAXLISTENER_ROOM = 2;
public static final int DSPROPERTY_EAXLISTENER_ROOMHF = 3;
public static final int DSPROPERTY_EAXLISTENER_ROOMROLLOFFFACTOR = 4;
public static final int DSPROPERTY_EAXLISTENER_DECAYTIME = 5;
public static final int DSPROPERTY_EAXLISTENER_DECAYHFRATIO = 6;
public static final int DSPROPERTY_EAXLISTENER_REFLECTIONS = 7;
public static final int DSPROPERTY_EAXLISTENER_REFLECTIONSDELAY = 8;
public static final int DSPROPERTY_EAXLISTENER_REVERB = 9;
public static final int DSPROPERTY_EAXLISTENER_REVERBDELAY = 10;
public static final int DSPROPERTY_EAXLISTENER_ENVIRONMENT = 11;
public static final int DSPROPERTY_EAXLISTENER_ENVIRONMENTSIZE = 12;
public static final int DSPROPERTY_EAXLISTENER_ENVIRONMENTDIFFUSION = 13;
public static final int DSPROPERTY_EAXLISTENER_AIRABSORPTIONHF = 14;
public static final int DSPROPERTY_EAXLISTENER_FLAGS = 15;
/** changes take effect immediately */
public static final int DSPROPERTY_EAXLISTENER_IMMEDIATE = 0x00000000;
/** changes take effect later */
public static final int DSPROPERTY_EAXLISTENER_DEFERRED = 0x80000000;
public static final int DSPROPERTY_EAXLISTENER_COMMITDEFERREDSETTINGS =
(DSPROPERTY_EAXLISTENER_NONE |
DSPROPERTY_EAXLISTENER_IMMEDIATE);
public static final int ENVIRONMENT_GENERIC = 0;
public static final int ENVIRONMENT_PADDEDCELL = 1;
public static final int ENVIRONMENT_ROOM = 2;
public static final int ENVIRONMENT_BATHROOM = 3;
public static final int ENVIRONMENT_LIVINGROOM = 4;
public static final int ENVIRONMENT_STONEROOM = 5;
public static final int ENVIRONMENT_AUDITORIUM = 6;
public static final int ENVIRONMENT_CONCERTHALL = 7;
public static final int ENVIRONMENT_CAVE = 8;
public static final int ENVIRONMENT_ARENA = 9;
public static final int ENVIRONMENT_HANGAR = 10;
public static final int ENVIRONMENT_CARPETEDHALLWAY = 11;
public static final int ENVIRONMENT_HALLWAY = 12;
public static final int ENVIRONMENT_STONECORRIDOR = 13;
public static final int ENVIRONMENT_ALLEY = 14;
public static final int ENVIRONMENT_FOREST = 15;
public static final int ENVIRONMENT_CITY = 16;
public static final int ENVIRONMENT_MOUNTAINS = 17;
public static final int ENVIRONMENT_QUARRY = 18;
public static final int ENVIRONMENT_PLAIN = 19;
public static final int ENVIRONMENT_PARKINGLOT = 20;
public static final int ENVIRONMENT_SEWERPIPE = 21;
public static final int ENVIRONMENT_UNDERWATER = 22;
public static final int ENVIRONMENT_DRUGGED = 23;
public static final int ENVIRONMENT_DIZZY = 24;
public static final int ENVIRONMENT_PSYCHOTIC = 25;
public static final int ENVIRONMENT_COUNT = 26;
/** reverberation decay time */
public static final int EAXLISTENERFLAGS_DECAYTIMESCALE = 0x00000001;
/** reflection level */
public static final int EAXLISTENERFLAGS_REFLECTIONSSCALE = 0x00000002;
/** initial reflection delay time */
public static final int EAXLISTENERFLAGS_REFLECTIONSDELAYSCALE = 0x00000004;
/** reflections level */
public static final int EAXLISTENERFLAGS_REVERBSCALE = 0x00000008;
/** late reverberation delay time */
public static final int EAXLISTENERFLAGS_REVERBDELAYSCALE = 0x00000010;
/** This flag limits high-frequency decay time according to air absorption. */
public static final int EAXLISTENERFLAGS_DECAYHFLIMIT = 0x00000020;
/** reserved future use */
public static final int EAXLISTENERFLAGS_RESERVED = 0xFFFFFFC0;
// property ranges and defaults:
public static final int EAXLISTENER_MINROOM = -10000;
public static final int EAXLISTENER_MAXROOM = 0;
public static final int EAXLISTENER_DEFAULTROOM = -1000;
public static final int EAXLISTENER_MINROOMHF = -10000;
public static final int EAXLISTENER_MAXROOMHF = 0;
public static final int EAXLISTENER_DEFAULTROOMHF = -100;
public static final float EAXLISTENER_MINROOMROLLOFFFACTOR = 0.0f;
public static final float EAXLISTENER_MAXROOMROLLOFFFACTOR = 10.0f;
public static final float EAXLISTENER_DEFAULTROOMROLLOFFFACTOR = 0.0f;
public static final float EAXLISTENER_MINDECAYTIME = 0.1f;
public static final float EAXLISTENER_MAXDECAYTIME = 20.0f;
public static final float EAXLISTENER_DEFAULTDECAYTIME = 1.49f;
public static final float EAXLISTENER_MINDECAYHFRATIO = 0.1f;
public static final float EAXLISTENER_MAXDECAYHFRATIO = 2.0f;
public static final float EAXLISTENER_DEFAULTDECAYHFRATIO = 0.83f;
public static final int EAXLISTENER_MINREFLECTIONS = -10000;
public static final int EAXLISTENER_MAXREFLECTIONS = 1000;
public static final int EAXLISTENER_DEFAULTREFLECTIONS = -2602;
public static final float EAXLISTENER_MINREFLECTIONSDELAY = 0.0f;
public static final float EAXLISTENER_MAXREFLECTIONSDELAY = 0.3f;
public static final float EAXLISTENER_DEFAULTREFLECTIONSDELAY = 0.007f;
public static final int EAXLISTENER_MINREVERB = -10000;
public static final int EAXLISTENER_MAXREVERB = 2000;
public static final int EAXLISTENER_DEFAULTREVERB = 200;
public static final float EAXLISTENER_MINREVERBDELAY = 0.0f;
public static final float EAXLISTENER_MAXREVERBDELAY = 0.1f;
public static final float EAXLISTENER_DEFAULTREVERBDELAY = 0.011f;
public static final int EAXLISTENER_MINENVIRONMENT = 0;
public static final int EAXLISTENER_MAXENVIRONMENT = (ENVIRONMENT_COUNT-1);
public static final int EAXLISTENER_DEFAULTENVIRONMENT = ENVIRONMENT_GENERIC;
public static final float EAXLISTENER_MINENVIRONMENTSIZE = 1.0f;
public static final float EAXLISTENER_MAXENVIRONMENTSIZE = 100.0f;
public static final float EAXLISTENER_DEFAULTENVIRONMENTSIZE = 7.5f;
public static final float EAXLISTENER_MINENVIRONMENTDIFFUSION = 0.0f;
public static final float EAXLISTENER_MAXENVIRONMENTDIFFUSION = 1.0f;
public static final float EAXLISTENER_DEFAULTENVIRONMENTDIFFUSION = 1.0f;
public static final float EAXLISTENER_MINAIRABSORPTIONHF = -100.0f;
public static final float EAXLISTENER_MAXAIRABSORPTIONHF = 0.0f;
public static final float EAXLISTENER_DEFAULTAIRABSORPTIONHF = -5.0f;
public static final int EAXLISTENER_DEFAULTFLAGS =
(EAXLISTENERFLAGS_DECAYTIMESCALE |
EAXLISTENERFLAGS_REFLECTIONSSCALE |
EAXLISTENERFLAGS_REFLECTIONSDELAYSCALE |
EAXLISTENERFLAGS_REVERBSCALE |
EAXLISTENERFLAGS_REVERBDELAYSCALE |
EAXLISTENERFLAGS_DECAYHFLIMIT);
//------------------------------------
public static final int DSPROPERTY_EAXBUFFER_NONE = 0;
public static final int DSPROPERTY_EAXBUFFER_ALLPARAMETERS = 1;
public static final int DSPROPERTY_EAXBUFFER_DIRECT = 2;
public static final int DSPROPERTY_EAXBUFFER_DIRECTHF = 3;
public static final int DSPROPERTY_EAXBUFFER_ROOM = 4;
public static final int DSPROPERTY_EAXBUFFER_ROOMHF = 5;
public static final int DSPROPERTY_EAXBUFFER_ROOMROLLOFFFACTOR = 6;
public static final int DSPROPERTY_EAXBUFFER_OBSTRUCTION = 7;
public static final int DSPROPERTY_EAXBUFFER_OBSTRUCTIONLFRATIO = 8;
public static final int DSPROPERTY_EAXBUFFER_OCCLUSION = 9;
public static final int DSPROPERTY_EAXBUFFER_OCCLUSIONLFRATIO = 10;
public static final int DSPROPERTY_EAXBUFFER_OCCLUSIONROOMRATIO = 11;
public static final int DSPROPERTY_EAXBUFFER_OUTSIDEVOLUMEHF = 12;
public static final int DSPROPERTY_EAXBUFFER_AIRABSORPTIONFACTOR = 13;
public static final int DSPROPERTY_EAXBUFFER_FLAGS = 14;
/** changes take effect immediately */
public static final int DSPROPERTY_EAXBUFFER_IMMEDIATE = 0x00000000;
/** changes take effect later */
public static final int DSPROPERTY_EAXBUFFER_DEFERRED = 0x80000000;
public static final int DSPROPERTY_EAXBUFFER_COMMITDEFERREDSETTINGS =
(DSPROPERTY_EAXBUFFER_NONE |
DSPROPERTY_EAXBUFFER_IMMEDIATE);
/** affects DSPROPERTY_EAXBUFFER_DIRECTHF */
public static final int EAXBUFFERFLAGS_DIRECTHFAUTO = 0x00000001;
/** affects DSPROPERTY_EAXBUFFER_ROOM */
public static final int EAXBUFFERFLAGS_ROOMAUTO = 0x00000002;
/** affects DSPROPERTY_EAXBUFFER_ROOMHF */
public static final int EAXBUFFERFLAGS_ROOMHFAUTO = 0x00000004;
/** reserved future use */
public static final int EAXBUFFERFLAGS_RESERVED = 0xFFFFFFF8;
// property ranges and defaults:
public static final int EAXBUFFER_MINDIRECT = -10000;
public static final int EAXBUFFER_MAXDIRECT = 1000;
public static final int EAXBUFFER_DEFAULTDIRECT = 0;
public static final int EAXBUFFER_MINDIRECTHF = -10000;
public static final int EAXBUFFER_MAXDIRECTHF = 0;
public static final int EAXBUFFER_DEFAULTDIRECTHF = 0;
public static final int EAXBUFFER_MINROOM = -10000;
public static final int EAXBUFFER_MAXROOM = 1000;
public static final int EAXBUFFER_DEFAULTROOM = 0;
public static final int EAXBUFFER_MINROOMHF = -10000;
public static final int EAXBUFFER_MAXROOMHF = 0;
public static final int EAXBUFFER_DEFAULTROOMHF = 0;
public static final float EAXBUFFER_MINROOMROLLOFFFACTOR = 0.0f;
public static final float EAXBUFFER_MAXROOMROLLOFFFACTOR = 10.f;
public static final float EAXBUFFER_DEFAULTROOMROLLOFFFACTOR = 0.0f;
public static final int EAXBUFFER_MINOBSTRUCTION = -10000;
public static final int EAXBUFFER_MAXOBSTRUCTION = 0;
public static final int EAXBUFFER_DEFAULTOBSTRUCTION = 0;
public static final float EAXBUFFER_MINOBSTRUCTIONLFRATIO = 0.0f;
public static final float EAXBUFFER_MAXOBSTRUCTIONLFRATIO = 1.0f;
public static final float EAXBUFFER_DEFAULTOBSTRUCTIONLFRATIO = 0.0f;
public static final int EAXBUFFER_MINOCCLUSION = -10000;
public static final int EAXBUFFER_MAXOCCLUSION = 0;
public static final int EAXBUFFER_DEFAULTOCCLUSION = 0;
public static final float EAXBUFFER_MINOCCLUSIONLFRATIO = 0.0f;
public static final float EAXBUFFER_MAXOCCLUSIONLFRATIO = 1.0f;
public static final float EAXBUFFER_DEFAULTOCCLUSIONLFRATIO = 0.25f;
public static final float EAXBUFFER_MINOCCLUSIONROOMRATIO = 0.0f;
public static final float EAXBUFFER_MAXOCCLUSIONROOMRATIO = 10.0f;
public static final float EAXBUFFER_DEFAULTOCCLUSIONROOMRATIO = 0.5f;
public static final int EAXBUFFER_MINOUTSIDEVOLUMEHF = -10000;
public static final int EAXBUFFER_MAXOUTSIDEVOLUMEHF = 0;
public static final int EAXBUFFER_DEFAULTOUTSIDEVOLUMEHF = 0;
public static final float EAXBUFFER_MINAIRABSORPTIONFACTOR = 0.0f;
public static final float EAXBUFFER_MAXAIRABSORPTIONFACTOR = 10.0f;
public static final float EAXBUFFER_DEFAULTAIRABSORPTIONFACTOR = 1.0f;
public static final int EAXBUFFER_DEFAULTFLAGS =
(EAXBUFFERFLAGS_DIRECTHFAUTO |
EAXBUFFERFLAGS_ROOMAUTO |
EAXBUFFERFLAGS_ROOMHFAUTO);
// Single window material preset
public static final int MATERIAL_SINGLEWINDOW = -2800;
public static final float MATERIAL_SINGLEWINDOWLF = 0.71f;
public static final float MATERIAL_SINGLEWINDOWROOMRATIO = 0.43f;
// Double window material preset
public static final int MATERIAL_DOUBLEWINDOW = -5000;
public static final float MATERIAL_DOUBLEWINDOWHF = 0.40f;
public static final float MATERIAL_DOUBLEWINDOWROOMRATIO = 0.24f;
// Thin door material preset
public static final int MATERIAL_THINDOOR = -1800;
public static final float MATERIAL_THINDOORLF = 0.66f;
public static final float MATERIAL_THINDOORROOMRATIO = 0.66f;
// Thick door material preset
public static final int MATERIAL_THICKDOOR = -4400;
public static final float MATERIAL_THICKDOORLF = 0.64f;
public static final float MATERIAL_THICKDOORROOMRTATION = 0.27f;
// Wood wall material preset
public static final int MATERIAL_WOODWALL = -4000;
public static final float MATERIAL_WOODWALLLF = 0.50f;
public static final float MATERIAL_WOODWALLROOMRATIO = 0.30f;
// Brick wall material preset
public static final int MATERIAL_BRICKWALL = -5000;
public static final float MATERIAL_BRICKWALLLF = 0.60f;
public static final float MATERIAL_BRICKWALLROOMRATIO = 0.24f;
// Stone wall material preset
public static final int MATERIAL_STONEWALL = -6000;
public static final float MATERIAL_STONEWALLLF = 0.68f;
public static final float MATERIAL_STONEWALLROOMRATIO = 0.20f;
// Curtain material preset
public static final int MATERIAL_CURTAIN = -1200;
public static final float MATERIAL_CURTAINLF = 0.15f;
public static final float MATERIAL_CURTAINROOMRATIO = 1.00f;
}

View file

@ -0,0 +1,368 @@
/*
* Copyright (c) 2002 Light Weight Java Game Library Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'Light Weight Java Game Library' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl.openal.eax;
import org.lwjgl.Sys;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.lang.reflect.*;
/**
* $Id$
*
* This class encapsultaes the EAXBUFFERPROPERTIES struct
*
* @author Brian Matzon <brian@matzon.dk>
* @version $Revision$
*/
public class EAXBufferProperties {
/** ByteBuffer representing EAXBUFFERPROPERTIES */
protected ByteBuffer eaxBufferProperties;
/** size needed by ByteBuffer to contain EAXBUFFERPROPERTIES */
protected static int EAXBUFFERPROPERTIES_SIZE;
/** direct path level offset */
protected static int direct_offset;
/** direct path level at high frequencies offset */
protected static int directHF_offset;
/** room effect level offset */
protected static int room_offset;
/** room effect level at high frequencies offset */
protected static int roomHF_offset;
/** like DS3D flRolloffFactor but for room effect offset */
protected static int roomRolloffFactor_offset;
/** main obstruction control (attenuation at high frequencies) offset */
protected static int obstruction_offset;
/** obstruction low-frequency level re. main control offset */
protected static int obstructionLFRatio_offset;
/** main occlusion control (attenuation at high frequencies) offset */
protected static int occlusion_offset;
/** occlusion low-frequency level re. main control offset */
protected static int occlusionLFRatio_offset;
/** occlusion room effect level re. main control offset */
protected static int occlusionRoomRatio_offset;
/** outside sound cone level at high frequencies offset */
protected static int outsideVolumeHF_offset;
/** multiplies DSPROPERTY_EAXLISTENER_AIRABSORPTIONHF offset */
protected static int airAbsorptionFactor_offset;
/** modifies the behavior of properties offset */
protected static int flags_offset;
static {
System.loadLibrary(org.lwjgl.Sys.getLibraryName());
EAXBUFFERPROPERTIES_SIZE = sizeOfEaxBufferProperties();
assignOffsets();
}
/**
* Creates a new instance of EAXBufferProperties
*
* @param eaxBufferProperties address of EAXBUFFERPROPERTIES
*/
public EAXBufferProperties() {
eaxBufferProperties = ByteBuffer.allocateDirect(EAXBUFFERPROPERTIES_SIZE);
eaxBufferProperties.order(ByteOrder.nativeOrder());
}
/**
* Retireves the direct path level
*
* @return direct path level
*/
public long getDirect() {
return eaxBufferProperties.getLong(direct_offset);
}
/**
* Sets the direct path level
*
* @param direct direct path level to set to
*/
public void setDirect(long direct) {
eaxBufferProperties.putLong(direct_offset, direct);
}
/**
* Retireves the direct path level at high frequencies
*
* @return direct path level at high frequencies
*/
public long getDirectHF() {
return eaxBufferProperties.getLong(directHF_offset);
}
/**
* Sets the direct path level at high frequencies
*
* @param direct direct path level at high frequencies to set to
*/
public void setDirectHF(long directHF) {
eaxBufferProperties.putLong(directHF_offset, directHF);
}
/**
* Retireves the room effect level
*
* @return room effect level
*/
public long getRoom() {
return eaxBufferProperties.getLong(room_offset);
}
/**
* Sets the room effect level
*
* @param room room effect level to set to
*/
public void setRoom(long room) {
eaxBufferProperties.putLong(room_offset, room);
}
/**
* Retireves the room effect level at high frequencies
*
* @return room effect level at high frequencies
*/
public long getRoomHF() {
return eaxBufferProperties.getLong(roomHF_offset);
}
/**
* Sets the room effect level at high frequencies
*
* @param room room effect level at high frequencies to set to
*/
public void setRoomHF(long roomHF) {
eaxBufferProperties.putLong(roomHF_offset, roomHF);
}
/**
* Retireves the DS3D flRolloffFactor for room effect
*
* @return DS3D flRolloffFactor for room effect
*/
public float getRoomRolloffFactor() {
return eaxBufferProperties.getFloat(roomRolloffFactor_offset);
}
/**
* Sets the DS3D flRolloffFactor for room effect
*
* @param roomRolloffFactor DS3D flRolloffFactor for room effect to set to
*/
public void setRoomRolloffFactor(float roomRolloffFactor) {
eaxBufferProperties.putFloat(roomRolloffFactor_offset, roomRolloffFactor);
}
/**
* Retireves the main obstruction control (attenuation at high frequencies)
*
* @return main obstruction control (attenuation at high frequencies)
*/
public long getObstruction() {
return eaxBufferProperties.getLong(obstruction_offset);
}
/**
* Sets the main obstruction control (attenuation at high frequencies)
*
* @param obstruction main obstruction control (attenuation at high frequencies) to set to
*/
public void setObstruction(long obstruction) {
eaxBufferProperties.putLong(obstruction_offset, obstruction);
}
/**
* Retireves the obstruction low-frequency level re. main control
*
* @return obstruction low-frequency level re. main control
*/
public float getObstructionLFRatio() {
return eaxBufferProperties.getFloat(obstructionLFRatio_offset);
}
/**
* Sets the obstruction low-frequency level re. main control
*
* @param obstructionLFRatio obstruction low-frequency level re. main control to set to
*/
public void setObstructionLFRatio(float obstructionLFRatio) {
eaxBufferProperties.putFloat(obstructionLFRatio_offset, obstructionLFRatio);
}
/**
* Retireves the main occlusion control (attenuation at high frequencies)
*
* @return main occlusion control (attenuation at high frequencies)
*/
public long getOcclusion() {
return eaxBufferProperties.getLong(occlusion_offset);
}
/**
* Sets the main occlusion control (attenuation at high frequencies)
*
* @param occlusion main occlusion control (attenuation at high frequencies) to set to
*/
public void setOcclusion(long occlusion) {
eaxBufferProperties.putLong(occlusion_offset, occlusion);
}
/**
* Retireves the occlusion low-frequency level re. main control
*
* @return occlusion low-frequency level re. main control
*/
public float getOcclusionLFRatio() {
return eaxBufferProperties.getFloat(occlusionLFRatio_offset);
}
/**
* Sets the occlusion low-frequency level re. main control
*
* @param occlusionLFRatio occlusion low-frequency level re. main control to set to
*/
public void setOcclusionLFRatio(float occlusionLFRatio) {
eaxBufferProperties.putFloat(occlusionLFRatio_offset, occlusionLFRatio);
}
/**
* Retireves the occlusion room effect level re. main control
*
* @return occlusion room effect level re. main control
*/
public float getOcclusionRoomRatio() {
return eaxBufferProperties.getFloat(occlusionRoomRatio_offset);
}
/**
* Sets the OcclusionRoomRatio
*
* @param occlusionRoomRatio OcclusionRoomRatio to set to
*/
public void setOcclusionRoomRatio(float occlusionRoomRatio) {
eaxBufferProperties.putFloat(occlusionRoomRatio_offset, occlusionRoomRatio);
}
/**
* Retireves the OutsideVolumeHF
*
* @return OutsideVolumeHF
*/
public long getOutsideVolumeHF() {
return eaxBufferProperties.getLong(outsideVolumeHF_offset);
}
/**
* Sets the OutsideVolumeHF
*
* @param outsideVolumeHF OutsideVolumeHF to set to
*/
public void setOutsideVolumeHF(long outsideVolumeHF) {
eaxBufferProperties.putLong(outsideVolumeHF_offset, outsideVolumeHF);
}
/**
* Retireves the multiplier for DSPROPERTY_EAXLISTENER_AIRABSORPTIONHF
*
* @return multiplier for DSPROPERTY_EAXLISTENER_AIRABSORPTIONHF
*/
public float getAirAbsorptionFactor() {
return eaxBufferProperties.getFloat(airAbsorptionFactor_offset);
}
/**
* Sets the multiplier for DSPROPERTY_EAXLISTENER_AIRABSORPTIONHF
*
* @param airAbsorptionFactor multiplier for DSPROPERTY_EAXLISTENER_AIRABSORPTIONHF to set to
*/
public void setAirAbsorptionFactor(float airAbsorptionFactor) {
eaxBufferProperties.putFloat(airAbsorptionFactor_offset, airAbsorptionFactor);
}
/**
* Retireves the modifier for behavior of properties
*
* @return modifier for behavior of properties
*/
public long getFlags() {
return eaxBufferProperties.getLong(flags_offset);
}
/**
* Sets the modifier for behavior of properties
*
* @param flags modifier for behavior of properties to set to
*/
public void setFlags(long flags) {
eaxBufferProperties.putLong(flags_offset, flags);
}
/**
* Retrieves the address of this EAXBufferProperties
*/
public int getAddress() {
return Sys.getDirectBufferAddress(eaxBufferProperties);
}
/**
* Retrieves the size of the containing ByteBuffer
*/
public int getSize() {
return EAXBUFFERPROPERTIES_SIZE;
}
/**
* Retrieves the size of the EAXBUFFERPROPERTIES
*/
protected static native int sizeOfEaxBufferProperties();
/**
* Sets the offsets to the fields
*/
protected static native void assignOffsets();
}

View file

@ -0,0 +1,386 @@
/*
* Copyright (c) 2002 Light Weight Java Game Library Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'Light Weight Java Game Library' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl.openal.eax;
import org.lwjgl.Sys;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
/**
* $Id$
*
* This class encapsultaes the EAXLISTENERPROPERTIES struct
*
* @author Brian Matzon <brian@matzon.dk>
* @version $Revision$
*/
public class EAXListenerProperties {
/** ByteBuffer representing EAXLISTENERPROPERTIES */
protected ByteBuffer eaxListenerProperties;
/** size needed by ByteBuffer to contain EAXLISTENERPROPERTIES */
protected static int EAXLISTENERPROPERTIES_SIZE;
/** room effect level offset */
protected static int room_offset;
/** room effect level at high frequencies offset */
protected static int roomHF_offset;
/**like DS3D flRolloffFactor but for room effect offset */
protected static int roomRolloffFactor_offset;
/** reverberation decay time at low frequencies offset */
protected static int decayTime_offset;
/** high-frequency to low-frequency decay time ratio offset */
protected static int decayHFRatio_offset;
/** early reflections level relative to room effect offset */
protected static int reflections_offset;
/** initial reflection delay time offset */
protected static int reflectionsDelay_offset;
/** late reverberation level relative to room effect offset */
protected static int reverb_offset;
/** late reverberation delay time relative to initial reflection offset */
protected static int reverbDelay_offset;
/** sets all listener properties offset */
protected static int environment_offset;
/** environment size in meters offset */
protected static int environmentSize_offset;
/** environment diffusion offset */
protected static int environmentDiffusion_offset;
/** change in level per meter at 5 kHz offset */
protected static int airAbsorptionHF_offset;
/** modifies the behavior of properties offset */
protected static int flags_offset;
static {
System.loadLibrary(org.lwjgl.Sys.getLibraryName());
EAXLISTENERPROPERTIES_SIZE = sizeOfEaxListenerProperties();
assignOffsets();
}
/**
* Creates a new instance of EAXBufferProperties
*/
public EAXListenerProperties() {
eaxListenerProperties = ByteBuffer.allocateDirect(EAXLISTENERPROPERTIES_SIZE);
eaxListenerProperties.order(ByteOrder.nativeOrder());
}
/**
* Retireves the room effect level
*
* @return room effect level
*/
public long getRoom() {
return eaxListenerProperties.getLong(room_offset);
}
/**
* Sets the room effect level
*
* @param room room effect level to set to
*/
public void setRoom(long room) {
eaxListenerProperties.putLong(room_offset, room);
}
/**
* Retireves the room effect level at high frequencies
*
* @return room effect level at high frequencies
*/
public long getRoomHF() {
return eaxListenerProperties.getLong(roomHF_offset);
}
/**
* Sets the room effect level at high frequencies
*
* @param room room effect level at high frequencies to set to
*/
public void setRoomHF(long roomHF) {
eaxListenerProperties.putLong(roomHF_offset, roomHF);
}
/**
* Retireves the DS3D flRolloffFactor for room effect
*
* @return DS3D flRolloffFactor for room effect
*/
public float getRoomRolloffFactor() {
return eaxListenerProperties.getFloat(roomRolloffFactor_offset);
}
/**
* Sets the DS3D flRolloffFactor for room effect
*
* @param roomRolloffFactor DS3D flRolloffFactor for room effect to set to
*/
public void setRoomRolloffFactor(float roomRolloffFactor) {
eaxListenerProperties.putFloat(roomRolloffFactor_offset, roomRolloffFactor);
}
/**
* Retireves the reverberation decay time at low frequencies
*
* @return reverberation decay time at low frequencies
*/
public float getDecayTime() {
return eaxListenerProperties.getFloat(decayTime_offset);
}
/**
* Sets the reverberation decay time at low frequencies
*
* @param decayTime reverberation decay time at low frequencies to set to
*/
public void setDecayTime(float decayTime) {
eaxListenerProperties.putFloat(decayTime_offset, decayTime);
}
/**
* Retireves the high-frequency to low-frequency decay time ratio
*
* @return high-frequency to low-frequency decay time ratio
*/
public float getDecayTimeHFRatio() {
return eaxListenerProperties.getFloat(decayHFRatio_offset);
}
/**
* Sets the high-frequency to low-frequency decay time ratio
*
* @param decayTimeHFRatio high-frequency to low-frequency decay time ratio to set to
*/
public void setDecayTimeHFRatio(float decayTimeHFRatio) {
eaxListenerProperties.putFloat(decayHFRatio_offset, decayTimeHFRatio);
}
/**
* Retireves the early reflections level relative to room effect
*
* @return early reflections level relative to room effect
*/
public long getReflections() {
return eaxListenerProperties.getLong(reflections_offset);
}
/**
* Sets the early reflections level relative to room effect
*
* @param reflections early reflections level relative to room effect to set to
*/
public void setReflections(long reflections) {
eaxListenerProperties.putLong(reflections_offset, reflections);
}
/**
* Retireves the initial reflection delay time
*
* @return initial reflection delay time
*/
public float getReflectionsDelay() {
return eaxListenerProperties.getFloat(reflectionsDelay_offset);
}
/**
* Sets the initial reflection delay time
*
* @param reflectionsDelay initial reflection delay time to set to
*/
public void setReflectionsDelay(float reflectionsDelay) {
eaxListenerProperties.putFloat(reflectionsDelay_offset, reflectionsDelay);
}
/**
* Retireves the late reverberation level relative to room effect
*
* @return late reverberation level relative to room effect
*/
public long getReverb() {
return eaxListenerProperties.getLong(reverb_offset);
}
/**
* Sets the late reverberation level relative to room effect
*
* @param reverb late reverberation level relative to room effect to set to
*/
public void setReverb(long reverb) {
eaxListenerProperties.putLong(reverb_offset, reverb);
}
/**
* Retireves the late reverberation delay time relative to initial reflection
*
* @return late reverberation delay time relative to initial reflection
*/
public float getReverbDelay() {
return eaxListenerProperties.getFloat(reverbDelay_offset);
}
/**
* Sets the late reverberation delay time relative to initial reflection
*
* @param reverbDelay late reverberation delay time relative to initial reflection
*/
public void setReverbDelay(float reverbDelay) {
eaxListenerProperties.putFloat(reverbDelay_offset, reverbDelay);
}
/**
* Retireves the listener properties
*
* @return listener properties
*/
public long getEnvironment() {
return eaxListenerProperties.getLong(environment_offset);
}
/**
* Sets the listener properties
*
* @param environment listener properties to set to
*/
public void setEnvironment(long environment) {
eaxListenerProperties.putLong(environment_offset, environment);
}
/**
* Retireves the environment size in meters
*
* @return environment size in meters
*/
public float getEnvironmentSize() {
return eaxListenerProperties.getFloat(environmentSize_offset);
}
/**
* Sets the environment size in meters
*
* @param environmentSize environment size in meters to set to
*/
public void setEnvironmentSize(float environmentSize) {
eaxListenerProperties.putFloat(environmentSize_offset, environmentSize);
}
/**
* Retireves the environment diffusion
*
* @return environment diffusion
*/
public float getEnvironmentDiffusion() {
return eaxListenerProperties.getFloat(environmentDiffusion_offset);
}
/**
* Sets the environment diffusion
*
* @param environmentDiffusion environment diffusion to set to
*/
public void setEnvironmentDiffusion(float environmentDiffusion) {
eaxListenerProperties.putFloat(environmentDiffusion_offset, environmentDiffusion);
}
/**
* Retireves the change in level per meter at 5 kHz
*
* @return change in level per meter at 5 kHz
*/
public float getAirAbsorptionHF() {
return eaxListenerProperties.getFloat(airAbsorptionHF_offset);
}
/**
* Sets the change in level per meter at 5 kHz
*
* @param airAbsorptionHF change in level per meter at 5 kHz to set to
*/
public void setAirAbsorptionFactor(float airAbsorptionHF) {
eaxListenerProperties.putFloat(airAbsorptionHF_offset, airAbsorptionHF);
}
/**
* Retireves the modifier for behavior of properties
*
* @return modifier for behavior of properties
*/
public long getFlags() {
return eaxListenerProperties.getLong(flags_offset);
}
/**
* Sets the modifier for behavior of properties
*
* @param flags modifier for behavior of properties to set to
*/
public void setFlags(long flags) {
eaxListenerProperties.putLong(flags_offset, flags);
}
/**
* Retrieves the address of this EAXBufferProperties
*/
public int getAddress() {
return Sys.getDirectBufferAddress(eaxListenerProperties);
}
/**
* Retrieves the size of the containing ByteBuffer
*/
public int getSize() {
return EAXLISTENERPROPERTIES_SIZE;
}
/**
* Retrieves the size of the EAXLISTENERPROPERTIES
*/
protected static native int sizeOfEaxListenerProperties();
/**
* Sets the offsets to the fields
*/
protected static native void assignOffsets();
}

View file

@ -37,6 +37,8 @@ import org.lwjgl.openal.ALCcontext;
import org.lwjgl.openal.ALCdevice;
import org.lwjgl.openal.ALUT;
import org.lwjgl.openal.ALUTLoadWAVData;
import org.lwjgl.openal.eax.EAX;
import org.lwjgl.openal.eax.EAXBufferProperties;
import org.lwjgl.Sys;
import java.nio.ByteBuffer;
@ -213,6 +215,9 @@ public class ALTest extends BasicTest {
AL.INVERSE_DISTANCE_CLAMPED
};
/** Whether or not EAX is supported */
protected boolean eaxAvailable = false;
/**
* Creates an instance of ALTest
*/
@ -523,6 +528,9 @@ public class ALTest extends BasicTest {
System.exit(-1);
}
//do EAX check (can only be performed after device / context creation
eaxAvailable = al.isExtensionPresent("EAX");
do {
System.out.print("\n\n\nAutomated Test Series:\n\n");
System.out.print("A) Run Fully Automated Tests\n");
@ -530,7 +538,7 @@ public class ALTest extends BasicTest {
System.out.print("\nInteractive Tests:\n\n");
System.out.print("1 Position Test\n");
System.out.print("2 Looping Test\n");
System.out.print("*3 EAX 2.0 Test\n");
System.out.print("3 EAX 2.0 Test\n");
System.out.print("4 Queue Test\n");
System.out.print("5 Buffer Test\n");
System.out.print("6 Frequency Test\n");
@ -560,7 +568,11 @@ public class ALTest extends BasicTest {
i_LoopingTest();
break;
case '3':
i_EAXTest();
if(eaxAvailable) {
i_EAXTest();
} else {
System.out.println("EAX not supported");
}
break;
case '4':
i_QueueTest();
@ -1255,8 +1267,207 @@ public class ALTest extends BasicTest {
}
protected void i_EAXTest() {
System.out.println("i_EAXTest");
delay_ms(3000);
int error;
int ch = -1;
IntBuffer source = createIntBuffer(2);
IntBuffer Env = createIntBuffer(1);
IntBuffer Room = createIntBuffer(1);
IntBuffer Occlusion = createIntBuffer(1);
IntBuffer Obstruction = createIntBuffer(1);
EAXBufferProperties eaxBufferProp0 = new EAXBufferProperties();
FloatBuffer source0Pos = createFloatBuffer(3);
source0Pos.put(new float[] {-2.0f, 0.0f, 2.0f});
FloatBuffer source0Vel = createFloatBuffer(3);
source0Vel.put(new float[] {0.0f, 0.0f, 0.0f});
FloatBuffer source1Pos = createFloatBuffer(3);
source1Pos.put(new float[] {2.0f, 0.0f, -2.0f});
FloatBuffer source1Vel = createFloatBuffer(3);
source1Vel.put(new float[] {0.0f, 0.0f, 0.0f});
EAX eax = new EAX();
try {
eax.create();
} catch (Exception e) {
e.printStackTrace();
return;
}
// Clear Error Code
al.getError();
al.genSources(2, Sys.getDirectBufferAddress(source));
if ((error = al.getError()) != AL.NO_ERROR) {
displayALError("alGenSources 2 : ", error);
return;
}
al.sourcef(source.get(0),AL.PITCH,1.0f);
if ((error = al.getError()) != AL.NO_ERROR)
displayALError("alSourcef 0 AL_PITCH : \n", error);
al.sourcef(source.get(0),AL.GAIN,1.0f);
if ((error = al.getError()) != AL.NO_ERROR)
displayALError("alSourcef 0 AL_GAIN : \n", error);
al.sourcefv(source.get(0),AL.POSITION,Sys.getDirectBufferAddress(source0Pos));
if ((error = al.getError()) != AL.NO_ERROR)
displayALError("alSourcefv 0 AL_POSITION : \n", error);
al.sourcefv(source.get(0),AL.VELOCITY,Sys.getDirectBufferAddress(source0Vel));
if ((error = al.getError()) != AL.NO_ERROR)
displayALError("alSourcefv 0 AL_VELOCITY : \n", error);
al.sourcei(source.get(0),AL.BUFFER, buffers.get(0));
if ((error = al.getError()) != AL.NO_ERROR)
displayALError("alSourcei 0 AL_BUFFER buffer 0 : \n", error);
al.sourcei(source.get(0),AL.LOOPING,AL.TRUE);
if ((error = al.getError()) != AL.NO_ERROR)
displayALError("alSourcei 0 AL_LOOPING true: \n", error);
al.sourcef(source.get(1),AL.PITCH,1.0f);
if ((error = al.getError()) != AL.NO_ERROR)
displayALError("alSourcef 1 AL_PITCH : \n", error);
al.sourcef(source.get(1),AL.GAIN,1.0f);
if ((error = al.getError()) != AL.NO_ERROR)
displayALError("alSourcef 1 AL_GAIN : \n", error);
al.sourcefv(source.get(1),AL.POSITION,Sys.getDirectBufferAddress(source1Pos));
if ((error = al.getError()) != AL.NO_ERROR)
displayALError("alSourcefv 1 AL_POSITION : \n", error);
al.sourcefv(source.get(1),AL.VELOCITY,Sys.getDirectBufferAddress(source1Vel));
if ((error = al.getError()) != AL.NO_ERROR)
displayALError("alSourcefv 1 AL_VELOCITY : \n", error);
al.sourcei(source.get(1),AL.BUFFER, buffers.get(1));
if ((error = al.getError()) != AL.NO_ERROR)
displayALError("alSourcei 1 AL_BUFFER buffer 1 : \n", error);
al.sourcei(source.get(1),AL.LOOPING,AL.FALSE);
if ((error = al.getError()) != AL.NO_ERROR)
displayALError("alSourcei 1 AL_LOOPING false: \n", error);
System.out.print("EAX Test\n\n");
System.out.print("Press '1' to play source 0 (looping)\n");
System.out.print("Press '2' to play source 1 once (single shot)\n");
System.out.print("Press '3' to stop source 0\n");
System.out.print("Press '4' to stop source 1\n");
System.out.print("Press '5' to add Hangar reverb (DEFERRED)\n");
System.out.print("Press '6' to remove reverb (DEFERRED)\n");
System.out.print("Press '7' to occlude source 0 (DEFERRED)\n");
System.out.print("Press '8' to remove occlusion from source 0 (DEFERRED)\n");
System.out.print("Press '9' to obstruct source 1 (IMMEDIATE)\n");
System.out.print("Press '0' to remove obstruction from source 1 (IMMEDIATE)\n");
System.out.print("Press 'c' to COMMIT EAX settings\n");
System.out.print("Press 'q' to quit\n\n");
do {
try {
ch = System.in.read();
} catch (IOException ioe) {
}
switch (ch) {
case '1':
al.sourcePlay(source.get(0));
break;
case '2':
al.sourcePlay(source.get(1));
break;
case '3':
al.sourceStop(source.get(0));
break;
case '4':
al.sourceStop(source.get(1));
break;
case '5':
Env.put(0, EAX.ENVIRONMENT_HANGAR);
eax.eaxSet(EAX.LISTENER_GUID, EAX.DSPROPERTY_EAXLISTENER_ENVIRONMENT | EAX.DSPROPERTY_EAXLISTENER_DEFERRED,
0, Sys.getDirectBufferAddress(Env), 4);
if ((error = al.getError()) != AL.NO_ERROR)
displayALError("eaxSet EAXLISTENER_ENVIRONMENT | EAXLISTENER_DEFERRED : \n", error);
break;
case '6':
Room.put(-10000);
eax.eaxSet(EAX.LISTENER_GUID, EAX.DSPROPERTY_EAXLISTENER_ROOM | EAX.DSPROPERTY_EAXLISTENER_DEFERRED, 0,
Sys.getDirectBufferAddress(Room), 4);
if ((error = al.getError()) != AL.NO_ERROR)
displayALError("eaxSet EAXLISTENER_ROOM | EAXLISTENER_DEFERRED : \n", error);
break;
case '7':
eax.eaxGet(EAX.BUFFER_GUID, EAX.DSPROPERTY_EAXBUFFER_ALLPARAMETERS, source.get(0),
eaxBufferProp0.getAddress(), eaxBufferProp0.getSize());
if ((error = al.getError()) != AL.NO_ERROR)
displayALError("eaxGet EAXBUFFER_ALLPARAMETERS : \n", error);
eaxBufferProp0.setOcclusion(-5000);
eax.eaxSet(EAX.BUFFER_GUID, EAX.DSPROPERTY_EAXBUFFER_ALLPARAMETERS | EAX.DSPROPERTY_EAXBUFFER_DEFERRED, source.get(0),
eaxBufferProp0.getAddress(), eaxBufferProp0.getSize());
if ((error = al.getError()) != AL.NO_ERROR)
displayALError("eaxSet EAXBUFFER_ALLPARAMETERS | EAXBUFFER_DEFERRED : \n", error);
break;
case '8':
Occlusion.put(0, 0);
eax.eaxSet(EAX.BUFFER_GUID, EAX.DSPROPERTY_EAXBUFFER_OCCLUSION | EAX.DSPROPERTY_EAXBUFFER_DEFERRED, source.get(0),
Sys.getDirectBufferAddress(Occlusion), 4);
if ((error = al.getError()) != AL.NO_ERROR)
displayALError("eaxSet EAXBUFFER_OCCLUSION | EAXBUFFER_DEFERRED : \n", error);
break;
case '9':
Obstruction.put(0, -5000);
eax.eaxSet(EAX.BUFFER_GUID, EAX.DSPROPERTY_EAXBUFFER_OBSTRUCTION, source.get(1),
Sys.getDirectBufferAddress(Obstruction), 4);
if ((error = al.getError()) != AL.NO_ERROR)
displayALError("eaxSet EAXBUFFER_OBSTRUCTION : \n", error);
break;
case '0':
Obstruction.put(0, 0);
eax.eaxSet(EAX.BUFFER_GUID, EAX.DSPROPERTY_EAXBUFFER_OBSTRUCTION, source.get(1),
Sys.getDirectBufferAddress(Obstruction), 4);
if ((error = al.getError()) != AL.NO_ERROR)
displayALError("eaxSet EAXBUFFER_OBSTRUCTION : \n", error);
break;
case 'C':
// Commit settings on source 0
eax.eaxSet(EAX.BUFFER_GUID, EAX.DSPROPERTY_EAXBUFFER_COMMITDEFERREDSETTINGS,
source.get(0), 0, 0);
if ((error = al.getError()) != AL.NO_ERROR)
displayALError("eaxSet EAXBUFFER_COMMITDEFERREDSETTINGS : \n", error);
// Commit Listener settings
eax.eaxSet(EAX.LISTENER_GUID, EAX.DSPROPERTY_EAXLISTENER_COMMITDEFERREDSETTINGS,
0, 0, 0);
if ((error = al.getError()) != AL.NO_ERROR)
displayALError("eaxSet EAXLISTENER_COMMITDEFERREDSETTINGSENVIRONMENT : \n", error);
break;
}
} while (ch != 'Q');
// reset EAX level
Room.put(0, -10000);
eax.eaxSet(EAX.LISTENER_GUID, EAX.DSPROPERTY_EAXLISTENER_ROOM, 0, Sys.getDirectBufferAddress(Room), 4);
if ((error = al.getError()) != AL.NO_ERROR)
displayALError("eaxSet EAXLISTENER_ROOM : \n", error);
// Release resources
al.sourceStopv(2, Sys.getDirectBufferAddress(source));
if ((error = al.getError()) != AL.NO_ERROR)
displayALError("alSourceStopv 2 : ", error);
al.deleteSources(2, Sys.getDirectBufferAddress(source));
if ((error = al.getError()) != AL.NO_ERROR)
displayALError("alDeleteSources 2 : ", error);
}
protected void i_QueueTest() {