summaryrefslogtreecommitdiffstats
path: root/src/java/net
diff options
context:
space:
mode:
authorathomas <[email protected]>2003-06-08 12:29:12 +0000
committerathomas <[email protected]>2003-06-08 12:29:12 +0000
commitdb6df987d115fa7ee101c514538c999fe2b76115 (patch)
treedf05467a29bd128947b1ff882932689dd3a720b9 /src/java/net
parent3cc4ef82f270967ef3702401d7783cce3ac0a29f (diff)
added missing copyright to OpenALTest.java
git-svn-id: file:///home/mbien/NetBeansProjects/JOGAMP/joal-sync/git-svn/../svn-server-sync/joal/trunk@23 03bf7f67-59de-4072-a415-9a990d468a3f
Diffstat (limited to 'src/java/net')
-rw-r--r--src/java/net/java/games/joal/util/WAVData.java40
-rw-r--r--src/java/net/java/games/joal/util/WAVLoader.java22
-rw-r--r--src/java/net/java/games/sound3d/AudioSystem3D.java9
-rw-r--r--src/java/net/java/games/sound3d/Listener.java160
-rw-r--r--src/java/net/java/games/sound3d/Source.java273
-rw-r--r--src/java/net/java/games/sound3d/Vec3f.java35
6 files changed, 412 insertions, 127 deletions
diff --git a/src/java/net/java/games/joal/util/WAVData.java b/src/java/net/java/games/joal/util/WAVData.java
index 0bc43fa..5e484bf 100644
--- a/src/java/net/java/games/joal/util/WAVData.java
+++ b/src/java/net/java/games/joal/util/WAVData.java
@@ -35,23 +35,33 @@ package net.java.games.joal.util;
import java.nio.ByteBuffer;
+
/**
- * @author Athomas Goldberg
+ * DOCUMENT ME!
*
+ * @author Athomas Goldberg
*/
public final class WAVData {
-
- public final ByteBuffer data;
- public final int format;
- public final int size;
- public final int freq;
- public final boolean loop;
-
- WAVData(ByteBuffer data, int format, int size, int freq, boolean loop) {
- this.data = data;
- this.format = format;
- this.size = size;
- this.freq = freq;
- this.loop = loop;
- }
+ //DOCUMENT ME!
+ public final ByteBuffer data;
+
+ //DOCUMENT ME!
+ public final int format;
+
+ //DOCUMENT ME!
+ public final int size;
+
+ //DOCUMENT ME!
+ public final int freq;
+
+ //DOCUMENT ME!
+ public final boolean loop;
+
+ WAVData(ByteBuffer data, int format, int size, int freq, boolean loop) {
+ this.data = data;
+ this.format = format;
+ this.size = size;
+ this.freq = freq;
+ this.loop = loop;
+ }
}
diff --git a/src/java/net/java/games/joal/util/WAVLoader.java b/src/java/net/java/games/joal/util/WAVLoader.java
index c0235da..6d5e79e 100644
--- a/src/java/net/java/games/joal/util/WAVLoader.java
+++ b/src/java/net/java/games/joal/util/WAVLoader.java
@@ -33,8 +33,11 @@
package net.java.games.joal.util;
+import net.java.games.joal.ALConstants;
+
import java.io.File;
import java.io.IOException;
+
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
@@ -44,19 +47,27 @@ import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
-import net.java.games.joal.ALConstants;
-
/**
- * @author Athomas Goldberg
+ * DOCUMENT ME!
*
+ * @author Athomas Goldberg
*/
public class WAVLoader implements ALConstants {
private static final int BUFFER_SIZE = 128000;
+ /**
+ * DOCUMENT ME!
+ *
+ * @param filename DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ *
+ * @throws UnsupportedAudioFileException DOCUMENT ME!
+ * @throws IOException DOCUMENT ME!
+ */
public static WAVData loadFromFile(String filename)
- throws UnsupportedAudioFileException,
- IOException {
+ throws UnsupportedAudioFileException, IOException {
WAVData result = null;
File soundFile = new File(filename);
AudioInputStream aIn = AudioSystem.getAudioInputStream(soundFile);
@@ -82,6 +93,7 @@ public class WAVLoader implements ALConstants {
aChannel.read(buffer);
result = new WAVData(buffer, format, size, freq, false);
aIn.close();
+
return result;
}
}
diff --git a/src/java/net/java/games/sound3d/AudioSystem3D.java b/src/java/net/java/games/sound3d/AudioSystem3D.java
index 66ef9cc..80eac7c 100644
--- a/src/java/net/java/games/sound3d/AudioSystem3D.java
+++ b/src/java/net/java/games/sound3d/AudioSystem3D.java
@@ -33,16 +33,16 @@
package net.java.games.sound3d;
-import java.io.IOException;
-
-import javax.sound.sampled.UnsupportedAudioFileException;
-
import net.java.games.joal.AL;
import net.java.games.joal.ALC;
import net.java.games.joal.ALFactory;
import net.java.games.joal.util.WAVData;
import net.java.games.joal.util.WAVLoader;
+import java.io.IOException;
+
+import javax.sound.sampled.UnsupportedAudioFileException;
+
/**
* DOCUMENT ME!
@@ -162,6 +162,7 @@ public class AudioSystem3D {
public static Source loadSource(String filename)
throws IOException, UnsupportedAudioFileException {
Buffer buffer = loadBuffer(filename);
+
return generateSource(buffer);
}
diff --git a/src/java/net/java/games/sound3d/Listener.java b/src/java/net/java/games/sound3d/Listener.java
index ad93099..e3509dc 100644
--- a/src/java/net/java/games/sound3d/Listener.java
+++ b/src/java/net/java/games/sound3d/Listener.java
@@ -35,61 +35,115 @@ package net.java.games.sound3d;
import net.java.games.joal.AL;
+
/**
- * @author Athomas Goldberg
+ * DOCUMENT ME!
*
+ * @author Athomas Goldberg
*/
public class Listener {
- private final AL al;
- Listener(AL al) {
- this.al = al;
- }
-
- public void setGain(float gain) {
- al.alListenerf(AL.AL_GAIN,gain);
- }
-
- public float getGain() {
- float[] f = new float[1];
- al.alGetListenerf(AL.AL_GAIN,f);
- return f[0];
- }
-
- public void setPosition(float x, float y, float z) {
- al.alListener3f(AL.AL_POSITION,x,y,z);
- }
-
- public void setPosition(Vec3f position) {
- al.alListener3f(AL.AL_POSITION,position.v1, position.v2, position.v3);
- }
-
- public Vec3f getPosition() {
- Vec3f result = null;
- float[] tmp = new float[3];
- al.alGetListenerfv(AL.AL_POSITION,tmp);
- result = new Vec3f(tmp[0],tmp[1],tmp[2]);
- return result;
- }
-
- public void setVelocity(Vec3f velocity) {
- al.alListener3f(AL.AL_VELOCITY,velocity.v1, velocity.v2, velocity.v3);
- }
-
- public Vec3f getVelocity() {
- Vec3f result = null;
- float[] tmp = new float[3];
- al.alGetListenerfv(AL.AL_VELOCITY,tmp);
- result = new Vec3f(tmp[0],tmp[1],tmp[2]);
- return result;
- }
-
- public void setOrientation(float[] orientation) {
- al.alListenerfv(AL.AL_ORIENTATION,orientation);
- }
-
- public float[] getOrientation() {
- float[] tmp = new float[6];
- al.alGetListenerfv(AL.AL_ORIENTATION,tmp);
- return tmp;
- }
+ private final AL al;
+
+ Listener(AL al) {
+ this.al = al;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param gain DOCUMENT ME!
+ */
+ public void setGain(float gain) {
+ al.alListenerf(AL.AL_GAIN, gain);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public float getGain() {
+ float[] f = new float[1];
+ al.alGetListenerf(AL.AL_GAIN, f);
+
+ return f[0];
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param x DOCUMENT ME!
+ * @param y DOCUMENT ME!
+ * @param z DOCUMENT ME!
+ */
+ public void setPosition(float x, float y, float z) {
+ al.alListener3f(AL.AL_POSITION, x, y, z);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param position DOCUMENT ME!
+ */
+ public void setPosition(Vec3f position) {
+ al.alListener3f(AL.AL_POSITION, position.v1, position.v2, position.v3);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public Vec3f getPosition() {
+ Vec3f result = null;
+ float[] tmp = new float[3];
+ al.alGetListenerfv(AL.AL_POSITION, tmp);
+ result = new Vec3f(tmp[0], tmp[1], tmp[2]);
+
+ return result;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param velocity DOCUMENT ME!
+ */
+ public void setVelocity(Vec3f velocity) {
+ al.alListener3f(AL.AL_VELOCITY, velocity.v1, velocity.v2, velocity.v3);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public Vec3f getVelocity() {
+ Vec3f result = null;
+ float[] tmp = new float[3];
+ al.alGetListenerfv(AL.AL_VELOCITY, tmp);
+ result = new Vec3f(tmp[0], tmp[1], tmp[2]);
+
+ return result;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param orientation DOCUMENT ME!
+ */
+ public void setOrientation(float[] orientation) {
+ al.alListenerfv(AL.AL_ORIENTATION, orientation);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public float[] getOrientation() {
+ float[] tmp = new float[6];
+ al.alGetListenerfv(AL.AL_ORIENTATION, tmp);
+
+ return tmp;
+ }
}
diff --git a/src/java/net/java/games/sound3d/Source.java b/src/java/net/java/games/sound3d/Source.java
index f96207c..a6cfd04 100644
--- a/src/java/net/java/games/sound3d/Source.java
+++ b/src/java/net/java/games/sound3d/Source.java
@@ -37,161 +37,294 @@ import net.java.games.joal.AL;
/**
- * @author Athomas Goldberg
+ * DOCUMENT ME!
*
+ * @author Athomas Goldberg
*/
public final class Source {
private final AL al;
private final int sourceName;
private Buffer buffer;
- Source(
- AL al,
- int sourceName) {
+ Source(AL al, int sourceName) {
this.al = al;
this.sourceName = sourceName;
}
+ /**
+ * DOCUMENT ME!
+ */
public void play() {
al.alSourcePlay(sourceName);
}
+ /**
+ * DOCUMENT ME!
+ */
public void pause() {
al.alSourcePause(sourceName);
}
+ /**
+ * DOCUMENT ME!
+ */
public void stop() {
al.alSourceStop(sourceName);
}
+ /**
+ * DOCUMENT ME!
+ */
public void rewind() {
al.alSourceRewind(sourceName);
}
+ /**
+ * DOCUMENT ME!
+ */
public void delete() {
al.alDeleteSources(1, new int[] { sourceName });
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @param pitch DOCUMENT ME!
+ */
public void setPitch(float pitch) {
al.alSourcef(sourceName, AL.AL_PITCH, pitch);
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
public float getPitch() {
- float[] result = new float[1];
- al.alGetSourcef(sourceName, AL.AL_PITCH,result);
+ float[] result = new float[1];
+ al.alGetSourcef(sourceName, AL.AL_PITCH, result);
+
return result[0];
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @param gain DOCUMENT ME!
+ */
public void setGain(float gain) {
al.alSourcef(sourceName, AL.AL_GAIN, gain);
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
public float getGain() {
- float[] result = new float[1];
+ float[] result = new float[1];
al.alGetSourcef(sourceName, AL.AL_GAIN, result);
+
return result[0];
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @param maxDistance DOCUMENT ME!
+ */
public void setMaxDistance(float maxDistance) {
al.alSourcef(sourceName, AL.AL_MAX_DISTANCE, maxDistance);
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
public float getMaxDistance() {
- float[] result = new float[1];
- al.alGetSourcef(sourceName, AL.AL_MAX_DISTANCE,result);
+ float[] result = new float[1];
+ al.alGetSourcef(sourceName, AL.AL_MAX_DISTANCE, result);
+
return result[0];
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @param rolloffFactor DOCUMENT ME!
+ */
public void setRolloffFactor(float rolloffFactor) {
al.alSourcef(sourceName, AL.AL_ROLLOFF_FACTOR, rolloffFactor);
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
public float getRolloffFactor() {
- float[] result = new float[1];
+ float[] result = new float[1];
al.alGetSourcef(sourceName, AL.AL_ROLLOFF_FACTOR, result);
+
return result[0];
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @param referenceDistance DOCUMENT ME!
+ */
public void setReferenceDistance(float referenceDistance) {
al.alSourcef(sourceName, AL.AL_REFERENCE_DISTANCE, referenceDistance);
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
public float getReferenceDistance() {
- float[] result = new float[1];
+ float[] result = new float[1];
al.alGetSourcef(sourceName, AL.AL_REFERENCE_DISTANCE, result);
+
return result[0];
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @param minGain DOCUMENT ME!
+ */
public void setMinGain(float minGain) {
al.alSourcef(sourceName, AL.AL_MIN_GAIN, minGain);
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
public float getMinGain() {
- float[] result = new float[1];
+ float[] result = new float[1];
al.alGetSourcef(sourceName, AL.AL_MIN_GAIN, result);
+
return result[0];
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @param maxGain DOCUMENT ME!
+ */
public void setMaxGain(float maxGain) {
al.alSourcef(sourceName, AL.AL_MAX_GAIN, maxGain);
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
public float getMaxGain() {
- float[] result = new float[1];
+ float[] result = new float[1];
al.alGetSourcef(sourceName, AL.AL_MAX_GAIN, result);
+
return result[0];
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @param coneOuterGain DOCUMENT ME!
+ */
public void setConeOuterGain(float coneOuterGain) {
al.alSourcef(sourceName, AL.AL_CONE_OUTER_GAIN, coneOuterGain);
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
public float getConeOuterGain() {
- float[] result = new float[1];
+ float[] result = new float[1];
al.alGetSourcef(sourceName, AL.AL_CONE_OUTER_GAIN, result);
+
return result[0];
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @param position DOCUMENT ME!
+ */
public void setPosition(Vec3f position) {
al.alSource3f(
sourceName,
AL.AL_POSITION,
position.v1,
position.v2,
- position.v3);
- }
-
- public void setPosition(
- float x,
- float y,
- float z) {
+ position.v3
+ );
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param x DOCUMENT ME!
+ * @param y DOCUMENT ME!
+ * @param z DOCUMENT ME!
+ */
+ public void setPosition(float x, float y, float z) {
al.alSource3f(sourceName, AL.AL_POSITION, x, y, z);
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
public Vec3f getPosition() {
Vec3f result = null;
float[] pos = new float[3];
al.alGetSourcefv(sourceName, AL.AL_POSITION, pos);
result = new Vec3f(pos[0], pos[1], pos[2]);
+
return result;
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @param velocity DOCUMENT ME!
+ */
public void setVelocity(Vec3f velocity) {
al.alSource3f(
sourceName,
AL.AL_VELOCITY,
velocity.v1,
velocity.v2,
- velocity.v3);
- }
-
- public void setVelocity(
- float x,
- float y,
- float z) {
+ velocity.v3
+ );
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param x DOCUMENT ME!
+ * @param y DOCUMENT ME!
+ * @param z DOCUMENT ME!
+ */
+ public void setVelocity(float x, float y, float z) {
al.alSource3f(sourceName, AL.AL_VELOCITY, x, y, z);
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
public Vec3f getVelocity() {
Vec3f result = null;
float[] vel = new float[3];
@@ -201,22 +334,37 @@ public final class Source {
return result;
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @param direction DOCUMENT ME!
+ */
public void setDirection(Vec3f direction) {
al.alSource3f(
sourceName,
AL.AL_DIRECTION,
direction.v1,
direction.v2,
- direction.v3);
- }
-
- public void setDirection(
- float x,
- float y,
- float z) {
+ direction.v3
+ );
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param x DOCUMENT ME!
+ * @param y DOCUMENT ME!
+ * @param z DOCUMENT ME!
+ */
+ public void setDirection(float x, float y, float z) {
al.alSource3f(sourceName, AL.AL_DIRECTION, x, y, z);
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
public Vec3f getDirection() {
Vec3f result = null;
float[] dir = new float[3];
@@ -226,43 +374,86 @@ public final class Source {
return result;
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @param isRelative DOCUMENT ME!
+ */
public void setSourceRelative(boolean isRelative) {
int rel = isRelative ? 1 : 0;
al.alSourcei(sourceName, AL.AL_SOURCE_RELATIVE, rel);
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
public boolean isSourceRelative() {
- int[] result = new int[1];
+ int[] result = new int[1];
al.alGetSourcei(sourceName, AL.AL_SOURCE_RELATIVE, result);
+
return result[0] == 1;
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @param isLooping DOCUMENT ME!
+ */
public void setLooping(boolean isLooping) {
int loop = isLooping ? 1 : 0;
al.alSourcei(sourceName, AL.AL_LOOPING, loop);
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
public int getBuffersQueued() {
- int[] result = new int[1];
+ int[] result = new int[1];
al.alGetSourcei(sourceName, AL.AL_BUFFERS_QUEUED, result);
+
return result[0];
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
public int getBuffersProcessed() {
- int[] result = new int[1];
+ int[] result = new int[1];
al.alGetSourcei(sourceName, AL.AL_BUFFERS_PROCESSED, result);
+
return result[0];
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @param buffer DOCUMENT ME!
+ */
public void setBuffer(Buffer buffer) {
al.alSourcei(sourceName, AL.AL_BUFFER, buffer.bufferName);
this.buffer = buffer;
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
public Buffer getBuffer() {
return buffer;
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @param buffers DOCUMENT ME!
+ */
public void queueBuffers(Buffer[] buffers) {
int numBuffers = buffers.length;
int[] arr = new int[numBuffers];
@@ -274,6 +465,11 @@ public final class Source {
al.alSourceQueueBuffers(sourceName, numBuffers, arr);
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @param buffers DOCUMENT ME!
+ */
public void unqueueBuffers(Buffer[] buffers) {
int numBuffers = buffers.length;
int[] arr = new int[numBuffers];
@@ -281,6 +477,7 @@ public final class Source {
for (int i = 0; i < numBuffers; i++) {
arr[i] = buffers[i].bufferName;
}
+
al.alSourceUnqueueBuffers(sourceName, numBuffers, arr);
}
}
diff --git a/src/java/net/java/games/sound3d/Vec3f.java b/src/java/net/java/games/sound3d/Vec3f.java
index 4823812..a97c304 100644
--- a/src/java/net/java/games/sound3d/Vec3f.java
+++ b/src/java/net/java/games/sound3d/Vec3f.java
@@ -16,7 +16,6 @@
* 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 MIDROSYSTEMS, INC. ("SUN") AND ITS
@@ -35,18 +34,30 @@
package net.java.games.sound3d;
/**
- * @author Athomas Goldberg
+ * DOCUMENT ME!
*
+ * @author Athomas Goldberg
*/
public final class Vec3f {
-
- public final float v1;
- public final float v2;
- public final float v3;
-
- public Vec3f(float v1, float v2, float v3) {
- this.v1 = v1;
- this.v2 = v2;
- this.v3 = v3;
- }
+ //DOCUMENT ME!
+ public final float v1;
+
+ //DOCUMENT ME!
+ public final float v2;
+
+ //DOCUMENT ME!
+ public final float v3;
+
+ /**
+ * Creates a new Vec3f object.
+ *
+ * @param v1 DOCUMENT ME!
+ * @param v2 DOCUMENT ME!
+ * @param v3 DOCUMENT ME!
+ */
+ public Vec3f(float v1, float v2, float v3) {
+ this.v1 = v1;
+ this.v2 = v2;
+ this.v3 = v3;
+ }
}