From 4050d93e4747b5418379319e7216af6113ea23e5 Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Mon, 29 Mar 2010 18:35:57 +0200 Subject: renamed package to com.jogamp.openal.* --- README.txt | 2 +- make/build.xml | 4 +- make/joal-alc.cfg | 6 +- make/joal-common.cfg | 2 +- make/joal.cfg | 6 +- make/joalversion | 2 +- make/validate-properties.xml | 2 +- src/java/build.xml | 10 +- src/java/com/jogamp/openal/ALException.java | 62 ++ src/java/com/jogamp/openal/ALFactory.java | 91 ++ src/java/com/jogamp/openal/eax/EAX.java | 140 ++++ src/java/com/jogamp/openal/eax/EAXConstants.java | 350 ++++++++ src/java/com/jogamp/openal/eax/EAXFactory.java | 54 ++ .../jogamp/openal/impl/ALProcAddressLookup.java | 162 ++++ .../com/jogamp/openal/impl/NativeLibLoader.java | 114 +++ .../com/jogamp/openal/sound3d/AudioSystem3D.java | 273 ++++++ src/java/com/jogamp/openal/sound3d/Buffer.java | 144 ++++ src/java/com/jogamp/openal/sound3d/Context.java | 77 ++ src/java/com/jogamp/openal/sound3d/Device.java | 59 ++ src/java/com/jogamp/openal/sound3d/Listener.java | 171 ++++ src/java/com/jogamp/openal/sound3d/Source.java | 508 ++++++++++++ src/java/com/jogamp/openal/sound3d/Vec3f.java | 63 ++ src/java/com/jogamp/openal/util/ALut.java | 146 ++++ src/java/com/jogamp/openal/util/BufferUtils.java | 266 ++++++ src/java/com/jogamp/openal/util/WAVData.java | 75 ++ src/java/com/jogamp/openal/util/WAVLoader.java | 135 +++ src/java/net/java/games/joal/ALException.java | 62 -- src/java/net/java/games/joal/ALFactory.java | 89 -- src/java/net/java/games/joal/eax/EAX.java | 140 ---- src/java/net/java/games/joal/eax/EAXConstants.java | 350 -------- src/java/net/java/games/joal/eax/EAXFactory.java | 54 -- .../java/games/joal/impl/ALProcAddressLookup.java | 159 ---- .../net/java/games/joal/impl/NativeLibLoader.java | 114 --- src/java/net/java/games/joal/util/ALut.java | 146 ---- src/java/net/java/games/joal/util/BufferUtils.java | 266 ------ src/java/net/java/games/joal/util/WAVData.java | 75 -- src/java/net/java/games/joal/util/WAVLoader.java | 135 --- src/java/net/java/games/sound3d/AudioSystem3D.java | 273 ------ src/java/net/java/games/sound3d/Buffer.java | 144 ---- src/java/net/java/games/sound3d/Context.java | 77 -- src/java/net/java/games/sound3d/Device.java | 59 -- src/java/net/java/games/sound3d/Listener.java | 171 ---- src/java/net/java/games/sound3d/Source.java | 508 ------------ src/java/net/java/games/sound3d/Vec3f.java | 63 -- test/build.xml | 2 +- test/src/OpenALTest.java | 120 --- test/src/Sound3DTest.java | 116 --- test/src/com/jogamp/openal/ALTest.java | 919 ++++++++++++++++++++ test/src/com/jogamp/openal/OpenALTest.java | 122 +++ test/src/com/jogamp/openal/Sound3DTest.java | 117 +++ test/src/net/java/games/joal/ALTest.java | 920 --------------------- 51 files changed, 4066 insertions(+), 4059 deletions(-) create mode 100755 src/java/com/jogamp/openal/ALException.java create mode 100644 src/java/com/jogamp/openal/ALFactory.java create mode 100644 src/java/com/jogamp/openal/eax/EAX.java create mode 100644 src/java/com/jogamp/openal/eax/EAXConstants.java create mode 100644 src/java/com/jogamp/openal/eax/EAXFactory.java create mode 100755 src/java/com/jogamp/openal/impl/ALProcAddressLookup.java create mode 100755 src/java/com/jogamp/openal/impl/NativeLibLoader.java create mode 100644 src/java/com/jogamp/openal/sound3d/AudioSystem3D.java create mode 100644 src/java/com/jogamp/openal/sound3d/Buffer.java create mode 100644 src/java/com/jogamp/openal/sound3d/Context.java create mode 100644 src/java/com/jogamp/openal/sound3d/Device.java create mode 100644 src/java/com/jogamp/openal/sound3d/Listener.java create mode 100644 src/java/com/jogamp/openal/sound3d/Source.java create mode 100644 src/java/com/jogamp/openal/sound3d/Vec3f.java create mode 100644 src/java/com/jogamp/openal/util/ALut.java create mode 100644 src/java/com/jogamp/openal/util/BufferUtils.java create mode 100644 src/java/com/jogamp/openal/util/WAVData.java create mode 100644 src/java/com/jogamp/openal/util/WAVLoader.java delete mode 100755 src/java/net/java/games/joal/ALException.java delete mode 100644 src/java/net/java/games/joal/ALFactory.java delete mode 100644 src/java/net/java/games/joal/eax/EAX.java delete mode 100644 src/java/net/java/games/joal/eax/EAXConstants.java delete mode 100644 src/java/net/java/games/joal/eax/EAXFactory.java delete mode 100755 src/java/net/java/games/joal/impl/ALProcAddressLookup.java delete mode 100755 src/java/net/java/games/joal/impl/NativeLibLoader.java delete mode 100644 src/java/net/java/games/joal/util/ALut.java delete mode 100644 src/java/net/java/games/joal/util/BufferUtils.java delete mode 100644 src/java/net/java/games/joal/util/WAVData.java delete mode 100644 src/java/net/java/games/joal/util/WAVLoader.java delete mode 100644 src/java/net/java/games/sound3d/AudioSystem3D.java delete mode 100644 src/java/net/java/games/sound3d/Buffer.java delete mode 100644 src/java/net/java/games/sound3d/Context.java delete mode 100644 src/java/net/java/games/sound3d/Device.java delete mode 100644 src/java/net/java/games/sound3d/Listener.java delete mode 100644 src/java/net/java/games/sound3d/Source.java delete mode 100644 src/java/net/java/games/sound3d/Vec3f.java delete mode 100644 test/src/OpenALTest.java delete mode 100644 test/src/Sound3DTest.java create mode 100644 test/src/com/jogamp/openal/ALTest.java create mode 100644 test/src/com/jogamp/openal/OpenALTest.java create mode 100644 test/src/com/jogamp/openal/Sound3DTest.java delete mode 100644 test/src/net/java/games/joal/ALTest.java diff --git a/README.txt b/README.txt index 54982f3..98ab414 100644 --- a/README.txt +++ b/README.txt @@ -31,7 +31,7 @@ * design, construction, operation or maintenance of any nuclear facility. */ -Project: net.java.games.joal.* & net.java.games.sound3d.* +Project: com.jogamp.openal.* & com.jogamp.openal.sound3d.* Purpose Open Source Java Bindings for OpenAL and Object-Oriented 3D sound toolkit Author: -- JOAL/Sound3D API Original Author diff --git a/make/build.xml b/make/build.xml index 402e590..71be711 100755 --- a/make/build.xml +++ b/make/build.xml @@ -191,8 +191,8 @@ - - + + diff --git a/make/joal-alc.cfg b/make/joal-alc.cfg index 50a8fa2..8626e43 100755 --- a/make/joal-alc.cfg +++ b/make/joal-alc.cfg @@ -3,7 +3,7 @@ Include joal-common.cfg Style InterfaceAndImpl JavaClass ALC -ImplPackage net.java.games.joal.impl +ImplPackage com.jogamp.openal.impl ImplJavaClass ALCImpl Extends ALC ALCConstants @@ -14,8 +14,8 @@ ProcAddressNameExpr LP $UPPERCASE({0}) Import java.io.UnsupportedEncodingException Import java.util.* -Import net.java.games.joal.* -Import net.java.games.joal.impl.* +Import com.jogamp.openal.* +Import com.jogamp.openal.impl.* # Factor out the OpenAL constants into their own interface Ignore ^AL_.+ diff --git a/make/joal-common.cfg b/make/joal-common.cfg index 85dba07..dab5b77 100755 --- a/make/joal-common.cfg +++ b/make/joal-common.cfg @@ -1,4 +1,4 @@ -Package net.java.games.joal +Package com.jogamp.openal # Specify output directories HierarchicalNativeOutput false diff --git a/make/joal.cfg b/make/joal.cfg index eb9c874..b22de32 100755 --- a/make/joal.cfg +++ b/make/joal.cfg @@ -3,7 +3,7 @@ Include joal-common.cfg Style InterfaceAndImpl JavaClass AL -ImplPackage net.java.games.joal.impl +ImplPackage com.jogamp.openal.impl ImplJavaClass ALImpl Extends AL ALConstants @@ -12,8 +12,8 @@ ProcAddressTableClassName ALProcAddressTable GetProcAddressTableExpr ALProcAddressLookup.getALProcAddressTable() ProcAddressNameExpr LP $UPPERCASE({0}) -Import net.java.games.joal.* -Import net.java.games.joal.impl.* +Import com.jogamp.openal.* +Import com.jogamp.openal.impl.* Import com.jogamp.gluegen.runtime.* # Factor out the OpenAL constants into their own interface diff --git a/make/joalversion b/make/joalversion index dc78238..85b5770 100755 --- a/make/joalversion +++ b/make/joalversion @@ -4,5 +4,5 @@ Specification-Vendor: JogAmp.org Implementation-Title: Java Bindings for the OpenAL API Implementation-Version: @VERSION@ Implementation-Vendor: JogAmp.org -Extension-Name: net.java.games.joal +Extension-Name: com.jogamp.openal Implementation-Vendor-Id: JogAmp.org diff --git a/make/validate-properties.xml b/make/validate-properties.xml index 8fc9e33..146bd4f 100755 --- a/make/validate-properties.xml +++ b/make/validate-properties.xml @@ -49,7 +49,7 @@ - we can not overwrite it. --> - + diff --git a/src/java/build.xml b/src/java/build.xml index 44a11ae..9e11377 100644 --- a/src/java/build.xml +++ b/src/java/build.xml @@ -47,19 +47,19 @@ - - - - + + + - + diff --git a/src/java/com/jogamp/openal/ALException.java b/src/java/com/jogamp/openal/ALException.java new file mode 100755 index 0000000..7f0dcd3 --- /dev/null +++ b/src/java/com/jogamp/openal/ALException.java @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * -Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. + * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING + * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR + * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS + * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A + * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. + * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT + * OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR + * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS + * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use in the + * design, construction, operation or maintenance of any nuclear facility. + */ + +package com.jogamp.openal; + +/** A generic exception for OpenAL errors used throughout the binding + as a substitute for {@link RuntimeException}. */ + +public class ALException extends RuntimeException { + /** Constructs an ALException object. */ + public ALException() { + super(); + } + + /** Constructs an ALException object with the specified detail + message. */ + public ALException(String message) { + super(message); + } + + /** Constructs an ALException object with the specified detail + message and root cause. */ + public ALException(String message, Throwable cause) { + super(message, cause); + } + + /** Constructs an ALException object with the specified root + cause. */ + public ALException(Throwable cause) { + super(cause); + } +} diff --git a/src/java/com/jogamp/openal/ALFactory.java b/src/java/com/jogamp/openal/ALFactory.java new file mode 100644 index 0000000..f58fe4b --- /dev/null +++ b/src/java/com/jogamp/openal/ALFactory.java @@ -0,0 +1,91 @@ +/** + * Copyright (c) 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * -Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. + * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING + * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR + * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS + * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A + * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. + * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT + * OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR + * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS + * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use in the + * design, construction, operation or maintenance of any nuclear facility. + */ + +package com.jogamp.openal; + +import com.jogamp.openal.AL; +import com.jogamp.openal.ALC; +import com.jogamp.openal.impl.*; + +/** + * This class provides factory methods for generating AL and ALC objects. + * + * @author Athomas Goldberg + * @author Kenneth Russell + */ +public class ALFactory { + private static boolean initialized = false; + private static AL al; + private static ALC alc; + + private ALFactory() {} + + private static synchronized void initialize() throws ALException { + try { + if (!initialized) { + NativeLibLoader.load(); + initialized = true; + } + } catch (UnsatisfiedLinkError e) { + throw new ALException(e); + } + } + + /** + * Get the default AL object. This object is used to access most of the + * OpenAL functionality. + * + * @return the AL object + */ + public static AL getAL() throws ALException { + initialize(); + if (al == null) { + al = new ALImpl(); + } + return al; + } + + /** + * Get the default ALC object. This object is used to access most of the + * OpenAL context functionality. + * + * @return the ALC object + */ + public static ALC getALC() throws ALException{ + initialize(); + if (alc == null) { + alc = new ALCImpl(); + } + return alc; + } +} diff --git a/src/java/com/jogamp/openal/eax/EAX.java b/src/java/com/jogamp/openal/eax/EAX.java new file mode 100644 index 0000000..93af6bc --- /dev/null +++ b/src/java/com/jogamp/openal/eax/EAX.java @@ -0,0 +1,140 @@ +/** +* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* -Redistribution of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may +* be used to endorse or promote products derived from this software without +* specific prior written permission. +* +* This software is provided "AS IS," without a warranty of any kind. +* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING +* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS +* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A +* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. +* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT +* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR +* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, +* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS +* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* +* You acknowledge that this software is not designed or intended for use in the +* design, construction, operation or maintenance of any nuclear facility. +*/ + +package com.jogamp.openal.eax; + +import java.nio.Buffer; + + +/** + * @author Athomas Goldberg + * + */ +public class EAX implements EAXConstants { + static { + System.loadLibrary("joal_native"); + } + + public static final int SOURCE = 0; + public static final int LISTENER = 1; + + private final int sourceGUID = SOURCE; + private final int listenerGUID = LISTENER; + + /** + * @param sourceGUID + * @param listenerGUID + */ + EAX(int sourceGUID, int listenerGUID) { + // this.sourceGUID = sourceGUID; + // this.listenerGUID = listenerGUID; + } + + /** + * This method sets an EAX property value.
+ *
+ * Interface to C Language function: + *
ALenum EAXSet(const struct _GUID *propertySetID, ALuint property, ALuint source, ALvoid *value, ALuint size)
+ * + * @param objectFlag a flag indicating a LISTENER or a SOURCE + * @param pname the property being set + * @param source the ID of the source, or 0 for Listener properties + * @param value a direct Buffer to hold the value retrieved + * @param size the size of the Buffer + */ + public native void EAXSet( + int objectFlag, + int pname, + int source, + Buffer value, + int size + ); + + /** + * This method retrieves an EAX property value.
+ *
+ * Interface to C Language function: + *
ALenum EAXGet(const struct _GUID *propertySetID, ALuint property, ALuint source, ALvoid *value, ALuint size)
+ * + * @param objectFlag a flag indicating a LISTENER or a SOURCE + * @param pname the property being queried + * @param source the ID of the source, or 0 for Listener properties + * @param value a direct Buffer to hold the value retrieved + * @param size the size of the Buffer + */ + public native void EAXGet( + int objectFlag, + int pname, + int source, + Buffer value, + int size + ); + + /** + * This method sets a source property. + * @param sourceID the ID of the source whose property is being set. + * @param pname the name of the property being set + * @param value a direct Buffer containing the value to be set + */ + public void setSourceProperty(int sourceID, int pname, Buffer value) { + EAXSet(sourceGUID, pname, sourceID, value, value.capacity()); + } + + /** + * This method retrieves a source property. + * @param sourceID the ID of the source whose property is being retrieved. + * @param pname the name of the property being retrieved + * @param value a direct Buffer to hold the value to be retrieved + */ + public void getSourceProperty(int pname, int sourceID, Buffer value) { + EAXGet(sourceGUID, pname, sourceID, value, value.capacity()); + } + + /** + * This method sets a Listener property. + * @param pname the name of the property being set + * @param value a direct Buffer containing the value to be set + */ + public void setListenerProperty(int pname, Buffer value) { + EAXSet(listenerGUID, pname, 0, value, value.capacity()); + } + + /** + * This method retrieves a Listener property. + * @param pname the name of the property being retrieved + * @param value a direct Buffer to hold the value to be retrieved + */ + public void getListenerProperty(int pname, Buffer value) { + EAXGet(listenerGUID, pname, 0, value, value.capacity()); + } +} diff --git a/src/java/com/jogamp/openal/eax/EAXConstants.java b/src/java/com/jogamp/openal/eax/EAXConstants.java new file mode 100644 index 0000000..106932d --- /dev/null +++ b/src/java/com/jogamp/openal/eax/EAXConstants.java @@ -0,0 +1,350 @@ +/** +* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* -Redistribution of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may +* be used to endorse or promote products derived from this software without +* specific prior written permission. +* +* This software is provided "AS IS," without a warranty of any kind. +* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING +* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS +* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A +* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. +* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT +* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR +* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, +* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS +* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* +* You acknowledge that this software is not designed or intended for use in the +* design, construction, operation or maintenance of any nuclear facility. +*/ + +package com.jogamp.openal.eax; +/** + * + * This class implements the basic EAX extension constants. + * + * @author Athomas Goldberg + */ +public interface EAXConstants { + + public final static int DSPROPERTY_EAXLISTENER_NONE = 0; + public final static int DSPROPERTY_EAXLISTENER_ALLPARAMETERS = 1; + public final static int DSPROPERTY_EAXLISTENER_ROOM = 2; + public final static int DSPROPERTY_EAXLISTENER_ROOMHF = 3; + public final static int DSPROPERTY_EAXLISTENER_ROOMROLLOFFFACTOR = 4; + public final static int DSPROPERTY_EAXLISTENER_DECAYTIME = 5; + public final static int DSPROPERTY_EAXLISTENER_DECAYHFRATIO = 6; + public final static int DSPROPERTY_EAXLISTENER_REFLECTIONS = 7; + public final static int DSPROPERTY_EAXLISTENER_REFLECTIONSDELAY = 8; + public final static int DSPROPERTY_EAXLISTENER_REVERB = 9; + public final static int DSPROPERTY_EAXLISTENER_REVERBDELAY = 10; + public final static int DSPROPERTY_EAXLISTENER_ENVIRONMENT = 11; + public final static int DSPROPERTY_EAXLISTENER_ENVIRONMENTSIZE = 12; + public final static int DSPROPERTY_EAXLISTENER_ENVIRONMENTDIFFUSION = 13; + public final static int DSPROPERTY_EAXLISTENER_AIRABSORPTIONHF = 14; + public final static int DSPROPERTY_EAXLISTENER_FLAGS = 15; + +// OR these flags with property id // + /** 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; + + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_GENERIC = 0; + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_PADDEDCELL = 1; + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_ROOM = 2; + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_BATHROOM = 3; + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_LIVINGROOM = 4; + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_STONEROOM = 5; + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_AUDITORIUM = 6; + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_CONCERTHALL = 7; + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_CAVE = 8; + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_ARENA = 9; + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_HANGAR = 10; + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_CARPETEDHALLWAY = 11; + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_HALLWAY = 12; + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_STONECORRIDOR = 13; + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_ALLEY = 14; + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_FOREST = 15; + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_CITY = 16; + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_MOUNTAINS = 17; + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_QUARRY = 18; + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_PLAIN = 19; + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_PARKINGLOT = 20; + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_SEWERPIPE = 21; + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_UNDERWATER = 22; + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_DRUGGED = 23; + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_DIZZY = 24; + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_PSYCHOTIC = 25; + /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ + public final static int EAX_ENVIRONMENT_COUNT = 26; + +// These flags determine what properties are affected by environment size. + /** reverberation decay time */ + public final static int EAXLISTENERFLAGS_DECAYTIMESCALE = 0x00000001; + /** reflection level */ + public final static int EAXLISTENERFLAGS_REFLECTIONSSCALE = 0x00000002; + /** initial reflection delay time */ + public final static int EAXLISTENERFLAGS_REFLECTIONSDELAYSCALE = 0x00000004; + /** reflections level */ + public final static int EAXLISTENERFLAGS_REVERBSCALE = 0x00000008; + /** late reverberation delay time */ + public final static int EAXLISTENERFLAGS_REVERBDELAYSCALE = 0x00000010; + + /** This flag limits high-frequency decay time according to air absorption.*/ + public final static int EAXLISTENERFLAGS_DECAYHFLIMIT = 0x00000020; + /** reserved future use */ + public final static int EAXLISTENERFLAGS_RESERVED = 0xFFFFFFC0; + +// property ranges and defaults: + + public final static int EAXLISTENER_MINROOM = -10000; + public final static int EAXLISTENER_MAXROOM = 0; + public final static int EAXLISTENER_DEFAULTROOM = -1000; + + public final static int EAXLISTENER_MINROOMHF = -10000; + public final static int EAXLISTENER_MAXROOMHF = 0; + public final static int EAXLISTENER_DEFAULTROOMHF = -100; + + public final static float EAXLISTENER_MINROOMROLLOFFFACTOR = 0.0f; + public final static float EAXLISTENER_MAXROOMROLLOFFFACTOR = 10.0f; + public final static float EAXLISTENER_DEFAULTROOMROLLOFFFACTOR = 0.0f; + + public final static float EAXLISTENER_MINDECAYTIME = 0.1f; + public final static float EAXLISTENER_MAXDECAYTIME = 20.0f; + public final static float EAXLISTENER_DEFAULTDECAYTIME = 1.49f; + + public final static float EAXLISTENER_MINDECAYHFRATIO = 0.1f; + public final static float EAXLISTENER_MAXDECAYHFRATIO = 2.0f; + public final static float EAXLISTENER_DEFAULTDECAYHFRATIO = 0.83f; + + public final static int EAXLISTENER_MINREFLECTIONS = -10000; + public final static int EAXLISTENER_MAXREFLECTIONS = 1000; + public final static int EAXLISTENER_DEFAULTREFLECTIONS = -2602; + + public final static float EAXLISTENER_MINREFLECTIONSDELAY = 0.0f; + public final static float EAXLISTENER_MAXREFLECTIONSDELAY = 0.3f; + public final static float EAXLISTENER_DEFAULTREFLECTIONSDELAY = 0.007f; + + public final static int EAXLISTENER_MINREVERB = -10000; + public final static int EAXLISTENER_MAXREVERB = 2000; + public final static int EAXLISTENER_DEFAULTREVERB = 200; + + public final static float EAXLISTENER_MINREVERBDELAY = 0.0f; + public final static float EAXLISTENER_MAXREVERBDELAY = 0.1f; + public final static float EAXLISTENER_DEFAULTREVERBDELAY = 0.011f; + + public final static int EAXLISTENER_MINENVIRONMENT = 0; + public final static int EAXLISTENER_MAXENVIRONMENT = EAX_ENVIRONMENT_COUNT-1; + public final static int EAXLISTENER_DEFAULTENVIRONMENT = EAX_ENVIRONMENT_GENERIC; + + public final static float EAXLISTENER_MINENVIRONMENTSIZE = 1.0f; + public final static float EAXLISTENER_MAXENVIRONMENTSIZE = 100.0f; + public final static float EAXLISTENER_DEFAULTENVIRONMENTSIZE = 7.5f; + + public final static float EAXLISTENER_MINENVIRONMENTDIFFUSION = 0.0f; + public final static float EAXLISTENER_MAXENVIRONMENTDIFFUSION = 1.0f; + public final static float EAXLISTENER_DEFAULTENVIRONMENTDIFFUSION = 1.0f; + + public final static float EAXLISTENER_MINAIRABSORPTIONHF = -100.0f; + public final static float EAXLISTENER_MAXAIRABSORPTIONHF = 0.0f; + public final static float EAXLISTENER_DEFAULTAIRABSORPTIONHF = -5.0f; + + public final static int EAXLISTENER_DEFAULTFLAGS = + EAXLISTENERFLAGS_DECAYTIMESCALE | + EAXLISTENERFLAGS_REFLECTIONSSCALE | + EAXLISTENERFLAGS_REFLECTIONSDELAYSCALE | + EAXLISTENERFLAGS_REVERBSCALE | + EAXLISTENERFLAGS_REVERBDELAYSCALE | + EAXLISTENERFLAGS_DECAYHFLIMIT; + + public final static int DSPROPERTY_EAXBUFFER_NONE = 0; + public final static int DSPROPERTY_EAXBUFFER_ALLPARAMETERS = 1; + public final static int DSPROPERTY_EAXBUFFER_DIRECT = 2; + public final static int DSPROPERTY_EAXBUFFER_DIRECTHF = 3; + public final static int DSPROPERTY_EAXBUFFER_ROOM = 4; + public final static int DSPROPERTY_EAXBUFFER_ROOMHF = 5; + public final static int DSPROPERTY_EAXBUFFER_ROOMROLLOFFFACTOR = 6; + public final static int DSPROPERTY_EAXBUFFER_OBSTRUCTION = 7; + public final static int DSPROPERTY_EAXBUFFER_OBSTRUCTIONLFRATIO = 8; + public final static int DSPROPERTY_EAXBUFFER_OCCLUSION = 9; + public final static int DSPROPERTY_EAXBUFFER_OCCLUSIONLFRATIO = 10; + public final static int DSPROPERTY_EAXBUFFER_OCCLUSIONROOMRATIO = 11; + public final static int DSPROPERTY_EAXBUFFER_OUTSIDEVOLUMEHF = 13; + public final static int DSPROPERTY_EAXBUFFER_AIRABSORPTIONFACTOR = 14; + public final static int DSPROPERTY_EAXBUFFER_FLAGS = 15; + +// OR these flags with property id + /** changes take effect immediately */ + public final static int DSPROPERTY_EAXBUFFER_IMMEDIATE = 0x00000000; + /** changes take effect later */ + public final static int DSPROPERTY_EAXBUFFER_DEFERRED = 0x80000000; + public final static int DSPROPERTY_EAXBUFFER_COMMITDEFERREDSETTINGS = + DSPROPERTY_EAXBUFFER_NONE | + DSPROPERTY_EAXBUFFER_IMMEDIATE; + + +// Used by DSPROPERTY_EAXBUFFER_FLAGS +// TRUE: value is computed automatically - property is an offset +// FALSE: value is used directly +// +// Note: The number and order of flags may change in future EAX versions. +// To insure future compatibility, use flag defines as follows: +// myFlags = EAXBUFFERFLAGS_DIRECTHFAUTO | EAXBUFFERFLAGS_ROOMAUTO; +// instead of: +// myFlags = 0x00000003; +// + /** affects DSPROPERTY_EAXBUFFER_DIRECTHF */ + public final static int EAXBUFFERFLAGS_DIRECTHFAUTO = 0x00000001; + /** affects DSPROPERTY_EAXBUFFER_ROOM */ + public final static int EAXBUFFERFLAGS_ROOMAUTO = 0x00000002; + /** affects DSPROPERTY_EAXBUFFER_ROOMHF */ + public final static int EAXBUFFERFLAGS_ROOMHFAUTO = 0x00000004; + /** reserved future use */ + public final static int EAXBUFFERFLAGS_RESERVED = 0xFFFFFFF8; + +// property ranges and defaults: + + public final static int EAXBUFFER_MINDIRECT = (-10000); + public final static int EAXBUFFER_MAXDIRECT = 1000; + public final static int EAXBUFFER_DEFAULTDIRECT = 0; + + public final static int EAXBUFFER_MINDIRECTHF = (-10000); + public final static int EAXBUFFER_MAXDIRECTHF = 0; + public final static int EAXBUFFER_DEFAULTDIRECTHF = 0; + + public final static int EAXBUFFER_MINROOM = (-10000); + public final static int EAXBUFFER_MAXROOM = 1000; + public final static int EAXBUFFER_DEFAULTROOM = 0; + + public final static int EAXBUFFER_MINROOMHF = (-10000); + public final static int EAXBUFFER_MAXROOMHF = 0; + public final static int EAXBUFFER_DEFAULTROOMHF = 0; + + public final static float EAXBUFFER_MINROOMROLLOFFFACTOR = 0.0f; + public final static float EAXBUFFER_MAXROOMROLLOFFFACTOR = 10.f; + public final static float EAXBUFFER_DEFAULTROOMROLLOFFFACTOR = 0.0f; + + public final static int EAXBUFFER_MINOBSTRUCTION = (-10000); + public final static int EAXBUFFER_MAXOBSTRUCTION = 0; + public final static int EAXBUFFER_DEFAULTOBSTRUCTION = 0; + + public final static float EAXBUFFER_MINOBSTRUCTIONLFRATIO = 0.0f; + public final static float EAXBUFFER_MAXOBSTRUCTIONLFRATIO = 1.0f; + public final static float EAXBUFFER_DEFAULTOBSTRUCTIONLFRATIO = 0.0f; + + public final static int EAXBUFFER_MINOCCLUSION = (-10000); + public final static int EAXBUFFER_MAXOCCLUSION = 0; + public final static int EAXBUFFER_DEFAULTOCCLUSION = 0; + + public final static float EAXBUFFER_MINOCCLUSIONLFRATIO = 0.0f; + public final static float EAXBUFFER_MAXOCCLUSIONLFRATIO = 1.0f; + public final static float EAXBUFFER_DEFAULTOCCLUSIONLFRATIO = 0.25f; + + public final static float EAXBUFFER_MINOCCLUSIONROOMRATIO = 0.0f; + public final static float EAXBUFFER_MAXOCCLUSIONROOMRATIO = 10.0f; + public final static float EAXBUFFER_DEFAULTOCCLUSIONROOMRATIO = 0.5f; + + public final static int EAXBUFFER_MINOUTSIDEVOLUMEHF = (-10000); + public final static int EAXBUFFER_MAXOUTSIDEVOLUMEHF = 0; + public final static int EAXBUFFER_DEFAULTOUTSIDEVOLUMEHF = 0; + + public final static float EAXBUFFER_MINAIRABSORPTIONFACTOR = 0.0f; + public final static float EAXBUFFER_MAXAIRABSORPTIONFACTOR = 10.0f; + public final static float EAXBUFFER_DEFAULTAIRABSORPTIONFACTOR = 1.0f; + + public final static int EAXBUFFER_DEFAULTFLAGS = + EAXBUFFERFLAGS_DIRECTHFAUTO | + EAXBUFFERFLAGS_ROOMAUTO | + EAXBUFFERFLAGS_ROOMHFAUTO; + +// Material transmission presets +// 3 values in this order: +// 1: occlusion (or obstruction) +// 2: occlusion LF Ratio (or obstruction LF Ratio) +// 3: occlusion Room Ratio + +// Single window material preset + public final static int EAX_MATERIAL_SINGLEWINDOW = (-2800); + public final static float EAX_MATERIAL_SINGLEWINDOWLF = 0.71f; + public final static float EAX_MATERIAL_SINGLEWINDOWROOMRATIO = 0.43f; + +// Double window material preset + public final static int EAX_MATERIAL_DOUBLEWINDOW = (-5000); + public final static float EAX_MATERIAL_DOUBLEWINDOWHF = 0.40f; + public final static float EAX_MATERIAL_DOUBLEWINDOWROOMRATIO = 0.24f; + +// Thin door material preset + public final static int EAX_MATERIAL_THINDOOR = (-1800); + public final static float EAX_MATERIAL_THINDOORLF = 0.66f; + public final static float EAX_MATERIAL_THINDOORROOMRATIO = 0.66f; + +// Thick door material preset + public final static int EAX_MATERIAL_THICKDOOR = (-4400); + public final static float EAX_MATERIAL_THICKDOORLF = 0.64f; + public final static float EAX_MATERIAL_THICKDOORROOMRTATION = 0.27f; + +// Wood wall material preset + public final static int EAX_MATERIAL_WOODWALL = (-4000); + public final static float EAX_MATERIAL_WOODWALLLF = 0.50f; + public final static float EAX_MATERIAL_WOODWALLROOMRATIO = 0.30f; + +// Brick wall material preset + public final static int EAX_MATERIAL_BRICKWALL = (-5000); + public final static float EAX_MATERIAL_BRICKWALLLF = 0.60f; + public final static float EAX_MATERIAL_BRICKWALLROOMRATIO = 0.24f; + +// Stone wall material preset + public final static int EAX_MATERIAL_STONEWALL = (-6000); + public final static float EAX_MATERIAL_STONEWALLLF = 0.68f; + public final static float EAX_MATERIAL_STONEWALLROOMRATIO = 0.20f; + +// Curtain material preset + public final static int EAX_MATERIAL_CURTAIN = (-1200); + public final static float EAX_MATERIAL_CURTAINLF = 0.15f; + public final static float EAX_MATERIAL_CURTAINROOMRATIO = 1.00f; +} \ No newline at end of file diff --git a/src/java/com/jogamp/openal/eax/EAXFactory.java b/src/java/com/jogamp/openal/eax/EAXFactory.java new file mode 100644 index 0000000..9aa2e9d --- /dev/null +++ b/src/java/com/jogamp/openal/eax/EAXFactory.java @@ -0,0 +1,54 @@ +/** +* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* -Redistribution of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may +* be used to endorse or promote products derived from this software without +* specific prior written permission. +* +* This software is provided "AS IS," without a warranty of any kind. +* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING +* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS +* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A +* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. +* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT +* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR +* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, +* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS +* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* +* You acknowledge that this software is not designed or intended for use in the +* design, construction, operation or maintenance of any nuclear facility. +*/ + +package com.jogamp.openal.eax; + +/** + * @author Athomas Goldberg + * + */ +public final class EAXFactory { + private static int SOURCE_GUID; + private static int LISTENER_GUID; + + private static EAX eax; + + private static native void init(); + public static EAX getEAX() { + if(eax == null) { + init(); + eax = new EAX(SOURCE_GUID, LISTENER_GUID); + } + return eax; + } +} diff --git a/src/java/com/jogamp/openal/impl/ALProcAddressLookup.java b/src/java/com/jogamp/openal/impl/ALProcAddressLookup.java new file mode 100755 index 0000000..1b6407a --- /dev/null +++ b/src/java/com/jogamp/openal/impl/ALProcAddressLookup.java @@ -0,0 +1,162 @@ +/** + * Copyright (c) 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * -Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. + * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING + * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR + * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS + * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A + * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. + * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT + * OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR + * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS + * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use in the + * design, construction, operation or maintenance of any nuclear facility. + */ + +package com.jogamp.openal.impl; + +import java.lang.reflect.Field; + +import com.jogamp.openal.*; +import com.jogamp.gluegen.runtime.*; +import com.jogamp.openal.impl.ALCProcAddressTable; +import com.jogamp.openal.impl.ALImpl; +import com.jogamp.openal.impl.ALProcAddressTable; + +/** Helper class for managing OpenAL-related proc address tables. */ + +public class ALProcAddressLookup { + private static final ALProcAddressTable alTable = new ALProcAddressTable(); + private static volatile boolean alTableInitialized = false; + private static final ALCProcAddressTable alcTable = new ALCProcAddressTable(); + private static volatile boolean alcTableInitialized = false; + private static final DynamicLookup lookup = new DynamicLookup(); + private static volatile NativeLibrary openAL = null; + + static class DynamicLookup implements DynamicLookupHelper { + public long dynamicLookupFunction(String functionName) { + // At some point this may require an OpenAL context to be + // current as we will actually use alGetProcAddress. Since + // this routine is currently broken and there are no + // per-context function pointers anyway we could actually do + // this work anywhere. + if (openAL == null) { + // We choose not to search the system path first because we + // bundle a very recent version of OpenAL which we would like + // to override existing installations + openAL = NativeLibrary.open("OpenAL32", "openal", "OpenAL", + false, + ALProcAddressLookup.class.getClassLoader()); + if (openAL == null) { + throw new RuntimeException("Unable to find and load OpenAL library"); + } + } + return openAL.dynamicLookupFunction(functionName); + } + } + + public static void resetALProcAddressTable() { + if (!alTableInitialized) { + synchronized (ALProcAddressLookup.class) { + if (!alTableInitialized) { + // At some point this may require an OpenAL context to be + // current as we will actually use alGetProcAddress. Since + // this routine is currently broken and there are no + // per-context function pointers anyway we could actually do + // this work anywhere. We should also in theory have + // per-ALcontext ALProcAddressTables and per-ALCdevice + // ALCProcAddressTables. + ProcAddressHelper.resetProcAddressTable(alTable, lookup); + + // The above only manages to find addresses for the core OpenAL + // functions. The below uses alGetProcAddress() to find the addresses + // of extensions such as EFX, just as in the C++ examples of the + // OpenAL 1.1 SDK. + useALGetProcAddress(); + + alTableInitialized = true; + } + } + } + } + + public static void resetALCProcAddressTable() { + if (!alcTableInitialized) { + synchronized (ALProcAddressLookup.class) { + if (!alcTableInitialized) { + // At some point this may require an OpenAL device to be + // created as we will actually use alcGetProcAddress. Since + // this routine is currently broken and there are no + // per-device function pointers anyway we could actually do + // this work anywhere. We should also in theory have + // per-ALcontext ALProcAddressTables and per-ALCdevice + // ALCProcAddressTables. + ProcAddressHelper.resetProcAddressTable(alcTable, lookup); + alcTableInitialized = true; + } + } + } + } + + public static ALProcAddressTable getALProcAddressTable() { + return alTable; + } + + public static ALCProcAddressTable getALCProcAddressTable() { + return alcTable; + } + + + /** + * Retrieves the values of the OpenAL functions using alGetProcAddress(). + */ + private static void useALGetProcAddress() { + String addrOfPrefix = "_addressof_"; + ALImpl al = (ALImpl) ALFactory.getAL(); + + Field[] fields = ALProcAddressTable.class.getFields(); + for (int i = 0; i < fields.length; i++) { + Field field = fields[i]; + + // Skip non-address fields + String fieldname = field.getName(); + if (!fieldname.startsWith(addrOfPrefix)) { + continue; + } + try { + String functionname = fieldname.substring(addrOfPrefix.length()); + long fieldval = field.getLong(alTable); + + // Skip fields which have already been valued + if (fieldval != 0) { + continue; + } + + // Get the address + long procAddressVal = al.alGetProcAddress(functionname); + field.setLong(alTable, procAddressVal); + } + catch (Exception ex) { + throw new RuntimeException("Unable to repopulate ALProcAddressTable values", ex); + } + } + } +} diff --git a/src/java/com/jogamp/openal/impl/NativeLibLoader.java b/src/java/com/jogamp/openal/impl/NativeLibLoader.java new file mode 100755 index 0000000..d4ac106 --- /dev/null +++ b/src/java/com/jogamp/openal/impl/NativeLibLoader.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution 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 Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + */ + +package com.jogamp.openal.impl; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.security.*; + +import com.jogamp.gluegen.runtime.*; + +public class NativeLibLoader { + private static volatile boolean loadingEnabled = true; + private static volatile boolean didLoading; + + private NativeLibLoader() {} + + public static void disableLoading() { + loadingEnabled = false; + } + + public static void enableLoading() { + loadingEnabled = true; + } + + public static void load() { + if (!didLoading && loadingEnabled) { + synchronized (NativeLibLoader.class) { + if (!didLoading && loadingEnabled) { + didLoading = true; + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + // Workaround for problem in OpenAL32.dll, which is actually + // the "wrapper" DLL which looks for real OpenAL + // implementations like nvopenal.dll and "*oal.dll". + // joal.dll matches this wildcard and a bug in OpenAL32.dll + // causes a call through a null function pointer. + loadLibraryInternal("joal_native"); + + // Workaround for 4845371. + // Make sure the first reference to the JNI GetDirectBufferAddress is done + // from a privileged context so the VM's internal class lookups will succeed. + // FIXME: need to figure out an appropriate entry point to call for JOAL + // JAWT jawt = new JAWT(); + // JAWTFactory.JAWT_GetAWT(jawt); + + return null; + } + }); + } + } + } + } + + private static void loadLibraryInternal(String libraryName) { + String sunAppletLauncher = System.getProperty("sun.jnlp.applet.launcher"); + boolean usingJNLPAppletLauncher = Boolean.valueOf(sunAppletLauncher).booleanValue(); + + if (usingJNLPAppletLauncher) { + try { + Class jnlpAppletLauncherClass = Class.forName("org.jdesktop.applet.util.JNLPAppletLauncher"); + Method jnlpLoadLibraryMethod = jnlpAppletLauncherClass.getDeclaredMethod("loadLibrary", new Class[] { String.class }); + jnlpLoadLibraryMethod.invoke(null, new Object[] { libraryName }); + } catch (Exception e) { + Throwable t = e; + if (t instanceof InvocationTargetException) { + t = ((InvocationTargetException) t).getTargetException(); + } + if (t instanceof Error) + throw (Error) t; + if (t instanceof RuntimeException) { + throw (RuntimeException) t; + } + // Throw UnsatisfiedLinkError for best compatibility with System.loadLibrary() + throw (UnsatisfiedLinkError) new UnsatisfiedLinkError().initCause(e); + } + } else { + System.loadLibrary(libraryName); + } + } +} diff --git a/src/java/com/jogamp/openal/sound3d/AudioSystem3D.java b/src/java/com/jogamp/openal/sound3d/AudioSystem3D.java new file mode 100644 index 0000000..1070d21 --- /dev/null +++ b/src/java/com/jogamp/openal/sound3d/AudioSystem3D.java @@ -0,0 +1,273 @@ +/** + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * -Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. + * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING + * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR + * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS + * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A + * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. + * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT + * OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR + * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS + * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use in the + * design, construction, operation or maintenance of any nuclear facility. + */ + +package com.jogamp.openal.sound3d; + +import com.jogamp.openal.*; +import com.jogamp.openal.util.WAVData; +import com.jogamp.openal.util.WAVLoader; + +import java.io.*; + +import javax.sound.sampled.UnsupportedAudioFileException; + + +/** + * The AudioSystem3D class provides a set of methods for creating and + * manipulating a 3D audio environment. + * + * @author Athomas Goldberg + */ +public class AudioSystem3D { + private static AL al; + private static ALC alc; + private static Listener listener; + + /** + * Iniitalize the Sound3D environment. This must be called before + * other methods in the class can be used. + */ + public static void init() throws ALException { + al = ALFactory.getAL(); + alc = ALFactory.getALC(); + } + + /** + * Creates a new Sound3D Context for a specified device. + * + * @param device The device the Context is being created for. + * + * @return The new Sound3D context. + */ + public static Context createContext(Device device) { + Context result = null; + ALCcontext realContext = alc.alcCreateContext(device.realDevice, null); + result = new Context(alc, realContext, device); + return result; + } + + /** + * Makes the specified context the current context. + * + * @param context the context to make current. + */ + public static void makeContextCurrent(Context context) { + ALCcontext realContext = null; + + if (context != null) { + realContext = context.realContext; + } + + alc.alcMakeContextCurrent(realContext); + } + + /** + * Opens the specifified audio device. + * + * @param deviceName The specified device name, On windows this will be + * DirectSound3D. We will be automating device discovery in upcoming versions + * of this class. + * + * @return The device described by the specifed name. + */ + public static Device openDevice(String deviceName) { + Device result = null; + ALCdevice realDevice = alc.alcOpenDevice(deviceName); + result = new Device(alc, realDevice); + + return result; + } + + /** + * Generate an array of Sound3D buffers. + * + * @param numBuffers The number of Sound3D buffers to generate. + * + * @return an array of (initially enpty) Sound3D buffers. + */ + public static Buffer[] generateBuffers(int numBuffers) { + Buffer[] result = new Buffer[numBuffers]; + int[] arr = new int[numBuffers]; + al.alGenBuffers(numBuffers, arr, 0); + + for (int i = 0; i < numBuffers; i++) { + result[i] = new Buffer(al, arr[i]); + } + + return result; + } + + /** + * Loads a Sound3D buffer with the specified audio file. + * + * @param filename the name of the file to load. + * + * @return a new Sound3D buffer containing the audio data from the + * specified file. + * + * @throws IOException If the file cannot be found or some other IO error + * occurs. + * @throws UnsupportedAudioFileException If the format of the audio data is + * not supported + */ + public static Buffer loadBuffer(String filename) + throws IOException, UnsupportedAudioFileException { + Buffer result; + Buffer[] tmp = generateBuffers(1); + result = tmp[0]; + + WAVData wd = WAVLoader.loadFromFile(filename); + result.configure(wd.data, wd.format, wd.freq); + + return result; + } + + /** + * Loads a Sound3D buffer with the specified audio file. + * + * @param stream contains the stream associated with the audio file. + * + * @return a new Sound3D buffer containing the audio data from the + * passed stream. + * + * @throws IOException If the stream cannot be read or some other IO error + * occurs. + * @throws UnsupportedAudioFileException If the format of the audio data is + * not supported + */ + public static Buffer loadBuffer(InputStream stream) + throws IOException, UnsupportedAudioFileException { + Buffer result; + Buffer[] tmp = generateBuffers(1); + result = tmp[0]; + + if (!(stream instanceof BufferedInputStream)) { + stream = new BufferedInputStream(stream); + } + WAVData wd = WAVLoader.loadFromStream(stream); + + result.configure(wd.data, wd.format, wd.freq); + + return result; + } + + /** + * Loads a Sound3D Source with the specified audio file. This is + * functionally equivalent to generateSource(loadBuffer(fileName)); + * + * @param filename the name of the file to load. + * + * @return a new Sound3D Source containing the audio data from the + * specified file. + * + * @throws IOException If the file cannot be found or some other IO error + * occurs. + * @throws UnsupportedAudioFileException If the format of the audio data is + * not supported + */ + public static Source loadSource(String filename) + throws IOException, UnsupportedAudioFileException { + Buffer buffer = loadBuffer(filename); + + return generateSource(buffer); + } + + /** + * Loads a Sound3D Source with the specified audio stream. This is + * functionally equivalent to generateSource(loadBuffer(stream)); + * + * @param stream contains the stream associated with the audio file. + * + * @return a new Sound3D Source containing the audio data from the + * passed stream. + * + * @throws IOException If the file cannot be found or some other IO error + * occurs. + * @throws UnsupportedAudioFileException If the format of the audio data is + * not supported + */ + public static Source loadSource(InputStream stream) + throws IOException, UnsupportedAudioFileException { + Buffer buffer = loadBuffer(stream); + + return generateSource(buffer); + } + + /** + * Generates a set of uninitialized Source3D sources + * + * @param numSources the number of Sound3D sources to generate. + * + * @return an array of uninitialized sources. + */ + public static Source[] generateSources(int numSources) { + Source[] result = new Source[numSources]; + int[] arr = new int[numSources]; + al.alGenSources(numSources, arr, 0); + + for (int i = 0; i < numSources; i++) { + result[i] = new Source(al, arr[i]); + } + + return result; + } + + /** + * Generate a Sound3D source from an initialized Buffer. + * + * @param buff The buffer to generate the source from. + * + * @return the newly generated Source. + */ + public static Source generateSource(Buffer buff) { + Source result = null; + Source[] tmp = generateSources(1); + result = tmp[0]; + result.setBuffer(buff); + + return result; + } + + /** + * Get the listener object associated with this Sound3D environment. + * + * @return The listener object. + */ + public static Listener getListener() { + if (listener == null) { + listener = new Listener(al); + } + + return listener; + } +} diff --git a/src/java/com/jogamp/openal/sound3d/Buffer.java b/src/java/com/jogamp/openal/sound3d/Buffer.java new file mode 100644 index 0000000..54d120e --- /dev/null +++ b/src/java/com/jogamp/openal/sound3d/Buffer.java @@ -0,0 +1,144 @@ +/** +* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* -Redistribution of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may +* be used to endorse or promote products derived from this software without +* specific prior written permission. +* +* This software is provided "AS IS," without a warranty of any kind. +* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING +* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS +* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A +* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. +* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT +* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR +* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, +* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS +* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* +* You acknowledge that this software is not designed or intended for use in the +* design, construction, operation or maintenance of any nuclear facility. +*/ + +package com.jogamp.openal.sound3d; + +import com.jogamp.openal.AL; + +import java.nio.ByteBuffer; + + +/** + * The Sound3D Buffer is a container for audio data used in the Sound3D + * environment. + * + * @author Athomas Goldberg + */ +public class Buffer { + public final static int FORMAT_MONO8 = AL.AL_FORMAT_MONO8; + + public final static int FORMAT_MONO16 = AL.AL_FORMAT_MONO16; + + public final static int FORMAT_STEREO8 = AL.AL_FORMAT_STEREO8; + + public final static int FORMAT_STEREO16 = AL.AL_FORMAT_STEREO16; + final int bufferID; + private ByteBuffer data; + private boolean isConfigured = false; + private final AL al; + + Buffer(AL al, int bufferID) { + this.bufferID = bufferID; + this.al = al; + } + + /** + * Configure the Sound3D buffer + * + * @param data the raw audio data + * @param format the format of the data: FORMAT_MONO8, FORMAT_MONO16, + * FORMAT_STEREO8 and FORMAT_STEREO16 + * @param freq the frequency of the data + */ + public void configure(ByteBuffer data, int format, int freq) { + if (!isConfigured) { + this.data = data; + al.alBufferData(bufferID, format, data, data.capacity(), freq); + } + } + + /** + * Delete this buffer, and free its resources. + */ + public void delete() { + data = null; + al.alDeleteBuffers(1, new int[] { bufferID }, 0); + } + + /** + * Get the bit-depth of the data, (8 or 16) + * + * @return the bit-depth of the data + */ + public int getBitDepth() { + int[] i = new int[1]; + al.alGetBufferi(bufferID, AL.AL_BITS, i, 0); + + return i[0]; + } + + /** + * Get the number of channels of the data (1-Mono, 2-Stereo) + * + * @return the number of audio channels. + */ + public int getNumChannels() { + int[] i = new int[1]; + al.alGetBufferi(bufferID, AL.AL_CHANNELS, i, 0); + + return i[0]; + } + + /** + * Gets the raw data contained in this buffer. + * + * @return the raw buffer data. + */ + public ByteBuffer getData() { + return data; + } + + /** + * Gets the audio frequency of the data contained in this buffer. + * + * @return the frequency of the data + */ + public int getFrequency() { + int[] i = new int[1]; + al.alGetBufferi(bufferID, AL.AL_FREQUENCY, i, 0); + + return i[0]; + } + + /** + * Gets the size (in bytes) of the raw data containe in this buffer. + * + * @return the size of the data. + */ + public int getSize() { + int[] i = new int[1]; + al.alGetBufferi(bufferID, AL.AL_SIZE, i, 0); + + return i[0]; + } +} diff --git a/src/java/com/jogamp/openal/sound3d/Context.java b/src/java/com/jogamp/openal/sound3d/Context.java new file mode 100644 index 0000000..5562153 --- /dev/null +++ b/src/java/com/jogamp/openal/sound3d/Context.java @@ -0,0 +1,77 @@ +/** +* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* -Redistribution of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may +* be used to endorse or promote products derived from this software without +* specific prior written permission. +* +* This software is provided "AS IS," without a warranty of any kind. +* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING +* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS +* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A +* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. +* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT +* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR +* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, +* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS +* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* +* You acknowledge that this software is not designed or intended for use in the +* design, construction, operation or maintenance of any nuclear facility. +*/ + +package com.jogamp.openal.sound3d; + +import com.jogamp.openal.*; + + +/** + * This class provides a Sound3D Context associated with a specified device. + * + * @author Athomas Goldberg + */ +public class Context { + private final ALC alc; + final ALCcontext realContext; + final Device device; + + Context(ALC alc, ALCcontext realContext, Device device) { + this.alc = alc; + this.realContext = realContext; + this.device = device; + } + + /** + * Suspend this context + */ + public void suspend() { + alc.alcSuspendContext(realContext); + } + + /** + * destroys this context freeing its resources. + */ + public void destroy() { + alc.alcDestroyContext(realContext); + } + + /** + * Gets the device associated with this context. + * + * @return the device associated with this context. + */ + public Device getDevice() { + return device; + } +} diff --git a/src/java/com/jogamp/openal/sound3d/Device.java b/src/java/com/jogamp/openal/sound3d/Device.java new file mode 100644 index 0000000..086d3ad --- /dev/null +++ b/src/java/com/jogamp/openal/sound3d/Device.java @@ -0,0 +1,59 @@ +/** +* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* -Redistribution of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may +* be used to endorse or promote products derived from this software without +* specific prior written permission. +* +* This software is provided "AS IS," without a warranty of any kind. +* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING +* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS +* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A +* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. +* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT +* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR +* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, +* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS +* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* +* You acknowledge that this software is not designed or intended for use in the +* design, construction, operation or maintenance of any nuclear facility. +*/ + +package com.jogamp.openal.sound3d; + +import com.jogamp.openal.*; + + +/** + * This class provides a handle to a specific audio device. + * + * @author Athomas Goldberg + */ +public class Device { + private final ALC alc; + final ALCdevice realDevice; + + Device(ALC alc, ALCdevice realDevice) { + this.alc = alc; + this.realDevice = realDevice; + } + + /** + * closes the device, freeing its resources. + */ + public void close() { + alc.alcCloseDevice(realDevice); + } +} diff --git a/src/java/com/jogamp/openal/sound3d/Listener.java b/src/java/com/jogamp/openal/sound3d/Listener.java new file mode 100644 index 0000000..fe8b869 --- /dev/null +++ b/src/java/com/jogamp/openal/sound3d/Listener.java @@ -0,0 +1,171 @@ +/** +* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* -Redistribution of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may +* be used to endorse or promote products derived from this software without +* specific prior written permission. +* +* This software is provided "AS IS," without a warranty of any kind. +* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING +* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS +* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A +* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. +* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT +* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR +* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, +* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS +* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* +* You acknowledge that this software is not designed or intended for use in the +* design, construction, operation or maintenance of any nuclear facility. +*/ + +package com.jogamp.openal.sound3d; + +import com.jogamp.openal.AL; + + +/** + * This class represents the human listener in the Sound3D environment. It + * provides methods for controlling the position, orientation as well as other + * properties associated with the listener. + * + * @author Athomas Goldberg + */ +public class Listener { + private final AL al; + + Listener(AL al) { + this.al = al; + } + + /** + * Sets the Gain, or volume of the audio in the environment relative to the + * listener + * + * @param gain the gain, or volume + */ + public void setGain(float gain) { + al.alListenerf(AL.AL_GAIN, gain); + } + + /** + * Gets the value of the gain, or volume of the audio in the environment + * relative to the listener. + * + * @return the gain value. + */ + public float getGain() { + float[] f = new float[1]; + al.alGetListenerf(AL.AL_GAIN, f, 0); + + return f[0]; + } + + /** + * Sets the position in (x-y-z coordinates) of the Listener in the Sound3D + * environment. + * + * @param x The position of the listener along the X-axis in the Sound3D + * environment + * @param y The position of the listener along the Y-axis in the Sound3D + * environment + * @param z The position of the listener along the Z-axis in the Sound3D + * environment + */ + public void setPosition(float x, float y, float z) { + al.alListener3f(AL.AL_POSITION, x, y, z); + } + + /** + * Sets the position in (x-y-z coordinates) of the Listener in the Sound3D + * environment. + * + * @param position a Vec3f object containing the x,y and z coordinates of + * Listener. + */ + public void setPosition(Vec3f position) { + al.alListener3f(AL.AL_POSITION, position.v1, position.v2, position.v3); + } + + /** + * Gets the position in (x-y-z coordinates) of the Listener in the Sound3D + * environment. + * + * @return a Vec3f object containing the x,y and z coordinates of + * Listener. + */ + public Vec3f getPosition() { + Vec3f result = null; + float[] tmp = new float[3]; + al.alGetListenerfv(AL.AL_POSITION, tmp, 0); + result = new Vec3f(tmp[0], tmp[1], tmp[2]); + + return result; + } + + /** + * Sets the velocity in (x-y-z coordinates) of the Listener in the Sound3D + * environment. Used in determining doppler shift. + * + * @param velocity a Vec3f object containing the velicity in + * x,y and z coordinates of Listener. + */ + public void setVelocity(Vec3f velocity) { + al.alListener3f(AL.AL_VELOCITY, velocity.v1, velocity.v2, velocity.v3); + } + + /** + * Gets the velocity in (x-y-z coordinates) of the Listener in the Sound3D + * environment. Used in determining doppler shift. + * + * @return a Vec3f object containing the velicity in + * x,y and z coordinates of Listener. + */ + public Vec3f getVelocity() { + Vec3f result = null; + float[] tmp = new float[3]; + al.alGetListenerfv(AL.AL_VELOCITY, tmp, 0); + result = new Vec3f(tmp[0], tmp[1], tmp[2]); + + return result; + } + + /** + * Sets the orientation of the Listener in the Sound3D environment. + * Orientation is expressed as "up" and "at" vectors. + * + * @param orientation The first 3 elements of the array should contain + * the x,y,z up-vector, the second 3 elements should contain the x,z,z + * look-at vector. + */ + public void setOrientation(float[] orientation) { + al.alListenerfv(AL.AL_ORIENTATION, orientation, 0); + } + + /** + * Gets the orientation of the Listener in the Sound3D environment. + * Orientation is expressed as "up" and "at" vectors. + * + * @return an array containing the orientation of the listener. + * The first 3 elements of the array contain + * the x,y,z up-vector, the second 3 elements contain the x,z,z + * look-at vector. + */ + public float[] getOrientation() { + float[] tmp = new float[6]; + al.alGetListenerfv(AL.AL_ORIENTATION, tmp, 0); + return tmp; + } +} diff --git a/src/java/com/jogamp/openal/sound3d/Source.java b/src/java/com/jogamp/openal/sound3d/Source.java new file mode 100644 index 0000000..2e2f512 --- /dev/null +++ b/src/java/com/jogamp/openal/sound3d/Source.java @@ -0,0 +1,508 @@ +/** +* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* -Redistribution of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may +* be used to endorse or promote products derived from this software without +* specific prior written permission. +* +* This software is provided "AS IS," without a warranty of any kind. +* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING +* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS +* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A +* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. +* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT +* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR +* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, +* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS +* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* +* You acknowledge that this software is not designed or intended for use in the +* design, construction, operation or maintenance of any nuclear facility. +*/ + +package com.jogamp.openal.sound3d; + +import com.jogamp.openal.AL; + +/** + * This class is used to represent sound-producing objects in the Sound3D + * environment. It contains methods for setting the position, direction, pitch, + * gain and other properties along with methods for starting, pausing, rewinding + * and stopping sudio projecting from a source. + * + * @author Athomas Goldberg + */ +public final class Source { + private final AL al; + private final int sourceID; + private Buffer buffer; + + Source(AL al, int sourceID) { + this.al = al; + this.sourceID = sourceID; + } + + /** + * Beginning playing the audio in this source. + */ + public void play() { + al.alSourcePlay(sourceID); + } + + /** + * pauses the audio in this Source. + */ + public void pause() { + al.alSourcePause(sourceID); + } + + /** + * Stops the audio in this Source + */ + public void stop() { + al.alSourceStop(sourceID); + } + + /** + * Rewinds the audio in this source + */ + public void rewind() { + al.alSourceRewind(sourceID); + } + + /** + * Delete this source, freeing its resources. + */ + public void delete() { + al.alDeleteSources(1, new int[] { sourceID }, 0); + } + + /** + * Sets the pitch of the audio on this source. The pitch may be modified + * without altering the playback speed of the audio. + * + * @param pitch the pitch value of this source. + */ + public void setPitch(float pitch) { + al.alSourcef(sourceID, AL.AL_PITCH, pitch); + } + + /** + * Gets the pitch of the audio on this source. The pitch may be modified + * without altering the playback speed of the audio. + * + * @return the pitch value of this source. + */ + public float getPitch() { + float[] result = new float[1]; + al.alGetSourcef(sourceID, AL.AL_PITCH, result, 0); + + return result[0]; + } + + /** + * Sets the gain of the audio on this source. This can be used to contro + * the volume of the source. + * + * @param gain the gain of the audio on this source + */ + public void setGain(float gain) { + al.alSourcef(sourceID, AL.AL_GAIN, gain); + } + + /** + * Gets the gain of the audio on this source. This can be used to contro + * the volume of the source. + * + * @return the gain of the audio on this source + */ + public float getGain() { + float[] result = new float[1]; + al.alGetSourcef(sourceID, AL.AL_GAIN, result, 0); + + return result[0]; + } + + /** + * Sets the max distance where there will no longer be any attenuation of + * the source. + * + * @param maxDistance the max ditance for source attentuation. + */ + public void setMaxDistance(float maxDistance) { + al.alSourcef(sourceID, AL.AL_MAX_DISTANCE, maxDistance); + } + + /** + * Gets the max distance where there will no longer be any attenuation of + * the source. + * + * @return the max ditance for source attentuation. + */ + public float getMaxDistance() { + float[] result = new float[1]; + al.alGetSourcef(sourceID, AL.AL_MAX_DISTANCE, result, 0); + + return result[0]; + } + + /** + * Sets the rolloff rate of the source. The default value is 1.0 + * + * @param rolloffFactor the rolloff rate of the source. + */ + public void setRolloffFactor(float rolloffFactor) { + al.alSourcef(sourceID, AL.AL_ROLLOFF_FACTOR, rolloffFactor); + } + + /** + * Gets the rolloff rate of the source. The default value is 1.0 + * + * @return the rolloff rate of the source. + */ + public float getRolloffFactor() { + float[] result = new float[1]; + al.alGetSourcef(sourceID, AL.AL_ROLLOFF_FACTOR, result, 0); + + return result[0]; + } + + /** + * Sets the distance under which the volume for the source would normally + * drop by half, before being influenced by rolloff factor or max distance. + * + * @param referenceDistance the reference distance for the source. + */ + public void setReferenceDistance(float referenceDistance) { + al.alSourcef(sourceID, AL.AL_REFERENCE_DISTANCE, referenceDistance); + } + + /** + * Gets the distance under which the volume for the source would normally + * drop by half, before being influenced by rolloff factor or max distance. + * + * @return the reference distance for the source. + */ + public float getReferenceDistance() { + float[] result = new float[1]; + al.alGetSourcef(sourceID, AL.AL_REFERENCE_DISTANCE, result, 0); + + return result[0]; + } + + /** + * Sets the minimum gain for this source. + * + * @param minGain the minimum gain for this source. + */ + public void setMinGain(float minGain) { + al.alSourcef(sourceID, AL.AL_MIN_GAIN, minGain); + } + + /** + * Gets the minimum gain for this source. + * + * @return the minimum gain for this source. + */ + public float getMinGain() { + float[] result = new float[1]; + al.alGetSourcef(sourceID, AL.AL_MIN_GAIN, result, 0); + + return result[0]; + } + + /** + * Sets the maximum gain for this source. + * + * @param maxGain the maximum gain for this source + */ + public void setMaxGain(float maxGain) { + al.alSourcef(sourceID, AL.AL_MAX_GAIN, maxGain); + } + + /** + * SGets the maximum gain for this source. + * + * @return the maximum gain for this source + */ + public float getMaxGain() { + float[] result = new float[1]; + al.alGetSourcef(sourceID, AL.AL_MAX_GAIN, result, 0); + + return result[0]; + } + + /** + * Sets the gain when outside the oriented cone. + * + * @param coneOuterGain the gain when outside the oriented cone. + */ + public void setConeOuterGain(float coneOuterGain) { + al.alSourcef(sourceID, AL.AL_CONE_OUTER_GAIN, coneOuterGain); + } + + /** + * Gets the gain when outside the oriented cone. + * + * @return the gain when outside the oriented cone. + */ + public float getConeOuterGain() { + float[] result = new float[1]; + al.alGetSourcef(sourceID, AL.AL_CONE_OUTER_GAIN, result, 0); + + return result[0]; + } + + /** + * Sets the x,y,z position of the source. + * + * @param position a Vec3f object containing the x,y,z position of the + * source. + */ + public void setPosition(Vec3f position) { + al.alSource3f( + sourceID, + AL.AL_POSITION, + position.v1, + position.v2, + position.v3); + } + + /** + * Sets the x,y,z position of the source. + * + * @param x the x position of the source. + * @param y the y position of the source. + * @param z the z position of the source. + */ + public void setPosition(float x, float y, float z) { + al.alSource3f(sourceID, AL.AL_POSITION, x, y, z); + } + + /** + * Gets the x,y,z position of the source. + * + * @return a Vec3f object containing the x,y,z position of the + * source. + */ + public Vec3f getPosition() { + Vec3f result = null; + float[] pos = new float[3]; + al.alGetSourcefv(sourceID, AL.AL_POSITION, pos, 0); + result = new Vec3f(pos[0], pos[1], pos[2]); + + return result; + } + + /** + * Sets the velocity vector of the source. + * + * @param velocity the velocity vector of the source + */ + public void setVelocity(Vec3f velocity) { + al.alSource3f( + sourceID, + AL.AL_VELOCITY, + velocity.v1, + velocity.v2, + velocity.v3); + } + + /** + * Sets the velocity vector of the source. + * + * @param x the x velocity of the source. + * @param y the y velocity of the source. + * @param z the z velocity of the source. + */ + public void setVelocity(float x, float y, float z) { + al.alSource3f(sourceID, AL.AL_VELOCITY, x, y, z); + } + + /** + * Gets the velocity vector of the source. + * + * @return the velocity vector of the source + */ + public Vec3f getVelocity() { + Vec3f result = null; + float[] vel = new float[3]; + al.alGetSourcefv(sourceID, AL.AL_VELOCITY, vel, 0); + result = new Vec3f(vel[0], vel[1], vel[2]); + + return result; + } + + /** + * Sets the direction vector of the source. + * + * @param direction the direction vector of the source. + */ + public void setDirection(Vec3f direction) { + al.alSource3f( + sourceID, + AL.AL_DIRECTION, + direction.v1, + direction.v2, + direction.v3); + } + + /** + * Sets the direction vector of the source. + * + * @param x the x direction of the source. + * @param y the y direction of the source. + * @param z the z direction of the source. + */ + public void setDirection(float x, float y, float z) { + al.alSource3f(sourceID, AL.AL_DIRECTION, x, y, z); + } + + /** + * Gets the direction vector of the source. + * + * @return the direction vector of the source. + */ + public Vec3f getDirection() { + Vec3f result = null; + float[] dir = new float[3]; + al.alGetSourcefv(sourceID, AL.AL_DIRECTION, dir, 0); + result = new Vec3f(dir[0], dir[1], dir[2]); + + return result; + } + + /** + * Determines if the position of the source is relative to the listener. + * The default is false. + * @param isRelative true if the position of the source is relative + * to the listener, false if the position of the source is relative to the + * world. + */ + public void setSourceRelative(boolean isRelative) { + int rel = isRelative ? 1 : 0; + al.alSourcei(sourceID, AL.AL_SOURCE_RELATIVE, rel); + } + + /** + * Determines if the position of the source is relative to the listener. + * The default is false. + * @return true if the position of the source is relative + * to the listener, false if the position of the source is relative to the + * world. + */ + public boolean isSourceRelative() { + int[] result = new int[1]; + al.alGetSourcei(sourceID, AL.AL_SOURCE_RELATIVE, result, 0); + + return result[0] == 1; + } + + /** + * turns looping on or off. + * + * @param isLooping true-looping is on, false-looping is off + */ + public void setLooping(boolean isLooping) { + int loop = isLooping ? 1 : 0; + al.alSourcei(sourceID, AL.AL_LOOPING, loop); + } + + /** + * indicates whether looping is turned on or off. + * + * @return true-looping is on, false-looping is off + */ + public boolean getLooping() { + boolean result = false; + int[] tmp = new int[1]; + al.alGetSourcei(sourceID, AL.AL_LOOPING, tmp, 0); + return tmp[0] == AL.AL_TRUE; + } + + + /** + * Gets the number of buffers currently queued on this source. + * @return the number of buffers currently queued on this source. + */ + public int getBuffersQueued() { + int[] result = new int[1]; + al.alGetSourcei(sourceID, AL.AL_BUFFERS_QUEUED, result, 0); + + return result[0]; + } + + /** + * Gets the number of buffers already processed on this source. + * @return the number of buffers already processed on this source. + */ + public int getBuffersProcessed() { + int[] result = new int[1]; + al.alGetSourcei(sourceID, AL.AL_BUFFERS_PROCESSED, result, 0); + + return result[0]; + } + + /** + * Sets the buffer associated with this source. + * + * @param buffer the buffer associated with this source + */ + public void setBuffer(Buffer buffer) { + al.alSourcei(sourceID, AL.AL_BUFFER, buffer.bufferID); + this.buffer = buffer; + } + + /** + * Gets the buffer associated with this source. + * + * @return the buffer associated with this source + */ + public Buffer getBuffer() { + return buffer; + } + + /** + * Queues one or more buffers on a source. Useful for streaming audio, + * buffers will be played in the order they are queued. + * + * @param buffers a set of initialized (loaded) buffers. + */ + public void queueBuffers(Buffer[] buffers) { + int numBuffers = buffers.length; + int[] arr = new int[numBuffers]; + + for (int i = 0; i < numBuffers; i++) { + arr[i] = buffers[i].bufferID; + } + + al.alSourceQueueBuffers(sourceID, numBuffers, arr, 0); + } + + /** + * Unqueues one or more buffers on a source. + * + * @param buffers a set of previously queued buffers. + */ + public void unqueueBuffers(Buffer[] buffers) { + int numBuffers = buffers.length; + int[] arr = new int[numBuffers]; + + for (int i = 0; i < numBuffers; i++) { + arr[i] = buffers[i].bufferID; + } + + al.alSourceUnqueueBuffers(sourceID, numBuffers, arr, 0); + } +} diff --git a/src/java/com/jogamp/openal/sound3d/Vec3f.java b/src/java/com/jogamp/openal/sound3d/Vec3f.java new file mode 100644 index 0000000..3a5aea2 --- /dev/null +++ b/src/java/com/jogamp/openal/sound3d/Vec3f.java @@ -0,0 +1,63 @@ +/** +* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* -Redistribution of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may +* be used to endorse or promote products derived from this software without +* specific prior written permission. +* +* This software is provided "AS IS," without a warranty of any kind. +* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING +* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS +* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A +* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. +* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT +* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR +* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, +* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS +* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* +* You acknowledge that this software is not designed or intended for use in the +* design, construction, operation or maintenance of any nuclear facility. +*/ + +package com.jogamp.openal.sound3d; + +/** + * A onvenience class representing a 3-element float vector + * + * @author Athomas Goldberg + */ +public final class Vec3f { + /** the first element in the vector */ + public final float v1; + + /** the first element in the vector */ + public final float v2; + + /** the first element in the vector */ + public final float v3; + + /** + * Creates a new Vec3f object. + * + * @param v1 the first element in the vector + * @param v2 the second element in the vector + * @param v3 the third element in the vector + */ + public Vec3f(float v1, float v2, float v3) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + } +} diff --git a/src/java/com/jogamp/openal/util/ALut.java b/src/java/com/jogamp/openal/util/ALut.java new file mode 100644 index 0000000..2db47d0 --- /dev/null +++ b/src/java/com/jogamp/openal/util/ALut.java @@ -0,0 +1,146 @@ +/** +* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* -Redistribution of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may +* be used to endorse or promote products derived from this software without +* specific prior written permission. +* +* This software is provided "AS IS," without a warranty of any kind. +* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING +* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS +* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A +* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. +* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT +* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR +* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, +* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS +* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* +* You acknowledge that this software is not designed or intended for use in the +* design, construction, operation or maintenance of any nuclear facility. +* +* Created on Jun 27, 2003 +*/ + +package com.jogamp.openal.util; + +import java.io.*; +import java.nio.ByteBuffer; + +import javax.sound.sampled.UnsupportedAudioFileException; + +import com.jogamp.openal.*; + +/** + * @author Athomas Goldberg + * + */ +public final class ALut { + + private static ALC alc; + private static ALCdevice device; + private static ALCcontext context; + private static Thread initializingThread; + + private ALut() { } + + /** Initializes the OpenAL Utility Toolkit, creates an OpenAL + context and makes it current on the current thread. The ALut may + only be initialized on one thread at any given time. */ + public static synchronized void alutInit() throws ALException { + if (context != null) { + throw new ALException("Already initialized on thread " + initializingThread.getName()); + } + if (alc == null) { + alc = ALFactory.getALC(); + } + String deviceName = null; + ALCdevice d = alc.alcOpenDevice(deviceName); + if (d == null) { + throw new ALException("Error opening default OpenAL device"); + } + ALCcontext c = alc.alcCreateContext(d, null); + if (c == null) { + alc.alcCloseDevice(d); + throw new ALException("Error creating OpenAL context"); + } + alc.alcMakeContextCurrent(c); + if (alc.alcGetError(d) != 0) { + alc.alcDestroyContext(c); + alc.alcCloseDevice(d); + throw new ALException("Error making OpenAL context current"); + } + // Fully initialized; finish setup + device = d; + context = c; + initializingThread = Thread.currentThread(); + } + + /** Shuts down the OpenAL Utility Toolkit; releases and destroys the + internal OpenAL context and closes the output device. Must be + called from the same thread as alutInit(). Most applications + should not need to call this; only those which wish to toggle + sound on / off at run time by initializing and un-initializing + OpenAL need to call it. */ + public static synchronized void alutExit() throws ALException { + if (context == null) { + throw new ALException("Not initialized"); + } + alc.alcMakeContextCurrent(null); + alc.alcDestroyContext(context); + alc.alcCloseDevice(device); + context = null; + device = null; + initializingThread = null; + } + + public static void alutLoadWAVFile(String fileName, + int[] format, + ByteBuffer[] data, + int[] size, + int[] freq, + int[] loop) throws ALException { + try { + WAVData wd = WAVLoader.loadFromFile(fileName); + format[0] = wd.format; + data[0] = wd.data; + size[0] = wd.size; + freq[0] = wd.freq; + loop[0] = wd.loop ? AL.AL_TRUE : AL.AL_FALSE; + } catch (Exception e) { + throw new ALException(e); + } + } + + public static void alutLoadWAVFile(InputStream stream, + int[] format, + ByteBuffer[] data, + int[] size, + int[] freq, + int[] loop) throws ALException { + try { + if (!(stream instanceof BufferedInputStream)) { + stream = new BufferedInputStream(stream); + } + WAVData wd = WAVLoader.loadFromStream(stream); + format[0] = wd.format; + data[0] = wd.data; + size[0] = wd.size; + freq[0] = wd.freq; + loop[0] = wd.loop ? AL.AL_TRUE : AL.AL_FALSE; + } catch (Exception e) { + throw new ALException(e); + } + } +} diff --git a/src/java/com/jogamp/openal/util/BufferUtils.java b/src/java/com/jogamp/openal/util/BufferUtils.java new file mode 100644 index 0000000..74b0c78 --- /dev/null +++ b/src/java/com/jogamp/openal/util/BufferUtils.java @@ -0,0 +1,266 @@ +/* + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution 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 Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + * Sun gratefully acknowledges that this software was originally authored + * and developed by Kenneth Bradley Russell and Christopher John Kline. + */ + +package com.jogamp.openal.util; + +import java.nio.*; +import java.util.*; + +/** Utility routines for dealing with direct buffers. */ + +public class BufferUtils { + public static final int SIZEOF_BYTE = 1; + public static final int SIZEOF_SHORT = 2; + public static final int SIZEOF_INT = 4; + public static final int SIZEOF_FLOAT = 4; + public static final int SIZEOF_LONG = 8; + public static final int SIZEOF_DOUBLE = 8; + + //---------------------------------------------------------------------- + // Allocation routines + // + + /** Allocates a new direct ByteBuffer with the specified number of + elements. The returned buffer will have its byte order set to + the host platform's native byte order. */ + public static ByteBuffer newByteBuffer(int numElements) { + ByteBuffer bb = ByteBuffer.allocateDirect(numElements); + bb.order(ByteOrder.nativeOrder()); + return bb; + } + + /** Allocates a new direct DoubleBuffer with the specified number of + elements. The returned buffer will have its byte order set to + the host platform's native byte order. */ + public static DoubleBuffer newDoubleBuffer(int numElements) { + ByteBuffer bb = newByteBuffer(numElements * SIZEOF_DOUBLE); + return bb.asDoubleBuffer(); + } + + /** Allocates a new direct FloatBuffer with the specified number of + elements. The returned buffer will have its byte order set to + the host platform's native byte order. */ + public static FloatBuffer newFloatBuffer(int numElements) { + ByteBuffer bb = newByteBuffer(numElements * SIZEOF_FLOAT); + return bb.asFloatBuffer(); + } + + /** Allocates a new direct IntBuffer with the specified number of + elements. The returned buffer will have its byte order set to + the host platform's native byte order. */ + public static IntBuffer newIntBuffer(int numElements) { + ByteBuffer bb = newByteBuffer(numElements * SIZEOF_INT); + return bb.asIntBuffer(); + } + + /** Allocates a new direct LongBuffer with the specified number of + elements. The returned buffer will have its byte order set to + the host platform's native byte order. */ + public static LongBuffer newLongBuffer(int numElements) { + ByteBuffer bb = newByteBuffer(numElements * SIZEOF_LONG); + return bb.asLongBuffer(); + } + + /** Allocates a new direct ShortBuffer with the specified number of + elements. The returned buffer will have its byte order set to + the host platform's native byte order. */ + public static ShortBuffer newShortBuffer(int numElements) { + ByteBuffer bb = newByteBuffer(numElements * SIZEOF_SHORT); + return bb.asShortBuffer(); + } + + //---------------------------------------------------------------------- + // Copy routines (type-to-type) + // + + /** Copies the remaining elements (as defined by + limit() - position()) in the passed ByteBuffer into + a newly-allocated direct ByteBuffer. The returned buffer will + have its byte order set to the host platform's native byte + order. The position of the newly-allocated buffer will be zero, + and the position of the passed buffer is unchanged (though its + mark is changed). */ + public static ByteBuffer copyByteBuffer(ByteBuffer orig) { + ByteBuffer dest = newByteBuffer(orig.remaining()); + orig.mark(); + dest.put(orig); + orig.reset(); + dest.rewind(); + return dest; + } + + /** Copies the remaining elements (as defined by + limit() - position()) in the passed DoubleBuffer + into a newly-allocated direct DoubleBuffer. The returned buffer + will have its byte order set to the host platform's native byte + order. The position of the newly-allocated buffer will be zero, + and the position of the passed buffer is unchanged (though its + mark is changed). */ + public static DoubleBuffer copyDoubleBuffer(DoubleBuffer orig) { + return copyDoubleBufferAsByteBuffer(orig).asDoubleBuffer(); + } + + /** Copies the remaining elements (as defined by + limit() - position()) in the passed FloatBuffer + into a newly-allocated direct FloatBuffer. The returned buffer + will have its byte order set to the host platform's native byte + order. The position of the newly-allocated buffer will be zero, + and the position of the passed buffer is unchanged (though its + mark is changed). */ + public static FloatBuffer copyFloatBuffer(FloatBuffer orig) { + return copyFloatBufferAsByteBuffer(orig).asFloatBuffer(); + } + + /** Copies the remaining elements (as defined by + limit() - position()) in the passed IntBuffer + into a newly-allocated direct IntBuffer. The returned buffer + will have its byte order set to the host platform's native byte + order. The position of the newly-allocated buffer will be zero, + and the position of the passed buffer is unchanged (though its + mark is changed). */ + public static IntBuffer copyIntBuffer(IntBuffer orig) { + return copyIntBufferAsByteBuffer(orig).asIntBuffer(); + } + + /** Copies the remaining elements (as defined by + limit() - position()) in the passed LongBuffer + into a newly-allocated direct LongBuffer. The returned buffer + will have its byte order set to the host platform's native byte + order. The position of the newly-allocated buffer will be zero, + and the position of the passed buffer is unchanged (though its + mark is changed). */ + public static LongBuffer copyLongBuffer(LongBuffer orig) { + return copyLongBufferAsByteBuffer(orig).asLongBuffer(); + } + + /** Copies the remaining elements (as defined by + limit() - position()) in the passed ShortBuffer + into a newly-allocated direct ShortBuffer. The returned buffer + will have its byte order set to the host platform's native byte + order. The position of the newly-allocated buffer will be zero, + and the position of the passed buffer is unchanged (though its + mark is changed). */ + public static ShortBuffer copyShortBuffer(ShortBuffer orig) { + return copyShortBufferAsByteBuffer(orig).asShortBuffer(); + } + + //---------------------------------------------------------------------- + // Copy routines (type-to-ByteBuffer) + // + + /** Copies the remaining elements (as defined by + limit() - position()) in the passed DoubleBuffer + into a newly-allocated direct ByteBuffer. The returned buffer + will have its byte order set to the host platform's native byte + order. The position of the newly-allocated buffer will be zero, + and the position of the passed buffer is unchanged (though its + mark is changed). */ + public static ByteBuffer copyDoubleBufferAsByteBuffer(DoubleBuffer orig) { + ByteBuffer dest = newByteBuffer(orig.remaining() * SIZEOF_DOUBLE); + orig.mark(); + dest.asDoubleBuffer().put(orig); + orig.reset(); + dest.rewind(); + return dest; + } + + /** Copies the remaining elements (as defined by + limit() - position()) in the passed FloatBuffer + into a newly-allocated direct ByteBuffer. The returned buffer + will have its byte order set to the host platform's native byte + order. The position of the newly-allocated buffer will be zero, + and the position of the passed buffer is unchanged (though its + mark is changed). */ + public static ByteBuffer copyFloatBufferAsByteBuffer(FloatBuffer orig) { + ByteBuffer dest = newByteBuffer(orig.remaining() * SIZEOF_FLOAT); + orig.mark(); + dest.asFloatBuffer().put(orig); + orig.reset(); + dest.rewind(); + return dest; + } + + /** Copies the remaining elements (as defined by + limit() - position()) in the passed IntBuffer into + a newly-allocated direct ByteBuffer. The returned buffer will + have its byte order set to the host platform's native byte + order. The position of the newly-allocated buffer will be zero, + and the position of the passed buffer is unchanged (though its + mark is changed). */ + public static ByteBuffer copyIntBufferAsByteBuffer(IntBuffer orig) { + ByteBuffer dest = newByteBuffer(orig.remaining() * SIZEOF_INT); + orig.mark(); + dest.asIntBuffer().put(orig); + orig.reset(); + dest.rewind(); + return dest; + } + + /** Copies the remaining elements (as defined by + limit() - position()) in the passed LongBuffer into + a newly-allocated direct ByteBuffer. The returned buffer will + have its byte order set to the host platform's native byte + order. The position of the newly-allocated buffer will be zero, + and the position of the passed buffer is unchanged (though its + mark is changed). */ + public static ByteBuffer copyLongBufferAsByteBuffer(LongBuffer orig) { + ByteBuffer dest = newByteBuffer(orig.remaining() * SIZEOF_LONG); + orig.mark(); + dest.asLongBuffer().put(orig); + orig.reset(); + dest.rewind(); + return dest; + } + + /** Copies the remaining elements (as defined by + limit() - position()) in the passed ShortBuffer + into a newly-allocated direct ByteBuffer. The returned buffer + will have its byte order set to the host platform's native byte + order. The position of the newly-allocated buffer will be zero, + and the position of the passed buffer is unchanged (though its + mark is changed). */ + public static ByteBuffer copyShortBufferAsByteBuffer(ShortBuffer orig) { + ByteBuffer dest = newByteBuffer(orig.remaining() * SIZEOF_SHORT); + orig.mark(); + dest.asShortBuffer().put(orig); + orig.reset(); + dest.rewind(); + return dest; + } +} diff --git a/src/java/com/jogamp/openal/util/WAVData.java b/src/java/com/jogamp/openal/util/WAVData.java new file mode 100644 index 0000000..345c675 --- /dev/null +++ b/src/java/com/jogamp/openal/util/WAVData.java @@ -0,0 +1,75 @@ +/** +* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* -Redistribution of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may +* be used to endorse or promote products derived from this software without +* specific prior written permission. +* +* This software is provided "AS IS," without a warranty of any kind. +* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING +* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS +* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A +* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. +* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT +* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR +* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, +* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS +* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* +* You acknowledge that this software is not designed or intended for use in the +* design, construction, operation or maintenance of any nuclear facility. +*/ + +package com.jogamp.openal.util; + +import java.nio.ByteBuffer; + + +/** + * This class is a holder for WAV (.wav )file Data returned from the WavLoader + * + * @author Athomas Goldberg + */ +public final class WAVData { + /** The audio data */ + public final ByteBuffer data; + + /** the format of the Data. One of: + *
+     * AL.AL_FORMAT_MONO8
+     * AL.AL_FORMAT_MONO16
+     * AL.AL_FORMAT_STEREO8
+     * AL.AL_FORMAT_STEREO16
+     * 
+ * + */ + public final int format; + + /** Size (in bytes) of the data */ + public final int size; + + /** The frequency of the data */ + public final int freq; + + /** flag indicating whether or not the sound in the data should loop */ + public final boolean loop; + + WAVData(ByteBuffer data, int format, int size, int freq, boolean loop) { + this.data = data; + this.format = format; + this.size = size; + this.freq = freq; + this.loop = loop; + } +} diff --git a/src/java/com/jogamp/openal/util/WAVLoader.java b/src/java/com/jogamp/openal/util/WAVLoader.java new file mode 100644 index 0000000..4ee2305 --- /dev/null +++ b/src/java/com/jogamp/openal/util/WAVLoader.java @@ -0,0 +1,135 @@ +/** +* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* -Redistribution of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may +* be used to endorse or promote products derived from this software without +* specific prior written permission. +* +* This software is provided "AS IS," without a warranty of any kind. +* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING +* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS +* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A +* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. +* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT +* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR +* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, +* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS +* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* +* You acknowledge that this software is not designed or intended for use in the +* design, construction, operation or maintenance of any nuclear facility. +*/ + +package com.jogamp.openal.util; + +import java.io.*; +import java.nio.*; +import java.nio.channels.*; +import javax.sound.sampled.*; + +import com.jogamp.openal.*; + +/** + * A Loader utility for (.wav) files. Creates a WAVData object containing the + * data used by the AL.alBufferData method. + * + * @author Athomas Goldberg + */ +public class WAVLoader implements ALConstants { + private static final int BUFFER_SIZE = 128000; + + /** + * This method loads a (.wav) file into a WAVData object. + * + * @param filename The name of the (.wav) file + * + * @return a WAVData object containing the audio data + * + * @throws UnsupportedAudioFileException if the format of the audio if not + * supported. + * @throws IOException If the file can no be found or some other IO error + * occurs + */ + public static WAVData loadFromFile(String filename) + throws UnsupportedAudioFileException, IOException { + WAVData result = null; + File soundFile = new File(filename); + AudioInputStream aIn = AudioSystem.getAudioInputStream(soundFile); + return readFromStream(aIn); + } + + /** + * This method loads a (.wav) file into a WAVData object. + * + * @param stream An InputStream for the .WAV file. + * + * @return a WAVData object containing the audio data + * + * @throws UnsupportedAudioFileException if the format of the audio if not + * supported. + * @throws IOException If the file can no be found or some other IO error + * occurs + */ + public static WAVData loadFromStream(InputStream stream) + throws UnsupportedAudioFileException, IOException { + WAVData result = null; + AudioInputStream aIn = AudioSystem.getAudioInputStream(stream); + return readFromStream(aIn); + } + + + private static WAVData readFromStream(AudioInputStream aIn) + throws UnsupportedAudioFileException, IOException { + ReadableByteChannel aChannel = Channels.newChannel(aIn); + AudioFormat fmt = aIn.getFormat(); + int numChannels = fmt.getChannels(); + int bits = fmt.getSampleSizeInBits(); + int format = AL_FORMAT_MONO8; + + if ((bits == 8) && (numChannels == 1)) { + format = AL_FORMAT_MONO8; + } else if ((bits == 16) && (numChannels == 1)) { + format = AL_FORMAT_MONO16; + } else if ((bits == 8) && (numChannels == 2)) { + format = AL_FORMAT_STEREO8; + } else if ((bits == 16) && (numChannels == 2)) { + format = AL_FORMAT_STEREO16; + } + + int freq = Math.round(fmt.getSampleRate()); + int size = aIn.available(); + ByteBuffer buffer = ByteBuffer.allocateDirect(size); + while (buffer.remaining() > 0) { + aChannel.read(buffer); + } + buffer.rewind(); + + // Must byte swap on big endian platforms + // Thanks to swpalmer on javagaming.org forums for hint at fix + if ((bits == 16) && (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN)) { + int len = buffer.remaining(); + for (int i = 0; i < len; i += 2) { + byte a = buffer.get(i); + byte b = buffer.get(i+1); + buffer.put(i, b); + buffer.put(i+1, a); + } + } + + WAVData result = new WAVData(buffer, format, size, freq, false); + aIn.close(); + + return result; + } +} diff --git a/src/java/net/java/games/joal/ALException.java b/src/java/net/java/games/joal/ALException.java deleted file mode 100755 index 75c6944..0000000 --- a/src/java/net/java/games/joal/ALException.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright (c) 2003-2005 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * -Redistribution of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. - * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING - * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR - * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS - * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A - * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. - * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT - * OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR - * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS - * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use in the - * design, construction, operation or maintenance of any nuclear facility. - */ - -package net.java.games.joal; - -/** A generic exception for OpenAL errors used throughout the binding - as a substitute for {@link RuntimeException}. */ - -public class ALException extends RuntimeException { - /** Constructs an ALException object. */ - public ALException() { - super(); - } - - /** Constructs an ALException object with the specified detail - message. */ - public ALException(String message) { - super(message); - } - - /** Constructs an ALException object with the specified detail - message and root cause. */ - public ALException(String message, Throwable cause) { - super(message, cause); - } - - /** Constructs an ALException object with the specified root - cause. */ - public ALException(Throwable cause) { - super(cause); - } -} diff --git a/src/java/net/java/games/joal/ALFactory.java b/src/java/net/java/games/joal/ALFactory.java deleted file mode 100644 index 17a8c09..0000000 --- a/src/java/net/java/games/joal/ALFactory.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Copyright (c) 2003-2005 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * -Redistribution of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. - * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING - * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR - * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS - * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A - * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. - * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT - * OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR - * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS - * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use in the - * design, construction, operation or maintenance of any nuclear facility. - */ - -package net.java.games.joal; - -import net.java.games.joal.impl.*; - -/** - * This class provides factory methods for generating AL and ALC objects. - * - * @author Athomas Goldberg - * @author Kenneth Russell - */ -public class ALFactory { - private static boolean initialized = false; - private static AL al; - private static ALC alc; - - private ALFactory() {} - - private static synchronized void initialize() throws ALException { - try { - if (!initialized) { - NativeLibLoader.load(); - initialized = true; - } - } catch (UnsatisfiedLinkError e) { - throw new ALException(e); - } - } - - /** - * Get the default AL object. This object is used to access most of the - * OpenAL functionality. - * - * @return the AL object - */ - public static AL getAL() throws ALException { - initialize(); - if (al == null) { - al = new ALImpl(); - } - return al; - } - - /** - * Get the default ALC object. This object is used to access most of the - * OpenAL context functionality. - * - * @return the ALC object - */ - public static ALC getALC() throws ALException{ - initialize(); - if (alc == null) { - alc = new ALCImpl(); - } - return alc; - } -} diff --git a/src/java/net/java/games/joal/eax/EAX.java b/src/java/net/java/games/joal/eax/EAX.java deleted file mode 100644 index 68cd191..0000000 --- a/src/java/net/java/games/joal/eax/EAX.java +++ /dev/null @@ -1,140 +0,0 @@ -/** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ - -package net.java.games.joal.eax; - -import java.nio.Buffer; - - -/** - * @author Athomas Goldberg - * - */ -public class EAX implements EAXConstants { - static { - System.loadLibrary("joal_native"); - } - - public static final int SOURCE = 0; - public static final int LISTENER = 1; - - private final int sourceGUID = SOURCE; - private final int listenerGUID = LISTENER; - - /** - * @param sourceGUID - * @param listenerGUID - */ - EAX(int sourceGUID, int listenerGUID) { - // this.sourceGUID = sourceGUID; - // this.listenerGUID = listenerGUID; - } - - /** - * This method sets an EAX property value.
- *
- * Interface to C Language function: - *
ALenum EAXSet(const struct _GUID *propertySetID, ALuint property, ALuint source, ALvoid *value, ALuint size)
- * - * @param objectFlag a flag indicating a LISTENER or a SOURCE - * @param pname the property being set - * @param source the ID of the source, or 0 for Listener properties - * @param value a direct Buffer to hold the value retrieved - * @param size the size of the Buffer - */ - public native void EAXSet( - int objectFlag, - int pname, - int source, - Buffer value, - int size - ); - - /** - * This method retrieves an EAX property value.
- *
- * Interface to C Language function: - *
ALenum EAXGet(const struct _GUID *propertySetID, ALuint property, ALuint source, ALvoid *value, ALuint size)
- * - * @param objectFlag a flag indicating a LISTENER or a SOURCE - * @param pname the property being queried - * @param source the ID of the source, or 0 for Listener properties - * @param value a direct Buffer to hold the value retrieved - * @param size the size of the Buffer - */ - public native void EAXGet( - int objectFlag, - int pname, - int source, - Buffer value, - int size - ); - - /** - * This method sets a source property. - * @param sourceID the ID of the source whose property is being set. - * @param pname the name of the property being set - * @param value a direct Buffer containing the value to be set - */ - public void setSourceProperty(int sourceID, int pname, Buffer value) { - EAXSet(sourceGUID, pname, sourceID, value, value.capacity()); - } - - /** - * This method retrieves a source property. - * @param sourceID the ID of the source whose property is being retrieved. - * @param pname the name of the property being retrieved - * @param value a direct Buffer to hold the value to be retrieved - */ - public void getSourceProperty(int pname, int sourceID, Buffer value) { - EAXGet(sourceGUID, pname, sourceID, value, value.capacity()); - } - - /** - * This method sets a Listener property. - * @param pname the name of the property being set - * @param value a direct Buffer containing the value to be set - */ - public void setListenerProperty(int pname, Buffer value) { - EAXSet(listenerGUID, pname, 0, value, value.capacity()); - } - - /** - * This method retrieves a Listener property. - * @param pname the name of the property being retrieved - * @param value a direct Buffer to hold the value to be retrieved - */ - public void getListenerProperty(int pname, Buffer value) { - EAXGet(listenerGUID, pname, 0, value, value.capacity()); - } -} diff --git a/src/java/net/java/games/joal/eax/EAXConstants.java b/src/java/net/java/games/joal/eax/EAXConstants.java deleted file mode 100644 index 44f1bee..0000000 --- a/src/java/net/java/games/joal/eax/EAXConstants.java +++ /dev/null @@ -1,350 +0,0 @@ -/** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ - -package net.java.games.joal.eax; -/** - * - * This class implements the basic EAX extension constants. - * - * @author Athomas Goldberg - */ -public interface EAXConstants { - - public final static int DSPROPERTY_EAXLISTENER_NONE = 0; - public final static int DSPROPERTY_EAXLISTENER_ALLPARAMETERS = 1; - public final static int DSPROPERTY_EAXLISTENER_ROOM = 2; - public final static int DSPROPERTY_EAXLISTENER_ROOMHF = 3; - public final static int DSPROPERTY_EAXLISTENER_ROOMROLLOFFFACTOR = 4; - public final static int DSPROPERTY_EAXLISTENER_DECAYTIME = 5; - public final static int DSPROPERTY_EAXLISTENER_DECAYHFRATIO = 6; - public final static int DSPROPERTY_EAXLISTENER_REFLECTIONS = 7; - public final static int DSPROPERTY_EAXLISTENER_REFLECTIONSDELAY = 8; - public final static int DSPROPERTY_EAXLISTENER_REVERB = 9; - public final static int DSPROPERTY_EAXLISTENER_REVERBDELAY = 10; - public final static int DSPROPERTY_EAXLISTENER_ENVIRONMENT = 11; - public final static int DSPROPERTY_EAXLISTENER_ENVIRONMENTSIZE = 12; - public final static int DSPROPERTY_EAXLISTENER_ENVIRONMENTDIFFUSION = 13; - public final static int DSPROPERTY_EAXLISTENER_AIRABSORPTIONHF = 14; - public final static int DSPROPERTY_EAXLISTENER_FLAGS = 15; - -// OR these flags with property id // - /** 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; - - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_GENERIC = 0; - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_PADDEDCELL = 1; - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_ROOM = 2; - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_BATHROOM = 3; - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_LIVINGROOM = 4; - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_STONEROOM = 5; - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_AUDITORIUM = 6; - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_CONCERTHALL = 7; - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_CAVE = 8; - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_ARENA = 9; - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_HANGAR = 10; - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_CARPETEDHALLWAY = 11; - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_HALLWAY = 12; - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_STONECORRIDOR = 13; - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_ALLEY = 14; - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_FOREST = 15; - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_CITY = 16; - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_MOUNTAINS = 17; - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_QUARRY = 18; - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_PLAIN = 19; - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_PARKINGLOT = 20; - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_SEWERPIPE = 21; - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_UNDERWATER = 22; - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_DRUGGED = 23; - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_DIZZY = 24; - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_PSYCHOTIC = 25; - /** used by DSPROPERTY_EAXLISTENER_ENVIRONMENT */ - public final static int EAX_ENVIRONMENT_COUNT = 26; - -// These flags determine what properties are affected by environment size. - /** reverberation decay time */ - public final static int EAXLISTENERFLAGS_DECAYTIMESCALE = 0x00000001; - /** reflection level */ - public final static int EAXLISTENERFLAGS_REFLECTIONSSCALE = 0x00000002; - /** initial reflection delay time */ - public final static int EAXLISTENERFLAGS_REFLECTIONSDELAYSCALE = 0x00000004; - /** reflections level */ - public final static int EAXLISTENERFLAGS_REVERBSCALE = 0x00000008; - /** late reverberation delay time */ - public final static int EAXLISTENERFLAGS_REVERBDELAYSCALE = 0x00000010; - - /** This flag limits high-frequency decay time according to air absorption.*/ - public final static int EAXLISTENERFLAGS_DECAYHFLIMIT = 0x00000020; - /** reserved future use */ - public final static int EAXLISTENERFLAGS_RESERVED = 0xFFFFFFC0; - -// property ranges and defaults: - - public final static int EAXLISTENER_MINROOM = -10000; - public final static int EAXLISTENER_MAXROOM = 0; - public final static int EAXLISTENER_DEFAULTROOM = -1000; - - public final static int EAXLISTENER_MINROOMHF = -10000; - public final static int EAXLISTENER_MAXROOMHF = 0; - public final static int EAXLISTENER_DEFAULTROOMHF = -100; - - public final static float EAXLISTENER_MINROOMROLLOFFFACTOR = 0.0f; - public final static float EAXLISTENER_MAXROOMROLLOFFFACTOR = 10.0f; - public final static float EAXLISTENER_DEFAULTROOMROLLOFFFACTOR = 0.0f; - - public final static float EAXLISTENER_MINDECAYTIME = 0.1f; - public final static float EAXLISTENER_MAXDECAYTIME = 20.0f; - public final static float EAXLISTENER_DEFAULTDECAYTIME = 1.49f; - - public final static float EAXLISTENER_MINDECAYHFRATIO = 0.1f; - public final static float EAXLISTENER_MAXDECAYHFRATIO = 2.0f; - public final static float EAXLISTENER_DEFAULTDECAYHFRATIO = 0.83f; - - public final static int EAXLISTENER_MINREFLECTIONS = -10000; - public final static int EAXLISTENER_MAXREFLECTIONS = 1000; - public final static int EAXLISTENER_DEFAULTREFLECTIONS = -2602; - - public final static float EAXLISTENER_MINREFLECTIONSDELAY = 0.0f; - public final static float EAXLISTENER_MAXREFLECTIONSDELAY = 0.3f; - public final static float EAXLISTENER_DEFAULTREFLECTIONSDELAY = 0.007f; - - public final static int EAXLISTENER_MINREVERB = -10000; - public final static int EAXLISTENER_MAXREVERB = 2000; - public final static int EAXLISTENER_DEFAULTREVERB = 200; - - public final static float EAXLISTENER_MINREVERBDELAY = 0.0f; - public final static float EAXLISTENER_MAXREVERBDELAY = 0.1f; - public final static float EAXLISTENER_DEFAULTREVERBDELAY = 0.011f; - - public final static int EAXLISTENER_MINENVIRONMENT = 0; - public final static int EAXLISTENER_MAXENVIRONMENT = EAX_ENVIRONMENT_COUNT-1; - public final static int EAXLISTENER_DEFAULTENVIRONMENT = EAX_ENVIRONMENT_GENERIC; - - public final static float EAXLISTENER_MINENVIRONMENTSIZE = 1.0f; - public final static float EAXLISTENER_MAXENVIRONMENTSIZE = 100.0f; - public final static float EAXLISTENER_DEFAULTENVIRONMENTSIZE = 7.5f; - - public final static float EAXLISTENER_MINENVIRONMENTDIFFUSION = 0.0f; - public final static float EAXLISTENER_MAXENVIRONMENTDIFFUSION = 1.0f; - public final static float EAXLISTENER_DEFAULTENVIRONMENTDIFFUSION = 1.0f; - - public final static float EAXLISTENER_MINAIRABSORPTIONHF = -100.0f; - public final static float EAXLISTENER_MAXAIRABSORPTIONHF = 0.0f; - public final static float EAXLISTENER_DEFAULTAIRABSORPTIONHF = -5.0f; - - public final static int EAXLISTENER_DEFAULTFLAGS = - EAXLISTENERFLAGS_DECAYTIMESCALE | - EAXLISTENERFLAGS_REFLECTIONSSCALE | - EAXLISTENERFLAGS_REFLECTIONSDELAYSCALE | - EAXLISTENERFLAGS_REVERBSCALE | - EAXLISTENERFLAGS_REVERBDELAYSCALE | - EAXLISTENERFLAGS_DECAYHFLIMIT; - - public final static int DSPROPERTY_EAXBUFFER_NONE = 0; - public final static int DSPROPERTY_EAXBUFFER_ALLPARAMETERS = 1; - public final static int DSPROPERTY_EAXBUFFER_DIRECT = 2; - public final static int DSPROPERTY_EAXBUFFER_DIRECTHF = 3; - public final static int DSPROPERTY_EAXBUFFER_ROOM = 4; - public final static int DSPROPERTY_EAXBUFFER_ROOMHF = 5; - public final static int DSPROPERTY_EAXBUFFER_ROOMROLLOFFFACTOR = 6; - public final static int DSPROPERTY_EAXBUFFER_OBSTRUCTION = 7; - public final static int DSPROPERTY_EAXBUFFER_OBSTRUCTIONLFRATIO = 8; - public final static int DSPROPERTY_EAXBUFFER_OCCLUSION = 9; - public final static int DSPROPERTY_EAXBUFFER_OCCLUSIONLFRATIO = 10; - public final static int DSPROPERTY_EAXBUFFER_OCCLUSIONROOMRATIO = 11; - public final static int DSPROPERTY_EAXBUFFER_OUTSIDEVOLUMEHF = 13; - public final static int DSPROPERTY_EAXBUFFER_AIRABSORPTIONFACTOR = 14; - public final static int DSPROPERTY_EAXBUFFER_FLAGS = 15; - -// OR these flags with property id - /** changes take effect immediately */ - public final static int DSPROPERTY_EAXBUFFER_IMMEDIATE = 0x00000000; - /** changes take effect later */ - public final static int DSPROPERTY_EAXBUFFER_DEFERRED = 0x80000000; - public final static int DSPROPERTY_EAXBUFFER_COMMITDEFERREDSETTINGS = - DSPROPERTY_EAXBUFFER_NONE | - DSPROPERTY_EAXBUFFER_IMMEDIATE; - - -// Used by DSPROPERTY_EAXBUFFER_FLAGS -// TRUE: value is computed automatically - property is an offset -// FALSE: value is used directly -// -// Note: The number and order of flags may change in future EAX versions. -// To insure future compatibility, use flag defines as follows: -// myFlags = EAXBUFFERFLAGS_DIRECTHFAUTO | EAXBUFFERFLAGS_ROOMAUTO; -// instead of: -// myFlags = 0x00000003; -// - /** affects DSPROPERTY_EAXBUFFER_DIRECTHF */ - public final static int EAXBUFFERFLAGS_DIRECTHFAUTO = 0x00000001; - /** affects DSPROPERTY_EAXBUFFER_ROOM */ - public final static int EAXBUFFERFLAGS_ROOMAUTO = 0x00000002; - /** affects DSPROPERTY_EAXBUFFER_ROOMHF */ - public final static int EAXBUFFERFLAGS_ROOMHFAUTO = 0x00000004; - /** reserved future use */ - public final static int EAXBUFFERFLAGS_RESERVED = 0xFFFFFFF8; - -// property ranges and defaults: - - public final static int EAXBUFFER_MINDIRECT = (-10000); - public final static int EAXBUFFER_MAXDIRECT = 1000; - public final static int EAXBUFFER_DEFAULTDIRECT = 0; - - public final static int EAXBUFFER_MINDIRECTHF = (-10000); - public final static int EAXBUFFER_MAXDIRECTHF = 0; - public final static int EAXBUFFER_DEFAULTDIRECTHF = 0; - - public final static int EAXBUFFER_MINROOM = (-10000); - public final static int EAXBUFFER_MAXROOM = 1000; - public final static int EAXBUFFER_DEFAULTROOM = 0; - - public final static int EAXBUFFER_MINROOMHF = (-10000); - public final static int EAXBUFFER_MAXROOMHF = 0; - public final static int EAXBUFFER_DEFAULTROOMHF = 0; - - public final static float EAXBUFFER_MINROOMROLLOFFFACTOR = 0.0f; - public final static float EAXBUFFER_MAXROOMROLLOFFFACTOR = 10.f; - public final static float EAXBUFFER_DEFAULTROOMROLLOFFFACTOR = 0.0f; - - public final static int EAXBUFFER_MINOBSTRUCTION = (-10000); - public final static int EAXBUFFER_MAXOBSTRUCTION = 0; - public final static int EAXBUFFER_DEFAULTOBSTRUCTION = 0; - - public final static float EAXBUFFER_MINOBSTRUCTIONLFRATIO = 0.0f; - public final static float EAXBUFFER_MAXOBSTRUCTIONLFRATIO = 1.0f; - public final static float EAXBUFFER_DEFAULTOBSTRUCTIONLFRATIO = 0.0f; - - public final static int EAXBUFFER_MINOCCLUSION = (-10000); - public final static int EAXBUFFER_MAXOCCLUSION = 0; - public final static int EAXBUFFER_DEFAULTOCCLUSION = 0; - - public final static float EAXBUFFER_MINOCCLUSIONLFRATIO = 0.0f; - public final static float EAXBUFFER_MAXOCCLUSIONLFRATIO = 1.0f; - public final static float EAXBUFFER_DEFAULTOCCLUSIONLFRATIO = 0.25f; - - public final static float EAXBUFFER_MINOCCLUSIONROOMRATIO = 0.0f; - public final static float EAXBUFFER_MAXOCCLUSIONROOMRATIO = 10.0f; - public final static float EAXBUFFER_DEFAULTOCCLUSIONROOMRATIO = 0.5f; - - public final static int EAXBUFFER_MINOUTSIDEVOLUMEHF = (-10000); - public final static int EAXBUFFER_MAXOUTSIDEVOLUMEHF = 0; - public final static int EAXBUFFER_DEFAULTOUTSIDEVOLUMEHF = 0; - - public final static float EAXBUFFER_MINAIRABSORPTIONFACTOR = 0.0f; - public final static float EAXBUFFER_MAXAIRABSORPTIONFACTOR = 10.0f; - public final static float EAXBUFFER_DEFAULTAIRABSORPTIONFACTOR = 1.0f; - - public final static int EAXBUFFER_DEFAULTFLAGS = - EAXBUFFERFLAGS_DIRECTHFAUTO | - EAXBUFFERFLAGS_ROOMAUTO | - EAXBUFFERFLAGS_ROOMHFAUTO; - -// Material transmission presets -// 3 values in this order: -// 1: occlusion (or obstruction) -// 2: occlusion LF Ratio (or obstruction LF Ratio) -// 3: occlusion Room Ratio - -// Single window material preset - public final static int EAX_MATERIAL_SINGLEWINDOW = (-2800); - public final static float EAX_MATERIAL_SINGLEWINDOWLF = 0.71f; - public final static float EAX_MATERIAL_SINGLEWINDOWROOMRATIO = 0.43f; - -// Double window material preset - public final static int EAX_MATERIAL_DOUBLEWINDOW = (-5000); - public final static float EAX_MATERIAL_DOUBLEWINDOWHF = 0.40f; - public final static float EAX_MATERIAL_DOUBLEWINDOWROOMRATIO = 0.24f; - -// Thin door material preset - public final static int EAX_MATERIAL_THINDOOR = (-1800); - public final static float EAX_MATERIAL_THINDOORLF = 0.66f; - public final static float EAX_MATERIAL_THINDOORROOMRATIO = 0.66f; - -// Thick door material preset - public final static int EAX_MATERIAL_THICKDOOR = (-4400); - public final static float EAX_MATERIAL_THICKDOORLF = 0.64f; - public final static float EAX_MATERIAL_THICKDOORROOMRTATION = 0.27f; - -// Wood wall material preset - public final static int EAX_MATERIAL_WOODWALL = (-4000); - public final static float EAX_MATERIAL_WOODWALLLF = 0.50f; - public final static float EAX_MATERIAL_WOODWALLROOMRATIO = 0.30f; - -// Brick wall material preset - public final static int EAX_MATERIAL_BRICKWALL = (-5000); - public final static float EAX_MATERIAL_BRICKWALLLF = 0.60f; - public final static float EAX_MATERIAL_BRICKWALLROOMRATIO = 0.24f; - -// Stone wall material preset - public final static int EAX_MATERIAL_STONEWALL = (-6000); - public final static float EAX_MATERIAL_STONEWALLLF = 0.68f; - public final static float EAX_MATERIAL_STONEWALLROOMRATIO = 0.20f; - -// Curtain material preset - public final static int EAX_MATERIAL_CURTAIN = (-1200); - public final static float EAX_MATERIAL_CURTAINLF = 0.15f; - public final static float EAX_MATERIAL_CURTAINROOMRATIO = 1.00f; -} \ No newline at end of file diff --git a/src/java/net/java/games/joal/eax/EAXFactory.java b/src/java/net/java/games/joal/eax/EAXFactory.java deleted file mode 100644 index 0c47a2a..0000000 --- a/src/java/net/java/games/joal/eax/EAXFactory.java +++ /dev/null @@ -1,54 +0,0 @@ -/** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ - -package net.java.games.joal.eax; - -/** - * @author Athomas Goldberg - * - */ -public final class EAXFactory { - private static int SOURCE_GUID; - private static int LISTENER_GUID; - - private static EAX eax; - - private static native void init(); - public static EAX getEAX() { - if(eax == null) { - init(); - eax = new EAX(SOURCE_GUID, LISTENER_GUID); - } - return eax; - } -} diff --git a/src/java/net/java/games/joal/impl/ALProcAddressLookup.java b/src/java/net/java/games/joal/impl/ALProcAddressLookup.java deleted file mode 100755 index e2a6425..0000000 --- a/src/java/net/java/games/joal/impl/ALProcAddressLookup.java +++ /dev/null @@ -1,159 +0,0 @@ -/** - * Copyright (c) 2003-2005 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * -Redistribution of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. - * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING - * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR - * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS - * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A - * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. - * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT - * OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR - * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS - * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use in the - * design, construction, operation or maintenance of any nuclear facility. - */ - -package net.java.games.joal.impl; - -import java.lang.reflect.Field; - -import net.java.games.joal.*; -import com.jogamp.gluegen.runtime.*; - -/** Helper class for managing OpenAL-related proc address tables. */ - -public class ALProcAddressLookup { - private static final ALProcAddressTable alTable = new ALProcAddressTable(); - private static volatile boolean alTableInitialized = false; - private static final ALCProcAddressTable alcTable = new ALCProcAddressTable(); - private static volatile boolean alcTableInitialized = false; - private static final DynamicLookup lookup = new DynamicLookup(); - private static volatile NativeLibrary openAL = null; - - static class DynamicLookup implements DynamicLookupHelper { - public long dynamicLookupFunction(String functionName) { - // At some point this may require an OpenAL context to be - // current as we will actually use alGetProcAddress. Since - // this routine is currently broken and there are no - // per-context function pointers anyway we could actually do - // this work anywhere. - if (openAL == null) { - // We choose not to search the system path first because we - // bundle a very recent version of OpenAL which we would like - // to override existing installations - openAL = NativeLibrary.open("OpenAL32", "openal", "OpenAL", - false, - ALProcAddressLookup.class.getClassLoader()); - if (openAL == null) { - throw new RuntimeException("Unable to find and load OpenAL library"); - } - } - return openAL.dynamicLookupFunction(functionName); - } - } - - public static void resetALProcAddressTable() { - if (!alTableInitialized) { - synchronized (ALProcAddressLookup.class) { - if (!alTableInitialized) { - // At some point this may require an OpenAL context to be - // current as we will actually use alGetProcAddress. Since - // this routine is currently broken and there are no - // per-context function pointers anyway we could actually do - // this work anywhere. We should also in theory have - // per-ALcontext ALProcAddressTables and per-ALCdevice - // ALCProcAddressTables. - ProcAddressHelper.resetProcAddressTable(alTable, lookup); - - // The above only manages to find addresses for the core OpenAL - // functions. The below uses alGetProcAddress() to find the addresses - // of extensions such as EFX, just as in the C++ examples of the - // OpenAL 1.1 SDK. - useALGetProcAddress(); - - alTableInitialized = true; - } - } - } - } - - public static void resetALCProcAddressTable() { - if (!alcTableInitialized) { - synchronized (ALProcAddressLookup.class) { - if (!alcTableInitialized) { - // At some point this may require an OpenAL device to be - // created as we will actually use alcGetProcAddress. Since - // this routine is currently broken and there are no - // per-device function pointers anyway we could actually do - // this work anywhere. We should also in theory have - // per-ALcontext ALProcAddressTables and per-ALCdevice - // ALCProcAddressTables. - ProcAddressHelper.resetProcAddressTable(alcTable, lookup); - alcTableInitialized = true; - } - } - } - } - - public static ALProcAddressTable getALProcAddressTable() { - return alTable; - } - - public static ALCProcAddressTable getALCProcAddressTable() { - return alcTable; - } - - - /** - * Retrieves the values of the OpenAL functions using alGetProcAddress(). - */ - private static void useALGetProcAddress() { - String addrOfPrefix = "_addressof_"; - ALImpl al = (ALImpl) ALFactory.getAL(); - - Field[] fields = ALProcAddressTable.class.getFields(); - for (int i = 0; i < fields.length; i++) { - Field field = fields[i]; - - // Skip non-address fields - String fieldname = field.getName(); - if (!fieldname.startsWith(addrOfPrefix)) { - continue; - } - try { - String functionname = fieldname.substring(addrOfPrefix.length()); - long fieldval = field.getLong(alTable); - - // Skip fields which have already been valued - if (fieldval != 0) { - continue; - } - - // Get the address - long procAddressVal = al.alGetProcAddress(functionname); - field.setLong(alTable, procAddressVal); - } - catch (Exception ex) { - throw new RuntimeException("Unable to repopulate ALProcAddressTable values", ex); - } - } - } -} diff --git a/src/java/net/java/games/joal/impl/NativeLibLoader.java b/src/java/net/java/games/joal/impl/NativeLibLoader.java deleted file mode 100755 index 4b81794..0000000 --- a/src/java/net/java/games/joal/impl/NativeLibLoader.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution 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 Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use - * in the design, construction, operation or maintenance of any nuclear - * facility. - */ - -package net.java.games.joal.impl; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.security.*; - -import com.jogamp.gluegen.runtime.*; - -public class NativeLibLoader { - private static volatile boolean loadingEnabled = true; - private static volatile boolean didLoading; - - private NativeLibLoader() {} - - public static void disableLoading() { - loadingEnabled = false; - } - - public static void enableLoading() { - loadingEnabled = true; - } - - public static void load() { - if (!didLoading && loadingEnabled) { - synchronized (NativeLibLoader.class) { - if (!didLoading && loadingEnabled) { - didLoading = true; - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - // Workaround for problem in OpenAL32.dll, which is actually - // the "wrapper" DLL which looks for real OpenAL - // implementations like nvopenal.dll and "*oal.dll". - // joal.dll matches this wildcard and a bug in OpenAL32.dll - // causes a call through a null function pointer. - loadLibraryInternal("joal_native"); - - // Workaround for 4845371. - // Make sure the first reference to the JNI GetDirectBufferAddress is done - // from a privileged context so the VM's internal class lookups will succeed. - // FIXME: need to figure out an appropriate entry point to call for JOAL - // JAWT jawt = new JAWT(); - // JAWTFactory.JAWT_GetAWT(jawt); - - return null; - } - }); - } - } - } - } - - private static void loadLibraryInternal(String libraryName) { - String sunAppletLauncher = System.getProperty("sun.jnlp.applet.launcher"); - boolean usingJNLPAppletLauncher = Boolean.valueOf(sunAppletLauncher).booleanValue(); - - if (usingJNLPAppletLauncher) { - try { - Class jnlpAppletLauncherClass = Class.forName("org.jdesktop.applet.util.JNLPAppletLauncher"); - Method jnlpLoadLibraryMethod = jnlpAppletLauncherClass.getDeclaredMethod("loadLibrary", new Class[] { String.class }); - jnlpLoadLibraryMethod.invoke(null, new Object[] { libraryName }); - } catch (Exception e) { - Throwable t = e; - if (t instanceof InvocationTargetException) { - t = ((InvocationTargetException) t).getTargetException(); - } - if (t instanceof Error) - throw (Error) t; - if (t instanceof RuntimeException) { - throw (RuntimeException) t; - } - // Throw UnsatisfiedLinkError for best compatibility with System.loadLibrary() - throw (UnsatisfiedLinkError) new UnsatisfiedLinkError().initCause(e); - } - } else { - System.loadLibrary(libraryName); - } - } -} diff --git a/src/java/net/java/games/joal/util/ALut.java b/src/java/net/java/games/joal/util/ALut.java deleted file mode 100644 index 5d1746f..0000000 --- a/src/java/net/java/games/joal/util/ALut.java +++ /dev/null @@ -1,146 +0,0 @@ -/** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -* -* Created on Jun 27, 2003 -*/ - -package net.java.games.joal.util; - -import java.io.*; -import java.nio.ByteBuffer; - -import javax.sound.sampled.UnsupportedAudioFileException; - -import net.java.games.joal.*; - -/** - * @author Athomas Goldberg - * - */ -public final class ALut { - - private static ALC alc; - private static ALCdevice device; - private static ALCcontext context; - private static Thread initializingThread; - - private ALut() { } - - /** Initializes the OpenAL Utility Toolkit, creates an OpenAL - context and makes it current on the current thread. The ALut may - only be initialized on one thread at any given time. */ - public static synchronized void alutInit() throws ALException { - if (context != null) { - throw new ALException("Already initialized on thread " + initializingThread.getName()); - } - if (alc == null) { - alc = ALFactory.getALC(); - } - String deviceName = null; - ALCdevice d = alc.alcOpenDevice(deviceName); - if (d == null) { - throw new ALException("Error opening default OpenAL device"); - } - ALCcontext c = alc.alcCreateContext(d, null); - if (c == null) { - alc.alcCloseDevice(d); - throw new ALException("Error creating OpenAL context"); - } - alc.alcMakeContextCurrent(c); - if (alc.alcGetError(d) != 0) { - alc.alcDestroyContext(c); - alc.alcCloseDevice(d); - throw new ALException("Error making OpenAL context current"); - } - // Fully initialized; finish setup - device = d; - context = c; - initializingThread = Thread.currentThread(); - } - - /** Shuts down the OpenAL Utility Toolkit; releases and destroys the - internal OpenAL context and closes the output device. Must be - called from the same thread as alutInit(). Most applications - should not need to call this; only those which wish to toggle - sound on / off at run time by initializing and un-initializing - OpenAL need to call it. */ - public static synchronized void alutExit() throws ALException { - if (context == null) { - throw new ALException("Not initialized"); - } - alc.alcMakeContextCurrent(null); - alc.alcDestroyContext(context); - alc.alcCloseDevice(device); - context = null; - device = null; - initializingThread = null; - } - - public static void alutLoadWAVFile(String fileName, - int[] format, - ByteBuffer[] data, - int[] size, - int[] freq, - int[] loop) throws ALException { - try { - WAVData wd = WAVLoader.loadFromFile(fileName); - format[0] = wd.format; - data[0] = wd.data; - size[0] = wd.size; - freq[0] = wd.freq; - loop[0] = wd.loop ? AL.AL_TRUE : AL.AL_FALSE; - } catch (Exception e) { - throw new ALException(e); - } - } - - public static void alutLoadWAVFile(InputStream stream, - int[] format, - ByteBuffer[] data, - int[] size, - int[] freq, - int[] loop) throws ALException { - try { - if (!(stream instanceof BufferedInputStream)) { - stream = new BufferedInputStream(stream); - } - WAVData wd = WAVLoader.loadFromStream(stream); - format[0] = wd.format; - data[0] = wd.data; - size[0] = wd.size; - freq[0] = wd.freq; - loop[0] = wd.loop ? AL.AL_TRUE : AL.AL_FALSE; - } catch (Exception e) { - throw new ALException(e); - } - } -} diff --git a/src/java/net/java/games/joal/util/BufferUtils.java b/src/java/net/java/games/joal/util/BufferUtils.java deleted file mode 100644 index 05de65a..0000000 --- a/src/java/net/java/games/joal/util/BufferUtils.java +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution 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 Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use - * in the design, construction, operation or maintenance of any nuclear - * facility. - * - * Sun gratefully acknowledges that this software was originally authored - * and developed by Kenneth Bradley Russell and Christopher John Kline. - */ - -package net.java.games.joal.util; - -import java.nio.*; -import java.util.*; - -/** Utility routines for dealing with direct buffers. */ - -public class BufferUtils { - public static final int SIZEOF_BYTE = 1; - public static final int SIZEOF_SHORT = 2; - public static final int SIZEOF_INT = 4; - public static final int SIZEOF_FLOAT = 4; - public static final int SIZEOF_LONG = 8; - public static final int SIZEOF_DOUBLE = 8; - - //---------------------------------------------------------------------- - // Allocation routines - // - - /** Allocates a new direct ByteBuffer with the specified number of - elements. The returned buffer will have its byte order set to - the host platform's native byte order. */ - public static ByteBuffer newByteBuffer(int numElements) { - ByteBuffer bb = ByteBuffer.allocateDirect(numElements); - bb.order(ByteOrder.nativeOrder()); - return bb; - } - - /** Allocates a new direct DoubleBuffer with the specified number of - elements. The returned buffer will have its byte order set to - the host platform's native byte order. */ - public static DoubleBuffer newDoubleBuffer(int numElements) { - ByteBuffer bb = newByteBuffer(numElements * SIZEOF_DOUBLE); - return bb.asDoubleBuffer(); - } - - /** Allocates a new direct FloatBuffer with the specified number of - elements. The returned buffer will have its byte order set to - the host platform's native byte order. */ - public static FloatBuffer newFloatBuffer(int numElements) { - ByteBuffer bb = newByteBuffer(numElements * SIZEOF_FLOAT); - return bb.asFloatBuffer(); - } - - /** Allocates a new direct IntBuffer with the specified number of - elements. The returned buffer will have its byte order set to - the host platform's native byte order. */ - public static IntBuffer newIntBuffer(int numElements) { - ByteBuffer bb = newByteBuffer(numElements * SIZEOF_INT); - return bb.asIntBuffer(); - } - - /** Allocates a new direct LongBuffer with the specified number of - elements. The returned buffer will have its byte order set to - the host platform's native byte order. */ - public static LongBuffer newLongBuffer(int numElements) { - ByteBuffer bb = newByteBuffer(numElements * SIZEOF_LONG); - return bb.asLongBuffer(); - } - - /** Allocates a new direct ShortBuffer with the specified number of - elements. The returned buffer will have its byte order set to - the host platform's native byte order. */ - public static ShortBuffer newShortBuffer(int numElements) { - ByteBuffer bb = newByteBuffer(numElements * SIZEOF_SHORT); - return bb.asShortBuffer(); - } - - //---------------------------------------------------------------------- - // Copy routines (type-to-type) - // - - /** Copies the remaining elements (as defined by - limit() - position()) in the passed ByteBuffer into - a newly-allocated direct ByteBuffer. The returned buffer will - have its byte order set to the host platform's native byte - order. The position of the newly-allocated buffer will be zero, - and the position of the passed buffer is unchanged (though its - mark is changed). */ - public static ByteBuffer copyByteBuffer(ByteBuffer orig) { - ByteBuffer dest = newByteBuffer(orig.remaining()); - orig.mark(); - dest.put(orig); - orig.reset(); - dest.rewind(); - return dest; - } - - /** Copies the remaining elements (as defined by - limit() - position()) in the passed DoubleBuffer - into a newly-allocated direct DoubleBuffer. The returned buffer - will have its byte order set to the host platform's native byte - order. The position of the newly-allocated buffer will be zero, - and the position of the passed buffer is unchanged (though its - mark is changed). */ - public static DoubleBuffer copyDoubleBuffer(DoubleBuffer orig) { - return copyDoubleBufferAsByteBuffer(orig).asDoubleBuffer(); - } - - /** Copies the remaining elements (as defined by - limit() - position()) in the passed FloatBuffer - into a newly-allocated direct FloatBuffer. The returned buffer - will have its byte order set to the host platform's native byte - order. The position of the newly-allocated buffer will be zero, - and the position of the passed buffer is unchanged (though its - mark is changed). */ - public static FloatBuffer copyFloatBuffer(FloatBuffer orig) { - return copyFloatBufferAsByteBuffer(orig).asFloatBuffer(); - } - - /** Copies the remaining elements (as defined by - limit() - position()) in the passed IntBuffer - into a newly-allocated direct IntBuffer. The returned buffer - will have its byte order set to the host platform's native byte - order. The position of the newly-allocated buffer will be zero, - and the position of the passed buffer is unchanged (though its - mark is changed). */ - public static IntBuffer copyIntBuffer(IntBuffer orig) { - return copyIntBufferAsByteBuffer(orig).asIntBuffer(); - } - - /** Copies the remaining elements (as defined by - limit() - position()) in the passed LongBuffer - into a newly-allocated direct LongBuffer. The returned buffer - will have its byte order set to the host platform's native byte - order. The position of the newly-allocated buffer will be zero, - and the position of the passed buffer is unchanged (though its - mark is changed). */ - public static LongBuffer copyLongBuffer(LongBuffer orig) { - return copyLongBufferAsByteBuffer(orig).asLongBuffer(); - } - - /** Copies the remaining elements (as defined by - limit() - position()) in the passed ShortBuffer - into a newly-allocated direct ShortBuffer. The returned buffer - will have its byte order set to the host platform's native byte - order. The position of the newly-allocated buffer will be zero, - and the position of the passed buffer is unchanged (though its - mark is changed). */ - public static ShortBuffer copyShortBuffer(ShortBuffer orig) { - return copyShortBufferAsByteBuffer(orig).asShortBuffer(); - } - - //---------------------------------------------------------------------- - // Copy routines (type-to-ByteBuffer) - // - - /** Copies the remaining elements (as defined by - limit() - position()) in the passed DoubleBuffer - into a newly-allocated direct ByteBuffer. The returned buffer - will have its byte order set to the host platform's native byte - order. The position of the newly-allocated buffer will be zero, - and the position of the passed buffer is unchanged (though its - mark is changed). */ - public static ByteBuffer copyDoubleBufferAsByteBuffer(DoubleBuffer orig) { - ByteBuffer dest = newByteBuffer(orig.remaining() * SIZEOF_DOUBLE); - orig.mark(); - dest.asDoubleBuffer().put(orig); - orig.reset(); - dest.rewind(); - return dest; - } - - /** Copies the remaining elements (as defined by - limit() - position()) in the passed FloatBuffer - into a newly-allocated direct ByteBuffer. The returned buffer - will have its byte order set to the host platform's native byte - order. The position of the newly-allocated buffer will be zero, - and the position of the passed buffer is unchanged (though its - mark is changed). */ - public static ByteBuffer copyFloatBufferAsByteBuffer(FloatBuffer orig) { - ByteBuffer dest = newByteBuffer(orig.remaining() * SIZEOF_FLOAT); - orig.mark(); - dest.asFloatBuffer().put(orig); - orig.reset(); - dest.rewind(); - return dest; - } - - /** Copies the remaining elements (as defined by - limit() - position()) in the passed IntBuffer into - a newly-allocated direct ByteBuffer. The returned buffer will - have its byte order set to the host platform's native byte - order. The position of the newly-allocated buffer will be zero, - and the position of the passed buffer is unchanged (though its - mark is changed). */ - public static ByteBuffer copyIntBufferAsByteBuffer(IntBuffer orig) { - ByteBuffer dest = newByteBuffer(orig.remaining() * SIZEOF_INT); - orig.mark(); - dest.asIntBuffer().put(orig); - orig.reset(); - dest.rewind(); - return dest; - } - - /** Copies the remaining elements (as defined by - limit() - position()) in the passed LongBuffer into - a newly-allocated direct ByteBuffer. The returned buffer will - have its byte order set to the host platform's native byte - order. The position of the newly-allocated buffer will be zero, - and the position of the passed buffer is unchanged (though its - mark is changed). */ - public static ByteBuffer copyLongBufferAsByteBuffer(LongBuffer orig) { - ByteBuffer dest = newByteBuffer(orig.remaining() * SIZEOF_LONG); - orig.mark(); - dest.asLongBuffer().put(orig); - orig.reset(); - dest.rewind(); - return dest; - } - - /** Copies the remaining elements (as defined by - limit() - position()) in the passed ShortBuffer - into a newly-allocated direct ByteBuffer. The returned buffer - will have its byte order set to the host platform's native byte - order. The position of the newly-allocated buffer will be zero, - and the position of the passed buffer is unchanged (though its - mark is changed). */ - public static ByteBuffer copyShortBufferAsByteBuffer(ShortBuffer orig) { - ByteBuffer dest = newByteBuffer(orig.remaining() * SIZEOF_SHORT); - orig.mark(); - dest.asShortBuffer().put(orig); - orig.reset(); - dest.rewind(); - return dest; - } -} diff --git a/src/java/net/java/games/joal/util/WAVData.java b/src/java/net/java/games/joal/util/WAVData.java deleted file mode 100644 index c0584e9..0000000 --- a/src/java/net/java/games/joal/util/WAVData.java +++ /dev/null @@ -1,75 +0,0 @@ -/** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ - -package net.java.games.joal.util; - -import java.nio.ByteBuffer; - - -/** - * This class is a holder for WAV (.wav )file Data returned from the WavLoader - * - * @author Athomas Goldberg - */ -public final class WAVData { - /** The audio data */ - public final ByteBuffer data; - - /** the format of the Data. One of: - *
-     * AL.AL_FORMAT_MONO8
-     * AL.AL_FORMAT_MONO16
-     * AL.AL_FORMAT_STEREO8
-     * AL.AL_FORMAT_STEREO16
-     * 
- * - */ - public final int format; - - /** Size (in bytes) of the data */ - public final int size; - - /** The frequency of the data */ - public final int freq; - - /** flag indicating whether or not the sound in the data should loop */ - public final boolean loop; - - WAVData(ByteBuffer data, int format, int size, int freq, boolean loop) { - this.data = data; - this.format = format; - this.size = size; - this.freq = freq; - this.loop = loop; - } -} diff --git a/src/java/net/java/games/joal/util/WAVLoader.java b/src/java/net/java/games/joal/util/WAVLoader.java deleted file mode 100644 index e7a5257..0000000 --- a/src/java/net/java/games/joal/util/WAVLoader.java +++ /dev/null @@ -1,135 +0,0 @@ -/** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ - -package net.java.games.joal.util; - -import java.io.*; -import java.nio.*; -import java.nio.channels.*; -import javax.sound.sampled.*; - -import net.java.games.joal.*; - -/** - * A Loader utility for (.wav) files. Creates a WAVData object containing the - * data used by the AL.alBufferData method. - * - * @author Athomas Goldberg - */ -public class WAVLoader implements ALConstants { - private static final int BUFFER_SIZE = 128000; - - /** - * This method loads a (.wav) file into a WAVData object. - * - * @param filename The name of the (.wav) file - * - * @return a WAVData object containing the audio data - * - * @throws UnsupportedAudioFileException if the format of the audio if not - * supported. - * @throws IOException If the file can no be found or some other IO error - * occurs - */ - public static WAVData loadFromFile(String filename) - throws UnsupportedAudioFileException, IOException { - WAVData result = null; - File soundFile = new File(filename); - AudioInputStream aIn = AudioSystem.getAudioInputStream(soundFile); - return readFromStream(aIn); - } - - /** - * This method loads a (.wav) file into a WAVData object. - * - * @param stream An InputStream for the .WAV file. - * - * @return a WAVData object containing the audio data - * - * @throws UnsupportedAudioFileException if the format of the audio if not - * supported. - * @throws IOException If the file can no be found or some other IO error - * occurs - */ - public static WAVData loadFromStream(InputStream stream) - throws UnsupportedAudioFileException, IOException { - WAVData result = null; - AudioInputStream aIn = AudioSystem.getAudioInputStream(stream); - return readFromStream(aIn); - } - - - private static WAVData readFromStream(AudioInputStream aIn) - throws UnsupportedAudioFileException, IOException { - ReadableByteChannel aChannel = Channels.newChannel(aIn); - AudioFormat fmt = aIn.getFormat(); - int numChannels = fmt.getChannels(); - int bits = fmt.getSampleSizeInBits(); - int format = AL_FORMAT_MONO8; - - if ((bits == 8) && (numChannels == 1)) { - format = AL_FORMAT_MONO8; - } else if ((bits == 16) && (numChannels == 1)) { - format = AL_FORMAT_MONO16; - } else if ((bits == 8) && (numChannels == 2)) { - format = AL_FORMAT_STEREO8; - } else if ((bits == 16) && (numChannels == 2)) { - format = AL_FORMAT_STEREO16; - } - - int freq = Math.round(fmt.getSampleRate()); - int size = aIn.available(); - ByteBuffer buffer = ByteBuffer.allocateDirect(size); - while (buffer.remaining() > 0) { - aChannel.read(buffer); - } - buffer.rewind(); - - // Must byte swap on big endian platforms - // Thanks to swpalmer on javagaming.org forums for hint at fix - if ((bits == 16) && (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN)) { - int len = buffer.remaining(); - for (int i = 0; i < len; i += 2) { - byte a = buffer.get(i); - byte b = buffer.get(i+1); - buffer.put(i, b); - buffer.put(i+1, a); - } - } - - WAVData result = new WAVData(buffer, format, size, freq, false); - aIn.close(); - - return result; - } -} diff --git a/src/java/net/java/games/sound3d/AudioSystem3D.java b/src/java/net/java/games/sound3d/AudioSystem3D.java deleted file mode 100644 index 91fd45a..0000000 --- a/src/java/net/java/games/sound3d/AudioSystem3D.java +++ /dev/null @@ -1,273 +0,0 @@ -/** - * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * -Redistribution of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. - * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING - * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR - * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS - * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A - * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. - * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT - * OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR - * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS - * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use in the - * design, construction, operation or maintenance of any nuclear facility. - */ - -package net.java.games.sound3d; - -import net.java.games.joal.*; -import net.java.games.joal.util.WAVData; -import net.java.games.joal.util.WAVLoader; - -import java.io.*; - -import javax.sound.sampled.UnsupportedAudioFileException; - - -/** - * The AudioSystem3D class provides a set of methods for creating and - * manipulating a 3D audio environment. - * - * @author Athomas Goldberg - */ -public class AudioSystem3D { - private static AL al; - private static ALC alc; - private static Listener listener; - - /** - * Iniitalize the Sound3D environment. This must be called before - * other methods in the class can be used. - */ - public static void init() throws ALException { - al = ALFactory.getAL(); - alc = ALFactory.getALC(); - } - - /** - * Creates a new Sound3D Context for a specified device. - * - * @param device The device the Context is being created for. - * - * @return The new Sound3D context. - */ - public static Context createContext(Device device) { - Context result = null; - ALCcontext realContext = alc.alcCreateContext(device.realDevice, null); - result = new Context(alc, realContext, device); - return result; - } - - /** - * Makes the specified context the current context. - * - * @param context the context to make current. - */ - public static void makeContextCurrent(Context context) { - ALCcontext realContext = null; - - if (context != null) { - realContext = context.realContext; - } - - alc.alcMakeContextCurrent(realContext); - } - - /** - * Opens the specifified audio device. - * - * @param deviceName The specified device name, On windows this will be - * DirectSound3D. We will be automating device discovery in upcoming versions - * of this class. - * - * @return The device described by the specifed name. - */ - public static Device openDevice(String deviceName) { - Device result = null; - ALCdevice realDevice = alc.alcOpenDevice(deviceName); - result = new Device(alc, realDevice); - - return result; - } - - /** - * Generate an array of Sound3D buffers. - * - * @param numBuffers The number of Sound3D buffers to generate. - * - * @return an array of (initially enpty) Sound3D buffers. - */ - public static Buffer[] generateBuffers(int numBuffers) { - Buffer[] result = new Buffer[numBuffers]; - int[] arr = new int[numBuffers]; - al.alGenBuffers(numBuffers, arr, 0); - - for (int i = 0; i < numBuffers; i++) { - result[i] = new Buffer(al, arr[i]); - } - - return result; - } - - /** - * Loads a Sound3D buffer with the specified audio file. - * - * @param filename the name of the file to load. - * - * @return a new Sound3D buffer containing the audio data from the - * specified file. - * - * @throws IOException If the file cannot be found or some other IO error - * occurs. - * @throws UnsupportedAudioFileException If the format of the audio data is - * not supported - */ - public static Buffer loadBuffer(String filename) - throws IOException, UnsupportedAudioFileException { - Buffer result; - Buffer[] tmp = generateBuffers(1); - result = tmp[0]; - - WAVData wd = WAVLoader.loadFromFile(filename); - result.configure(wd.data, wd.format, wd.freq); - - return result; - } - - /** - * Loads a Sound3D buffer with the specified audio file. - * - * @param stream contains the stream associated with the audio file. - * - * @return a new Sound3D buffer containing the audio data from the - * passed stream. - * - * @throws IOException If the stream cannot be read or some other IO error - * occurs. - * @throws UnsupportedAudioFileException If the format of the audio data is - * not supported - */ - public static Buffer loadBuffer(InputStream stream) - throws IOException, UnsupportedAudioFileException { - Buffer result; - Buffer[] tmp = generateBuffers(1); - result = tmp[0]; - - if (!(stream instanceof BufferedInputStream)) { - stream = new BufferedInputStream(stream); - } - WAVData wd = WAVLoader.loadFromStream(stream); - - result.configure(wd.data, wd.format, wd.freq); - - return result; - } - - /** - * Loads a Sound3D Source with the specified audio file. This is - * functionally equivalent to generateSource(loadBuffer(fileName)); - * - * @param filename the name of the file to load. - * - * @return a new Sound3D Source containing the audio data from the - * specified file. - * - * @throws IOException If the file cannot be found or some other IO error - * occurs. - * @throws UnsupportedAudioFileException If the format of the audio data is - * not supported - */ - public static Source loadSource(String filename) - throws IOException, UnsupportedAudioFileException { - Buffer buffer = loadBuffer(filename); - - return generateSource(buffer); - } - - /** - * Loads a Sound3D Source with the specified audio stream. This is - * functionally equivalent to generateSource(loadBuffer(stream)); - * - * @param stream contains the stream associated with the audio file. - * - * @return a new Sound3D Source containing the audio data from the - * passed stream. - * - * @throws IOException If the file cannot be found or some other IO error - * occurs. - * @throws UnsupportedAudioFileException If the format of the audio data is - * not supported - */ - public static Source loadSource(InputStream stream) - throws IOException, UnsupportedAudioFileException { - Buffer buffer = loadBuffer(stream); - - return generateSource(buffer); - } - - /** - * Generates a set of uninitialized Source3D sources - * - * @param numSources the number of Sound3D sources to generate. - * - * @return an array of uninitialized sources. - */ - public static Source[] generateSources(int numSources) { - Source[] result = new Source[numSources]; - int[] arr = new int[numSources]; - al.alGenSources(numSources, arr, 0); - - for (int i = 0; i < numSources; i++) { - result[i] = new Source(al, arr[i]); - } - - return result; - } - - /** - * Generate a Sound3D source from an initialized Buffer. - * - * @param buff The buffer to generate the source from. - * - * @return the newly generated Source. - */ - public static Source generateSource(Buffer buff) { - Source result = null; - Source[] tmp = generateSources(1); - result = tmp[0]; - result.setBuffer(buff); - - return result; - } - - /** - * Get the listener object associated with this Sound3D environment. - * - * @return The listener object. - */ - public static Listener getListener() { - if (listener == null) { - listener = new Listener(al); - } - - return listener; - } -} diff --git a/src/java/net/java/games/sound3d/Buffer.java b/src/java/net/java/games/sound3d/Buffer.java deleted file mode 100644 index 97f67d2..0000000 --- a/src/java/net/java/games/sound3d/Buffer.java +++ /dev/null @@ -1,144 +0,0 @@ -/** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ - -package net.java.games.sound3d; - -import net.java.games.joal.AL; - -import java.nio.ByteBuffer; - - -/** - * The Sound3D Buffer is a container for audio data used in the Sound3D - * environment. - * - * @author Athomas Goldberg - */ -public class Buffer { - public final static int FORMAT_MONO8 = AL.AL_FORMAT_MONO8; - - public final static int FORMAT_MONO16 = AL.AL_FORMAT_MONO16; - - public final static int FORMAT_STEREO8 = AL.AL_FORMAT_STEREO8; - - public final static int FORMAT_STEREO16 = AL.AL_FORMAT_STEREO16; - final int bufferID; - private ByteBuffer data; - private boolean isConfigured = false; - private final AL al; - - Buffer(AL al, int bufferID) { - this.bufferID = bufferID; - this.al = al; - } - - /** - * Configure the Sound3D buffer - * - * @param data the raw audio data - * @param format the format of the data: FORMAT_MONO8, FORMAT_MONO16, - * FORMAT_STEREO8 and FORMAT_STEREO16 - * @param freq the frequency of the data - */ - public void configure(ByteBuffer data, int format, int freq) { - if (!isConfigured) { - this.data = data; - al.alBufferData(bufferID, format, data, data.capacity(), freq); - } - } - - /** - * Delete this buffer, and free its resources. - */ - public void delete() { - data = null; - al.alDeleteBuffers(1, new int[] { bufferID }, 0); - } - - /** - * Get the bit-depth of the data, (8 or 16) - * - * @return the bit-depth of the data - */ - public int getBitDepth() { - int[] i = new int[1]; - al.alGetBufferi(bufferID, AL.AL_BITS, i, 0); - - return i[0]; - } - - /** - * Get the number of channels of the data (1-Mono, 2-Stereo) - * - * @return the number of audio channels. - */ - public int getNumChannels() { - int[] i = new int[1]; - al.alGetBufferi(bufferID, AL.AL_CHANNELS, i, 0); - - return i[0]; - } - - /** - * Gets the raw data contained in this buffer. - * - * @return the raw buffer data. - */ - public ByteBuffer getData() { - return data; - } - - /** - * Gets the audio frequency of the data contained in this buffer. - * - * @return the frequency of the data - */ - public int getFrequency() { - int[] i = new int[1]; - al.alGetBufferi(bufferID, AL.AL_FREQUENCY, i, 0); - - return i[0]; - } - - /** - * Gets the size (in bytes) of the raw data containe in this buffer. - * - * @return the size of the data. - */ - public int getSize() { - int[] i = new int[1]; - al.alGetBufferi(bufferID, AL.AL_SIZE, i, 0); - - return i[0]; - } -} diff --git a/src/java/net/java/games/sound3d/Context.java b/src/java/net/java/games/sound3d/Context.java deleted file mode 100644 index 49344cd..0000000 --- a/src/java/net/java/games/sound3d/Context.java +++ /dev/null @@ -1,77 +0,0 @@ -/** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ - -package net.java.games.sound3d; - -import net.java.games.joal.*; - - -/** - * This class provides a Sound3D Context associated with a specified device. - * - * @author Athomas Goldberg - */ -public class Context { - private final ALC alc; - final ALCcontext realContext; - final Device device; - - Context(ALC alc, ALCcontext realContext, Device device) { - this.alc = alc; - this.realContext = realContext; - this.device = device; - } - - /** - * Suspend this context - */ - public void suspend() { - alc.alcSuspendContext(realContext); - } - - /** - * destroys this context freeing its resources. - */ - public void destroy() { - alc.alcDestroyContext(realContext); - } - - /** - * Gets the device associated with this context. - * - * @return the device associated with this context. - */ - public Device getDevice() { - return device; - } -} diff --git a/src/java/net/java/games/sound3d/Device.java b/src/java/net/java/games/sound3d/Device.java deleted file mode 100644 index 96c352b..0000000 --- a/src/java/net/java/games/sound3d/Device.java +++ /dev/null @@ -1,59 +0,0 @@ -/** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ - -package net.java.games.sound3d; - -import net.java.games.joal.*; - - -/** - * This class provides a handle to a specific audio device. - * - * @author Athomas Goldberg - */ -public class Device { - private final ALC alc; - final ALCdevice realDevice; - - Device(ALC alc, ALCdevice realDevice) { - this.alc = alc; - this.realDevice = realDevice; - } - - /** - * closes the device, freeing its resources. - */ - public void close() { - alc.alcCloseDevice(realDevice); - } -} diff --git a/src/java/net/java/games/sound3d/Listener.java b/src/java/net/java/games/sound3d/Listener.java deleted file mode 100644 index b25320c..0000000 --- a/src/java/net/java/games/sound3d/Listener.java +++ /dev/null @@ -1,171 +0,0 @@ -/** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ - -package net.java.games.sound3d; - -import net.java.games.joal.AL; - - -/** - * This class represents the human listener in the Sound3D environment. It - * provides methods for controlling the position, orientation as well as other - * properties associated with the listener. - * - * @author Athomas Goldberg - */ -public class Listener { - private final AL al; - - Listener(AL al) { - this.al = al; - } - - /** - * Sets the Gain, or volume of the audio in the environment relative to the - * listener - * - * @param gain the gain, or volume - */ - public void setGain(float gain) { - al.alListenerf(AL.AL_GAIN, gain); - } - - /** - * Gets the value of the gain, or volume of the audio in the environment - * relative to the listener. - * - * @return the gain value. - */ - public float getGain() { - float[] f = new float[1]; - al.alGetListenerf(AL.AL_GAIN, f, 0); - - return f[0]; - } - - /** - * Sets the position in (x-y-z coordinates) of the Listener in the Sound3D - * environment. - * - * @param x The position of the listener along the X-axis in the Sound3D - * environment - * @param y The position of the listener along the Y-axis in the Sound3D - * environment - * @param z The position of the listener along the Z-axis in the Sound3D - * environment - */ - public void setPosition(float x, float y, float z) { - al.alListener3f(AL.AL_POSITION, x, y, z); - } - - /** - * Sets the position in (x-y-z coordinates) of the Listener in the Sound3D - * environment. - * - * @param position a Vec3f object containing the x,y and z coordinates of - * Listener. - */ - public void setPosition(Vec3f position) { - al.alListener3f(AL.AL_POSITION, position.v1, position.v2, position.v3); - } - - /** - * Gets the position in (x-y-z coordinates) of the Listener in the Sound3D - * environment. - * - * @return a Vec3f object containing the x,y and z coordinates of - * Listener. - */ - public Vec3f getPosition() { - Vec3f result = null; - float[] tmp = new float[3]; - al.alGetListenerfv(AL.AL_POSITION, tmp, 0); - result = new Vec3f(tmp[0], tmp[1], tmp[2]); - - return result; - } - - /** - * Sets the velocity in (x-y-z coordinates) of the Listener in the Sound3D - * environment. Used in determining doppler shift. - * - * @param velocity a Vec3f object containing the velicity in - * x,y and z coordinates of Listener. - */ - public void setVelocity(Vec3f velocity) { - al.alListener3f(AL.AL_VELOCITY, velocity.v1, velocity.v2, velocity.v3); - } - - /** - * Gets the velocity in (x-y-z coordinates) of the Listener in the Sound3D - * environment. Used in determining doppler shift. - * - * @return a Vec3f object containing the velicity in - * x,y and z coordinates of Listener. - */ - public Vec3f getVelocity() { - Vec3f result = null; - float[] tmp = new float[3]; - al.alGetListenerfv(AL.AL_VELOCITY, tmp, 0); - result = new Vec3f(tmp[0], tmp[1], tmp[2]); - - return result; - } - - /** - * Sets the orientation of the Listener in the Sound3D environment. - * Orientation is expressed as "up" and "at" vectors. - * - * @param orientation The first 3 elements of the array should contain - * the x,y,z up-vector, the second 3 elements should contain the x,z,z - * look-at vector. - */ - public void setOrientation(float[] orientation) { - al.alListenerfv(AL.AL_ORIENTATION, orientation, 0); - } - - /** - * Gets the orientation of the Listener in the Sound3D environment. - * Orientation is expressed as "up" and "at" vectors. - * - * @return an array containing the orientation of the listener. - * The first 3 elements of the array contain - * the x,y,z up-vector, the second 3 elements contain the x,z,z - * look-at vector. - */ - public float[] getOrientation() { - float[] tmp = new float[6]; - al.alGetListenerfv(AL.AL_ORIENTATION, tmp, 0); - return tmp; - } -} diff --git a/src/java/net/java/games/sound3d/Source.java b/src/java/net/java/games/sound3d/Source.java deleted file mode 100644 index f5655be..0000000 --- a/src/java/net/java/games/sound3d/Source.java +++ /dev/null @@ -1,508 +0,0 @@ -/** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ - -package net.java.games.sound3d; - -import net.java.games.joal.AL; - -/** - * This class is used to represent sound-producing objects in the Sound3D - * environment. It contains methods for setting the position, direction, pitch, - * gain and other properties along with methods for starting, pausing, rewinding - * and stopping sudio projecting from a source. - * - * @author Athomas Goldberg - */ -public final class Source { - private final AL al; - private final int sourceID; - private Buffer buffer; - - Source(AL al, int sourceID) { - this.al = al; - this.sourceID = sourceID; - } - - /** - * Beginning playing the audio in this source. - */ - public void play() { - al.alSourcePlay(sourceID); - } - - /** - * pauses the audio in this Source. - */ - public void pause() { - al.alSourcePause(sourceID); - } - - /** - * Stops the audio in this Source - */ - public void stop() { - al.alSourceStop(sourceID); - } - - /** - * Rewinds the audio in this source - */ - public void rewind() { - al.alSourceRewind(sourceID); - } - - /** - * Delete this source, freeing its resources. - */ - public void delete() { - al.alDeleteSources(1, new int[] { sourceID }, 0); - } - - /** - * Sets the pitch of the audio on this source. The pitch may be modified - * without altering the playback speed of the audio. - * - * @param pitch the pitch value of this source. - */ - public void setPitch(float pitch) { - al.alSourcef(sourceID, AL.AL_PITCH, pitch); - } - - /** - * Gets the pitch of the audio on this source. The pitch may be modified - * without altering the playback speed of the audio. - * - * @return the pitch value of this source. - */ - public float getPitch() { - float[] result = new float[1]; - al.alGetSourcef(sourceID, AL.AL_PITCH, result, 0); - - return result[0]; - } - - /** - * Sets the gain of the audio on this source. This can be used to contro - * the volume of the source. - * - * @param gain the gain of the audio on this source - */ - public void setGain(float gain) { - al.alSourcef(sourceID, AL.AL_GAIN, gain); - } - - /** - * Gets the gain of the audio on this source. This can be used to contro - * the volume of the source. - * - * @return the gain of the audio on this source - */ - public float getGain() { - float[] result = new float[1]; - al.alGetSourcef(sourceID, AL.AL_GAIN, result, 0); - - return result[0]; - } - - /** - * Sets the max distance where there will no longer be any attenuation of - * the source. - * - * @param maxDistance the max ditance for source attentuation. - */ - public void setMaxDistance(float maxDistance) { - al.alSourcef(sourceID, AL.AL_MAX_DISTANCE, maxDistance); - } - - /** - * Gets the max distance where there will no longer be any attenuation of - * the source. - * - * @return the max ditance for source attentuation. - */ - public float getMaxDistance() { - float[] result = new float[1]; - al.alGetSourcef(sourceID, AL.AL_MAX_DISTANCE, result, 0); - - return result[0]; - } - - /** - * Sets the rolloff rate of the source. The default value is 1.0 - * - * @param rolloffFactor the rolloff rate of the source. - */ - public void setRolloffFactor(float rolloffFactor) { - al.alSourcef(sourceID, AL.AL_ROLLOFF_FACTOR, rolloffFactor); - } - - /** - * Gets the rolloff rate of the source. The default value is 1.0 - * - * @return the rolloff rate of the source. - */ - public float getRolloffFactor() { - float[] result = new float[1]; - al.alGetSourcef(sourceID, AL.AL_ROLLOFF_FACTOR, result, 0); - - return result[0]; - } - - /** - * Sets the distance under which the volume for the source would normally - * drop by half, before being influenced by rolloff factor or max distance. - * - * @param referenceDistance the reference distance for the source. - */ - public void setReferenceDistance(float referenceDistance) { - al.alSourcef(sourceID, AL.AL_REFERENCE_DISTANCE, referenceDistance); - } - - /** - * Gets the distance under which the volume for the source would normally - * drop by half, before being influenced by rolloff factor or max distance. - * - * @return the reference distance for the source. - */ - public float getReferenceDistance() { - float[] result = new float[1]; - al.alGetSourcef(sourceID, AL.AL_REFERENCE_DISTANCE, result, 0); - - return result[0]; - } - - /** - * Sets the minimum gain for this source. - * - * @param minGain the minimum gain for this source. - */ - public void setMinGain(float minGain) { - al.alSourcef(sourceID, AL.AL_MIN_GAIN, minGain); - } - - /** - * Gets the minimum gain for this source. - * - * @return the minimum gain for this source. - */ - public float getMinGain() { - float[] result = new float[1]; - al.alGetSourcef(sourceID, AL.AL_MIN_GAIN, result, 0); - - return result[0]; - } - - /** - * Sets the maximum gain for this source. - * - * @param maxGain the maximum gain for this source - */ - public void setMaxGain(float maxGain) { - al.alSourcef(sourceID, AL.AL_MAX_GAIN, maxGain); - } - - /** - * SGets the maximum gain for this source. - * - * @return the maximum gain for this source - */ - public float getMaxGain() { - float[] result = new float[1]; - al.alGetSourcef(sourceID, AL.AL_MAX_GAIN, result, 0); - - return result[0]; - } - - /** - * Sets the gain when outside the oriented cone. - * - * @param coneOuterGain the gain when outside the oriented cone. - */ - public void setConeOuterGain(float coneOuterGain) { - al.alSourcef(sourceID, AL.AL_CONE_OUTER_GAIN, coneOuterGain); - } - - /** - * Gets the gain when outside the oriented cone. - * - * @return the gain when outside the oriented cone. - */ - public float getConeOuterGain() { - float[] result = new float[1]; - al.alGetSourcef(sourceID, AL.AL_CONE_OUTER_GAIN, result, 0); - - return result[0]; - } - - /** - * Sets the x,y,z position of the source. - * - * @param position a Vec3f object containing the x,y,z position of the - * source. - */ - public void setPosition(Vec3f position) { - al.alSource3f( - sourceID, - AL.AL_POSITION, - position.v1, - position.v2, - position.v3); - } - - /** - * Sets the x,y,z position of the source. - * - * @param x the x position of the source. - * @param y the y position of the source. - * @param z the z position of the source. - */ - public void setPosition(float x, float y, float z) { - al.alSource3f(sourceID, AL.AL_POSITION, x, y, z); - } - - /** - * Gets the x,y,z position of the source. - * - * @return a Vec3f object containing the x,y,z position of the - * source. - */ - public Vec3f getPosition() { - Vec3f result = null; - float[] pos = new float[3]; - al.alGetSourcefv(sourceID, AL.AL_POSITION, pos, 0); - result = new Vec3f(pos[0], pos[1], pos[2]); - - return result; - } - - /** - * Sets the velocity vector of the source. - * - * @param velocity the velocity vector of the source - */ - public void setVelocity(Vec3f velocity) { - al.alSource3f( - sourceID, - AL.AL_VELOCITY, - velocity.v1, - velocity.v2, - velocity.v3); - } - - /** - * Sets the velocity vector of the source. - * - * @param x the x velocity of the source. - * @param y the y velocity of the source. - * @param z the z velocity of the source. - */ - public void setVelocity(float x, float y, float z) { - al.alSource3f(sourceID, AL.AL_VELOCITY, x, y, z); - } - - /** - * Gets the velocity vector of the source. - * - * @return the velocity vector of the source - */ - public Vec3f getVelocity() { - Vec3f result = null; - float[] vel = new float[3]; - al.alGetSourcefv(sourceID, AL.AL_VELOCITY, vel, 0); - result = new Vec3f(vel[0], vel[1], vel[2]); - - return result; - } - - /** - * Sets the direction vector of the source. - * - * @param direction the direction vector of the source. - */ - public void setDirection(Vec3f direction) { - al.alSource3f( - sourceID, - AL.AL_DIRECTION, - direction.v1, - direction.v2, - direction.v3); - } - - /** - * Sets the direction vector of the source. - * - * @param x the x direction of the source. - * @param y the y direction of the source. - * @param z the z direction of the source. - */ - public void setDirection(float x, float y, float z) { - al.alSource3f(sourceID, AL.AL_DIRECTION, x, y, z); - } - - /** - * Gets the direction vector of the source. - * - * @return the direction vector of the source. - */ - public Vec3f getDirection() { - Vec3f result = null; - float[] dir = new float[3]; - al.alGetSourcefv(sourceID, AL.AL_DIRECTION, dir, 0); - result = new Vec3f(dir[0], dir[1], dir[2]); - - return result; - } - - /** - * Determines if the position of the source is relative to the listener. - * The default is false. - * @param isRelative true if the position of the source is relative - * to the listener, false if the position of the source is relative to the - * world. - */ - public void setSourceRelative(boolean isRelative) { - int rel = isRelative ? 1 : 0; - al.alSourcei(sourceID, AL.AL_SOURCE_RELATIVE, rel); - } - - /** - * Determines if the position of the source is relative to the listener. - * The default is false. - * @return true if the position of the source is relative - * to the listener, false if the position of the source is relative to the - * world. - */ - public boolean isSourceRelative() { - int[] result = new int[1]; - al.alGetSourcei(sourceID, AL.AL_SOURCE_RELATIVE, result, 0); - - return result[0] == 1; - } - - /** - * turns looping on or off. - * - * @param isLooping true-looping is on, false-looping is off - */ - public void setLooping(boolean isLooping) { - int loop = isLooping ? 1 : 0; - al.alSourcei(sourceID, AL.AL_LOOPING, loop); - } - - /** - * indicates whether looping is turned on or off. - * - * @return true-looping is on, false-looping is off - */ - public boolean getLooping() { - boolean result = false; - int[] tmp = new int[1]; - al.alGetSourcei(sourceID, AL.AL_LOOPING, tmp, 0); - return tmp[0] == AL.AL_TRUE; - } - - - /** - * Gets the number of buffers currently queued on this source. - * @return the number of buffers currently queued on this source. - */ - public int getBuffersQueued() { - int[] result = new int[1]; - al.alGetSourcei(sourceID, AL.AL_BUFFERS_QUEUED, result, 0); - - return result[0]; - } - - /** - * Gets the number of buffers already processed on this source. - * @return the number of buffers already processed on this source. - */ - public int getBuffersProcessed() { - int[] result = new int[1]; - al.alGetSourcei(sourceID, AL.AL_BUFFERS_PROCESSED, result, 0); - - return result[0]; - } - - /** - * Sets the buffer associated with this source. - * - * @param buffer the buffer associated with this source - */ - public void setBuffer(Buffer buffer) { - al.alSourcei(sourceID, AL.AL_BUFFER, buffer.bufferID); - this.buffer = buffer; - } - - /** - * Gets the buffer associated with this source. - * - * @return the buffer associated with this source - */ - public Buffer getBuffer() { - return buffer; - } - - /** - * Queues one or more buffers on a source. Useful for streaming audio, - * buffers will be played in the order they are queued. - * - * @param buffers a set of initialized (loaded) buffers. - */ - public void queueBuffers(Buffer[] buffers) { - int numBuffers = buffers.length; - int[] arr = new int[numBuffers]; - - for (int i = 0; i < numBuffers; i++) { - arr[i] = buffers[i].bufferID; - } - - al.alSourceQueueBuffers(sourceID, numBuffers, arr, 0); - } - - /** - * Unqueues one or more buffers on a source. - * - * @param buffers a set of previously queued buffers. - */ - public void unqueueBuffers(Buffer[] buffers) { - int numBuffers = buffers.length; - int[] arr = new int[numBuffers]; - - for (int i = 0; i < numBuffers; i++) { - arr[i] = buffers[i].bufferID; - } - - al.alSourceUnqueueBuffers(sourceID, numBuffers, arr, 0); - } -} diff --git a/src/java/net/java/games/sound3d/Vec3f.java b/src/java/net/java/games/sound3d/Vec3f.java deleted file mode 100644 index 71b1d92..0000000 --- a/src/java/net/java/games/sound3d/Vec3f.java +++ /dev/null @@ -1,63 +0,0 @@ -/** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ - -package net.java.games.sound3d; - -/** - * A onvenience class representing a 3-element float vector - * - * @author Athomas Goldberg - */ -public final class Vec3f { - /** the first element in the vector */ - public final float v1; - - /** the first element in the vector */ - public final float v2; - - /** the first element in the vector */ - public final float v3; - - /** - * Creates a new Vec3f object. - * - * @param v1 the first element in the vector - * @param v2 the second element in the vector - * @param v3 the third element in the vector - */ - public Vec3f(float v1, float v2, float v3) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - } -} diff --git a/test/build.xml b/test/build.xml index 7b1f8e2..4445eb5 100644 --- a/test/build.xml +++ b/test/build.xml @@ -66,7 +66,7 @@ - + diff --git a/test/src/OpenALTest.java b/test/src/OpenALTest.java deleted file mode 100644 index fb63a2f..0000000 --- a/test/src/OpenALTest.java +++ /dev/null @@ -1,120 +0,0 @@ -/** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ - -import java.nio.*; - -import net.java.games.joal.*; -import net.java.games.joal.eax.*; -import net.java.games.joal.util.*; - -/** - * @author Athomas Goldberg - * - */ -public class OpenALTest { - public static void main(String[] args) { - try { - ALC alc = ALFactory.getALC(); - ALCdevice device = alc.alcOpenDevice(null); - ALCcontext context = alc.alcCreateContext(device, null); - alc.alcMakeContextCurrent(context); - AL al = ALFactory.getAL(); - boolean eaxPresent = al.alIsExtensionPresent("EAX2.0"); - System.out.println("EAX present:" + eaxPresent); - EAX eax = EAXFactory.getEAX(); - - try { - int[] buffers = new int[1]; - al.alGenBuffers(1, buffers, 0); - - WAVData wd = WAVLoader.loadFromFile("lewiscarroll.wav"); - al.alBufferData(buffers[0], wd.format, wd.data, wd.size, wd.freq); - - int[] sources = new int[1]; - al.alGenSources(1, sources, 0); - al.alSourcei(sources[0], AL.AL_BUFFER, buffers[0]); - int[] loopArray = new int[1]; - al.alGetSourcei(sources[0], AL.AL_LOOPING, loopArray, 0); - System.out.println("Looping 1: " + (loopArray[0] == AL.AL_TRUE)); - int[] loopBuffer = new int[1]; - al.alGetSourcei(sources[0], AL.AL_LOOPING, loopBuffer, 0); - System.out.println("Looping 2: " + (loopBuffer[0] == AL.AL_TRUE)); - - if (eaxPresent) { - IntBuffer env = BufferUtils.newIntBuffer(1); - env.put(EAX.EAX_ENVIRONMENT_BATHROOM); - eax.setListenerProperty( - EAX.DSPROPERTY_EAXLISTENER_ENVIRONMENT, - env); - } - - al.alSourcePlay(sources[0]); - - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - } - - al.alSource3f(sources[0], AL.AL_POSITION, 2f, 2f, 2f); - - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - } - - al.alListener3f(AL.AL_POSITION, 3f, 3f, 3f); - - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - } - - al.alSource3f(sources[0], AL.AL_POSITION, 0, 0, 0); - - try { - Thread.sleep(10000); - } catch (InterruptedException e) { - } - - al.alSourceStop(sources[0]); - al.alDeleteSources(1, sources, 0); - alc.alcDestroyContext(context); - alc.alcCloseDevice(device); - } catch (Exception e) { - e.printStackTrace(); - } - } catch (ALException e) { - e.printStackTrace(); - } - } -} diff --git a/test/src/Sound3DTest.java b/test/src/Sound3DTest.java deleted file mode 100644 index f6a65a3..0000000 --- a/test/src/Sound3DTest.java +++ /dev/null @@ -1,116 +0,0 @@ -/** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ -import java.io.*; -import javax.sound.sampled.*; -import net.java.games.joal.*; -import net.java.games.sound3d.*; - -/** - * @author Athomas Goldberg - * - */ -public class Sound3DTest { - - public static float lerp(float v1, float v2, float t) { - float result = 0; - result = v1 + ((v2-v1) * t); - return result; - } - - public static void main(String[] args) { - try { - AudioSystem3D.init(); - } catch (ALException e) { - e.printStackTrace(); - return; - } - - // create the initial context - this can be collapsed into the init. - Device device = AudioSystem3D.openDevice(null); - Context context = AudioSystem3D.createContext(device); - AudioSystem3D.makeContextCurrent(context); - - // get the listener object - Listener listener = AudioSystem3D.getListener(); - listener.setPosition(0,0,0); - - // load a source and play it - try { - Source source1 = AudioSystem3D.loadSource("lewiscarroll.wav"); - source1.setPosition(0,0,0); - source1.setLooping(true); - source1.play(); - - try { - Thread.sleep(10000); - } catch (InterruptedException e) { - - } - - // move the source - source1.setPosition(1,1,1); - - // move the listener - for(int i = 0; i < 1000; i++) { - float t = ((float)i)/1000f; - float lp = lerp(0f,2f,t); - listener.setPosition(lp,lp,lp); - try { - Thread.sleep(10); - } catch (InterruptedException e) { - - } - } - - // fade listener out. - for(int i = 0; i < 1000; i++) { - float t = ((float)i)/1000f; - float lp = lerp(1f,0f,t); - listener.setGain(lp); - try { - Thread.sleep(10); - } catch (InterruptedException e) { - } - } - - source1.stop(); - source1.delete(); - context.destroy(); - device.close(); - } catch (IOException e) { - e.printStackTrace(); - } catch (UnsupportedAudioFileException e) { - e.printStackTrace(); - } - } -} diff --git a/test/src/com/jogamp/openal/ALTest.java b/test/src/com/jogamp/openal/ALTest.java new file mode 100644 index 0000000..45b7995 --- /dev/null +++ b/test/src/com/jogamp/openal/ALTest.java @@ -0,0 +1,919 @@ +/* + * Created on Jun 3, 2003 + * + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ +package com.jogamp.openal; + +import java.io.IOException; + +import javax.sound.sampled.UnsupportedAudioFileException; + +import junit.framework.TestCase; +import com.jogamp.openal.util.*; + +/** + * @author Athomas Goldberg + * + */ +public class ALTest extends TestCase { + + + static AL al; + static ALC alc; + static ALCcontext context; + static ALCdevice device; + final static String TEST_FILE ="lewiscarroll.wav"; + + /** + * Constructor for ALTest. + * @param arg0 + */ + public ALTest(String arg0) { + super(arg0); + } + + public void setUp() { + try { + al = ALFactory.getAL(); + alc = ALFactory.getALC(); + device = alc.alcOpenDevice(null); + context = alc.alcCreateContext(device, null); + alc.alcMakeContextCurrent(context); + } catch (ALException e) { + e.printStackTrace(); + } + } + + public void tearDown() { + alc.alcMakeContextCurrent(null); + alc.alcDestroyContext(context); + alc.alcCloseDevice(device); + } + + public static void main(String[] args) { + System.out.println("begin main"); + junit.textui.TestRunner.run(ALTest.class); + System.out.println("end main"); + } + + /* + * Test for void alGenBuffers(int, IntBuffer) + *//* + final public void testAlGenBuffersintIntBuffer() { + System.out.println("begin testAlGenBuffersintintBuffer"); + // try basic case + try { + IntBuffer buffers = BufferUtils.newIntBuffer(7); + al.alGenBuffers(7,buffers); + for(int i = 0; i < 7; i++) { + assertFalse(buffers.get(i) == 0); + assertTrue(al.alIsBuffer(buffers.get(i))); + } + } catch (Exception e) { + fail(e.getMessage()); + } + + Exception ex = null; + // buffers == null + try { + IntBuffer buffers = null; + al.alGenBuffers(7,buffers); + + + } catch(IllegalArgumentException e) { + ex = e; + } + assertNotNull(ex); + + ex = null; + // buffer too small + try { + IntBuffer buffers = BufferUtils.newIntBuffer(5); + al.alGenBuffers(7,buffers); + } catch(IllegalArgumentException e) { + ex = e; + } + assertNotNull(ex); + + ex = null; + // buffer not direct + try { + IntBuffer buffers = IntBuffer.allocate(7); + al.alGenBuffers(7,buffers); + } catch(IllegalArgumentException e) { + ex = e; + } + assertNotNull(ex); + System.out.println("end testAlGenBuffersintintBuffer"); + } +*/ + /* + * Test for void alGenBuffers(int, int[]) + */ + final public void testAlGenBuffersintintArray() { + + System.out.println("begin testAlGenBuffersintintArray"); + // try basic case + try { + int[] buffers = new int[7]; + al.alGenBuffers(7,buffers, 0); + for(int i = 0; i < 7; i++) { + assertFalse(buffers[i] == 0); + assertTrue(al.alIsBuffer(buffers[i])); + } + } catch (Exception e) { + fail(e.getMessage()); + } + + Exception ex = null; + // try exceptions + try { + int[] buffers = null; + al.alGenBuffers(7,buffers, 0); + + + } catch(IllegalArgumentException e) { + ex = e; + } + assertNotNull(ex); + ex = null; + try { + int[] buffers = new int[5]; + al.alGenBuffers(7,buffers, 0); + } catch(IllegalArgumentException e) { + ex = e; + } + assertNotNull(ex); + + System.out.println("end testAlGenBuffersintintArray"); + + } + + /* + * Test for void alDeleteBuffers(int, IntBuffer) + */ + final public void testAlDeleteBuffersintIntBuffer() { + System.out.println("begin testAlDeleteBuffersintintArray"); + // try basic case + try { + int[] buffers = new int[7]; + al.alGenBuffers(7,buffers,0); + for(int i = 0; i < 7; i++) { + assertFalse(buffers[i] == 0); + assertTrue(al.alIsBuffer(buffers[i])); + } + al.alDeleteBuffers(7,buffers,0); + for(int i = 0; i < 7; i++) { + assertFalse(al.alIsBuffer(buffers[i])); + } + } catch (Exception e) { + fail(e.getMessage()); + } + + Exception ex = null; + // try exceptions + try { + al.alDeleteBuffers(7,(int[])null, 0); + } catch(IllegalArgumentException e) { + ex = e; + } + assertNotNull(ex); + ex = null; + try { + int[] buffers = new int[5]; + al.alGenBuffers(5,buffers,0); + al.alDeleteBuffers(7,buffers,0); + } catch(IllegalArgumentException e) { + ex = e; + } + assertNotNull(ex); + + try { + int[] buffers = new int[7]; + al.alDeleteBuffers(7,buffers,0); + assertTrue(al.alGetError() != 0); + } catch(Exception e) { + fail("deleting an unfilled buffer list should generate an ALError but not an exception"); + } + + System.out.println("end testAlDeleteBuffersintintArray"); + } + + /* + * Test for void alDeleteBuffers(int, int[]) + */ + final public void testAlDeleteBuffersintintArray() { + System.out.println("begin testAlDeleteBuffersintIntBuffer"); + // try basic case + try { + int[] buffers = new int[7]; + al.alGenBuffers(7,buffers,0); + for(int i = 0; i < 7; i++) { + assertFalse(buffers[i] == 0); + assertTrue(al.alIsBuffer(buffers[i])); + } + al.alDeleteBuffers(7,buffers,0); + for(int i = 0; i < 7; i++) { + assertFalse(al.alIsBuffer(buffers[i])); + } + } catch (Exception e) { + fail(e.getMessage()); + } + + Exception ex = null; + // try exceptions + try { + al.alDeleteBuffers(7,(int[])null,0); + } catch(IllegalArgumentException e) { + ex = e; + } + assertNotNull(ex); + ex = null; + try { + int[] buffers = new int[5]; + al.alGenBuffers(5,buffers,0); + al.alDeleteBuffers(7,buffers,0); + } catch(IllegalArgumentException e) { + ex = e; + } + assertNotNull(ex); + + ex = null; + try { + int[] buffers = new int[5]; + al.alDeleteBuffers(7,buffers,0); + } catch(IllegalArgumentException e) { + ex = e; + } + assertNotNull(ex); + + try { + int[] buffers = new int[7]; + al.alDeleteBuffers(7,buffers,0); + assertTrue(al.alGetError() != 0); + } catch(Exception e) { + fail("deleting an unfilled buffer list should generate an ALError but not an exception"); + } + + System.out.println("end testAlDeleteBuffersintintArray"); + } + + final public void testAlIsBuffer() { + System.out.println("begin testALIsBuffer"); + try { + // check a bufferlist with known bad values + int[] buffers = new int[7]; + for(int i = 0; i < 7; i++) { + buffers[i] = -1; + assertFalse(al.alIsBuffer(buffers[i])); + } + // created + al.alGenBuffers(7,buffers,0); + for(int i = 0; i < 7; i++) { + assertTrue(al.alIsBuffer(buffers[i])); + } + // deleted + al.alDeleteBuffers(7,buffers,0); + for(int i = 0; i < 7; i++) { + assertFalse(al.alIsBuffer(buffers[i])); + } + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } + System.out.println("end testALisBuffer"); + } + + /* + * Test for void alBufferData(int, int, Buffer, int, int) + */ + final public void testAlBufferDataintintByteBufferintint() { + System.out.println("begin testAlBufferDataintintByteBufferintint"); + try { + int[] buffers = new int[1]; + al.alGenBuffers(1, buffers, 0); + WAVData wd = + WAVLoader.loadFromFile(TEST_FILE); + al.alBufferData( + buffers[0], + wd.format, + wd.data, + wd.size, + wd.freq + ); + int[] tmp = new int[1]; + al.alGetBufferi(buffers[0],AL.AL_SIZE,tmp,0); + assertFalse(tmp[0] == 0); + } catch(Exception e) { + fail(e.toString()); + } + Exception ex = null; + try { + int[] buffers = new int[1]; + al.alGenBuffers(1, buffers, 0); + + al.alBufferData( + buffers[0], + AL.AL_FORMAT_STEREO16, + null, + 0, + 0 + ); + } catch(IllegalArgumentException e) { + ex = e; + } + assertNotNull(ex); + + System.out.println("end testAlBufferDataintintByteBufferintint"); + } + + /* + * Test for void alGetBufferf(int, int, float[]) + */ + final public void testAlGetBufferfintintfloatArray() { + System.out.println("begin testAlGetBufferfintintfloatArray"); + + // there are currently NO float attributes for buffers. + + System.out.println("end testAlGetBufferfintintfloatArray"); + } + + /* + * Test for void alGetBufferf(int, int, FloatBuffer) + */ + final public void testAlGetBufferfintintFloatBuffer() { + System.out.println("begin testAlGetBufferfintintFloatBuffer"); + + // there are currently NO float attributes for buffers. + + System.out.println("end testAlGetBufferfintintFloatBuffer"); + } + + /* + * Test for float alGetBufferf(int, int) + */ + final public void testAlGetBufferfintint() { + System.out.println("begin testAlGetBufferfintintFloatBuffer"); + + // there are currently NO float attributes for buffers. + + System.out.println("end testAlGetBufferfintintFloatBuffer"); + } + + /* + * Test for void alGetBufferi(int, int, int[]) + */ + final public void testAlGetBufferiintintintArray() { + System.out.println("begin testAlGetBufferiintintintArray"); + try { + int[] buffers = new int[1]; + al.alGenBuffers(1, buffers, 0); + WAVData wd = + WAVLoader.loadFromFile(TEST_FILE); + al.alBufferData( + buffers[0], + wd.format, + wd.data, + wd.size, + wd.freq + ); + int[] size = new int[1]; + int[] freq = new int[1]; + al.alGetBufferi(buffers[0],AL.AL_SIZE, size, 0); + al.alGetBufferi(buffers[0],AL.AL_FREQUENCY, freq, 0); + assertEquals(wd.size, size[0]); + assertEquals(wd.freq, freq[0]); + } catch(Exception e) { + fail(e.toString()); + } + + Exception ex = null; + try { + int[] buffers = new int[1]; + al.alGenBuffers(1, buffers, 0); + WAVData wd = + WAVLoader.loadFromFile(TEST_FILE); + al.alBufferData( + buffers[0], + wd.format, + wd.data, + wd.size, + wd.freq + ); + int[] size = null; + al.alGetBufferi(buffers[0],AL.AL_SIZE, size, 0); + + } catch (IllegalArgumentException e) { + ex = e; + } catch (UnsupportedAudioFileException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (IOException e) { + e.printStackTrace(); + fail(e.getMessage()); + } + + assertNotNull(ex); + + System.out.println("end testAlGetBufferiintintintArray"); + } + + /* + * Test for void alGetBufferi(int, int, IntBuffer) + */ + final public void testAlGetBufferiintintIntBuffer() { + try { + int[] buffers = new int[1]; + al.alGenBuffers(1, buffers, 0); + WAVData wd = + WAVLoader.loadFromFile(TEST_FILE); + al.alBufferData( + buffers[0], + wd.format, + wd.data, + wd.size, + wd.freq + ); + int[] size = new int[1]; + int[] freq = new int[1]; + al.alGetBufferi(buffers[0],AL.AL_SIZE, size, 0); + al.alGetBufferi(buffers[0],AL.AL_FREQUENCY, freq, 0); + assertEquals(wd.size, size[0]); + assertEquals(wd.freq, freq[0]); + } catch(Exception e) { + fail(e.toString()); + } + Exception ex = null; + try { + int[] buffers = new int[1]; + al.alGenBuffers(1, buffers, 0); + WAVData wd = + WAVLoader.loadFromFile(TEST_FILE); + al.alBufferData( + buffers[0], + wd.format, + wd.data, + wd.size, + wd.freq + ); + int[] size = null; + al.alGetBufferi(buffers[0],AL.AL_SIZE, size, 0); + + } catch (IllegalArgumentException e) { + ex = e; + } catch (UnsupportedAudioFileException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (IOException e) { + e.printStackTrace(); + fail(e.getMessage()); + } + + assertNotNull(ex); + ex = null; + try { + int[] buffers = new int[1]; + al.alGenBuffers(1, buffers, 0); + WAVData wd = + WAVLoader.loadFromFile(TEST_FILE); + al.alBufferData( + buffers[0], + wd.format, + wd.data, + wd.size, + wd.freq + ); + int[] size = new int[1]; + al.alGetBufferi(buffers[0],AL.AL_SIZE, size, 0); + + } catch (IllegalArgumentException e) { + ex = e; + } catch (UnsupportedAudioFileException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (IOException e) { + e.printStackTrace(); + fail(e.getMessage()); + } + +// assertNotNull(ex); + } + + /* + * Test for int alGetBufferi(int, int) + */ + final public void testAlGetBufferiintint() { + //TODO Implement alGetBufferi(). + } + + /* + * Test for void alGenSources(int, int[]) + */ + final public void testAlGenSourcesintintArray() { + //TODO Implement alGenSources(). + } + + /* + * Test for void alGenSources(int, IntBuffer) + */ + final public void testAlGenSourcesintIntBuffer() { + //TODO Implement alGenSources(). + } + + /* + * Test for void alDeleteSources(int, int[]) + */ + final public void testAlDeleteSourcesintintArray() { + //TODO Implement alDeleteSources(). + } + + /* + * Test for void alDeleteSources(int, IntBuffer) + */ + final public void testAlDeleteSourcesintIntBuffer() { + //TODO Implement alDeleteSources(). + } + + final public void testAlIsSource() { + //TODO Implement alIsSource(). + } + + final public void testAlSourcei() { + //TODO Implement alSourcei(). + } + + final public void testAlSourcef() { + //TODO Implement alSourcef(). + } + + /* + * Test for void alSourcefv(int, int, float[]) + */ + final public void testAlSourcefvintintfloatArray() { + //TODO Implement alSourcefv(). + } + + /* + * Test for void alSourcefv(int, int, FloatBuffer) + */ + final public void testAlSourcefvintintFloatBuffer() { + //TODO Implement alSourcefv(). + } + + final public void testAlSource3f() { + //TODO Implement alSource3f(). + } + + /* + * Test for void alGetSourcef(int, int, float[]) + */ + final public void testAlGetSourcefintintfloatArray() { + //TODO Implement alGetSourcef(). + } + + /* + * Test for void alGetSourcef(int, int, FloatBuffer) + */ + final public void testAlGetSourcefintintFloatBuffer() { + //TODO Implement alGetSourcef(). + } + + /* + * Test for float alGetSourcef(int, int) + */ + final public void testAlGetSourcefintint() { + //TODO Implement alGetSourcef(). + } + + /* + * Test for void alGetSourcefv(int, int, FloatBuffer) + */ + final public void testAlGetSourcefvintintFloatBuffer() { + //TODO Implement alGetSourcefv(). + } + + /* + * Test for void alGetSourcefv(int, int, float[]) + */ + final public void testAlGetSourcefvintintfloatArray() { + //TODO Implement alGetSourcefv(). + } + + /* + * Test for void alGetSourcei(int, int, int[]) + */ + final public void testAlGetSourceiintintintArray() { + //TODO Implement alGetSourcei(). + } + + /* + * Test for void alGetSourcei(int, int, IntBuffer) + */ + final public void testAlGetSourceiintintIntBuffer() { + //TODO Implement alGetSourcei(). + } + + /* + * Test for int alGetSourcei(int, int) + */ + final public void testAlGetSourceiintint() { + //TODO Implement alGetSourcei(). + } + + final public void testAlSourcePlay() { + //TODO Implement alSourcePlay(). + } + + /* + * Test for void alSourcePlayv(int, IntBuffer) + */ + final public void testAlSourcePlayvintIntBuffer() { + //TODO Implement alSourcePlayv(). + } + + /* + * Test for void alSourcePlayv(int, int[]) + */ + final public void testAlSourcePlayvintintArray() { + //TODO Implement alSourcePlayv(). + } + + final public void testAlSourcePause() { + //TODO Implement alSourcePause(). + } + + /* + * Test for void alSourcePausev(int, int[]) + */ + final public void testAlSourcePausevintintArray() { + //TODO Implement alSourcePausev(). + } + + /* + * Test for void alSourcePausev(int, IntBuffer) + */ + final public void testAlSourcePausevintIntBuffer() { + //TODO Implement alSourcePausev(). + } + + final public void testAlSourceStop() { + //TODO Implement alSourceStop(). + } + + /* + * Test for void alSourceStopv(int, int[]) + */ + final public void testAlSourceStopvintintArray() { + //TODO Implement alSourceStopv(). + } + + /* + * Test for void alSourceStopv(int, IntBuffer) + */ + final public void testAlSourceStopvintIntBuffer() { + //TODO Implement alSourceStopv(). + } + + final public void testAlSourceRewind() { + //TODO Implement alSourceRewind(). + } + + /* + * Test for void alSourceRewindv(int, int[]) + */ + final public void testAlSourceRewindvintintArray() { + //TODO Implement alSourceRewindv(). + } + + /* + * Test for void alSourceRewindv(int, IntBuffer) + */ + final public void testAlSourceRewindvintIntBuffer() { + //TODO Implement alSourceRewindv(). + } + + /* + * Test for void alSourceQueueBuffers(int, int, int[]) + */ + final public void testAlSourceQueueBuffersintintintArray() { + //TODO Implement alSourceQueueBuffers(). + } + + /* + * Test for void alSourceQueueBuffers(int, int, IntBuffer) + */ + final public void testAlSourceQueueBuffersintintIntBuffer() { + //TODO Implement alSourceQueueBuffers(). + } + + /* + * Test for void alSourceUnqueueBuffers(int, int, int[]) + */ + final public void testAlSourceUnqueueBuffersintintintArray() { + //TODO Implement alSourceUnqueueBuffers(). + } + + /* + * Test for void alSourceUnqueueBuffers(int, int, IntBuffer) + */ + final public void testAlSourceUnqueueBuffersintintIntBuffer() { + //TODO Implement alSourceUnqueueBuffers(). + } + + final public void testAlListenerf() { + //TODO Implement alListenerf(). + } + + final public void testAlListener3f() { + //TODO Implement alListener3f(). + } + + /* + * Test for void alListenerfv(int, float[]) + */ + final public void testAlListenerfvintfloatArray() { + //TODO Implement alListenerfv(). + } + + /* + * Test for void alListenerfv(int, FloatBuffer) + */ + final public void testAlListenerfvintFloatBuffer() { + //TODO Implement alListenerfv(). + } + + final public void testAlListeneri() { + //TODO Implement alListeneri(). + } + + /* + * Test for void alGetListenerf(int, float[]) + */ + final public void testAlGetListenerfintfloatArray() { + //TODO Implement alGetListenerf(). + } + + /* + * Test for void alGetListenerf(int, FloatBuffer) + */ + final public void testAlGetListenerfintFloatBuffer() { + //TODO Implement alGetListenerf(). + } + + /* + * Test for float alGetListenerf(int) + */ + final public void testAlGetListenerfint() { + //TODO Implement alGetListenerf(). + } + + /* + * Test for void alGetListener3f(int, FloatBuffer, FloatBuffer, FloatBuffer) + */ + final public void testAlGetListener3fintFloatBufferFloatBufferFloatBuffer() { + //TODO Implement alGetListener3f(). + } + + /* + * Test for void alGetListener3f(int, float[], float[], float[]) + */ + final public void testAlGetListener3fintfloatArrayfloatArrayfloatArray() { + //TODO Implement alGetListener3f(). + } + + /* + * Test for void alGetListenerfv(int, float[]) + */ + final public void testAlGetListenerfvintfloatArray() { + //TODO Implement alGetListenerfv(). + } + + /* + * Test for void alGetListenerfv(int, FloatBuffer) + */ + final public void testAlGetListenerfvintFloatBuffer() { + //TODO Implement alGetListenerfv(). + } + + /* + * Test for void alGetListeneri(int, int[]) + */ + final public void testAlGetListeneriintintArray() { + //TODO Implement alGetListeneri(). + } + + /* + * Test for void alGetListeneri(int, IntBuffer) + */ + final public void testAlGetListeneriintIntBuffer() { + //TODO Implement alGetListeneri(). + } + + /* + * Test for int alGetListeneri(int) + */ + final public void testAlGetListeneriint() { + //TODO Implement alGetListeneri(). + } + + final public void testAlEnable() { + //TODO Implement alEnable(). + } + + final public void testAlDisable() { + //TODO Implement alDisable(). + } + + final public void testAlIsEnabled() { + //TODO Implement alIsEnabled(). + } + + final public void testAlGetBoolean() { + //TODO Implement alGetBoolean(). + } + + final public void testAlGetDouble() { + //TODO Implement alGetDouble(). + } + + final public void testAlGetFloat() { + //TODO Implement alGetFloat(). + } + + final public void testAlGetInteger() { + //TODO Implement alGetInteger(). + } + + /* + * Test for void alGetDoublev(int, DoubleBuffer) + */ + final public void testAlGetDoublevintDoubleBuffer() { + //TODO Implement alGetDoublev(). + } + + /* + * Test for void alGetDoublev(int, double[]) + */ + final public void testAlGetDoublevintdoubleArray() { + //TODO Implement alGetDoublev(). + } + + /* + * Test for void alGetFloatv(int, FloatBuffer) + */ + final public void testAlGetFloatvintFloatBuffer() { + //TODO Implement alGetFloatv(). + } + + /* + * Test for void alGetFloatv(int, float[]) + */ + final public void testAlGetFloatvintfloatArray() { + //TODO Implement alGetFloatv(). + } + + /* + * Test for void alGetIntegerv(int, IntBuffer) + */ + final public void testAlGetIntegervintIntBuffer() { + //TODO Implement alGetIntegerv(). + } + + /* + * Test for void alGetIntegerv(int, int[]) + */ + final public void testAlGetIntegervintintArray() { + //TODO Implement alGetIntegerv(). + } + + final public void testAlGetString() { + //TODO Implement alGetString(). + } + + final public void testAlDistanceModel() { + //TODO Implement alDistanceModel(). + } + + final public void testAlDopplerFactor() { + //TODO Implement alDopplerFactor(). + } + + final public void testAlDopplerVelocity() { + //TODO Implement alDopplerVelocity(). + } + + final public void testAlGetError() { + //TODO Implement alGetError(). + } + + final public void testAlIsExtensionPresent() { + //TODO Implement alIsExtensionPresent(). + } + + final public void testAlGetEnumValue() { + //TODO Implement alGetEnumValue(). + } + +} diff --git a/test/src/com/jogamp/openal/OpenALTest.java b/test/src/com/jogamp/openal/OpenALTest.java new file mode 100644 index 0000000..7826899 --- /dev/null +++ b/test/src/com/jogamp/openal/OpenALTest.java @@ -0,0 +1,122 @@ +package com.jogamp.openal; + +/** +* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* -Redistribution of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may +* be used to endorse or promote products derived from this software without +* specific prior written permission. +* +* This software is provided "AS IS," without a warranty of any kind. +* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING +* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS +* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A +* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. +* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT +* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR +* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, +* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS +* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* +* You acknowledge that this software is not designed or intended for use in the +* design, construction, operation or maintenance of any nuclear facility. +*/ + +import java.nio.*; + +import com.jogamp.openal.*; +import com.jogamp.openal.eax.*; +import com.jogamp.openal.util.*; + +/** + * @author Athomas Goldberg + * + */ +public class OpenALTest { + public static void main(String[] args) { + try { + ALC alc = ALFactory.getALC(); + ALCdevice device = alc.alcOpenDevice(null); + ALCcontext context = alc.alcCreateContext(device, null); + alc.alcMakeContextCurrent(context); + AL al = ALFactory.getAL(); + boolean eaxPresent = al.alIsExtensionPresent("EAX2.0"); + System.out.println("EAX present:" + eaxPresent); + EAX eax = EAXFactory.getEAX(); + + try { + int[] buffers = new int[1]; + al.alGenBuffers(1, buffers, 0); + + WAVData wd = WAVLoader.loadFromFile("lewiscarroll.wav"); + al.alBufferData(buffers[0], wd.format, wd.data, wd.size, wd.freq); + + int[] sources = new int[1]; + al.alGenSources(1, sources, 0); + al.alSourcei(sources[0], AL.AL_BUFFER, buffers[0]); + int[] loopArray = new int[1]; + al.alGetSourcei(sources[0], AL.AL_LOOPING, loopArray, 0); + System.out.println("Looping 1: " + (loopArray[0] == AL.AL_TRUE)); + int[] loopBuffer = new int[1]; + al.alGetSourcei(sources[0], AL.AL_LOOPING, loopBuffer, 0); + System.out.println("Looping 2: " + (loopBuffer[0] == AL.AL_TRUE)); + + if (eaxPresent) { + IntBuffer env = BufferUtils.newIntBuffer(1); + env.put(EAX.EAX_ENVIRONMENT_BATHROOM); + eax.setListenerProperty( + EAX.DSPROPERTY_EAXLISTENER_ENVIRONMENT, + env); + } + + al.alSourcePlay(sources[0]); + + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + } + + al.alSource3f(sources[0], AL.AL_POSITION, 2f, 2f, 2f); + + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + } + + al.alListener3f(AL.AL_POSITION, 3f, 3f, 3f); + + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + } + + al.alSource3f(sources[0], AL.AL_POSITION, 0, 0, 0); + + try { + Thread.sleep(10000); + } catch (InterruptedException e) { + } + + al.alSourceStop(sources[0]); + al.alDeleteSources(1, sources, 0); + alc.alcDestroyContext(context); + alc.alcCloseDevice(device); + } catch (Exception e) { + e.printStackTrace(); + } + } catch (ALException e) { + e.printStackTrace(); + } + } +} diff --git a/test/src/com/jogamp/openal/Sound3DTest.java b/test/src/com/jogamp/openal/Sound3DTest.java new file mode 100644 index 0000000..2cd2c11 --- /dev/null +++ b/test/src/com/jogamp/openal/Sound3DTest.java @@ -0,0 +1,117 @@ +package com.jogamp.openal; + +/** +* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* -Redistribution of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* -Redistribution 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 Sun Microsystems, Inc. or the names of contributors may +* be used to endorse or promote products derived from this software without +* specific prior written permission. +* +* This software is provided "AS IS," without a warranty of any kind. +* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING +* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS +* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A +* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. +* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT +* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR +* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, +* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS +* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* +* You acknowledge that this software is not designed or intended for use in the +* design, construction, operation or maintenance of any nuclear facility. +*/ +import java.io.*; +import javax.sound.sampled.*; +import com.jogamp.openal.sound3d.*; + +/** + * @author Athomas Goldberg + * + */ +public class Sound3DTest { + + public static float lerp(float v1, float v2, float t) { + float result = 0; + result = v1 + ((v2-v1) * t); + return result; + } + + public static void main(String[] args) { + try { + AudioSystem3D.init(); + } catch (ALException e) { + e.printStackTrace(); + return; + } + + // create the initial context - this can be collapsed into the init. + Device device = AudioSystem3D.openDevice(null); + Context context = AudioSystem3D.createContext(device); + AudioSystem3D.makeContextCurrent(context); + + // get the listener object + Listener listener = AudioSystem3D.getListener(); + listener.setPosition(0,0,0); + + // load a source and play it + try { + Source source1 = AudioSystem3D.loadSource("lewiscarroll.wav"); + source1.setPosition(0,0,0); + source1.setLooping(true); + source1.play(); + + try { + Thread.sleep(10000); + } catch (InterruptedException e) { + + } + + // move the source + source1.setPosition(1,1,1); + + // move the listener + for(int i = 0; i < 1000; i++) { + float t = ((float)i)/1000f; + float lp = lerp(0f,2f,t); + listener.setPosition(lp,lp,lp); + try { + Thread.sleep(10); + } catch (InterruptedException e) { + + } + } + + // fade listener out. + for(int i = 0; i < 1000; i++) { + float t = ((float)i)/1000f; + float lp = lerp(1f,0f,t); + listener.setGain(lp); + try { + Thread.sleep(10); + } catch (InterruptedException e) { + } + } + + source1.stop(); + source1.delete(); + context.destroy(); + device.close(); + } catch (IOException e) { + e.printStackTrace(); + } catch (UnsupportedAudioFileException e) { + e.printStackTrace(); + } + } +} diff --git a/test/src/net/java/games/joal/ALTest.java b/test/src/net/java/games/joal/ALTest.java deleted file mode 100644 index 7b25aa1..0000000 --- a/test/src/net/java/games/joal/ALTest.java +++ /dev/null @@ -1,920 +0,0 @@ -/* - * Created on Jun 3, 2003 - * - * Copyright 2003 Sun Microsystems, Inc. All rights reserved. - * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. - */ -package net.java.games.joal; - -import java.io.IOException; -import java.nio.ByteBuffer; - -import javax.sound.sampled.UnsupportedAudioFileException; - -import junit.framework.TestCase; -import net.java.games.joal.util.*; - -/** - * @author Athomas Goldberg - * - */ -public class ALTest extends TestCase { - - - static AL al; - static ALC alc; - static ALCcontext context; - static ALCdevice device; - final static String TEST_FILE ="lewiscarroll.wav"; - - /** - * Constructor for ALTest. - * @param arg0 - */ - public ALTest(String arg0) { - super(arg0); - } - - public void setUp() { - try { - al = ALFactory.getAL(); - alc = ALFactory.getALC(); - device = alc.alcOpenDevice(null); - context = alc.alcCreateContext(device, null); - alc.alcMakeContextCurrent(context); - } catch (ALException e) { - e.printStackTrace(); - } - } - - public void tearDown() { - alc.alcMakeContextCurrent(null); - alc.alcDestroyContext(context); - alc.alcCloseDevice(device); - } - - public static void main(String[] args) { - System.out.println("begin main"); - junit.textui.TestRunner.run(ALTest.class); - System.out.println("end main"); - } - - /* - * Test for void alGenBuffers(int, IntBuffer) - *//* - final public void testAlGenBuffersintIntBuffer() { - System.out.println("begin testAlGenBuffersintintBuffer"); - // try basic case - try { - IntBuffer buffers = BufferUtils.newIntBuffer(7); - al.alGenBuffers(7,buffers); - for(int i = 0; i < 7; i++) { - assertFalse(buffers.get(i) == 0); - assertTrue(al.alIsBuffer(buffers.get(i))); - } - } catch (Exception e) { - fail(e.getMessage()); - } - - Exception ex = null; - // buffers == null - try { - IntBuffer buffers = null; - al.alGenBuffers(7,buffers); - - - } catch(IllegalArgumentException e) { - ex = e; - } - assertNotNull(ex); - - ex = null; - // buffer too small - try { - IntBuffer buffers = BufferUtils.newIntBuffer(5); - al.alGenBuffers(7,buffers); - } catch(IllegalArgumentException e) { - ex = e; - } - assertNotNull(ex); - - ex = null; - // buffer not direct - try { - IntBuffer buffers = IntBuffer.allocate(7); - al.alGenBuffers(7,buffers); - } catch(IllegalArgumentException e) { - ex = e; - } - assertNotNull(ex); - System.out.println("end testAlGenBuffersintintBuffer"); - } -*/ - /* - * Test for void alGenBuffers(int, int[]) - */ - final public void testAlGenBuffersintintArray() { - - System.out.println("begin testAlGenBuffersintintArray"); - // try basic case - try { - int[] buffers = new int[7]; - al.alGenBuffers(7,buffers, 0); - for(int i = 0; i < 7; i++) { - assertFalse(buffers[i] == 0); - assertTrue(al.alIsBuffer(buffers[i])); - } - } catch (Exception e) { - fail(e.getMessage()); - } - - Exception ex = null; - // try exceptions - try { - int[] buffers = null; - al.alGenBuffers(7,buffers, 0); - - - } catch(IllegalArgumentException e) { - ex = e; - } - assertNotNull(ex); - ex = null; - try { - int[] buffers = new int[5]; - al.alGenBuffers(7,buffers, 0); - } catch(IllegalArgumentException e) { - ex = e; - } - assertNotNull(ex); - - System.out.println("end testAlGenBuffersintintArray"); - - } - - /* - * Test for void alDeleteBuffers(int, IntBuffer) - */ - final public void testAlDeleteBuffersintIntBuffer() { - System.out.println("begin testAlDeleteBuffersintintArray"); - // try basic case - try { - int[] buffers = new int[7]; - al.alGenBuffers(7,buffers,0); - for(int i = 0; i < 7; i++) { - assertFalse(buffers[i] == 0); - assertTrue(al.alIsBuffer(buffers[i])); - } - al.alDeleteBuffers(7,buffers,0); - for(int i = 0; i < 7; i++) { - assertFalse(al.alIsBuffer(buffers[i])); - } - } catch (Exception e) { - fail(e.getMessage()); - } - - Exception ex = null; - // try exceptions - try { - al.alDeleteBuffers(7,(int[])null, 0); - } catch(IllegalArgumentException e) { - ex = e; - } - assertNotNull(ex); - ex = null; - try { - int[] buffers = new int[5]; - al.alGenBuffers(5,buffers,0); - al.alDeleteBuffers(7,buffers,0); - } catch(IllegalArgumentException e) { - ex = e; - } - assertNotNull(ex); - - try { - int[] buffers = new int[7]; - al.alDeleteBuffers(7,buffers,0); - assertTrue(al.alGetError() != 0); - } catch(Exception e) { - fail("deleting an unfilled buffer list should generate an ALError but not an exception"); - } - - System.out.println("end testAlDeleteBuffersintintArray"); - } - - /* - * Test for void alDeleteBuffers(int, int[]) - */ - final public void testAlDeleteBuffersintintArray() { - System.out.println("begin testAlDeleteBuffersintIntBuffer"); - // try basic case - try { - int[] buffers = new int[7]; - al.alGenBuffers(7,buffers,0); - for(int i = 0; i < 7; i++) { - assertFalse(buffers[i] == 0); - assertTrue(al.alIsBuffer(buffers[i])); - } - al.alDeleteBuffers(7,buffers,0); - for(int i = 0; i < 7; i++) { - assertFalse(al.alIsBuffer(buffers[i])); - } - } catch (Exception e) { - fail(e.getMessage()); - } - - Exception ex = null; - // try exceptions - try { - al.alDeleteBuffers(7,(int[])null,0); - } catch(IllegalArgumentException e) { - ex = e; - } - assertNotNull(ex); - ex = null; - try { - int[] buffers = new int[5]; - al.alGenBuffers(5,buffers,0); - al.alDeleteBuffers(7,buffers,0); - } catch(IllegalArgumentException e) { - ex = e; - } - assertNotNull(ex); - - ex = null; - try { - int[] buffers = new int[5]; - al.alDeleteBuffers(7,buffers,0); - } catch(IllegalArgumentException e) { - ex = e; - } - assertNotNull(ex); - - try { - int[] buffers = new int[7]; - al.alDeleteBuffers(7,buffers,0); - assertTrue(al.alGetError() != 0); - } catch(Exception e) { - fail("deleting an unfilled buffer list should generate an ALError but not an exception"); - } - - System.out.println("end testAlDeleteBuffersintintArray"); - } - - final public void testAlIsBuffer() { - System.out.println("begin testALIsBuffer"); - try { - // check a bufferlist with known bad values - int[] buffers = new int[7]; - for(int i = 0; i < 7; i++) { - buffers[i] = -1; - assertFalse(al.alIsBuffer(buffers[i])); - } - // created - al.alGenBuffers(7,buffers,0); - for(int i = 0; i < 7; i++) { - assertTrue(al.alIsBuffer(buffers[i])); - } - // deleted - al.alDeleteBuffers(7,buffers,0); - for(int i = 0; i < 7; i++) { - assertFalse(al.alIsBuffer(buffers[i])); - } - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } - System.out.println("end testALisBuffer"); - } - - /* - * Test for void alBufferData(int, int, Buffer, int, int) - */ - final public void testAlBufferDataintintByteBufferintint() { - System.out.println("begin testAlBufferDataintintByteBufferintint"); - try { - int[] buffers = new int[1]; - al.alGenBuffers(1, buffers, 0); - WAVData wd = - WAVLoader.loadFromFile(TEST_FILE); - al.alBufferData( - buffers[0], - wd.format, - wd.data, - wd.size, - wd.freq - ); - int[] tmp = new int[1]; - al.alGetBufferi(buffers[0],AL.AL_SIZE,tmp,0); - assertFalse(tmp[0] == 0); - } catch(Exception e) { - fail(e.toString()); - } - Exception ex = null; - try { - int[] buffers = new int[1]; - al.alGenBuffers(1, buffers, 0); - - al.alBufferData( - buffers[0], - AL.AL_FORMAT_STEREO16, - null, - 0, - 0 - ); - } catch(IllegalArgumentException e) { - ex = e; - } - assertNotNull(ex); - - System.out.println("end testAlBufferDataintintByteBufferintint"); - } - - /* - * Test for void alGetBufferf(int, int, float[]) - */ - final public void testAlGetBufferfintintfloatArray() { - System.out.println("begin testAlGetBufferfintintfloatArray"); - - // there are currently NO float attributes for buffers. - - System.out.println("end testAlGetBufferfintintfloatArray"); - } - - /* - * Test for void alGetBufferf(int, int, FloatBuffer) - */ - final public void testAlGetBufferfintintFloatBuffer() { - System.out.println("begin testAlGetBufferfintintFloatBuffer"); - - // there are currently NO float attributes for buffers. - - System.out.println("end testAlGetBufferfintintFloatBuffer"); - } - - /* - * Test for float alGetBufferf(int, int) - */ - final public void testAlGetBufferfintint() { - System.out.println("begin testAlGetBufferfintintFloatBuffer"); - - // there are currently NO float attributes for buffers. - - System.out.println("end testAlGetBufferfintintFloatBuffer"); - } - - /* - * Test for void alGetBufferi(int, int, int[]) - */ - final public void testAlGetBufferiintintintArray() { - System.out.println("begin testAlGetBufferiintintintArray"); - try { - int[] buffers = new int[1]; - al.alGenBuffers(1, buffers, 0); - WAVData wd = - WAVLoader.loadFromFile(TEST_FILE); - al.alBufferData( - buffers[0], - wd.format, - wd.data, - wd.size, - wd.freq - ); - int[] size = new int[1]; - int[] freq = new int[1]; - al.alGetBufferi(buffers[0],AL.AL_SIZE, size, 0); - al.alGetBufferi(buffers[0],AL.AL_FREQUENCY, freq, 0); - assertEquals(wd.size, size[0]); - assertEquals(wd.freq, freq[0]); - } catch(Exception e) { - fail(e.toString()); - } - - Exception ex = null; - try { - int[] buffers = new int[1]; - al.alGenBuffers(1, buffers, 0); - WAVData wd = - WAVLoader.loadFromFile(TEST_FILE); - al.alBufferData( - buffers[0], - wd.format, - wd.data, - wd.size, - wd.freq - ); - int[] size = null; - al.alGetBufferi(buffers[0],AL.AL_SIZE, size, 0); - - } catch (IllegalArgumentException e) { - ex = e; - } catch (UnsupportedAudioFileException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - - assertNotNull(ex); - - System.out.println("end testAlGetBufferiintintintArray"); - } - - /* - * Test for void alGetBufferi(int, int, IntBuffer) - */ - final public void testAlGetBufferiintintIntBuffer() { - try { - int[] buffers = new int[1]; - al.alGenBuffers(1, buffers, 0); - WAVData wd = - WAVLoader.loadFromFile(TEST_FILE); - al.alBufferData( - buffers[0], - wd.format, - wd.data, - wd.size, - wd.freq - ); - int[] size = new int[1]; - int[] freq = new int[1]; - al.alGetBufferi(buffers[0],AL.AL_SIZE, size, 0); - al.alGetBufferi(buffers[0],AL.AL_FREQUENCY, freq, 0); - assertEquals(wd.size, size[0]); - assertEquals(wd.freq, freq[0]); - } catch(Exception e) { - fail(e.toString()); - } - Exception ex = null; - try { - int[] buffers = new int[1]; - al.alGenBuffers(1, buffers, 0); - WAVData wd = - WAVLoader.loadFromFile(TEST_FILE); - al.alBufferData( - buffers[0], - wd.format, - wd.data, - wd.size, - wd.freq - ); - int[] size = null; - al.alGetBufferi(buffers[0],AL.AL_SIZE, size, 0); - - } catch (IllegalArgumentException e) { - ex = e; - } catch (UnsupportedAudioFileException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - - assertNotNull(ex); - ex = null; - try { - int[] buffers = new int[1]; - al.alGenBuffers(1, buffers, 0); - WAVData wd = - WAVLoader.loadFromFile(TEST_FILE); - al.alBufferData( - buffers[0], - wd.format, - wd.data, - wd.size, - wd.freq - ); - int[] size = new int[1]; - al.alGetBufferi(buffers[0],AL.AL_SIZE, size, 0); - - } catch (IllegalArgumentException e) { - ex = e; - } catch (UnsupportedAudioFileException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - -// assertNotNull(ex); - } - - /* - * Test for int alGetBufferi(int, int) - */ - final public void testAlGetBufferiintint() { - //TODO Implement alGetBufferi(). - } - - /* - * Test for void alGenSources(int, int[]) - */ - final public void testAlGenSourcesintintArray() { - //TODO Implement alGenSources(). - } - - /* - * Test for void alGenSources(int, IntBuffer) - */ - final public void testAlGenSourcesintIntBuffer() { - //TODO Implement alGenSources(). - } - - /* - * Test for void alDeleteSources(int, int[]) - */ - final public void testAlDeleteSourcesintintArray() { - //TODO Implement alDeleteSources(). - } - - /* - * Test for void alDeleteSources(int, IntBuffer) - */ - final public void testAlDeleteSourcesintIntBuffer() { - //TODO Implement alDeleteSources(). - } - - final public void testAlIsSource() { - //TODO Implement alIsSource(). - } - - final public void testAlSourcei() { - //TODO Implement alSourcei(). - } - - final public void testAlSourcef() { - //TODO Implement alSourcef(). - } - - /* - * Test for void alSourcefv(int, int, float[]) - */ - final public void testAlSourcefvintintfloatArray() { - //TODO Implement alSourcefv(). - } - - /* - * Test for void alSourcefv(int, int, FloatBuffer) - */ - final public void testAlSourcefvintintFloatBuffer() { - //TODO Implement alSourcefv(). - } - - final public void testAlSource3f() { - //TODO Implement alSource3f(). - } - - /* - * Test for void alGetSourcef(int, int, float[]) - */ - final public void testAlGetSourcefintintfloatArray() { - //TODO Implement alGetSourcef(). - } - - /* - * Test for void alGetSourcef(int, int, FloatBuffer) - */ - final public void testAlGetSourcefintintFloatBuffer() { - //TODO Implement alGetSourcef(). - } - - /* - * Test for float alGetSourcef(int, int) - */ - final public void testAlGetSourcefintint() { - //TODO Implement alGetSourcef(). - } - - /* - * Test for void alGetSourcefv(int, int, FloatBuffer) - */ - final public void testAlGetSourcefvintintFloatBuffer() { - //TODO Implement alGetSourcefv(). - } - - /* - * Test for void alGetSourcefv(int, int, float[]) - */ - final public void testAlGetSourcefvintintfloatArray() { - //TODO Implement alGetSourcefv(). - } - - /* - * Test for void alGetSourcei(int, int, int[]) - */ - final public void testAlGetSourceiintintintArray() { - //TODO Implement alGetSourcei(). - } - - /* - * Test for void alGetSourcei(int, int, IntBuffer) - */ - final public void testAlGetSourceiintintIntBuffer() { - //TODO Implement alGetSourcei(). - } - - /* - * Test for int alGetSourcei(int, int) - */ - final public void testAlGetSourceiintint() { - //TODO Implement alGetSourcei(). - } - - final public void testAlSourcePlay() { - //TODO Implement alSourcePlay(). - } - - /* - * Test for void alSourcePlayv(int, IntBuffer) - */ - final public void testAlSourcePlayvintIntBuffer() { - //TODO Implement alSourcePlayv(). - } - - /* - * Test for void alSourcePlayv(int, int[]) - */ - final public void testAlSourcePlayvintintArray() { - //TODO Implement alSourcePlayv(). - } - - final public void testAlSourcePause() { - //TODO Implement alSourcePause(). - } - - /* - * Test for void alSourcePausev(int, int[]) - */ - final public void testAlSourcePausevintintArray() { - //TODO Implement alSourcePausev(). - } - - /* - * Test for void alSourcePausev(int, IntBuffer) - */ - final public void testAlSourcePausevintIntBuffer() { - //TODO Implement alSourcePausev(). - } - - final public void testAlSourceStop() { - //TODO Implement alSourceStop(). - } - - /* - * Test for void alSourceStopv(int, int[]) - */ - final public void testAlSourceStopvintintArray() { - //TODO Implement alSourceStopv(). - } - - /* - * Test for void alSourceStopv(int, IntBuffer) - */ - final public void testAlSourceStopvintIntBuffer() { - //TODO Implement alSourceStopv(). - } - - final public void testAlSourceRewind() { - //TODO Implement alSourceRewind(). - } - - /* - * Test for void alSourceRewindv(int, int[]) - */ - final public void testAlSourceRewindvintintArray() { - //TODO Implement alSourceRewindv(). - } - - /* - * Test for void alSourceRewindv(int, IntBuffer) - */ - final public void testAlSourceRewindvintIntBuffer() { - //TODO Implement alSourceRewindv(). - } - - /* - * Test for void alSourceQueueBuffers(int, int, int[]) - */ - final public void testAlSourceQueueBuffersintintintArray() { - //TODO Implement alSourceQueueBuffers(). - } - - /* - * Test for void alSourceQueueBuffers(int, int, IntBuffer) - */ - final public void testAlSourceQueueBuffersintintIntBuffer() { - //TODO Implement alSourceQueueBuffers(). - } - - /* - * Test for void alSourceUnqueueBuffers(int, int, int[]) - */ - final public void testAlSourceUnqueueBuffersintintintArray() { - //TODO Implement alSourceUnqueueBuffers(). - } - - /* - * Test for void alSourceUnqueueBuffers(int, int, IntBuffer) - */ - final public void testAlSourceUnqueueBuffersintintIntBuffer() { - //TODO Implement alSourceUnqueueBuffers(). - } - - final public void testAlListenerf() { - //TODO Implement alListenerf(). - } - - final public void testAlListener3f() { - //TODO Implement alListener3f(). - } - - /* - * Test for void alListenerfv(int, float[]) - */ - final public void testAlListenerfvintfloatArray() { - //TODO Implement alListenerfv(). - } - - /* - * Test for void alListenerfv(int, FloatBuffer) - */ - final public void testAlListenerfvintFloatBuffer() { - //TODO Implement alListenerfv(). - } - - final public void testAlListeneri() { - //TODO Implement alListeneri(). - } - - /* - * Test for void alGetListenerf(int, float[]) - */ - final public void testAlGetListenerfintfloatArray() { - //TODO Implement alGetListenerf(). - } - - /* - * Test for void alGetListenerf(int, FloatBuffer) - */ - final public void testAlGetListenerfintFloatBuffer() { - //TODO Implement alGetListenerf(). - } - - /* - * Test for float alGetListenerf(int) - */ - final public void testAlGetListenerfint() { - //TODO Implement alGetListenerf(). - } - - /* - * Test for void alGetListener3f(int, FloatBuffer, FloatBuffer, FloatBuffer) - */ - final public void testAlGetListener3fintFloatBufferFloatBufferFloatBuffer() { - //TODO Implement alGetListener3f(). - } - - /* - * Test for void alGetListener3f(int, float[], float[], float[]) - */ - final public void testAlGetListener3fintfloatArrayfloatArrayfloatArray() { - //TODO Implement alGetListener3f(). - } - - /* - * Test for void alGetListenerfv(int, float[]) - */ - final public void testAlGetListenerfvintfloatArray() { - //TODO Implement alGetListenerfv(). - } - - /* - * Test for void alGetListenerfv(int, FloatBuffer) - */ - final public void testAlGetListenerfvintFloatBuffer() { - //TODO Implement alGetListenerfv(). - } - - /* - * Test for void alGetListeneri(int, int[]) - */ - final public void testAlGetListeneriintintArray() { - //TODO Implement alGetListeneri(). - } - - /* - * Test for void alGetListeneri(int, IntBuffer) - */ - final public void testAlGetListeneriintIntBuffer() { - //TODO Implement alGetListeneri(). - } - - /* - * Test for int alGetListeneri(int) - */ - final public void testAlGetListeneriint() { - //TODO Implement alGetListeneri(). - } - - final public void testAlEnable() { - //TODO Implement alEnable(). - } - - final public void testAlDisable() { - //TODO Implement alDisable(). - } - - final public void testAlIsEnabled() { - //TODO Implement alIsEnabled(). - } - - final public void testAlGetBoolean() { - //TODO Implement alGetBoolean(). - } - - final public void testAlGetDouble() { - //TODO Implement alGetDouble(). - } - - final public void testAlGetFloat() { - //TODO Implement alGetFloat(). - } - - final public void testAlGetInteger() { - //TODO Implement alGetInteger(). - } - - /* - * Test for void alGetDoublev(int, DoubleBuffer) - */ - final public void testAlGetDoublevintDoubleBuffer() { - //TODO Implement alGetDoublev(). - } - - /* - * Test for void alGetDoublev(int, double[]) - */ - final public void testAlGetDoublevintdoubleArray() { - //TODO Implement alGetDoublev(). - } - - /* - * Test for void alGetFloatv(int, FloatBuffer) - */ - final public void testAlGetFloatvintFloatBuffer() { - //TODO Implement alGetFloatv(). - } - - /* - * Test for void alGetFloatv(int, float[]) - */ - final public void testAlGetFloatvintfloatArray() { - //TODO Implement alGetFloatv(). - } - - /* - * Test for void alGetIntegerv(int, IntBuffer) - */ - final public void testAlGetIntegervintIntBuffer() { - //TODO Implement alGetIntegerv(). - } - - /* - * Test for void alGetIntegerv(int, int[]) - */ - final public void testAlGetIntegervintintArray() { - //TODO Implement alGetIntegerv(). - } - - final public void testAlGetString() { - //TODO Implement alGetString(). - } - - final public void testAlDistanceModel() { - //TODO Implement alDistanceModel(). - } - - final public void testAlDopplerFactor() { - //TODO Implement alDopplerFactor(). - } - - final public void testAlDopplerVelocity() { - //TODO Implement alDopplerVelocity(). - } - - final public void testAlGetError() { - //TODO Implement alGetError(). - } - - final public void testAlIsExtensionPresent() { - //TODO Implement alIsExtensionPresent(). - } - - final public void testAlGetEnumValue() { - //TODO Implement alGetEnumValue(). - } - -} -- cgit v1.2.3