mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-05 14:35:58 +00:00
OpenAL / EAX Refactor
This commit is contained in:
parent
2e7df4d4ce
commit
3fe2d6cb69
35 changed files with 1686 additions and 1710 deletions
|
|
@ -31,6 +31,13 @@
|
|||
*/
|
||||
package org.lwjgl.openal;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.lwjgl.Display;
|
||||
import org.lwjgl.Sys;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
* <br>
|
||||
|
|
@ -39,7 +46,7 @@ package org.lwjgl.openal;
|
|||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
*/
|
||||
public abstract class AL extends CoreAL {
|
||||
public abstract class AL {
|
||||
|
||||
/** ALC instance. */
|
||||
protected static ALC alc;
|
||||
|
|
@ -53,7 +60,8 @@ public abstract class AL extends CoreAL {
|
|||
/**
|
||||
* String that requests a certain device or device configuration.
|
||||
* If null is specified, the implementation will provide an
|
||||
* implementation specific default. */
|
||||
* implementation specific default.
|
||||
*/
|
||||
protected static String deviceArguments;
|
||||
|
||||
/** Frequency for mixing output buffer, in units of Hz. */
|
||||
|
|
@ -65,6 +73,40 @@ public abstract class AL extends CoreAL {
|
|||
/** Flag, indicating a synchronous context. */
|
||||
protected static int contextSynchronized = ALC.ALC_FALSE;
|
||||
|
||||
/** Have we been created? */
|
||||
protected static boolean created;
|
||||
|
||||
static {
|
||||
initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Static initialization
|
||||
*/
|
||||
private static void initialize() {
|
||||
System.loadLibrary(org.lwjgl.Sys.getLibraryName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Native method to create AL instance
|
||||
*
|
||||
* @param oalPaths Array of strings containing paths to search for OpenAL library
|
||||
* @return true if the AL creation process succeeded
|
||||
*/
|
||||
protected static native void nCreate(String[] oalPaths) throws OpenALException;
|
||||
|
||||
/**
|
||||
* Native method the destroy the AL
|
||||
*/
|
||||
protected static native void nDestroy();
|
||||
|
||||
/**
|
||||
* @return true if AL has been created
|
||||
*/
|
||||
public static boolean isCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an OpenAL instance. Using this constructor will cause OpenAL to
|
||||
* open the device using supplied device argument, and create a context using the context values
|
||||
|
|
@ -99,10 +141,52 @@ public abstract class AL extends CoreAL {
|
|||
if(created) {
|
||||
return;
|
||||
}
|
||||
|
||||
BaseAL.create();
|
||||
|
||||
ALC.create();
|
||||
// need to pass path of possible locations of OAL to native side
|
||||
String libpath = System.getProperty("java.library.path");
|
||||
String seperator = System.getProperty("path.separator");
|
||||
String libname;
|
||||
String jwsLibname;
|
||||
|
||||
// libname is hardcoded atm - this will change in a near future...
|
||||
switch (Display.getPlatform()) {
|
||||
case Display.PLATFORM_WGL:
|
||||
libname = "lwjglaudio.dll";
|
||||
jwsLibname = "lwjglaudio";
|
||||
break;
|
||||
case Display.PLATFORM_GLX:
|
||||
libname = "libopenal.so";
|
||||
jwsLibname = "openal";
|
||||
break;
|
||||
case Display.PLATFORM_AGL:
|
||||
libname = "openal.dylib";
|
||||
jwsLibname = "openal";
|
||||
break;
|
||||
default:
|
||||
throw new OpenALException("Unknown platform");
|
||||
}
|
||||
|
||||
String jwsPath = getPathFromJWS(jwsLibname);
|
||||
if (jwsPath != null) {
|
||||
libpath += seperator
|
||||
+ jwsPath.substring(0, jwsPath.lastIndexOf(File.separator));
|
||||
}
|
||||
|
||||
StringTokenizer st = new StringTokenizer(libpath, seperator);
|
||||
|
||||
//create needed string array
|
||||
String[] oalPaths = new String[st.countTokens() + 1];
|
||||
|
||||
//build paths
|
||||
for (int i = 0; i < oalPaths.length - 1; i++) {
|
||||
oalPaths[i] = st.nextToken() + File.separator + libname;
|
||||
}
|
||||
|
||||
//add cwd path
|
||||
oalPaths[oalPaths.length - 1] = libname;
|
||||
nCreate(oalPaths);
|
||||
|
||||
ALC.create();
|
||||
|
||||
device = ALC.alcOpenDevice(deviceArguments);
|
||||
|
||||
|
|
@ -118,6 +202,7 @@ public abstract class AL extends CoreAL {
|
|||
|
||||
ALC.alcMakeContextCurrent(context.context);
|
||||
|
||||
created = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -140,7 +225,36 @@ public abstract class AL extends CoreAL {
|
|||
contextFrequency = -1;
|
||||
contextRefresh = -1;
|
||||
contextSynchronized = ALC.ALC_FALSE;
|
||||
|
||||
BaseAL.destroy();
|
||||
|
||||
created = false;
|
||||
nDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to locate OpenAL from the JWS Library path
|
||||
* This method exists because OpenAL is loaded from native code, and as such
|
||||
* is exempt from JWS library loading rutines. OpenAL therefore always fails.
|
||||
* We therefore invoke the protected method of the JWS classloader to see if it can
|
||||
* locate it.
|
||||
*
|
||||
* @param libname Name of library to search for
|
||||
* @return Absolute path to library if found, otherwise null
|
||||
*/
|
||||
private static String getPathFromJWS(String libname) {
|
||||
try {
|
||||
|
||||
Sys.log("JWS Classloader looking for: " + libname);
|
||||
|
||||
Object o = AL.class.getClassLoader();
|
||||
Class c = o.getClass();
|
||||
Method findLibrary =
|
||||
c.getMethod("findLibrary", new Class[] { String.class });
|
||||
Object[] arguments = new Object[] { libname };
|
||||
return (String) findLibrary.invoke(o, arguments);
|
||||
|
||||
} catch (Exception e) {
|
||||
Sys.log("Failure locating OpenAL using classloader:" + e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -43,7 +43,317 @@ import java.nio.IntBuffer;
|
|||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
*/
|
||||
public abstract class CoreAL extends BaseAL implements BaseALConstants {
|
||||
public final class AL10 {
|
||||
|
||||
/** Bad value */
|
||||
public static final int AL_INVALID = -1;
|
||||
|
||||
/** Disable value */
|
||||
public static final int AL_NONE = 0;
|
||||
|
||||
/** Boolean False */
|
||||
public static final int AL_FALSE = 0;
|
||||
|
||||
/** Boolean True */
|
||||
public static final int AL_TRUE = 1;
|
||||
|
||||
/**
|
||||
* Indicate the type of SOURCE.
|
||||
* Sources can be spatialized
|
||||
*/
|
||||
public static final int AL_SOURCE_TYPE = 0x200;
|
||||
|
||||
/** Indicate source has absolute coordinates */
|
||||
public static final int AL_SOURCE_ABSOLUTE = 0x201;
|
||||
|
||||
/** Indicate Source has listener relative coordinates */
|
||||
public static final int AL_SOURCE_RELATIVE = 0x202;
|
||||
|
||||
/**
|
||||
* Directional source, inner cone angle, in degrees
|
||||
* Range: [0-360]
|
||||
* Default: 360
|
||||
*/
|
||||
public static final int AL_CONE_INNER_ANGLE = 0x1001;
|
||||
|
||||
/**
|
||||
* Directional source, outer cone angle, in degrees.
|
||||
* Range: [0-360]
|
||||
* Default: 360
|
||||
*/
|
||||
public static final int AL_CONE_OUTER_ANGLE = 0x1002;
|
||||
|
||||
/**
|
||||
* Specify the pitch to be applied, either at source,
|
||||
* or on mixer results, at listener.
|
||||
* Range: [0.5-2.0]
|
||||
* Default: 1.0
|
||||
*/
|
||||
public static final int AL_PITCH = 0x1003;
|
||||
|
||||
/**
|
||||
* Specify the current location in three dimensional space.
|
||||
* OpenAL, like OpenGL, uses a right handed coordinate system,
|
||||
* where in a frontal default view X (thumb) points right,
|
||||
* Y points up (index finger), and Z points towards the
|
||||
* viewer/camera (middle finger).
|
||||
* To switch from a left handed coordinate system, flip the
|
||||
* sign on the Z coordinate.
|
||||
* Listener position is always in the world coordinate system.
|
||||
*/
|
||||
public static final int AL_POSITION = 0x1004;
|
||||
|
||||
/** Specify the current direction as forward vector. */
|
||||
public static final int AL_DIRECTION = 0x1005;
|
||||
|
||||
/** Specify the current velocity in three dimensional space. */
|
||||
public static final int AL_VELOCITY = 0x1006;
|
||||
|
||||
/**
|
||||
* Indicate whether source has to loop infinite.
|
||||
* Type: ALboolean
|
||||
* Range: [TRUE, FALSE]
|
||||
* Default: FALSE
|
||||
*/
|
||||
public static final int AL_LOOPING = 0x1007;
|
||||
|
||||
/**
|
||||
* Indicate the buffer to provide sound samples.
|
||||
* Type: ALuint.
|
||||
* Range: any valid Buffer id.
|
||||
*/
|
||||
public static final int AL_BUFFER = 0x1009;
|
||||
|
||||
/**
|
||||
* Indicate the gain (volume amplification) applied.
|
||||
* Type: ALfloat.
|
||||
* Range: ]0.0- ]
|
||||
* A value of 1.0 means un-attenuated/unchanged.
|
||||
* Each division by 2 equals an attenuation of -6dB.
|
||||
* Each multiplicaton with 2 equals an amplification of +6dB.
|
||||
* A value of 0.0 is meaningless with respect to a logarithmic
|
||||
* scale; it is interpreted as zero volume - the channel
|
||||
* is effectively disabled.
|
||||
*/
|
||||
public static final int AL_GAIN = 0x100A;
|
||||
|
||||
/**
|
||||
* Indicate minimum source attenuation.
|
||||
* Type: ALfloat
|
||||
* Range: [0.0 - 1.0]
|
||||
*/
|
||||
public static final int AL_MIN_GAIN = 0x100D;
|
||||
|
||||
/**
|
||||
* Indicate maximum source attenuation.
|
||||
* Type: ALfloat
|
||||
* Range: [0.0 - 1.0]
|
||||
*/
|
||||
public static final int AL_MAX_GAIN = 0x100E;
|
||||
|
||||
/**
|
||||
* Specify the current orientation.
|
||||
* Type: ALfv6 (at/up)
|
||||
* Range: N/A
|
||||
*/
|
||||
public static final int AL_ORIENTATION = 0x100F;
|
||||
|
||||
/* byte offset into source (in canon format). -1 if source
|
||||
* is not playing. Don't set this, get this.
|
||||
*
|
||||
* Type: ALfloat
|
||||
* Range: [0.0 - ]
|
||||
* Default: 1.0
|
||||
*/
|
||||
public static final int AL_REFERENCE_DISTANCE = 0x1020;
|
||||
|
||||
/**
|
||||
* Indicate the rolloff factor for the source.
|
||||
* Type: ALfloat
|
||||
* Range: [0.0 - ]
|
||||
* Default: 1.0
|
||||
*/
|
||||
public static final int AL_ROLLOFF_FACTOR = 0x1021;
|
||||
|
||||
/**
|
||||
* Indicate the gain (volume amplification) applied.
|
||||
* Type: ALfloat.
|
||||
* Range: ]0.0- ]
|
||||
* A value of 1.0 means un-attenuated/unchanged.
|
||||
* Each division by 2 equals an attenuation of -6dB.
|
||||
* Each multiplicaton with 2 equals an amplification of +6dB.
|
||||
* A value of 0.0 is meaningless with respect to a logarithmic
|
||||
* scale; it is interpreted as zero volume - the channel
|
||||
* is effectively disabled.
|
||||
*/
|
||||
public static final int AL_CONE_OUTER_GAIN = 0x1022;
|
||||
|
||||
/**
|
||||
* Specify the maximum distance.
|
||||
* Type: ALfloat
|
||||
* Range: [0.0 - ]
|
||||
*/
|
||||
public static final int AL_MAX_DISTANCE = 0x1023;
|
||||
|
||||
/**
|
||||
* Specify the channel mask. (Creative)
|
||||
* Type: ALuint
|
||||
* Range: [0 - 255]
|
||||
*/
|
||||
public static final int AL_CHANNEL_MASK = 0x3000;
|
||||
|
||||
/** Source state information */
|
||||
public static final int AL_SOURCE_STATE = 0x1010;
|
||||
|
||||
/** Source state information */
|
||||
public static final int AL_INITIAL = 0x1011;
|
||||
|
||||
/** Source state information */
|
||||
public static final int AL_PLAYING = 0x1012;
|
||||
|
||||
/** Source state information */
|
||||
public static final int AL_PAUSED = 0x1013;
|
||||
|
||||
/** Source state information */
|
||||
public static final int AL_STOPPED = 0x1014;
|
||||
|
||||
/** Buffer Queue params */
|
||||
public static final int AL_BUFFERS_QUEUED = 0x1015;
|
||||
|
||||
/** Buffer Queue params */
|
||||
public static final int AL_BUFFERS_PROCESSED = 0x1016;
|
||||
|
||||
/** Sound buffers: format specifier. */
|
||||
public static final int AL_FORMAT_MONO8 = 0x1100;
|
||||
|
||||
/** Sound buffers: format specifier. */
|
||||
public static final int AL_FORMAT_MONO16 = 0x1101;
|
||||
|
||||
/** Sound buffers: format specifier. */
|
||||
public static final int AL_FORMAT_STEREO8 = 0x1102;
|
||||
|
||||
/** Sound buffers: format specifier. */
|
||||
public static final int AL_FORMAT_STEREO16 = 0x1103;
|
||||
|
||||
/** Ogg Vorbis format specifier. */
|
||||
public static final int AL_FORMAT_VORBIS_EXT = 0x10003;
|
||||
|
||||
/**
|
||||
* Sound buffers: frequency, in units of Hertz [Hz].
|
||||
* This is the number of samples per second. Half of the
|
||||
* sample frequency marks the maximum significant
|
||||
* frequency component.
|
||||
*/
|
||||
public static final int AL_FREQUENCY = 0x2001;
|
||||
|
||||
/**
|
||||
* Sound buffers: frequency, in units of Hertz [Hz].
|
||||
* This is the number of samples per second. Half of the
|
||||
* sample frequency marks the maximum significant
|
||||
* frequency component.
|
||||
*/
|
||||
public static final int AL_BITS = 0x2002;
|
||||
|
||||
/**
|
||||
* Sound buffers: frequency, in units of Hertz [Hz].
|
||||
* This is the number of samples per second. Half of the
|
||||
* sample frequency marks the maximum significant
|
||||
* frequency component.
|
||||
*/
|
||||
public static final int AL_CHANNELS = 0x2003;
|
||||
|
||||
/**
|
||||
* Sound buffers: frequency, in units of Hertz [Hz].
|
||||
* This is the number of samples per second. Half of the
|
||||
* sample frequency marks the maximum significant
|
||||
* frequency component.
|
||||
*/
|
||||
public static final int AL_SIZE = 0x2004;
|
||||
|
||||
/**
|
||||
* Sound buffers: frequency, in units of Hertz [Hz].
|
||||
* This is the number of samples per second. Half of the
|
||||
* sample frequency marks the maximum significant
|
||||
* frequency component.
|
||||
*/
|
||||
public static final int AL_DATA = 0x2005;
|
||||
|
||||
/**
|
||||
* Buffer state.
|
||||
*
|
||||
* Not supported for public use (yet).
|
||||
*/
|
||||
public static final int AL_UNUSED = 0x2010;
|
||||
|
||||
/**
|
||||
* Buffer state.
|
||||
*
|
||||
* Not supported for public use (yet).
|
||||
*/
|
||||
public static final int AL_PENDING = 0x2011;
|
||||
|
||||
/**
|
||||
* Buffer state.
|
||||
*
|
||||
* Not supported for public use (yet).
|
||||
*/
|
||||
public static final int AL_PROCESSED = 0x2012;
|
||||
|
||||
/** Errors: No Error. */
|
||||
public static final int AL_NO_ERROR = AL_FALSE;
|
||||
|
||||
/** Illegal name passed as an argument to an AL call. */
|
||||
public static final int AL_INVALID_NAME = 0xA001;
|
||||
|
||||
/** Illegal enum passed as an argument to an AL call. */
|
||||
public static final int AL_INVALID_ENUM = 0xA002;
|
||||
|
||||
/**
|
||||
* Illegal value passed as an argument to an AL call.
|
||||
* Applies to parameter values, but not to enumerations.
|
||||
*/
|
||||
public static final int AL_INVALID_VALUE = 0xA003;
|
||||
|
||||
/**
|
||||
* A function was called at inappropriate time,
|
||||
* or in an inappropriate way, causing an illegal state.
|
||||
* This can be an incompatible ALenum, object ID,
|
||||
* and/or function.
|
||||
*/
|
||||
public static final int AL_INVALID_OPERATION = 0xA004;
|
||||
|
||||
/**
|
||||
* A function could not be completed,
|
||||
* because there is not enough memory available.
|
||||
*/
|
||||
public static final int AL_OUT_OF_MEMORY = 0xA005;
|
||||
|
||||
/** Context strings: Vendor */
|
||||
public static final int AL_VENDOR = 0xB001;
|
||||
|
||||
/** Context strings: Version */
|
||||
public static final int AL_VERSION = 0xB002;
|
||||
|
||||
/** Context strings: Renderer */
|
||||
public static final int AL_RENDERER = 0xB003;
|
||||
|
||||
/** Context strings: Extensions */
|
||||
public static final int AL_EXTENSIONS = 0xB004;
|
||||
|
||||
/** Doppler scale. Default 1.0 */
|
||||
public static final int AL_DOPPLER_FACTOR = 0xC000;
|
||||
|
||||
/** Doppler velocity. Default 1.0 */
|
||||
public static final int AL_DOPPLER_VELOCITY = 0xC001;
|
||||
|
||||
/** Distance model. Default INVERSE_DISTANCE_CLAMPED */
|
||||
public static final int AL_DISTANCE_MODEL = 0xD000;
|
||||
|
||||
/** Distance model */
|
||||
public static final int AL_INVERSE_DISTANCE = 0xD001;
|
||||
|
||||
/** Distance model */
|
||||
public static final int AL_INVERSE_DISTANCE_CLAMPED = 0xD002;
|
||||
|
||||
/**
|
||||
* The application can temporarily disable certain AL capabilities on a per Context
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2002 Lightweight Java Game Library Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'Light Weight Java Game Library' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.lwjgl.openal;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
* <br>
|
||||
* This class contains all OpenAL constants, including extensions.
|
||||
*
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
*/
|
||||
public interface ALConstants extends BaseALConstants {
|
||||
}
|
||||
|
|
@ -1,191 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2002 Lightweight Java Game Library Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'Light Weight Java Game Library' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.lwjgl.openal;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.lwjgl.Display;
|
||||
import org.lwjgl.Sys;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
* <br>
|
||||
* The base AL functionality (no actual AL methods).
|
||||
*
|
||||
* This has been provided as a base class that we can use for either the
|
||||
* full AL 1.0 specification or as a cut-down OpenAL embedded spec. (aka
|
||||
* a mini-driver).
|
||||
*
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
*/
|
||||
public abstract class BaseAL {
|
||||
/** Have we been created? */
|
||||
protected static boolean created;
|
||||
|
||||
static {
|
||||
initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Override to provide any initialization code after creation.
|
||||
*/
|
||||
protected static void init() throws OpenALException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Static initialization
|
||||
*/
|
||||
private static void initialize() {
|
||||
System.loadLibrary(org.lwjgl.Sys.getLibraryName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the AL instance
|
||||
*
|
||||
* @throws Exception if a failiure occured in the AL creation process
|
||||
*/
|
||||
public static void create() throws OpenALException {
|
||||
if (created) {
|
||||
return;
|
||||
}
|
||||
|
||||
// need to pass path of possible locations of OAL to native side
|
||||
String libpath = System.getProperty("java.library.path");
|
||||
String seperator = System.getProperty("path.separator");
|
||||
String libname;
|
||||
String jwsLibname;
|
||||
|
||||
// libname is hardcoded atm - this will change in a near future...
|
||||
switch (Display.getPlatform()) {
|
||||
case Display.PLATFORM_WGL:
|
||||
libname = "lwjglaudio.dll";
|
||||
jwsLibname = "lwjglaudio";
|
||||
break;
|
||||
case Display.PLATFORM_GLX:
|
||||
libname = "libopenal.so";
|
||||
jwsLibname = "openal";
|
||||
break;
|
||||
case Display.PLATFORM_AGL:
|
||||
libname = "openal.dylib";
|
||||
jwsLibname = "openal";
|
||||
break;
|
||||
default:
|
||||
throw new OpenALException("Unknown platform");
|
||||
}
|
||||
|
||||
String jwsPath = getPathFromJWS(jwsLibname);
|
||||
if (jwsPath != null) {
|
||||
libpath += seperator
|
||||
+ jwsPath.substring(0, jwsPath.lastIndexOf(File.separator));
|
||||
}
|
||||
|
||||
StringTokenizer st = new StringTokenizer(libpath, seperator);
|
||||
|
||||
//create needed string array
|
||||
String[] oalPaths = new String[st.countTokens() + 1];
|
||||
|
||||
//build paths
|
||||
for (int i = 0; i < oalPaths.length - 1; i++) {
|
||||
oalPaths[i] = st.nextToken() + File.separator + libname;
|
||||
}
|
||||
|
||||
//add cwd path
|
||||
oalPaths[oalPaths.length - 1] = libname;
|
||||
nCreate(oalPaths);
|
||||
|
||||
init();
|
||||
created = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to locate OpenAL from the JWS Library path
|
||||
* This method exists because OpenAL is loaded from native code, and as such
|
||||
* is exempt from JWS library loading rutines. OpenAL therefore always fails.
|
||||
* We therefore invoke the protected method of the JWS classloader to see if it can
|
||||
* locate it.
|
||||
*
|
||||
* @param libname Name of library to search for
|
||||
* @return Absolute path to library if found, otherwise null
|
||||
*/
|
||||
private static String getPathFromJWS(String libname) {
|
||||
try {
|
||||
|
||||
Sys.log("JWS Classloader looking for: " + libname);
|
||||
|
||||
Object o = BaseAL.class.getClassLoader();
|
||||
Class c = o.getClass();
|
||||
Method findLibrary =
|
||||
c.getMethod("findLibrary", new Class[] { String.class });
|
||||
Object[] arguments = new Object[] { libname };
|
||||
return (String) findLibrary.invoke(o, arguments);
|
||||
|
||||
} catch (Exception e) {
|
||||
Sys.log("Failure locating OpenAL using classloader:" + e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Native method to create AL instance
|
||||
*
|
||||
* @param oalPaths Array of strings containing paths to search for OpenAL library
|
||||
* @return true if the AL creation process succeeded
|
||||
*/
|
||||
protected static native void nCreate(String[] oalPaths) throws OpenALException;
|
||||
|
||||
/**
|
||||
* Calls whatever destruction rutines that are needed
|
||||
*/
|
||||
public static void destroy() {
|
||||
if (!created) {
|
||||
return;
|
||||
}
|
||||
created = false;
|
||||
nDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Native method the destroy the AL
|
||||
*/
|
||||
protected static native void nDestroy();
|
||||
|
||||
|
||||
/**
|
||||
* @return true if AL has been created
|
||||
*/
|
||||
public static boolean isCreated() {
|
||||
return created;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,353 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2002 Lightweight Java Game Library Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'Light Weight Java Game Library' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.lwjgl.openal;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
* <br>
|
||||
* This class implements all basic OpenAL constants.
|
||||
*
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
*/
|
||||
public interface BaseALConstants {
|
||||
|
||||
/** Bad value */
|
||||
public static final int AL_INVALID = -1;
|
||||
|
||||
/** Disable value */
|
||||
public static final int AL_NONE = 0;
|
||||
|
||||
/** Boolean False */
|
||||
public static final int AL_FALSE = 0;
|
||||
|
||||
/** Boolean True */
|
||||
public static final int AL_TRUE = 1;
|
||||
|
||||
/**
|
||||
* Indicate the type of SOURCE.
|
||||
* Sources can be spatialized
|
||||
*/
|
||||
public static final int AL_SOURCE_TYPE = 0x200;
|
||||
|
||||
/** Indicate source has absolute coordinates */
|
||||
public static final int AL_SOURCE_ABSOLUTE = 0x201;
|
||||
|
||||
/** Indicate Source has listener relative coordinates */
|
||||
public static final int AL_SOURCE_RELATIVE = 0x202;
|
||||
|
||||
/**
|
||||
* Directional source, inner cone angle, in degrees
|
||||
* Range: [0-360]
|
||||
* Default: 360
|
||||
*/
|
||||
public static final int AL_CONE_INNER_ANGLE = 0x1001;
|
||||
|
||||
/**
|
||||
* Directional source, outer cone angle, in degrees.
|
||||
* Range: [0-360]
|
||||
* Default: 360
|
||||
*/
|
||||
public static final int AL_CONE_OUTER_ANGLE = 0x1002;
|
||||
|
||||
/**
|
||||
* Specify the pitch to be applied, either at source,
|
||||
* or on mixer results, at listener.
|
||||
* Range: [0.5-2.0]
|
||||
* Default: 1.0
|
||||
*/
|
||||
public static final int AL_PITCH = 0x1003;
|
||||
|
||||
/**
|
||||
* Specify the current location in three dimensional space.
|
||||
* OpenAL, like OpenGL, uses a right handed coordinate system,
|
||||
* where in a frontal default view X (thumb) points right,
|
||||
* Y points up (index finger), and Z points towards the
|
||||
* viewer/camera (middle finger).
|
||||
* To switch from a left handed coordinate system, flip the
|
||||
* sign on the Z coordinate.
|
||||
* Listener position is always in the world coordinate system.
|
||||
*/
|
||||
public static final int AL_POSITION = 0x1004;
|
||||
|
||||
/** Specify the current direction as forward vector. */
|
||||
public static final int AL_DIRECTION = 0x1005;
|
||||
|
||||
/** Specify the current velocity in three dimensional space. */
|
||||
public static final int AL_VELOCITY = 0x1006;
|
||||
|
||||
/**
|
||||
* Indicate whether source has to loop infinite.
|
||||
* Type: ALboolean
|
||||
* Range: [TRUE, FALSE]
|
||||
* Default: FALSE
|
||||
*/
|
||||
public static final int AL_LOOPING = 0x1007;
|
||||
|
||||
/**
|
||||
* Indicate the buffer to provide sound samples.
|
||||
* Type: ALuint.
|
||||
* Range: any valid Buffer id.
|
||||
*/
|
||||
public static final int AL_BUFFER = 0x1009;
|
||||
|
||||
/**
|
||||
* Indicate the gain (volume amplification) applied.
|
||||
* Type: ALfloat.
|
||||
* Range: ]0.0- ]
|
||||
* A value of 1.0 means un-attenuated/unchanged.
|
||||
* Each division by 2 equals an attenuation of -6dB.
|
||||
* Each multiplicaton with 2 equals an amplification of +6dB.
|
||||
* A value of 0.0 is meaningless with respect to a logarithmic
|
||||
* scale; it is interpreted as zero volume - the channel
|
||||
* is effectively disabled.
|
||||
*/
|
||||
public static final int AL_GAIN = 0x100A;
|
||||
|
||||
/**
|
||||
* Indicate minimum source attenuation.
|
||||
* Type: ALfloat
|
||||
* Range: [0.0 - 1.0]
|
||||
*/
|
||||
public static final int AL_MIN_GAIN = 0x100D;
|
||||
|
||||
/**
|
||||
* Indicate maximum source attenuation.
|
||||
* Type: ALfloat
|
||||
* Range: [0.0 - 1.0]
|
||||
*/
|
||||
public static final int AL_MAX_GAIN = 0x100E;
|
||||
|
||||
/**
|
||||
* Specify the current orientation.
|
||||
* Type: ALfv6 (at/up)
|
||||
* Range: N/A
|
||||
*/
|
||||
public static final int AL_ORIENTATION = 0x100F;
|
||||
|
||||
/* byte offset into source (in canon format). -1 if source
|
||||
* is not playing. Don't set this, get this.
|
||||
*
|
||||
* Type: ALfloat
|
||||
* Range: [0.0 - ]
|
||||
* Default: 1.0
|
||||
*/
|
||||
public static final int AL_REFERENCE_DISTANCE = 0x1020;
|
||||
|
||||
/**
|
||||
* Indicate the rolloff factor for the source.
|
||||
* Type: ALfloat
|
||||
* Range: [0.0 - ]
|
||||
* Default: 1.0
|
||||
*/
|
||||
public static final int AL_ROLLOFF_FACTOR = 0x1021;
|
||||
|
||||
/**
|
||||
* Indicate the gain (volume amplification) applied.
|
||||
* Type: ALfloat.
|
||||
* Range: ]0.0- ]
|
||||
* A value of 1.0 means un-attenuated/unchanged.
|
||||
* Each division by 2 equals an attenuation of -6dB.
|
||||
* Each multiplicaton with 2 equals an amplification of +6dB.
|
||||
* A value of 0.0 is meaningless with respect to a logarithmic
|
||||
* scale; it is interpreted as zero volume - the channel
|
||||
* is effectively disabled.
|
||||
*/
|
||||
public static final int AL_CONE_OUTER_GAIN = 0x1022;
|
||||
|
||||
/**
|
||||
* Specify the maximum distance.
|
||||
* Type: ALfloat
|
||||
* Range: [0.0 - ]
|
||||
*/
|
||||
public static final int AL_MAX_DISTANCE = 0x1023;
|
||||
|
||||
/**
|
||||
* Specify the channel mask. (Creative)
|
||||
* Type: ALuint
|
||||
* Range: [0 - 255]
|
||||
*/
|
||||
public static final int AL_CHANNEL_MASK = 0x3000;
|
||||
|
||||
/** Source state information */
|
||||
public static final int AL_SOURCE_STATE = 0x1010;
|
||||
|
||||
/** Source state information */
|
||||
public static final int AL_INITIAL = 0x1011;
|
||||
|
||||
/** Source state information */
|
||||
public static final int AL_PLAYING = 0x1012;
|
||||
|
||||
/** Source state information */
|
||||
public static final int AL_PAUSED = 0x1013;
|
||||
|
||||
/** Source state information */
|
||||
public static final int AL_STOPPED = 0x1014;
|
||||
|
||||
/** Buffer Queue params */
|
||||
public static final int AL_BUFFERS_QUEUED = 0x1015;
|
||||
|
||||
/** Buffer Queue params */
|
||||
public static final int AL_BUFFERS_PROCESSED = 0x1016;
|
||||
|
||||
/** Sound buffers: format specifier. */
|
||||
public static final int AL_FORMAT_MONO8 = 0x1100;
|
||||
|
||||
/** Sound buffers: format specifier. */
|
||||
public static final int AL_FORMAT_MONO16 = 0x1101;
|
||||
|
||||
/** Sound buffers: format specifier. */
|
||||
public static final int AL_FORMAT_STEREO8 = 0x1102;
|
||||
|
||||
/** Sound buffers: format specifier. */
|
||||
public static final int AL_FORMAT_STEREO16 = 0x1103;
|
||||
|
||||
/** Ogg Vorbis format specifier. */
|
||||
public static final int AL_FORMAT_VORBIS_EXT = 0x1110;
|
||||
|
||||
/**
|
||||
* Sound buffers: frequency, in units of Hertz [Hz].
|
||||
* This is the number of samples per second. Half of the
|
||||
* sample frequency marks the maximum significant
|
||||
* frequency component.
|
||||
*/
|
||||
public static final int AL_FREQUENCY = 0x2001;
|
||||
|
||||
/**
|
||||
* Sound buffers: frequency, in units of Hertz [Hz].
|
||||
* This is the number of samples per second. Half of the
|
||||
* sample frequency marks the maximum significant
|
||||
* frequency component.
|
||||
*/
|
||||
public static final int AL_BITS = 0x2002;
|
||||
|
||||
/**
|
||||
* Sound buffers: frequency, in units of Hertz [Hz].
|
||||
* This is the number of samples per second. Half of the
|
||||
* sample frequency marks the maximum significant
|
||||
* frequency component.
|
||||
*/
|
||||
public static final int AL_CHANNELS = 0x2003;
|
||||
|
||||
/**
|
||||
* Sound buffers: frequency, in units of Hertz [Hz].
|
||||
* This is the number of samples per second. Half of the
|
||||
* sample frequency marks the maximum significant
|
||||
* frequency component.
|
||||
*/
|
||||
public static final int AL_SIZE = 0x2004;
|
||||
|
||||
/**
|
||||
* Sound buffers: frequency, in units of Hertz [Hz].
|
||||
* This is the number of samples per second. Half of the
|
||||
* sample frequency marks the maximum significant
|
||||
* frequency component.
|
||||
*/
|
||||
public static final int AL_DATA = 0x2005;
|
||||
|
||||
/**
|
||||
* Buffer state.
|
||||
*
|
||||
* Not supported for public use (yet).
|
||||
*/
|
||||
public static final int AL_UNUSED = 0x2010;
|
||||
|
||||
/**
|
||||
* Buffer state.
|
||||
*
|
||||
* Not supported for public use (yet).
|
||||
*/
|
||||
public static final int AL_PENDING = 0x2011;
|
||||
|
||||
/**
|
||||
* Buffer state.
|
||||
*
|
||||
* Not supported for public use (yet).
|
||||
*/
|
||||
public static final int AL_PROCESSED = 0x2012;
|
||||
|
||||
/** Errors: No Error. */
|
||||
public static final int AL_NO_ERROR = AL_FALSE;
|
||||
|
||||
/** Illegal name passed as an argument to an AL call. */
|
||||
public static final int AL_INVALID_NAME = 0xA001;
|
||||
|
||||
/** Illegal enum passed as an argument to an AL call. */
|
||||
public static final int AL_INVALID_ENUM = 0xA002;
|
||||
|
||||
/**
|
||||
* Illegal value passed as an argument to an AL call.
|
||||
* Applies to parameter values, but not to enumerations.
|
||||
*/
|
||||
public static final int AL_INVALID_VALUE = 0xA003;
|
||||
|
||||
/**
|
||||
* A function was called at inappropriate time,
|
||||
* or in an inappropriate way, causing an illegal state.
|
||||
* This can be an incompatible ALenum, object ID,
|
||||
* and/or function.
|
||||
*/
|
||||
public static final int AL_INVALID_OPERATION = 0xA004;
|
||||
|
||||
/**
|
||||
* A function could not be completed,
|
||||
* because there is not enough memory available.
|
||||
*/
|
||||
public static final int AL_OUT_OF_MEMORY = 0xA005;
|
||||
|
||||
/** Context strings: Vendor */
|
||||
public static final int AL_VENDOR = 0xB001;
|
||||
|
||||
/** Context strings: Version */
|
||||
public static final int AL_VERSION = 0xB002;
|
||||
|
||||
/** Context strings: Renderer */
|
||||
public static final int AL_RENDERER = 0xB003;
|
||||
|
||||
/** Context strings: Extensions */
|
||||
public static final int AL_EXTENSIONS = 0xB004;
|
||||
|
||||
/** Doppler scale. Default 1.0 */
|
||||
public static final int AL_DOPPLER_FACTOR = 0xC000;
|
||||
|
||||
/** Doppler velocity. Default 1.0 */
|
||||
public static final int AL_DOPPLER_VELOCITY = 0xC001;
|
||||
|
||||
/** Distance model. Default INVERSE_DISTANCE_CLAMPED */
|
||||
public static final int AL_DISTANCE_MODEL = 0xD000;
|
||||
|
||||
/** Distance model */
|
||||
public static final int AL_INVERSE_DISTANCE = 0xD001;
|
||||
|
||||
/** Distance model */
|
||||
public static final int AL_INVERSE_DISTANCE_CLAMPED = 0xD002;
|
||||
}
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2002 Lightweight Java Game Library Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'Light Weight Java Game Library' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.lwjgl.openal.eax;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
*
|
||||
* The base OpenAL EAX functionality.
|
||||
*
|
||||
* This has been provided as a base class that we can use for either the
|
||||
* full EAX specification or as a cut-down OpenAL EAX embedded spec. (aka
|
||||
* a mini-driver).
|
||||
*
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
*/
|
||||
public abstract class BaseEAX {
|
||||
|
||||
/** Has the EAX object been created? */
|
||||
protected static boolean created;
|
||||
|
||||
static {
|
||||
initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Static initialization
|
||||
*/
|
||||
private static void initialize() {
|
||||
System.loadLibrary(org.lwjgl.Sys.getLibraryName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the EAX functions
|
||||
*
|
||||
* @throws Exception if the EAX extensions couldn't be loaded
|
||||
*/
|
||||
public static void create() throws Exception {
|
||||
if (created) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!nCreate()) {
|
||||
throw new Exception("EAX instance could not be created.");
|
||||
}
|
||||
CoreEAX.init();
|
||||
created = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Native method to create EAX instance
|
||||
*
|
||||
* @return true if the EAX extensions could be found
|
||||
*/
|
||||
protected static native boolean nCreate();
|
||||
|
||||
/**
|
||||
* "Destroy" the EAX object
|
||||
*/
|
||||
public static void destroy() {
|
||||
if (!created) {
|
||||
return;
|
||||
}
|
||||
created = false;
|
||||
nDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Native method the destroy the EAX
|
||||
*/
|
||||
protected static native void nDestroy();
|
||||
|
||||
/**
|
||||
* @return true if EAX has been created
|
||||
*/
|
||||
public static boolean isCreated() {
|
||||
return created;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2002 Lightweight Java Game Library Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'Light Weight Java Game Library' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.lwjgl.openal.eax;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
*
|
||||
* This class implements the basic EAX extension constants.
|
||||
*
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
*/
|
||||
public interface BaseEAXConstants {
|
||||
public static final int EAX_ENVIRONMENT_GENERIC = 0;
|
||||
public static final int EAX_ENVIRONMENT_PADDEDCELL = 1;
|
||||
public static final int EAX_ENVIRONMENT_ROOM = 2;
|
||||
public static final int EAX_ENVIRONMENT_BATHROOM = 3;
|
||||
public static final int EAX_ENVIRONMENT_LIVINGROOM = 4;
|
||||
public static final int EAX_ENVIRONMENT_STONEROOM = 5;
|
||||
public static final int EAX_ENVIRONMENT_AUDITORIUM = 6;
|
||||
public static final int EAX_ENVIRONMENT_CONCERTHALL = 7;
|
||||
public static final int EAX_ENVIRONMENT_CAVE = 8;
|
||||
public static final int EAX_ENVIRONMENT_ARENA = 9;
|
||||
public static final int EAX_ENVIRONMENT_HANGAR = 10;
|
||||
public static final int EAX_ENVIRONMENT_CARPETEDHALLWAY = 11;
|
||||
public static final int EAX_ENVIRONMENT_HALLWAY = 12;
|
||||
public static final int EAX_ENVIRONMENT_STONECORRIDOR = 13;
|
||||
public static final int EAX_ENVIRONMENT_ALLEY = 14;
|
||||
public static final int EAX_ENVIRONMENT_FOREST = 15;
|
||||
public static final int EAX_ENVIRONMENT_CITY = 16;
|
||||
public static final int EAX_ENVIRONMENT_MOUNTAINS = 17;
|
||||
public static final int EAX_ENVIRONMENT_QUARRY = 18;
|
||||
public static final int EAX_ENVIRONMENT_PLAIN = 19;
|
||||
public static final int EAX_ENVIRONMENT_PARKINGLOT = 20;
|
||||
public static final int EAX_ENVIRONMENT_SEWERPIPE = 21;
|
||||
public static final int EAX_ENVIRONMENT_UNDERWATER = 22;
|
||||
public static final int EAX_ENVIRONMENT_DRUGGED = 23;
|
||||
public static final int EAX_ENVIRONMENT_DIZZY = 24;
|
||||
public static final int EAX_ENVIRONMENT_PSYCHOTIC = 25;
|
||||
public static final int EAX_ENVIRONMENT_COUNT = 26;
|
||||
|
||||
// Single window material preset
|
||||
public static final int EAX_MATERIAL_SINGLEWINDOW = -2800;
|
||||
public static final float EAX_MATERIAL_SINGLEWINDOWLF = 0.71f;
|
||||
public static final float EAX_MATERIAL_SINGLEWINDOWROOMRATIO = 0.43f;
|
||||
|
||||
// Double window material preset
|
||||
public static final int EAX_MATERIAL_DOUBLEWINDOW = -5000;
|
||||
public static final float EAX_MATERIAL_DOUBLEWINDOWHF = 0.40f;
|
||||
public static final float EAX_MATERIAL_DOUBLEWINDOWROOMRATIO = 0.24f;
|
||||
|
||||
// Thin door material preset
|
||||
public static final int EAX_MATERIAL_THINDOOR = -1800;
|
||||
public static final float EAX_MATERIAL_THINDOORLF = 0.66f;
|
||||
public static final float EAX_MATERIAL_THINDOORROOMRATIO = 0.66f;
|
||||
|
||||
// Thick door material preset
|
||||
public static final int EAX_MATERIAL_THICKDOOR = -4400;
|
||||
public static final float EAX_MATERIAL_THICKDOORLF = 0.64f;
|
||||
public static final float EAX_MATERIAL_THICKDOORROOMRTATION = 0.27f;
|
||||
|
||||
// Wood wall material preset
|
||||
public static final int EAX_MATERIAL_WOODWALL = -4000;
|
||||
public static final float EAX_MATERIAL_WOODWALLLF = 0.50f;
|
||||
public static final float EAX_MATERIAL_WOODWALLROOMRATIO = 0.30f;
|
||||
|
||||
// Brick wall material preset
|
||||
public static final int EAX_MATERIAL_BRICKWALL = -5000;
|
||||
public static final float EAX_MATERIAL_BRICKWALLLF = 0.60f;
|
||||
public static final float EAX_MATERIAL_BRICKWALLROOMRATIO = 0.24f;
|
||||
|
||||
// Stone wall material preset
|
||||
public static final int EAX_MATERIAL_STONEWALL = -6000;
|
||||
public static final float EAX_MATERIAL_STONEWALLLF = 0.68f;
|
||||
public static final float EAX_MATERIAL_STONEWALLROOMRATIO = 0.20f;
|
||||
|
||||
// Curtain material preset
|
||||
public static final int EAX_MATERIAL_CURTAIN = -1200;
|
||||
public static final float EAX_MATERIAL_CURTAINLF = 0.15f;
|
||||
public static final float EAX_MATERIAL_CURTAINROOMRATIO = 1.00f;
|
||||
}
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2002 Lightweight Java Game Library Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'Light Weight Java Game Library' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.lwjgl.openal.eax;
|
||||
|
||||
import java.nio.Buffer;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
*
|
||||
* This is the OpenAL EAX class. It extends the latest core.
|
||||
*
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class CoreEAX extends BaseEAX implements BaseEAXConstants {
|
||||
|
||||
/** GUID for buffer */
|
||||
public static final int BUFFER_GUID = 1;
|
||||
|
||||
/** GUID for listener */
|
||||
public static final int LISTENER_GUID = 2;
|
||||
|
||||
/**
|
||||
* Load extensions
|
||||
*/
|
||||
protected static void init() {
|
||||
determineAvailableExtensions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines available EAX extensions
|
||||
*/
|
||||
protected static native void determineAvailableExtensions();
|
||||
|
||||
/**
|
||||
* Retrieves an EAX Value
|
||||
*
|
||||
* @param propertySetID adress to the property set GUID of the object being queried (a listener or a source)
|
||||
* @param property property being queried
|
||||
* @param source the source to be queried
|
||||
* @param data Buffer to write value to
|
||||
* @param size size of area being written to
|
||||
* @return OpenAL Error code
|
||||
*/
|
||||
public static int eaxGet(int propertySetID, int property, int source, Buffer data, int size) {
|
||||
return neaxGet(propertySetID, property, source, data, data.position(), size);
|
||||
}
|
||||
private static native int neaxGet(int propertySetID, int property, int source, Buffer data, int position, int size);
|
||||
|
||||
/**
|
||||
* Sets an EAX Value
|
||||
*
|
||||
* @param propertySetID adress to the property set GUID of the object being queried (a listener or a source)
|
||||
* @param property property being queried
|
||||
* @param source the source to be queried
|
||||
* @param data Buffer to write value to
|
||||
* @param size size of area being written to
|
||||
* @return OpenAL Error code
|
||||
*/
|
||||
public static int eaxSet(int propertySetID, int property, int source, Buffer data, int size) {
|
||||
return neaxSet(propertySetID, property, source, data, data.position(), size);
|
||||
}
|
||||
private static native int neaxSet(int propertySetID, int property, int source, Buffer data, int position, int size);
|
||||
}
|
||||
|
|
@ -39,5 +39,66 @@
|
|||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class EAX extends CoreEAX {
|
||||
public class EAX {
|
||||
|
||||
/** Has the EAX object been created? */
|
||||
protected static boolean created;
|
||||
|
||||
static {
|
||||
initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Static initialization
|
||||
*/
|
||||
private static void initialize() {
|
||||
System.loadLibrary(org.lwjgl.Sys.getLibraryName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the EAX functions
|
||||
*
|
||||
* @throws Exception if the EAX extensions couldn't be loaded
|
||||
*/
|
||||
public static void create() throws Exception {
|
||||
if (created) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!nCreate()) {
|
||||
throw new Exception("EAX instance could not be created.");
|
||||
}
|
||||
EAX20.init();
|
||||
created = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Native method to create EAX instance
|
||||
*
|
||||
* @return true if the EAX extensions could be found
|
||||
*/
|
||||
protected static native boolean nCreate();
|
||||
|
||||
/**
|
||||
* "Destroy" the EAX object
|
||||
*/
|
||||
public static void destroy() {
|
||||
if (!created) {
|
||||
return;
|
||||
}
|
||||
created = false;
|
||||
nDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Native method the destroy the EAX
|
||||
*/
|
||||
protected static native void nDestroy();
|
||||
|
||||
/**
|
||||
* @return true if EAX has been created
|
||||
*/
|
||||
public static boolean isCreated() {
|
||||
return created;
|
||||
}
|
||||
}
|
||||
161
src/java/org/lwjgl/openal/eax/EAX20.java
Normal file
161
src/java/org/lwjgl/openal/eax/EAX20.java
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
/*
|
||||
* Copyright (c) 2002 Lightweight Java Game Library Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'Light Weight Java Game Library' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.lwjgl.openal.eax;
|
||||
|
||||
import java.nio.Buffer;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
*
|
||||
* This is the OpenAL EAX class. It extends the latest core.
|
||||
*
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class EAX20 {
|
||||
|
||||
/** GUID for buffer */
|
||||
public static final int BUFFER_GUID = 1;
|
||||
|
||||
/** GUID for listener */
|
||||
public static final int LISTENER_GUID = 2;
|
||||
|
||||
public static final int EAX_ENVIRONMENT_GENERIC = 0;
|
||||
public static final int EAX_ENVIRONMENT_PADDEDCELL = 1;
|
||||
public static final int EAX_ENVIRONMENT_ROOM = 2;
|
||||
public static final int EAX_ENVIRONMENT_BATHROOM = 3;
|
||||
public static final int EAX_ENVIRONMENT_LIVINGROOM = 4;
|
||||
public static final int EAX_ENVIRONMENT_STONEROOM = 5;
|
||||
public static final int EAX_ENVIRONMENT_AUDITORIUM = 6;
|
||||
public static final int EAX_ENVIRONMENT_CONCERTHALL = 7;
|
||||
public static final int EAX_ENVIRONMENT_CAVE = 8;
|
||||
public static final int EAX_ENVIRONMENT_ARENA = 9;
|
||||
public static final int EAX_ENVIRONMENT_HANGAR = 10;
|
||||
public static final int EAX_ENVIRONMENT_CARPETEDHALLWAY = 11;
|
||||
public static final int EAX_ENVIRONMENT_HALLWAY = 12;
|
||||
public static final int EAX_ENVIRONMENT_STONECORRIDOR = 13;
|
||||
public static final int EAX_ENVIRONMENT_ALLEY = 14;
|
||||
public static final int EAX_ENVIRONMENT_FOREST = 15;
|
||||
public static final int EAX_ENVIRONMENT_CITY = 16;
|
||||
public static final int EAX_ENVIRONMENT_MOUNTAINS = 17;
|
||||
public static final int EAX_ENVIRONMENT_QUARRY = 18;
|
||||
public static final int EAX_ENVIRONMENT_PLAIN = 19;
|
||||
public static final int EAX_ENVIRONMENT_PARKINGLOT = 20;
|
||||
public static final int EAX_ENVIRONMENT_SEWERPIPE = 21;
|
||||
public static final int EAX_ENVIRONMENT_UNDERWATER = 22;
|
||||
public static final int EAX_ENVIRONMENT_DRUGGED = 23;
|
||||
public static final int EAX_ENVIRONMENT_DIZZY = 24;
|
||||
public static final int EAX_ENVIRONMENT_PSYCHOTIC = 25;
|
||||
public static final int EAX_ENVIRONMENT_COUNT = 26;
|
||||
|
||||
// Single window material preset
|
||||
public static final int EAX_MATERIAL_SINGLEWINDOW = -2800;
|
||||
public static final float EAX_MATERIAL_SINGLEWINDOWLF = 0.71f;
|
||||
public static final float EAX_MATERIAL_SINGLEWINDOWROOMRATIO = 0.43f;
|
||||
|
||||
// Double window material preset
|
||||
public static final int EAX_MATERIAL_DOUBLEWINDOW = -5000;
|
||||
public static final float EAX_MATERIAL_DOUBLEWINDOWHF = 0.40f;
|
||||
public static final float EAX_MATERIAL_DOUBLEWINDOWROOMRATIO = 0.24f;
|
||||
|
||||
// Thin door material preset
|
||||
public static final int EAX_MATERIAL_THINDOOR = -1800;
|
||||
public static final float EAX_MATERIAL_THINDOORLF = 0.66f;
|
||||
public static final float EAX_MATERIAL_THINDOORROOMRATIO = 0.66f;
|
||||
|
||||
// Thick door material preset
|
||||
public static final int EAX_MATERIAL_THICKDOOR = -4400;
|
||||
public static final float EAX_MATERIAL_THICKDOORLF = 0.64f;
|
||||
public static final float EAX_MATERIAL_THICKDOORROOMRTATION = 0.27f;
|
||||
|
||||
// Wood wall material preset
|
||||
public static final int EAX_MATERIAL_WOODWALL = -4000;
|
||||
public static final float EAX_MATERIAL_WOODWALLLF = 0.50f;
|
||||
public static final float EAX_MATERIAL_WOODWALLROOMRATIO = 0.30f;
|
||||
|
||||
// Brick wall material preset
|
||||
public static final int EAX_MATERIAL_BRICKWALL = -5000;
|
||||
public static final float EAX_MATERIAL_BRICKWALLLF = 0.60f;
|
||||
public static final float EAX_MATERIAL_BRICKWALLROOMRATIO = 0.24f;
|
||||
|
||||
// Stone wall material preset
|
||||
public static final int EAX_MATERIAL_STONEWALL = -6000;
|
||||
public static final float EAX_MATERIAL_STONEWALLLF = 0.68f;
|
||||
public static final float EAX_MATERIAL_STONEWALLROOMRATIO = 0.20f;
|
||||
|
||||
// Curtain material preset
|
||||
public static final int EAX_MATERIAL_CURTAIN = -1200;
|
||||
public static final float EAX_MATERIAL_CURTAINLF = 0.15f;
|
||||
public static final float EAX_MATERIAL_CURTAINROOMRATIO = 1.00f;
|
||||
|
||||
/**
|
||||
* Load extensions
|
||||
*/
|
||||
protected static void init() {
|
||||
determineAvailableExtensions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines available EAX extensions
|
||||
*/
|
||||
protected static native void determineAvailableExtensions();
|
||||
|
||||
/**
|
||||
* Retrieves an EAX Value
|
||||
*
|
||||
* @param propertySetID adress to the property set GUID of the object being queried (a listener or a source)
|
||||
* @param property property being queried
|
||||
* @param source the source to be queried
|
||||
* @param data Buffer to write value to
|
||||
* @param size size of area being written to
|
||||
* @return OpenAL Error code
|
||||
*/
|
||||
public static int eaxGet(int propertySetID, int property, int source, Buffer data, int size) {
|
||||
return neaxGet(propertySetID, property, source, data, data.position(), size);
|
||||
}
|
||||
private static native int neaxGet(int propertySetID, int property, int source, Buffer data, int position, int size);
|
||||
|
||||
/**
|
||||
* Sets an EAX Value
|
||||
*
|
||||
* @param propertySetID adress to the property set GUID of the object being queried (a listener or a source)
|
||||
* @param property property being queried
|
||||
* @param source the source to be queried
|
||||
* @param data Buffer to write value to
|
||||
* @param size size of area being written to
|
||||
* @return OpenAL Error code
|
||||
*/
|
||||
public static int eaxSet(int propertySetID, int property, int source, Buffer data, int size) {
|
||||
return neaxSet(propertySetID, property, source, data, data.position(), size);
|
||||
}
|
||||
private static native int neaxSet(int propertySetID, int property, int source, Buffer data, int position, int size);
|
||||
}
|
||||
|
|
@ -229,8 +229,8 @@ public class EAXBufferProperties {
|
|||
* Loads current EAX values from current source
|
||||
*/
|
||||
public void loadEAXValues() {
|
||||
EAX.eaxGet(
|
||||
CoreEAX.BUFFER_GUID,
|
||||
EAX20.eaxGet(
|
||||
EAX20.BUFFER_GUID,
|
||||
EAXBUFFER_ALLPARAMETERS,
|
||||
currentSource,
|
||||
eaxBufferProperties,
|
||||
|
|
@ -271,8 +271,8 @@ public class EAXBufferProperties {
|
|||
*/
|
||||
public void commit() {
|
||||
// call eaxSet with Buffer guid, setting all parameters
|
||||
EAX.eaxSet(
|
||||
CoreEAX.BUFFER_GUID, EAXBUFFER_ALLPARAMETERS,
|
||||
EAX20.eaxSet(
|
||||
EAX20.BUFFER_GUID, EAXBUFFER_ALLPARAMETERS,
|
||||
currentSource, eaxBufferProperties, EAXBUFFERPROPERTIES_SIZE);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -184,9 +184,9 @@ public class EAXListenerProperties {
|
|||
|
||||
public static final int EAXLISTENER_MINENVIRONMENT = 0;
|
||||
public static final int EAXLISTENER_MAXENVIRONMENT =
|
||||
(EAX.EAX_ENVIRONMENT_COUNT - 1);
|
||||
(EAX20.EAX_ENVIRONMENT_COUNT - 1);
|
||||
public static final int EAXLISTENER_DEFAULTENVIRONMENT =
|
||||
EAX.EAX_ENVIRONMENT_GENERIC;
|
||||
EAX20.EAX_ENVIRONMENT_GENERIC;
|
||||
|
||||
public static final float EAXLISTENER_MINENVIRONMENTSIZE = 1.0f;
|
||||
public static final float EAXLISTENER_MAXENVIRONMENTSIZE = 100.0f;
|
||||
|
|
@ -226,8 +226,8 @@ public class EAXListenerProperties {
|
|||
* Loads current EAX values
|
||||
*/
|
||||
public void loadEAXValues() {
|
||||
EAX.eaxGet(
|
||||
CoreEAX.LISTENER_GUID,
|
||||
EAX20.eaxGet(
|
||||
EAX20.LISTENER_GUID,
|
||||
EAXLISTENER_ALLPARAMETERS,
|
||||
0,
|
||||
eaxListenerProperties,
|
||||
|
|
@ -269,8 +269,8 @@ public class EAXListenerProperties {
|
|||
*/
|
||||
public void commit() {
|
||||
// call eaxSet with Listener guid, setting all parameters
|
||||
EAX.eaxSet(
|
||||
CoreEAX.LISTENER_GUID, EAXLISTENER_ALLPARAMETERS | EAXLISTENER_IMMEDIATE,
|
||||
EAX20.eaxSet(
|
||||
EAX20.LISTENER_GUID, EAXLISTENER_ALLPARAMETERS | EAXLISTENER_IMMEDIATE,
|
||||
0, eaxListenerProperties, EAXLISTENERPROPERTIES_SIZE);
|
||||
}
|
||||
|
||||
|
|
@ -575,8 +575,8 @@ public class EAXListenerProperties {
|
|||
// only the environment value and its size. Also pass the
|
||||
// EAXLISTENER_ENVIRONMENT value (and since we're committing IMMEDIATE too)
|
||||
if (autoCommit) {
|
||||
EAX.eaxSet(
|
||||
CoreEAX.LISTENER_GUID, EAXLISTENER_ENVIRONMENT | EAXLISTENER_IMMEDIATE,
|
||||
EAX20.eaxSet(
|
||||
EAX20.LISTENER_GUID, EAXLISTENER_ENVIRONMENT | EAXLISTENER_IMMEDIATE,
|
||||
0, eaxListenerProperties.position(environment_offset), 4);
|
||||
|
||||
// rewind buffer
|
||||
|
|
@ -609,8 +609,8 @@ public class EAXListenerProperties {
|
|||
// only the environment size value and its size. Also pass the
|
||||
// EAXLISTENER_ENVIRONMENTSIZE value (and since we're committing IMMEDIATE too)
|
||||
if (autoCommit) {
|
||||
EAX.eaxSet(
|
||||
CoreEAX.LISTENER_GUID, EAXLISTENER_ENVIRONMENTSIZE | EAXLISTENER_IMMEDIATE,
|
||||
EAX20.eaxSet(
|
||||
EAX20.LISTENER_GUID, EAXLISTENER_ENVIRONMENTSIZE | EAXLISTENER_IMMEDIATE,
|
||||
0, eaxListenerProperties.position(environmentSize_offset), 4);
|
||||
|
||||
// rewind buffer
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import java.nio.FloatBuffer;
|
|||
import java.nio.IntBuffer;
|
||||
|
||||
import org.lwjgl.openal.AL;
|
||||
import org.lwjgl.openal.AL10;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
|
|
@ -115,7 +116,7 @@ public abstract class BasicTest {
|
|||
* @param error Error code causing exit
|
||||
*/
|
||||
protected void exit(int error) {
|
||||
System.out.println("OpenAL Error: " + AL.alGetString(error));
|
||||
System.out.println("OpenAL Error: " + AL10.alGetString(error));
|
||||
alExit();
|
||||
System.exit(-1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,9 @@ import java.nio.IntBuffer;
|
|||
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.openal.AL;
|
||||
import org.lwjgl.openal.AL10;
|
||||
import org.lwjgl.openal.eax.EAX;
|
||||
import org.lwjgl.openal.eax.EAX20;
|
||||
import org.lwjgl.openal.eax.EAXBufferProperties;
|
||||
import org.lwjgl.openal.eax.EAXListenerProperties;
|
||||
|
||||
|
|
@ -94,9 +96,9 @@ public class EAXTest extends BasicTest {
|
|||
runTest();
|
||||
|
||||
// kill sources and buffers
|
||||
AL.alSourceStop(soundSources.get(0));
|
||||
AL.alDeleteSources(soundSources);
|
||||
AL.alDeleteBuffers(soundBuffers);
|
||||
AL10.alSourceStop(soundSources.get(0));
|
||||
AL10.alDeleteSources(soundSources);
|
||||
AL10.alDeleteBuffers(soundBuffers);
|
||||
|
||||
EAX.destroy();
|
||||
}
|
||||
|
|
@ -108,22 +110,22 @@ public class EAXTest extends BasicTest {
|
|||
private boolean initialize() {
|
||||
// creating buffers
|
||||
Sys.log("Creating buffers");
|
||||
AL.alGenBuffers(soundBuffers);
|
||||
AL10.alGenBuffers(soundBuffers);
|
||||
soundBuffers.rewind();
|
||||
|
||||
// creating sources
|
||||
Sys.log("Creating sources");
|
||||
AL.alGenSources(soundSources);
|
||||
AL10.alGenSources(soundSources);
|
||||
soundSources.rewind();
|
||||
|
||||
// load sound files (left, center, right).wav
|
||||
Sys.log("Loading Footsteps.wav");
|
||||
WaveData footsteps = WaveData.create("Footsteps.wav");
|
||||
AL.alBufferData(soundBuffers.get(0), footsteps.format, footsteps.data, footsteps.data.capacity(), footsteps.samplerate);
|
||||
AL.alSourcef(soundSources.get(0), AL.AL_PITCH, 1.0f);
|
||||
AL.alSourcef(soundSources.get(0), AL.AL_GAIN, 1.0f);
|
||||
AL.alSourcei(soundSources.get(0), AL.AL_BUFFER, soundBuffers.get(0));
|
||||
AL.alSourcei(soundSources.get(0), AL.AL_LOOPING, AL.AL_TRUE);
|
||||
AL10.alBufferData(soundBuffers.get(0), footsteps.format, footsteps.data, footsteps.data.capacity(), footsteps.samplerate);
|
||||
AL10.alSourcef(soundSources.get(0), AL10.AL_PITCH, 1.0f);
|
||||
AL10.alSourcef(soundSources.get(0), AL10.AL_GAIN, 1.0f);
|
||||
AL10.alSourcei(soundSources.get(0), AL10.AL_BUFFER, soundBuffers.get(0));
|
||||
AL10.alSourcei(soundSources.get(0), AL10.AL_LOOPING, AL10.AL_TRUE);
|
||||
|
||||
// create eax property objects
|
||||
listenerProperties = new EAXListenerProperties();
|
||||
|
|
@ -132,7 +134,7 @@ public class EAXTest extends BasicTest {
|
|||
// set buffer to work on source 0
|
||||
bufferProperties.setCurrentSource(soundSources.get(0));
|
||||
|
||||
return AL.alGetError() == AL.AL_NO_ERROR;
|
||||
return AL10.alGetError() == AL10.AL_NO_ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -142,7 +144,7 @@ public class EAXTest extends BasicTest {
|
|||
boolean running = true;
|
||||
char key;
|
||||
|
||||
assert AL.alIsBuffer(soundBuffers.get(0)) : "Failed to validate buffer";
|
||||
assert AL10.alIsBuffer(soundBuffers.get(0)) : "Failed to validate buffer";
|
||||
|
||||
// handle menu
|
||||
do {
|
||||
|
|
@ -152,25 +154,25 @@ public class EAXTest extends BasicTest {
|
|||
switch (key) {
|
||||
// play sound
|
||||
case '1' : {
|
||||
AL.alSourcePlay(soundSources.get(0));
|
||||
AL10.alSourcePlay(soundSources.get(0));
|
||||
break;
|
||||
}
|
||||
|
||||
// stop sound
|
||||
case '2' : {
|
||||
AL.alSourceStop(soundSources.get(0));
|
||||
AL10.alSourceStop(soundSources.get(0));
|
||||
break;
|
||||
}
|
||||
|
||||
// add reverb
|
||||
case '3' : {
|
||||
listenerProperties.setEnvironment(EAX.EAX_ENVIRONMENT_HANGAR);
|
||||
listenerProperties.setEnvironment(EAX20.EAX_ENVIRONMENT_HANGAR);
|
||||
break;
|
||||
}
|
||||
|
||||
// remove reverb
|
||||
case '4' : {
|
||||
listenerProperties.setEnvironment(EAX.EAX_ENVIRONMENT_GENERIC);
|
||||
listenerProperties.setEnvironment(EAX20.EAX_ENVIRONMENT_GENERIC);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,8 +34,9 @@ package org.lwjgl.test.openal;
|
|||
import java.nio.IntBuffer;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.openal.AL;
|
||||
import org.lwjgl.openal.AL10;
|
||||
import org.lwjgl.openal.eax.EAX;
|
||||
import org.lwjgl.openal.eax.EAX20;
|
||||
import org.lwjgl.openal.eax.EAXListenerProperties;
|
||||
import org.lwjgl.opengl.Window;
|
||||
import org.lwjgl.vector.Vector3f;
|
||||
|
|
@ -96,14 +97,14 @@ public class MovingSoundTest extends BasicTest {
|
|||
|
||||
// al generate buffers and sources
|
||||
buffers.position(0).limit(1);
|
||||
AL.alGenBuffers(buffers);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alGenBuffers(buffers);
|
||||
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
sources.position(0).limit(1);
|
||||
AL.alGenSources(sources);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alGenSources(sources);
|
||||
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
@ -111,13 +112,13 @@ public class MovingSoundTest extends BasicTest {
|
|||
WaveData wavefile = WaveData.create(args[0]);
|
||||
|
||||
//copy to buffers
|
||||
AL.alBufferData(
|
||||
AL10.alBufferData(
|
||||
buffers.get(0),
|
||||
wavefile.format,
|
||||
wavefile.data,
|
||||
wavefile.data.capacity(),
|
||||
wavefile.samplerate);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
@ -125,28 +126,28 @@ public class MovingSoundTest extends BasicTest {
|
|||
wavefile.dispose();
|
||||
|
||||
//set up source input
|
||||
AL.alSourcei(sources.get(0), AL.AL_BUFFER, buffers.get(0));
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alSourcei(sources.get(0), AL10.AL_BUFFER, buffers.get(0));
|
||||
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
AL.alSourcef(sources.get(0), AL.AL_REFERENCE_DISTANCE, 1024.0f);
|
||||
AL.alSourcef(sources.get(0), AL.AL_ROLLOFF_FACTOR, 0.5f);
|
||||
AL10.alSourcef(sources.get(0), AL10.AL_REFERENCE_DISTANCE, 1024.0f);
|
||||
AL10.alSourcef(sources.get(0), AL10.AL_ROLLOFF_FACTOR, 0.5f);
|
||||
|
||||
//lets loop the sound
|
||||
AL.alSourcei(sources.get(0), AL.AL_LOOPING, AL.AL_TRUE);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alSourcei(sources.get(0), AL10.AL_LOOPING, AL10.AL_TRUE);
|
||||
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//play source 0
|
||||
AL.alSourcePlay(sources.get(0));
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alSourcePlay(sources.get(0));
|
||||
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//setup EAX if possible
|
||||
if (AL.alIsExtensionPresent("EAX")) {
|
||||
if (AL10.alIsExtensionPresent("EAX")) {
|
||||
try {
|
||||
EAX.create();
|
||||
eaxListenerProp = new EAXListenerProperties();
|
||||
|
|
@ -163,31 +164,31 @@ public class MovingSoundTest extends BasicTest {
|
|||
if(Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {
|
||||
if(Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
|
||||
listenerPosition.x -= MOVEMENT;
|
||||
AL.alListener3f(AL.AL_POSITION, listenerPosition.x, listenerPosition.y, listenerPosition.z);
|
||||
AL10.alListener3f(AL10.AL_POSITION, listenerPosition.x, listenerPosition.y, listenerPosition.z);
|
||||
System.out.println("listenerx: " + listenerPosition.x);
|
||||
} else {
|
||||
sourcePosition.x -= MOVEMENT;
|
||||
AL.alSource3f(sources.get(0), AL.AL_POSITION, sourcePosition.x, sourcePosition.y, sourcePosition.z);
|
||||
AL10.alSource3f(sources.get(0), AL10.AL_POSITION, sourcePosition.x, sourcePosition.y, sourcePosition.z);
|
||||
System.out.println("sourcex: " + sourcePosition.x);
|
||||
}
|
||||
}
|
||||
if(Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {
|
||||
if(Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
|
||||
listenerPosition.x += MOVEMENT;
|
||||
AL.alListener3f(AL.AL_POSITION, listenerPosition.x, listenerPosition.y, listenerPosition.z);
|
||||
AL10.alListener3f(AL10.AL_POSITION, listenerPosition.x, listenerPosition.y, listenerPosition.z);
|
||||
System.out.println("listenerx: " + listenerPosition.x);
|
||||
} else {
|
||||
sourcePosition.x += MOVEMENT;
|
||||
AL.alSource3f(sources.get(0), AL.AL_POSITION, sourcePosition.x, sourcePosition.y, sourcePosition.z);
|
||||
AL10.alSource3f(sources.get(0), AL10.AL_POSITION, sourcePosition.x, sourcePosition.y, sourcePosition.z);
|
||||
System.out.println("sourcex: " + sourcePosition.x);
|
||||
}
|
||||
}
|
||||
|
||||
if(Keyboard.isKeyDown(Keyboard.KEY_E)) {
|
||||
if(eaxApplied) {
|
||||
eaxListenerProp.setEnvironment(EAX.EAX_ENVIRONMENT_GENERIC);
|
||||
eaxListenerProp.setEnvironment(EAX20.EAX_ENVIRONMENT_GENERIC);
|
||||
} else {
|
||||
eaxListenerProp.setEnvironment(EAX.EAX_ENVIRONMENT_HANGAR);
|
||||
eaxListenerProp.setEnvironment(EAX20.EAX_ENVIRONMENT_HANGAR);
|
||||
}
|
||||
eaxApplied = !eaxApplied;
|
||||
}
|
||||
|
|
@ -203,21 +204,21 @@ public class MovingSoundTest extends BasicTest {
|
|||
}
|
||||
|
||||
//stop source 0
|
||||
AL.alSourceStop(sources.get(0));
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alSourceStop(sources.get(0));
|
||||
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//delete buffers and sources
|
||||
sources.position(0).limit(1);
|
||||
AL.alDeleteSources(sources);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alDeleteSources(sources);
|
||||
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
buffers.position(0).limit(1);
|
||||
AL.alDeleteBuffers(buffers);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alDeleteBuffers(buffers);
|
||||
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import java.nio.ByteOrder;
|
|||
import java.nio.IntBuffer;
|
||||
|
||||
import org.lwjgl.openal.AL;
|
||||
import org.lwjgl.openal.AL10;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
|
|
@ -87,7 +88,7 @@ public class OpenALCreationTest {
|
|||
* @param error Error code causing exit
|
||||
*/
|
||||
protected void exit(int error) {
|
||||
System.out.println("OpenAL Error: " + AL.alGetString(error));
|
||||
System.out.println("OpenAL Error: " + AL10.alGetString(error));
|
||||
alExit();
|
||||
System.exit(-1);
|
||||
}
|
||||
|
|
@ -137,14 +138,14 @@ public class OpenALCreationTest {
|
|||
|
||||
// al generate buffers and sources
|
||||
buffers.position(0).limit(1);
|
||||
AL.alGenBuffers(buffers);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alGenBuffers(buffers);
|
||||
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
sources.position(0).limit(1);
|
||||
AL.alGenSources(sources);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alGenSources(sources);
|
||||
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
@ -152,13 +153,13 @@ public class OpenALCreationTest {
|
|||
WaveData wavefile = WaveData.create("Footsteps.wav");
|
||||
|
||||
//copy to buffers
|
||||
AL.alBufferData(
|
||||
AL10.alBufferData(
|
||||
buffers.get(0),
|
||||
wavefile.format,
|
||||
wavefile.data,
|
||||
wavefile.data.capacity(),
|
||||
wavefile.samplerate);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
@ -166,20 +167,20 @@ public class OpenALCreationTest {
|
|||
wavefile.dispose();
|
||||
|
||||
//set up source input
|
||||
AL.alSourcei(sources.get(0), AL.AL_BUFFER, buffers.get(0));
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alSourcei(sources.get(0), AL10.AL_BUFFER, buffers.get(0));
|
||||
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//lets loop the sound
|
||||
AL.alSourcei(sources.get(0), AL.AL_LOOPING, AL.AL_TRUE);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alSourcei(sources.get(0), AL10.AL_LOOPING, AL10.AL_TRUE);
|
||||
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//play source 0
|
||||
AL.alSourcePlay(sources.get(0));
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alSourcePlay(sources.get(0));
|
||||
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
@ -192,21 +193,21 @@ public class OpenALCreationTest {
|
|||
System.out.println("done");
|
||||
|
||||
//stop source 0
|
||||
AL.alSourceStop(sources.get(0));
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alSourceStop(sources.get(0));
|
||||
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//delete buffers and sources
|
||||
sources.position(0).limit(1);
|
||||
AL.alDeleteSources(sources);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alDeleteSources(sources);
|
||||
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
buffers.position(0).limit(1);
|
||||
AL.alDeleteBuffers(buffers);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alDeleteBuffers(buffers);
|
||||
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import java.nio.ByteBuffer;
|
|||
import java.nio.ByteOrder;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import org.lwjgl.openal.AL;
|
||||
import org.lwjgl.openal.AL10;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
|
|
@ -70,7 +70,7 @@ public class PlayTest extends BasicTest {
|
|||
|
||||
if(args[0].endsWith(".ogg")) {
|
||||
System.out.print("Attempting to load Ogg Vorbis file, checking for extension...");
|
||||
if(AL.alIsExtensionPresent("AL_EXT_vorbis")) {
|
||||
if(AL10.alIsExtensionPresent("AL_EXT_vorbis")) {
|
||||
System.out.println("found");
|
||||
usingVorbis = true;
|
||||
} else {
|
||||
|
|
@ -88,14 +88,14 @@ public class PlayTest extends BasicTest {
|
|||
|
||||
// al generate buffers and sources
|
||||
buffers.position(0).limit(1);
|
||||
AL.alGenBuffers(buffers);
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alGenBuffers(buffers);
|
||||
if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
sources.position(0).limit(1);
|
||||
AL.alGenSources(sources);
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alGenSources(sources);
|
||||
if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
@ -103,38 +103,38 @@ public class PlayTest extends BasicTest {
|
|||
ByteBuffer filebuffer = getData(args[0]);
|
||||
|
||||
// pass directly to buffer data
|
||||
AL.alBufferData(buffers.get(0), AL.AL_FORMAT_VORBIS_EXT, filebuffer, -1, -1);
|
||||
AL10.alBufferData(buffers.get(0), AL10.AL_FORMAT_VORBIS_EXT, filebuffer, -1, -1);
|
||||
filebuffer.clear();
|
||||
} else {
|
||||
// load wave data from buffer
|
||||
WaveData wavefile = WaveData.create(args[0]);
|
||||
|
||||
//copy to buffers
|
||||
AL.alBufferData(buffers.get(0), wavefile.format, wavefile.data, wavefile.data.capacity(), wavefile.samplerate);
|
||||
AL10.alBufferData(buffers.get(0), wavefile.format, wavefile.data, wavefile.data.capacity(), wavefile.samplerate);
|
||||
|
||||
//unload file again
|
||||
wavefile.dispose();
|
||||
}
|
||||
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//set up source input
|
||||
AL.alSourcei(sources.get(0), AL.AL_BUFFER, buffers.get(0));
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alSourcei(sources.get(0), AL10.AL_BUFFER, buffers.get(0));
|
||||
if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//lets loop the sound
|
||||
AL.alSourcei(sources.get(0), AL.AL_LOOPING, AL.AL_TRUE);
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alSourcei(sources.get(0), AL10.AL_LOOPING, AL10.AL_TRUE);
|
||||
if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//play source 0
|
||||
AL.alSourcePlay(sources.get(0));
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alSourcePlay(sources.get(0));
|
||||
if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
@ -146,21 +146,21 @@ public class PlayTest extends BasicTest {
|
|||
}
|
||||
|
||||
//stop source 0
|
||||
AL.alSourceStop(sources.get(0));
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alSourceStop(sources.get(0));
|
||||
if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//delete buffers and sources
|
||||
sources.position(0).limit(1);
|
||||
AL.alDeleteSources(sources);
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alDeleteSources(sources);
|
||||
if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
buffers.position(0).limit(1);
|
||||
AL.alDeleteBuffers(buffers);
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alDeleteBuffers(buffers);
|
||||
if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import java.nio.ByteBuffer;
|
|||
import java.nio.ByteOrder;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import org.lwjgl.openal.AL;
|
||||
import org.lwjgl.openal.AL10;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
|
|
@ -70,7 +70,7 @@ public class PlayTestMemory extends BasicTest {
|
|||
|
||||
if(args[0].endsWith(".ogg")) {
|
||||
System.out.print("Attempting to load Ogg Vorbis file, checking for extension...");
|
||||
if(AL.alIsExtensionPresent("AL_EXT_vorbis")) {
|
||||
if(AL10.alIsExtensionPresent("AL_EXT_vorbis")) {
|
||||
System.out.println("found");
|
||||
usingVorbis = true;
|
||||
} else {
|
||||
|
|
@ -88,14 +88,14 @@ public class PlayTestMemory extends BasicTest {
|
|||
|
||||
// al generate buffers and sources
|
||||
buffers.position(0).limit(1);
|
||||
AL.alGenBuffers(buffers);
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alGenBuffers(buffers);
|
||||
if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
sources.position(0).limit(1);
|
||||
AL.alGenSources(sources);
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alGenSources(sources);
|
||||
if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
@ -111,40 +111,40 @@ public class PlayTestMemory extends BasicTest {
|
|||
//ALUTLoadWAVData file = alut.loadWAVMemory(Sys.getDirectBufferAddress(filebuffer));
|
||||
if(usingVorbis) {
|
||||
// pass directly to buffer data
|
||||
AL.alBufferData(buffers.get(0), AL.AL_FORMAT_VORBIS_EXT, filebuffer, -1, -1);
|
||||
AL10.alBufferData(buffers.get(0), AL10.AL_FORMAT_VORBIS_EXT, filebuffer, -1, -1);
|
||||
filebuffer.clear();
|
||||
} else {
|
||||
// load wave data from buffer
|
||||
WaveData wavefile = WaveData.create(filebuffer.array());
|
||||
|
||||
//copy to buffers
|
||||
AL.alBufferData(buffers.get(0), wavefile.format, wavefile.data, wavefile.data.capacity(), wavefile.samplerate);
|
||||
AL10.alBufferData(buffers.get(0), wavefile.format, wavefile.data, wavefile.data.capacity(), wavefile.samplerate);
|
||||
|
||||
//unload file again
|
||||
wavefile.dispose();
|
||||
}
|
||||
|
||||
// check for errors
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
||||
//set up source input
|
||||
AL.alSourcei(sources.get(0), AL.AL_BUFFER, buffers.get(0));
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alSourcei(sources.get(0), AL10.AL_BUFFER, buffers.get(0));
|
||||
if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//lets loop the sound
|
||||
AL.alSourcei(sources.get(0), AL.AL_LOOPING, AL.AL_TRUE);
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alSourcei(sources.get(0), AL10.AL_LOOPING, AL10.AL_TRUE);
|
||||
if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//play source 0
|
||||
AL.alSourcePlay(sources.get(0));
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alSourcePlay(sources.get(0));
|
||||
if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
@ -156,21 +156,21 @@ public class PlayTestMemory extends BasicTest {
|
|||
}
|
||||
|
||||
//stop source 0
|
||||
AL.alSourceStop(sources.get(0));
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alSourceStop(sources.get(0));
|
||||
if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//delete buffers and sources
|
||||
sources.position(0).limit(1);
|
||||
AL.alDeleteSources(sources);
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alDeleteSources(sources);
|
||||
if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
buffers.position(0).limit(1);
|
||||
AL.alDeleteBuffers(buffers);
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alDeleteBuffers(buffers);
|
||||
if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import org.lwjgl.Sys;
|
|||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.openal.AL;
|
||||
import org.lwjgl.openal.AL10;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.Window;
|
||||
import org.lwjgl.opengl.glu.GLU;
|
||||
|
|
@ -158,17 +159,17 @@ public class PositionTest extends BasicTest {
|
|||
rightPosition.flip();
|
||||
rightVelocity.flip();
|
||||
|
||||
AL.alListener(AL.AL_POSITION, listenerPosition);
|
||||
AL.alListener(AL.AL_VELOCITY, listenerVelocity);
|
||||
AL.alListener(AL.AL_ORIENTATION, listenerOrientation);
|
||||
AL10.alListener(AL10.AL_POSITION, listenerPosition);
|
||||
AL10.alListener(AL10.AL_VELOCITY, listenerVelocity);
|
||||
AL10.alListener(AL10.AL_ORIENTATION, listenerOrientation);
|
||||
|
||||
// creating buffers
|
||||
Sys.log("Creating buffers");
|
||||
AL.alGenBuffers(soundBuffers);
|
||||
AL10.alGenBuffers(soundBuffers);
|
||||
soundBuffers.rewind();
|
||||
|
||||
// creating sources
|
||||
AL.alGenSources(soundSources);
|
||||
AL10.alGenSources(soundSources);
|
||||
soundSources.rewind();
|
||||
|
||||
// load sound files (left, center, right).wav
|
||||
|
|
@ -176,33 +177,33 @@ public class PositionTest extends BasicTest {
|
|||
|
||||
Sys.log("Loading left.wav");
|
||||
WaveData left = WaveData.create("left.wav");
|
||||
AL.alBufferData(soundBuffers.get(LEFT), left.format, left.data, left.data.capacity(), left.samplerate);
|
||||
AL.alSourcef(soundSources.get(LEFT), AL.AL_PITCH, 1.0f);
|
||||
AL.alSourcef(soundSources.get(LEFT), AL.AL_GAIN, 1.0f);
|
||||
AL.alSource(soundSources.get(LEFT), AL.AL_POSITION, leftPosition);
|
||||
AL.alSource(soundSources.get(LEFT), AL.AL_VELOCITY, leftVelocity);
|
||||
AL.alSourcei(soundSources.get(LEFT), AL.AL_BUFFER, soundBuffers.get(LEFT));
|
||||
AL.alSourcei(soundSources.get(LEFT), AL.AL_LOOPING, AL.AL_TRUE);
|
||||
AL10.alBufferData(soundBuffers.get(LEFT), left.format, left.data, left.data.capacity(), left.samplerate);
|
||||
AL10.alSourcef(soundSources.get(LEFT), AL10.AL_PITCH, 1.0f);
|
||||
AL10.alSourcef(soundSources.get(LEFT), AL10.AL_GAIN, 1.0f);
|
||||
AL10.alSource(soundSources.get(LEFT), AL10.AL_POSITION, leftPosition);
|
||||
AL10.alSource(soundSources.get(LEFT), AL10.AL_VELOCITY, leftVelocity);
|
||||
AL10.alSourcei(soundSources.get(LEFT), AL10.AL_BUFFER, soundBuffers.get(LEFT));
|
||||
AL10.alSourcei(soundSources.get(LEFT), AL10.AL_LOOPING, AL10.AL_TRUE);
|
||||
|
||||
Sys.log("Loading center.wav");
|
||||
WaveData center = WaveData.create("center.wav");
|
||||
AL.alBufferData(soundBuffers.get(CENTER), center.format, center.data, center.data.capacity(), center.samplerate);
|
||||
AL.alSourcef(soundSources.get(CENTER), AL.AL_PITCH, 1.0f);
|
||||
AL.alSourcef(soundSources.get(CENTER), AL.AL_GAIN, 1.0f);
|
||||
AL.alSource(soundSources.get(CENTER), AL.AL_POSITION, centerPosition);
|
||||
AL.alSource(soundSources.get(CENTER), AL.AL_VELOCITY, centerVelocity);
|
||||
AL.alSourcei(soundSources.get(CENTER), AL.AL_BUFFER, soundBuffers.get(CENTER));
|
||||
AL.alSourcei(soundSources.get(CENTER), AL.AL_LOOPING, AL.AL_TRUE);
|
||||
AL10.alBufferData(soundBuffers.get(CENTER), center.format, center.data, center.data.capacity(), center.samplerate);
|
||||
AL10.alSourcef(soundSources.get(CENTER), AL10.AL_PITCH, 1.0f);
|
||||
AL10.alSourcef(soundSources.get(CENTER), AL10.AL_GAIN, 1.0f);
|
||||
AL10.alSource(soundSources.get(CENTER), AL10.AL_POSITION, centerPosition);
|
||||
AL10.alSource(soundSources.get(CENTER), AL10.AL_VELOCITY, centerVelocity);
|
||||
AL10.alSourcei(soundSources.get(CENTER), AL10.AL_BUFFER, soundBuffers.get(CENTER));
|
||||
AL10.alSourcei(soundSources.get(CENTER), AL10.AL_LOOPING, AL10.AL_TRUE);
|
||||
|
||||
Sys.log("Loading right.wav");
|
||||
WaveData right = WaveData.create("right.wav");
|
||||
AL.alBufferData(soundBuffers.get(RIGHT), right.format, right.data, right.data.capacity(), right.samplerate);
|
||||
AL.alSourcef(soundSources.get(RIGHT), AL.AL_PITCH, 1.0f);
|
||||
AL.alSourcef(soundSources.get(RIGHT), AL.AL_GAIN, 1.0f);
|
||||
AL.alSource(soundSources.get(RIGHT), AL.AL_POSITION, rightPosition);
|
||||
AL.alSource(soundSources.get(RIGHT), AL.AL_VELOCITY, rightVelocity);
|
||||
AL.alSourcei(soundSources.get(RIGHT), AL.AL_BUFFER, soundBuffers.get(RIGHT));
|
||||
AL.alSourcei(soundSources.get(RIGHT), AL.AL_LOOPING, AL.AL_TRUE);
|
||||
AL10.alBufferData(soundBuffers.get(RIGHT), right.format, right.data, right.data.capacity(), right.samplerate);
|
||||
AL10.alSourcef(soundSources.get(RIGHT), AL10.AL_PITCH, 1.0f);
|
||||
AL10.alSourcef(soundSources.get(RIGHT), AL10.AL_GAIN, 1.0f);
|
||||
AL10.alSource(soundSources.get(RIGHT), AL10.AL_POSITION, rightPosition);
|
||||
AL10.alSource(soundSources.get(RIGHT), AL10.AL_VELOCITY, rightVelocity);
|
||||
AL10.alSourcei(soundSources.get(RIGHT), AL10.AL_BUFFER, soundBuffers.get(RIGHT));
|
||||
AL10.alSourcei(soundSources.get(RIGHT), AL10.AL_LOOPING, AL10.AL_TRUE);
|
||||
|
||||
Sys.log("Soundfiles loaded successfully");
|
||||
// -----------------------------------------------------
|
||||
|
|
@ -281,11 +282,11 @@ public class PositionTest extends BasicTest {
|
|||
* Starts playing the sounds at different times
|
||||
*/
|
||||
private void startSounds() {
|
||||
AL.alSourcePlay(soundSources.get(LEFT));
|
||||
AL10.alSourcePlay(soundSources.get(LEFT));
|
||||
pause(300);
|
||||
AL.alSourcePlay(soundSources.get(CENTER));
|
||||
AL10.alSourcePlay(soundSources.get(CENTER));
|
||||
pause(500);
|
||||
AL.alSourcePlay(soundSources.get(RIGHT));
|
||||
AL10.alSourcePlay(soundSources.get(RIGHT));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -297,7 +298,7 @@ public class PositionTest extends BasicTest {
|
|||
// if requesting pause, and not paused - pause and stop sound
|
||||
if(paused && !pauseMode) {
|
||||
pauseMode = true;
|
||||
AL.alSourcePause(soundSources);
|
||||
AL10.alSourcePause(soundSources);
|
||||
}
|
||||
|
||||
// else go out of pause mode and start sounds
|
||||
|
|
@ -325,17 +326,17 @@ public class PositionTest extends BasicTest {
|
|||
// Test for play
|
||||
// ============================================
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_1)) {
|
||||
AL.alSourcePlay(soundSources.get(LEFT));
|
||||
AL10.alSourcePlay(soundSources.get(LEFT));
|
||||
Sys.log("Playing left.wav");
|
||||
}
|
||||
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_2)) {
|
||||
AL.alSourcePlay(soundSources.get(CENTER));
|
||||
AL10.alSourcePlay(soundSources.get(CENTER));
|
||||
Sys.log("Playing center.wav");
|
||||
}
|
||||
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_3)) {
|
||||
AL.alSourcePlay(soundSources.get(RIGHT));
|
||||
AL10.alSourcePlay(soundSources.get(RIGHT));
|
||||
Sys.log("Playing right.wav");
|
||||
}
|
||||
// --------------------------------------------
|
||||
|
|
@ -343,17 +344,17 @@ public class PositionTest extends BasicTest {
|
|||
// Test for stop
|
||||
// ============================================
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_4)) {
|
||||
AL.alSourceStop(soundSources.get(LEFT));
|
||||
AL10.alSourceStop(soundSources.get(LEFT));
|
||||
Sys.log("Stopped left.wav");
|
||||
}
|
||||
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_5)) {
|
||||
AL.alSourceStop(soundSources.get(CENTER));
|
||||
AL10.alSourceStop(soundSources.get(CENTER));
|
||||
Sys.log("Stopped center.wav");
|
||||
}
|
||||
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_6)) {
|
||||
AL.alSourceStop(soundSources.get(RIGHT));
|
||||
AL10.alSourceStop(soundSources.get(RIGHT));
|
||||
Sys.log("Stopped right.wav");
|
||||
}
|
||||
// --------------------------------------------
|
||||
|
|
@ -362,12 +363,12 @@ public class PositionTest extends BasicTest {
|
|||
// ============================================
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {
|
||||
listenerPosition.put(0, listenerPosition.get(0) - 0.1f);
|
||||
AL.alListener(AL.AL_POSITION, listenerPosition);
|
||||
AL10.alListener(AL10.AL_POSITION, listenerPosition);
|
||||
}
|
||||
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {
|
||||
listenerPosition.put(0, listenerPosition.get(0) + 0.1f);
|
||||
AL.alListener(AL.AL_POSITION, listenerPosition);
|
||||
AL10.alListener(AL10.AL_POSITION, listenerPosition);
|
||||
}
|
||||
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_UP)) {
|
||||
|
|
@ -376,7 +377,7 @@ public class PositionTest extends BasicTest {
|
|||
} else {
|
||||
listenerPosition.put(2, listenerPosition.get(2) - 0.1f);
|
||||
}
|
||||
AL.alListener(AL.AL_POSITION, listenerPosition);
|
||||
AL10.alListener(AL10.AL_POSITION, listenerPosition);
|
||||
}
|
||||
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {
|
||||
|
|
@ -385,7 +386,7 @@ public class PositionTest extends BasicTest {
|
|||
} else {
|
||||
listenerPosition.put(2, listenerPosition.get(2) + 0.1f);
|
||||
}
|
||||
AL.alListener(AL.AL_POSITION, listenerPosition);
|
||||
AL10.alListener(AL10.AL_POSITION, listenerPosition);
|
||||
}
|
||||
// --------------------------------------------
|
||||
|
||||
|
|
@ -400,7 +401,7 @@ public class PositionTest extends BasicTest {
|
|||
listenerPosition.put(2, listenerPosition.get(2) + 0.1f);
|
||||
}
|
||||
|
||||
AL.alListener(AL.AL_POSITION, listenerPosition);
|
||||
AL10.alListener(AL10.AL_POSITION, listenerPosition);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -463,9 +464,9 @@ public class PositionTest extends BasicTest {
|
|||
Mouse.destroy();
|
||||
|
||||
Sys.log("Shutting down OpenAL");
|
||||
AL.alSourceStop(soundSources);
|
||||
AL.alDeleteSources(soundSources);
|
||||
AL.alDeleteBuffers(soundBuffers);
|
||||
AL10.alSourceStop(soundSources);
|
||||
AL10.alDeleteSources(soundSources);
|
||||
AL10.alDeleteBuffers(soundBuffers);
|
||||
AL.destroy();
|
||||
|
||||
Sys.log("Shutting down Window");
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ package org.lwjgl.test.openal;
|
|||
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import org.lwjgl.openal.AL;
|
||||
import org.lwjgl.openal.AL10;
|
||||
import org.lwjgl.openal.OpenALException;
|
||||
|
||||
/**
|
||||
|
|
@ -97,15 +97,15 @@ public class SourceLimitTest extends BasicTest {
|
|||
|
||||
//Create sourcesToCreate sources in one fell swoop
|
||||
sources.position(0).limit(sourcesToCreate);
|
||||
AL.alGenSources(sources);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
System.out.println("failed to create " + sourcesToCreate + " sources (" + AL.alGetString(lastError) + ")");
|
||||
AL10.alGenSources(sources);
|
||||
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
System.out.println("failed to create " + sourcesToCreate + " sources (" + AL10.alGetString(lastError) + ")");
|
||||
return;
|
||||
}
|
||||
|
||||
//delete sources
|
||||
sources.position(0).limit(sourcesToCreate);
|
||||
AL.alDeleteSources(sources);
|
||||
AL10.alDeleteSources(sources);
|
||||
|
||||
System.out.println("created " + sourcesToCreate + " sources successfully!");
|
||||
}
|
||||
|
|
@ -124,8 +124,8 @@ public class SourceLimitTest extends BasicTest {
|
|||
for (int i = 0; i <= sourcesToCreate; i++) {
|
||||
sources[i] = createIntBuffer(1);
|
||||
sources[i].position(0).limit(1);
|
||||
AL.alGenSources(sources[i]);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
AL10.alGenSources(sources[i]);
|
||||
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
System.out.println("failed to create source: " + (i + 1));
|
||||
break;
|
||||
}
|
||||
|
|
@ -136,9 +136,9 @@ public class SourceLimitTest extends BasicTest {
|
|||
for (int i = 0; i < sourcesCreated; i++) {
|
||||
//delete buffers and sources
|
||||
sources[i].position(0).limit(1);
|
||||
AL.alDeleteSources(sources[i]);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
System.out.println("failed to delete source: " + i + "(" + AL.alGetString(lastError) + ")");
|
||||
AL10.alDeleteSources(sources[i]);
|
||||
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||
System.out.println("failed to delete source: " + i + "(" + AL10.alGetString(lastError) + ")");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ package org.lwjgl.test.openal;
|
|||
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import org.lwjgl.openal.AL;
|
||||
import org.lwjgl.openal.AL10;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
|
|
@ -81,8 +81,8 @@ public class StressTest extends BasicTest {
|
|||
private void createSources() {
|
||||
sources = createIntBuffer(4);
|
||||
sources.position(0).limit(4);
|
||||
AL.alGenSources(sources);
|
||||
if (AL.alGetError() != AL.AL_NO_ERROR) {
|
||||
AL10.alGenSources(sources);
|
||||
if (AL10.alGetError() != AL10.AL_NO_ERROR) {
|
||||
System.out.println("Unable to create 4 sources");
|
||||
alExit();
|
||||
}
|
||||
|
|
@ -91,32 +91,32 @@ public class StressTest extends BasicTest {
|
|||
private void createBuffers() {
|
||||
buffers = createIntBuffer(10);
|
||||
buffers.position(0).limit(10);
|
||||
AL.alGenBuffers(buffers);
|
||||
if (AL.alGetError() != AL.AL_NO_ERROR) {
|
||||
AL10.alGenBuffers(buffers);
|
||||
if (AL10.alGetError() != AL10.AL_NO_ERROR) {
|
||||
System.out.println("Unable to create 10 buffers");
|
||||
sources.position(0).limit(4);
|
||||
AL.alDeleteSources(sources);
|
||||
AL10.alDeleteSources(sources);
|
||||
alExit();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadSamples() throws Exception {
|
||||
AL.alGetError();
|
||||
AL10.alGetError();
|
||||
WaveData data = WaveData.create("ding.wav");
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
AL.alBufferData(
|
||||
AL10.alBufferData(
|
||||
buffers.get(i - 1),
|
||||
data.format,
|
||||
data.data,
|
||||
data.data.capacity(),
|
||||
data.samplerate);
|
||||
|
||||
if (AL.alGetError() != AL.AL_NO_ERROR) {
|
||||
if (AL10.alGetError() != AL10.AL_NO_ERROR) {
|
||||
System.out.println("Failed to load " + i + ".wav into buffer");
|
||||
sources.position(0).limit(4);
|
||||
AL.alDeleteSources(sources);
|
||||
AL10.alDeleteSources(sources);
|
||||
buffers.position(0).limit(10);
|
||||
AL.alDeleteBuffers(buffers);
|
||||
AL10.alDeleteBuffers(buffers);
|
||||
|
||||
alExit();
|
||||
}
|
||||
|
|
@ -132,11 +132,11 @@ public class StressTest extends BasicTest {
|
|||
long startTime = System.currentTimeMillis();
|
||||
|
||||
//mark background source as looping
|
||||
AL.alSourcei(sources.get(0), AL.AL_LOOPING, AL.AL_TRUE);
|
||||
AL10.alSourcei(sources.get(0), AL10.AL_LOOPING, AL10.AL_TRUE);
|
||||
|
||||
//play background
|
||||
AL.alSourcei(sources.get(0), AL.AL_BUFFER, buffers.get(0));
|
||||
AL.alSourcePlay(sources.get(0));
|
||||
AL10.alSourcei(sources.get(0), AL10.AL_BUFFER, buffers.get(0));
|
||||
AL10.alSourcePlay(sources.get(0));
|
||||
|
||||
while (System.currentTimeMillis() - startTime < (2000)) {
|
||||
|
||||
|
|
@ -144,22 +144,22 @@ public class StressTest extends BasicTest {
|
|||
System.out.println("random:" + randomBuffer);
|
||||
|
||||
//stop source at slot
|
||||
AL.alSourceStop(sources.get(nextSlot));
|
||||
if (AL.alGetError() != AL.AL_NO_ERROR) {
|
||||
AL10.alSourceStop(sources.get(nextSlot));
|
||||
if (AL10.alGetError() != AL10.AL_NO_ERROR) {
|
||||
System.out.println("Error stopping source.");
|
||||
}
|
||||
System.out.println("Stopped source: " + nextSlot);
|
||||
|
||||
//link source<->buffer
|
||||
AL.alSourcei(sources.get(nextSlot), AL.AL_BUFFER, buffers.get(randomBuffer));
|
||||
if (AL.alGetError() != AL.AL_NO_ERROR) {
|
||||
AL10.alSourcei(sources.get(nextSlot), AL10.AL_BUFFER, buffers.get(randomBuffer));
|
||||
if (AL10.alGetError() != AL10.AL_NO_ERROR) {
|
||||
System.out.println("Error linking buffer and source.");
|
||||
}
|
||||
System.out.println("linked source " + nextSlot + " with buffer " + randomBuffer);
|
||||
|
||||
//start playing
|
||||
System.out.println("playing source " + nextSlot);
|
||||
AL.alSourcePlay(sources.get(nextSlot++));
|
||||
AL10.alSourcePlay(sources.get(nextSlot++));
|
||||
if (nextSlot == 4) {
|
||||
nextSlot = startSlot;
|
||||
}
|
||||
|
|
@ -182,7 +182,7 @@ public class StressTest extends BasicTest {
|
|||
|
||||
//stop all sources
|
||||
for (int i = 0; i < 4; i++) {
|
||||
AL.alSourceStop(sources.get(i));
|
||||
AL10.alSourceStop(sources.get(i));
|
||||
System.out.println("Stopping source " + (i+1));
|
||||
}
|
||||
|
||||
|
|
@ -200,9 +200,9 @@ public class StressTest extends BasicTest {
|
|||
}
|
||||
|
||||
sources.position(0).limit(4);
|
||||
AL.alDeleteSources(sources);
|
||||
AL10.alDeleteSources(sources);
|
||||
buffers.position(0).limit(10);
|
||||
AL.alDeleteBuffers(buffers);
|
||||
AL10.alDeleteBuffers(buffers);
|
||||
}
|
||||
|
||||
private int getRandomBuffer() {
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ import javax.sound.sampled.AudioFormat;
|
|||
import javax.sound.sampled.AudioInputStream;
|
||||
import javax.sound.sampled.AudioSystem;
|
||||
|
||||
import org.lwjgl.openal.AL;
|
||||
import org.lwjgl.openal.AL10;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
|
|
@ -131,17 +131,17 @@ public class WaveData {
|
|||
int channels = 0;
|
||||
if (audioformat.getChannels() == 1) {
|
||||
if (audioformat.getSampleSizeInBits() == 8) {
|
||||
channels = AL.AL_FORMAT_MONO8;
|
||||
channels = AL10.AL_FORMAT_MONO8;
|
||||
} else if (audioformat.getSampleSizeInBits() == 16) {
|
||||
channels = AL.AL_FORMAT_MONO16;
|
||||
channels = AL10.AL_FORMAT_MONO16;
|
||||
} else {
|
||||
assert false : "Illegal sample size";
|
||||
}
|
||||
} else if (audioformat.getChannels() == 2) {
|
||||
if (audioformat.getSampleSizeInBits() == 8) {
|
||||
channels = AL.AL_FORMAT_STEREO8;
|
||||
channels = AL10.AL_FORMAT_STEREO8;
|
||||
} else if (audioformat.getSampleSizeInBits() == 16) {
|
||||
channels = AL.AL_FORMAT_STEREO16;
|
||||
channels = AL10.AL_FORMAT_STEREO16;
|
||||
} else {
|
||||
assert false : "Illegal sample size";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue