summaryrefslogtreecommitdiffstats
path: root/test/src/com/jogamp
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-03-29 18:35:57 +0200
committerMichael Bien <[email protected]>2010-03-29 18:35:57 +0200
commit4050d93e4747b5418379319e7216af6113ea23e5 (patch)
treedb71cc08193e1f893a2f2f296930eb11f6d8897c /test/src/com/jogamp
parent869f7899143296f70fbedb7ead9750aa2e4da172 (diff)
renamed package to com.jogamp.openal.*
Diffstat (limited to 'test/src/com/jogamp')
-rw-r--r--test/src/com/jogamp/openal/ALTest.java919
-rw-r--r--test/src/com/jogamp/openal/OpenALTest.java122
-rw-r--r--test/src/com/jogamp/openal/Sound3DTest.java117
3 files changed, 1158 insertions, 0 deletions
diff --git a/test/src/com/jogamp/openal/ALTest.java b/test/src/com/jogamp/openal/ALTest.java
new file mode 100644
index 0000000..45b7995
--- /dev/null
+++ b/test/src/com/jogamp/openal/ALTest.java
@@ -0,0 +1,919 @@
+/*
+ * Created on Jun 3, 2003
+ *
+ * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ */
+package com.jogamp.openal;
+
+import java.io.IOException;
+
+import javax.sound.sampled.UnsupportedAudioFileException;
+
+import junit.framework.TestCase;
+import com.jogamp.openal.util.*;
+
+/**
+ * @author Athomas Goldberg
+ *
+ */
+public class ALTest extends TestCase {
+
+
+ static AL al;
+ static ALC alc;
+ static ALCcontext context;
+ static ALCdevice device;
+ final static String TEST_FILE ="lewiscarroll.wav";
+
+ /**
+ * Constructor for ALTest.
+ * @param arg0
+ */
+ public ALTest(String arg0) {
+ super(arg0);
+ }
+
+ public void setUp() {
+ try {
+ al = ALFactory.getAL();
+ alc = ALFactory.getALC();
+ device = alc.alcOpenDevice(null);
+ context = alc.alcCreateContext(device, null);
+ alc.alcMakeContextCurrent(context);
+ } catch (ALException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void tearDown() {
+ alc.alcMakeContextCurrent(null);
+ alc.alcDestroyContext(context);
+ alc.alcCloseDevice(device);
+ }
+
+ public static void main(String[] args) {
+ System.out.println("begin main");
+ junit.textui.TestRunner.run(ALTest.class);
+ System.out.println("end main");
+ }
+
+ /*
+ * Test for void alGenBuffers(int, IntBuffer)
+ *//*
+ final public void testAlGenBuffersintIntBuffer() {
+ System.out.println("begin testAlGenBuffersintintBuffer");
+ // try basic case
+ try {
+ IntBuffer buffers = BufferUtils.newIntBuffer(7);
+ al.alGenBuffers(7,buffers);
+ for(int i = 0; i < 7; i++) {
+ assertFalse(buffers.get(i) == 0);
+ assertTrue(al.alIsBuffer(buffers.get(i)));
+ }
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+
+ Exception ex = null;
+ // buffers == null
+ try {
+ IntBuffer buffers = null;
+ al.alGenBuffers(7,buffers);
+
+
+ } catch(IllegalArgumentException e) {
+ ex = e;
+ }
+ assertNotNull(ex);
+
+ ex = null;
+ // buffer too small
+ try {
+ IntBuffer buffers = BufferUtils.newIntBuffer(5);
+ al.alGenBuffers(7,buffers);
+ } catch(IllegalArgumentException e) {
+ ex = e;
+ }
+ assertNotNull(ex);
+
+ ex = null;
+ // buffer not direct
+ try {
+ IntBuffer buffers = IntBuffer.allocate(7);
+ al.alGenBuffers(7,buffers);
+ } catch(IllegalArgumentException e) {
+ ex = e;
+ }
+ assertNotNull(ex);
+ System.out.println("end testAlGenBuffersintintBuffer");
+ }
+*/
+ /*
+ * Test for void alGenBuffers(int, int[])
+ */
+ final public void testAlGenBuffersintintArray() {
+
+ System.out.println("begin testAlGenBuffersintintArray");
+ // try basic case
+ try {
+ int[] buffers = new int[7];
+ al.alGenBuffers(7,buffers, 0);
+ for(int i = 0; i < 7; i++) {
+ assertFalse(buffers[i] == 0);
+ assertTrue(al.alIsBuffer(buffers[i]));
+ }
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+
+ Exception ex = null;
+ // try exceptions
+ try {
+ int[] buffers = null;
+ al.alGenBuffers(7,buffers, 0);
+
+
+ } catch(IllegalArgumentException e) {
+ ex = e;
+ }
+ assertNotNull(ex);
+ ex = null;
+ try {
+ int[] buffers = new int[5];
+ al.alGenBuffers(7,buffers, 0);
+ } catch(IllegalArgumentException e) {
+ ex = e;
+ }
+ assertNotNull(ex);
+
+ System.out.println("end testAlGenBuffersintintArray");
+
+ }
+
+ /*
+ * Test for void alDeleteBuffers(int, IntBuffer)
+ */
+ final public void testAlDeleteBuffersintIntBuffer() {
+ System.out.println("begin testAlDeleteBuffersintintArray");
+ // try basic case
+ try {
+ int[] buffers = new int[7];
+ al.alGenBuffers(7,buffers,0);
+ for(int i = 0; i < 7; i++) {
+ assertFalse(buffers[i] == 0);
+ assertTrue(al.alIsBuffer(buffers[i]));
+ }
+ al.alDeleteBuffers(7,buffers,0);
+ for(int i = 0; i < 7; i++) {
+ assertFalse(al.alIsBuffer(buffers[i]));
+ }
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+
+ Exception ex = null;
+ // try exceptions
+ try {
+ al.alDeleteBuffers(7,(int[])null, 0);
+ } catch(IllegalArgumentException e) {
+ ex = e;
+ }
+ assertNotNull(ex);
+ ex = null;
+ try {
+ int[] buffers = new int[5];
+ al.alGenBuffers(5,buffers,0);
+ al.alDeleteBuffers(7,buffers,0);
+ } catch(IllegalArgumentException e) {
+ ex = e;
+ }
+ assertNotNull(ex);
+
+ try {
+ int[] buffers = new int[7];
+ al.alDeleteBuffers(7,buffers,0);
+ assertTrue(al.alGetError() != 0);
+ } catch(Exception e) {
+ fail("deleting an unfilled buffer list should generate an ALError but not an exception");
+ }
+
+ System.out.println("end testAlDeleteBuffersintintArray");
+ }
+
+ /*
+ * Test for void alDeleteBuffers(int, int[])
+ */
+ final public void testAlDeleteBuffersintintArray() {
+ System.out.println("begin testAlDeleteBuffersintIntBuffer");
+ // try basic case
+ try {
+ int[] buffers = new int[7];
+ al.alGenBuffers(7,buffers,0);
+ for(int i = 0; i < 7; i++) {
+ assertFalse(buffers[i] == 0);
+ assertTrue(al.alIsBuffer(buffers[i]));
+ }
+ al.alDeleteBuffers(7,buffers,0);
+ for(int i = 0; i < 7; i++) {
+ assertFalse(al.alIsBuffer(buffers[i]));
+ }
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+
+ Exception ex = null;
+ // try exceptions
+ try {
+ al.alDeleteBuffers(7,(int[])null,0);
+ } catch(IllegalArgumentException e) {
+ ex = e;
+ }
+ assertNotNull(ex);
+ ex = null;
+ try {
+ int[] buffers = new int[5];
+ al.alGenBuffers(5,buffers,0);
+ al.alDeleteBuffers(7,buffers,0);
+ } catch(IllegalArgumentException e) {
+ ex = e;
+ }
+ assertNotNull(ex);
+
+ ex = null;
+ try {
+ int[] buffers = new int[5];
+ al.alDeleteBuffers(7,buffers,0);
+ } catch(IllegalArgumentException e) {
+ ex = e;
+ }
+ assertNotNull(ex);
+
+ try {
+ int[] buffers = new int[7];
+ al.alDeleteBuffers(7,buffers,0);
+ assertTrue(al.alGetError() != 0);
+ } catch(Exception e) {
+ fail("deleting an unfilled buffer list should generate an ALError but not an exception");
+ }
+
+ System.out.println("end testAlDeleteBuffersintintArray");
+ }
+
+ final public void testAlIsBuffer() {
+ System.out.println("begin testALIsBuffer");
+ try {
+ // check a bufferlist with known bad values
+ int[] buffers = new int[7];
+ for(int i = 0; i < 7; i++) {
+ buffers[i] = -1;
+ assertFalse(al.alIsBuffer(buffers[i]));
+ }
+ // created
+ al.alGenBuffers(7,buffers,0);
+ for(int i = 0; i < 7; i++) {
+ assertTrue(al.alIsBuffer(buffers[i]));
+ }
+ // deleted
+ al.alDeleteBuffers(7,buffers,0);
+ for(int i = 0; i < 7; i++) {
+ assertFalse(al.alIsBuffer(buffers[i]));
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ System.out.println("end testALisBuffer");
+ }
+
+ /*
+ * Test for void alBufferData(int, int, Buffer, int, int)
+ */
+ final public void testAlBufferDataintintByteBufferintint() {
+ System.out.println("begin testAlBufferDataintintByteBufferintint");
+ try {
+ int[] buffers = new int[1];
+ al.alGenBuffers(1, buffers, 0);
+ WAVData wd =
+ WAVLoader.loadFromFile(TEST_FILE);
+ al.alBufferData(
+ buffers[0],
+ wd.format,
+ wd.data,
+ wd.size,
+ wd.freq
+ );
+ int[] tmp = new int[1];
+ al.alGetBufferi(buffers[0],AL.AL_SIZE,tmp,0);
+ assertFalse(tmp[0] == 0);
+ } catch(Exception e) {
+ fail(e.toString());
+ }
+ Exception ex = null;
+ try {
+ int[] buffers = new int[1];
+ al.alGenBuffers(1, buffers, 0);
+
+ al.alBufferData(
+ buffers[0],
+ AL.AL_FORMAT_STEREO16,
+ null,
+ 0,
+ 0
+ );
+ } catch(IllegalArgumentException e) {
+ ex = e;
+ }
+ assertNotNull(ex);
+
+ System.out.println("end testAlBufferDataintintByteBufferintint");
+ }
+
+ /*
+ * Test for void alGetBufferf(int, int, float[])
+ */
+ final public void testAlGetBufferfintintfloatArray() {
+ System.out.println("begin testAlGetBufferfintintfloatArray");
+
+ // there are currently NO float attributes for buffers.
+
+ System.out.println("end testAlGetBufferfintintfloatArray");
+ }
+
+ /*
+ * Test for void alGetBufferf(int, int, FloatBuffer)
+ */
+ final public void testAlGetBufferfintintFloatBuffer() {
+ System.out.println("begin testAlGetBufferfintintFloatBuffer");
+
+ // there are currently NO float attributes for buffers.
+
+ System.out.println("end testAlGetBufferfintintFloatBuffer");
+ }
+
+ /*
+ * Test for float alGetBufferf(int, int)
+ */
+ final public void testAlGetBufferfintint() {
+ System.out.println("begin testAlGetBufferfintintFloatBuffer");
+
+ // there are currently NO float attributes for buffers.
+
+ System.out.println("end testAlGetBufferfintintFloatBuffer");
+ }
+
+ /*
+ * Test for void alGetBufferi(int, int, int[])
+ */
+ final public void testAlGetBufferiintintintArray() {
+ System.out.println("begin testAlGetBufferiintintintArray");
+ try {
+ int[] buffers = new int[1];
+ al.alGenBuffers(1, buffers, 0);
+ WAVData wd =
+ WAVLoader.loadFromFile(TEST_FILE);
+ al.alBufferData(
+ buffers[0],
+ wd.format,
+ wd.data,
+ wd.size,
+ wd.freq
+ );
+ int[] size = new int[1];
+ int[] freq = new int[1];
+ al.alGetBufferi(buffers[0],AL.AL_SIZE, size, 0);
+ al.alGetBufferi(buffers[0],AL.AL_FREQUENCY, freq, 0);
+ assertEquals(wd.size, size[0]);
+ assertEquals(wd.freq, freq[0]);
+ } catch(Exception e) {
+ fail(e.toString());
+ }
+
+ Exception ex = null;
+ try {
+ int[] buffers = new int[1];
+ al.alGenBuffers(1, buffers, 0);
+ WAVData wd =
+ WAVLoader.loadFromFile(TEST_FILE);
+ al.alBufferData(
+ buffers[0],
+ wd.format,
+ wd.data,
+ wd.size,
+ wd.freq
+ );
+ int[] size = null;
+ al.alGetBufferi(buffers[0],AL.AL_SIZE, size, 0);
+
+ } catch (IllegalArgumentException e) {
+ ex = e;
+ } catch (UnsupportedAudioFileException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+
+ assertNotNull(ex);
+
+ System.out.println("end testAlGetBufferiintintintArray");
+ }
+
+ /*
+ * Test for void alGetBufferi(int, int, IntBuffer)
+ */
+ final public void testAlGetBufferiintintIntBuffer() {
+ try {
+ int[] buffers = new int[1];
+ al.alGenBuffers(1, buffers, 0);
+ WAVData wd =
+ WAVLoader.loadFromFile(TEST_FILE);
+ al.alBufferData(
+ buffers[0],
+ wd.format,
+ wd.data,
+ wd.size,
+ wd.freq
+ );
+ int[] size = new int[1];
+ int[] freq = new int[1];
+ al.alGetBufferi(buffers[0],AL.AL_SIZE, size, 0);
+ al.alGetBufferi(buffers[0],AL.AL_FREQUENCY, freq, 0);
+ assertEquals(wd.size, size[0]);
+ assertEquals(wd.freq, freq[0]);
+ } catch(Exception e) {
+ fail(e.toString());
+ }
+ Exception ex = null;
+ try {
+ int[] buffers = new int[1];
+ al.alGenBuffers(1, buffers, 0);
+ WAVData wd =
+ WAVLoader.loadFromFile(TEST_FILE);
+ al.alBufferData(
+ buffers[0],
+ wd.format,
+ wd.data,
+ wd.size,
+ wd.freq
+ );
+ int[] size = null;
+ al.alGetBufferi(buffers[0],AL.AL_SIZE, size, 0);
+
+ } catch (IllegalArgumentException e) {
+ ex = e;
+ } catch (UnsupportedAudioFileException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+
+ assertNotNull(ex);
+ ex = null;
+ try {
+ int[] buffers = new int[1];
+ al.alGenBuffers(1, buffers, 0);
+ WAVData wd =
+ WAVLoader.loadFromFile(TEST_FILE);
+ al.alBufferData(
+ buffers[0],
+ wd.format,
+ wd.data,
+ wd.size,
+ wd.freq
+ );
+ int[] size = new int[1];
+ al.alGetBufferi(buffers[0],AL.AL_SIZE, size, 0);
+
+ } catch (IllegalArgumentException e) {
+ ex = e;
+ } catch (UnsupportedAudioFileException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+
+// assertNotNull(ex);
+ }
+
+ /*
+ * Test for int alGetBufferi(int, int)
+ */
+ final public void testAlGetBufferiintint() {
+ //TODO Implement alGetBufferi().
+ }
+
+ /*
+ * Test for void alGenSources(int, int[])
+ */
+ final public void testAlGenSourcesintintArray() {
+ //TODO Implement alGenSources().
+ }
+
+ /*
+ * Test for void alGenSources(int, IntBuffer)
+ */
+ final public void testAlGenSourcesintIntBuffer() {
+ //TODO Implement alGenSources().
+ }
+
+ /*
+ * Test for void alDeleteSources(int, int[])
+ */
+ final public void testAlDeleteSourcesintintArray() {
+ //TODO Implement alDeleteSources().
+ }
+
+ /*
+ * Test for void alDeleteSources(int, IntBuffer)
+ */
+ final public void testAlDeleteSourcesintIntBuffer() {
+ //TODO Implement alDeleteSources().
+ }
+
+ final public void testAlIsSource() {
+ //TODO Implement alIsSource().
+ }
+
+ final public void testAlSourcei() {
+ //TODO Implement alSourcei().
+ }
+
+ final public void testAlSourcef() {
+ //TODO Implement alSourcef().
+ }
+
+ /*
+ * Test for void alSourcefv(int, int, float[])
+ */
+ final public void testAlSourcefvintintfloatArray() {
+ //TODO Implement alSourcefv().
+ }
+
+ /*
+ * Test for void alSourcefv(int, int, FloatBuffer)
+ */
+ final public void testAlSourcefvintintFloatBuffer() {
+ //TODO Implement alSourcefv().
+ }
+
+ final public void testAlSource3f() {
+ //TODO Implement alSource3f().
+ }
+
+ /*
+ * Test for void alGetSourcef(int, int, float[])
+ */
+ final public void testAlGetSourcefintintfloatArray() {
+ //TODO Implement alGetSourcef().
+ }
+
+ /*
+ * Test for void alGetSourcef(int, int, FloatBuffer)
+ */
+ final public void testAlGetSourcefintintFloatBuffer() {
+ //TODO Implement alGetSourcef().
+ }
+
+ /*
+ * Test for float alGetSourcef(int, int)
+ */
+ final public void testAlGetSourcefintint() {
+ //TODO Implement alGetSourcef().
+ }
+
+ /*
+ * Test for void alGetSourcefv(int, int, FloatBuffer)
+ */
+ final public void testAlGetSourcefvintintFloatBuffer() {
+ //TODO Implement alGetSourcefv().
+ }
+
+ /*
+ * Test for void alGetSourcefv(int, int, float[])
+ */
+ final public void testAlGetSourcefvintintfloatArray() {
+ //TODO Implement alGetSourcefv().
+ }
+
+ /*
+ * Test for void alGetSourcei(int, int, int[])
+ */
+ final public void testAlGetSourceiintintintArray() {
+ //TODO Implement alGetSourcei().
+ }
+
+ /*
+ * Test for void alGetSourcei(int, int, IntBuffer)
+ */
+ final public void testAlGetSourceiintintIntBuffer() {
+ //TODO Implement alGetSourcei().
+ }
+
+ /*
+ * Test for int alGetSourcei(int, int)
+ */
+ final public void testAlGetSourceiintint() {
+ //TODO Implement alGetSourcei().
+ }
+
+ final public void testAlSourcePlay() {
+ //TODO Implement alSourcePlay().
+ }
+
+ /*
+ * Test for void alSourcePlayv(int, IntBuffer)
+ */
+ final public void testAlSourcePlayvintIntBuffer() {
+ //TODO Implement alSourcePlayv().
+ }
+
+ /*
+ * Test for void alSourcePlayv(int, int[])
+ */
+ final public void testAlSourcePlayvintintArray() {
+ //TODO Implement alSourcePlayv().
+ }
+
+ final public void testAlSourcePause() {
+ //TODO Implement alSourcePause().
+ }
+
+ /*
+ * Test for void alSourcePausev(int, int[])
+ */
+ final public void testAlSourcePausevintintArray() {
+ //TODO Implement alSourcePausev().
+ }
+
+ /*
+ * Test for void alSourcePausev(int, IntBuffer)
+ */
+ final public void testAlSourcePausevintIntBuffer() {
+ //TODO Implement alSourcePausev().
+ }
+
+ final public void testAlSourceStop() {
+ //TODO Implement alSourceStop().
+ }
+
+ /*
+ * Test for void alSourceStopv(int, int[])
+ */
+ final public void testAlSourceStopvintintArray() {
+ //TODO Implement alSourceStopv().
+ }
+
+ /*
+ * Test for void alSourceStopv(int, IntBuffer)
+ */
+ final public void testAlSourceStopvintIntBuffer() {
+ //TODO Implement alSourceStopv().
+ }
+
+ final public void testAlSourceRewind() {
+ //TODO Implement alSourceRewind().
+ }
+
+ /*
+ * Test for void alSourceRewindv(int, int[])
+ */
+ final public void testAlSourceRewindvintintArray() {
+ //TODO Implement alSourceRewindv().
+ }
+
+ /*
+ * Test for void alSourceRewindv(int, IntBuffer)
+ */
+ final public void testAlSourceRewindvintIntBuffer() {
+ //TODO Implement alSourceRewindv().
+ }
+
+ /*
+ * Test for void alSourceQueueBuffers(int, int, int[])
+ */
+ final public void testAlSourceQueueBuffersintintintArray() {
+ //TODO Implement alSourceQueueBuffers().
+ }
+
+ /*
+ * Test for void alSourceQueueBuffers(int, int, IntBuffer)
+ */
+ final public void testAlSourceQueueBuffersintintIntBuffer() {
+ //TODO Implement alSourceQueueBuffers().
+ }
+
+ /*
+ * Test for void alSourceUnqueueBuffers(int, int, int[])
+ */
+ final public void testAlSourceUnqueueBuffersintintintArray() {
+ //TODO Implement alSourceUnqueueBuffers().
+ }
+
+ /*
+ * Test for void alSourceUnqueueBuffers(int, int, IntBuffer)
+ */
+ final public void testAlSourceUnqueueBuffersintintIntBuffer() {
+ //TODO Implement alSourceUnqueueBuffers().
+ }
+
+ final public void testAlListenerf() {
+ //TODO Implement alListenerf().
+ }
+
+ final public void testAlListener3f() {
+ //TODO Implement alListener3f().
+ }
+
+ /*
+ * Test for void alListenerfv(int, float[])
+ */
+ final public void testAlListenerfvintfloatArray() {
+ //TODO Implement alListenerfv().
+ }
+
+ /*
+ * Test for void alListenerfv(int, FloatBuffer)
+ */
+ final public void testAlListenerfvintFloatBuffer() {
+ //TODO Implement alListenerfv().
+ }
+
+ final public void testAlListeneri() {
+ //TODO Implement alListeneri().
+ }
+
+ /*
+ * Test for void alGetListenerf(int, float[])
+ */
+ final public void testAlGetListenerfintfloatArray() {
+ //TODO Implement alGetListenerf().
+ }
+
+ /*
+ * Test for void alGetListenerf(int, FloatBuffer)
+ */
+ final public void testAlGetListenerfintFloatBuffer() {
+ //TODO Implement alGetListenerf().
+ }
+
+ /*
+ * Test for float alGetListenerf(int)
+ */
+ final public void testAlGetListenerfint() {
+ //TODO Implement alGetListenerf().
+ }
+
+ /*
+ * Test for void alGetListener3f(int, FloatBuffer, FloatBuffer, FloatBuffer)
+ */
+ final public void testAlGetListener3fintFloatBufferFloatBufferFloatBuffer() {
+ //TODO Implement alGetListener3f().
+ }
+
+ /*
+ * Test for void alGetListener3f(int, float[], float[], float[])
+ */
+ final public void testAlGetListener3fintfloatArrayfloatArrayfloatArray() {
+ //TODO Implement alGetListener3f().
+ }
+
+ /*
+ * Test for void alGetListenerfv(int, float[])
+ */
+ final public void testAlGetListenerfvintfloatArray() {
+ //TODO Implement alGetListenerfv().
+ }
+
+ /*
+ * Test for void alGetListenerfv(int, FloatBuffer)
+ */
+ final public void testAlGetListenerfvintFloatBuffer() {
+ //TODO Implement alGetListenerfv().
+ }
+
+ /*
+ * Test for void alGetListeneri(int, int[])
+ */
+ final public void testAlGetListeneriintintArray() {
+ //TODO Implement alGetListeneri().
+ }
+
+ /*
+ * Test for void alGetListeneri(int, IntBuffer)
+ */
+ final public void testAlGetListeneriintIntBuffer() {
+ //TODO Implement alGetListeneri().
+ }
+
+ /*
+ * Test for int alGetListeneri(int)
+ */
+ final public void testAlGetListeneriint() {
+ //TODO Implement alGetListeneri().
+ }
+
+ final public void testAlEnable() {
+ //TODO Implement alEnable().
+ }
+
+ final public void testAlDisable() {
+ //TODO Implement alDisable().
+ }
+
+ final public void testAlIsEnabled() {
+ //TODO Implement alIsEnabled().
+ }
+
+ final public void testAlGetBoolean() {
+ //TODO Implement alGetBoolean().
+ }
+
+ final public void testAlGetDouble() {
+ //TODO Implement alGetDouble().
+ }
+
+ final public void testAlGetFloat() {
+ //TODO Implement alGetFloat().
+ }
+
+ final public void testAlGetInteger() {
+ //TODO Implement alGetInteger().
+ }
+
+ /*
+ * Test for void alGetDoublev(int, DoubleBuffer)
+ */
+ final public void testAlGetDoublevintDoubleBuffer() {
+ //TODO Implement alGetDoublev().
+ }
+
+ /*
+ * Test for void alGetDoublev(int, double[])
+ */
+ final public void testAlGetDoublevintdoubleArray() {
+ //TODO Implement alGetDoublev().
+ }
+
+ /*
+ * Test for void alGetFloatv(int, FloatBuffer)
+ */
+ final public void testAlGetFloatvintFloatBuffer() {
+ //TODO Implement alGetFloatv().
+ }
+
+ /*
+ * Test for void alGetFloatv(int, float[])
+ */
+ final public void testAlGetFloatvintfloatArray() {
+ //TODO Implement alGetFloatv().
+ }
+
+ /*
+ * Test for void alGetIntegerv(int, IntBuffer)
+ */
+ final public void testAlGetIntegervintIntBuffer() {
+ //TODO Implement alGetIntegerv().
+ }
+
+ /*
+ * Test for void alGetIntegerv(int, int[])
+ */
+ final public void testAlGetIntegervintintArray() {
+ //TODO Implement alGetIntegerv().
+ }
+
+ final public void testAlGetString() {
+ //TODO Implement alGetString().
+ }
+
+ final public void testAlDistanceModel() {
+ //TODO Implement alDistanceModel().
+ }
+
+ final public void testAlDopplerFactor() {
+ //TODO Implement alDopplerFactor().
+ }
+
+ final public void testAlDopplerVelocity() {
+ //TODO Implement alDopplerVelocity().
+ }
+
+ final public void testAlGetError() {
+ //TODO Implement alGetError().
+ }
+
+ final public void testAlIsExtensionPresent() {
+ //TODO Implement alIsExtensionPresent().
+ }
+
+ final public void testAlGetEnumValue() {
+ //TODO Implement alGetEnumValue().
+ }
+
+}
diff --git a/test/src/com/jogamp/openal/OpenALTest.java b/test/src/com/jogamp/openal/OpenALTest.java
new file mode 100644
index 0000000..7826899
--- /dev/null
+++ b/test/src/com/jogamp/openal/OpenALTest.java
@@ -0,0 +1,122 @@
+package com.jogamp.openal;
+
+/**
+* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* -Redistribution of source code must retain the above copyright notice,
+* this list of conditions and the following disclaimer.
+*
+* -Redistribution in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* Neither the name of Sun Microsystems, Inc. or the names of contributors may
+* be used to endorse or promote products derived from this software without
+* specific prior written permission.
+*
+* This software is provided "AS IS," without a warranty of any kind.
+* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
+* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS
+* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A
+* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
+* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT
+* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
+* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+*
+* You acknowledge that this software is not designed or intended for use in the
+* design, construction, operation or maintenance of any nuclear facility.
+*/
+
+import java.nio.*;
+
+import com.jogamp.openal.*;
+import com.jogamp.openal.eax.*;
+import com.jogamp.openal.util.*;
+
+/**
+ * @author Athomas Goldberg
+ *
+ */
+public class OpenALTest {
+ public static void main(String[] args) {
+ try {
+ ALC alc = ALFactory.getALC();
+ ALCdevice device = alc.alcOpenDevice(null);
+ ALCcontext context = alc.alcCreateContext(device, null);
+ alc.alcMakeContextCurrent(context);
+ AL al = ALFactory.getAL();
+ boolean eaxPresent = al.alIsExtensionPresent("EAX2.0");
+ System.out.println("EAX present:" + eaxPresent);
+ EAX eax = EAXFactory.getEAX();
+
+ try {
+ int[] buffers = new int[1];
+ al.alGenBuffers(1, buffers, 0);
+
+ WAVData wd = WAVLoader.loadFromFile("lewiscarroll.wav");
+ al.alBufferData(buffers[0], wd.format, wd.data, wd.size, wd.freq);
+
+ int[] sources = new int[1];
+ al.alGenSources(1, sources, 0);
+ al.alSourcei(sources[0], AL.AL_BUFFER, buffers[0]);
+ int[] loopArray = new int[1];
+ al.alGetSourcei(sources[0], AL.AL_LOOPING, loopArray, 0);
+ System.out.println("Looping 1: " + (loopArray[0] == AL.AL_TRUE));
+ int[] loopBuffer = new int[1];
+ al.alGetSourcei(sources[0], AL.AL_LOOPING, loopBuffer, 0);
+ System.out.println("Looping 2: " + (loopBuffer[0] == AL.AL_TRUE));
+
+ if (eaxPresent) {
+ IntBuffer env = BufferUtils.newIntBuffer(1);
+ env.put(EAX.EAX_ENVIRONMENT_BATHROOM);
+ eax.setListenerProperty(
+ EAX.DSPROPERTY_EAXLISTENER_ENVIRONMENT,
+ env);
+ }
+
+ al.alSourcePlay(sources[0]);
+
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ }
+
+ al.alSource3f(sources[0], AL.AL_POSITION, 2f, 2f, 2f);
+
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ }
+
+ al.alListener3f(AL.AL_POSITION, 3f, 3f, 3f);
+
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ }
+
+ al.alSource3f(sources[0], AL.AL_POSITION, 0, 0, 0);
+
+ try {
+ Thread.sleep(10000);
+ } catch (InterruptedException e) {
+ }
+
+ al.alSourceStop(sources[0]);
+ al.alDeleteSources(1, sources, 0);
+ alc.alcDestroyContext(context);
+ alc.alcCloseDevice(device);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } catch (ALException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/test/src/com/jogamp/openal/Sound3DTest.java b/test/src/com/jogamp/openal/Sound3DTest.java
new file mode 100644
index 0000000..2cd2c11
--- /dev/null
+++ b/test/src/com/jogamp/openal/Sound3DTest.java
@@ -0,0 +1,117 @@
+package com.jogamp.openal;
+
+/**
+* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* -Redistribution of source code must retain the above copyright notice,
+* this list of conditions and the following disclaimer.
+*
+* -Redistribution in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* Neither the name of Sun Microsystems, Inc. or the names of contributors may
+* be used to endorse or promote products derived from this software without
+* specific prior written permission.
+*
+* This software is provided "AS IS," without a warranty of any kind.
+* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
+* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS
+* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A
+* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
+* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT
+* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
+* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+*
+* You acknowledge that this software is not designed or intended for use in the
+* design, construction, operation or maintenance of any nuclear facility.
+*/
+import java.io.*;
+import javax.sound.sampled.*;
+import com.jogamp.openal.sound3d.*;
+
+/**
+ * @author Athomas Goldberg
+ *
+ */
+public class Sound3DTest {
+
+ public static float lerp(float v1, float v2, float t) {
+ float result = 0;
+ result = v1 + ((v2-v1) * t);
+ return result;
+ }
+
+ public static void main(String[] args) {
+ try {
+ AudioSystem3D.init();
+ } catch (ALException e) {
+ e.printStackTrace();
+ return;
+ }
+
+ // create the initial context - this can be collapsed into the init.
+ Device device = AudioSystem3D.openDevice(null);
+ Context context = AudioSystem3D.createContext(device);
+ AudioSystem3D.makeContextCurrent(context);
+
+ // get the listener object
+ Listener listener = AudioSystem3D.getListener();
+ listener.setPosition(0,0,0);
+
+ // load a source and play it
+ try {
+ Source source1 = AudioSystem3D.loadSource("lewiscarroll.wav");
+ source1.setPosition(0,0,0);
+ source1.setLooping(true);
+ source1.play();
+
+ try {
+ Thread.sleep(10000);
+ } catch (InterruptedException e) {
+
+ }
+
+ // move the source
+ source1.setPosition(1,1,1);
+
+ // move the listener
+ for(int i = 0; i < 1000; i++) {
+ float t = ((float)i)/1000f;
+ float lp = lerp(0f,2f,t);
+ listener.setPosition(lp,lp,lp);
+ try {
+ Thread.sleep(10);
+ } catch (InterruptedException e) {
+
+ }
+ }
+
+ // fade listener out.
+ for(int i = 0; i < 1000; i++) {
+ float t = ((float)i)/1000f;
+ float lp = lerp(1f,0f,t);
+ listener.setGain(lp);
+ try {
+ Thread.sleep(10);
+ } catch (InterruptedException e) {
+ }
+ }
+
+ source1.stop();
+ source1.delete();
+ context.destroy();
+ device.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (UnsupportedAudioFileException e) {
+ e.printStackTrace();
+ }
+ }
+}