|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object glsound.SoundScape
public class SoundScape
SoundScape wraps OpenAL functions to create a sound environment. Can load and play several sounds, set properties of sounds (pitch, position, volume, dropoff), pause all sounds or one sound, control global volume. To run a demo of SoundScape just call the static demo() function:
SoundScape.demo();The class is static so can be used without instantiation, similar to LWJGL Display, Mouse and Keyboard classes:
SoundScape.create(); // init sound environment ... int soundData sd = SoundScape.loadSoundData("a_noise.wav"); int soundSource ss = SoundScape.makeSoundSource(soundData); SoundScape.setSoundPosition(ss, 10, 2, 0); SoundScape.play(ss); ... SoundScape.destroy();Requires the WaveData class to load wav files.
Borrows heavily from Brian Matzon's PlayTest demo (at http://lwjgl.org)
Field Summary | |
---|---|
static int |
SIZE_FLOAT
|
static int |
SIZE_INT
|
Constructor Summary | |
---|---|
SoundScape()
Creates an instance of SoundScape BUT SoundScape is meant to be used as static class. |
Method Summary | |
---|---|
protected static void |
alExit()
|
static java.nio.FloatBuffer |
allocFloats(float[] floatarray)
|
static java.nio.IntBuffer |
allocInts(int howmany)
|
static void |
create()
Prepare the SoundScape class for use |
static void |
demo()
Run a bare-bones demo of SoundScape. |
static void |
destroy()
Free up allocated sounds and shutdown audio environment. |
static void |
exit(int arg)
|
protected static java.nio.ByteBuffer |
getData(java.lang.String filename)
Reads the file into a ByteBuffer |
static float |
getGain(int soundSourceHandle)
|
static boolean |
isPlaying(int soundSourceHandle)
return true if this sound is playing |
static int |
loadSoundData(java.lang.String soundFilename)
Load sound data from a file into a buffer. |
static int |
makeSound(java.lang.String soundFilename)
|
static int |
makeSoundSource(int soundDataHandle)
Return integer handle to new sound source. |
static void |
pause(boolean bool)
Pause or resume all sounds playing in the SoundScape |
static void |
pause(int soundSourceHandle,
boolean pause)
Pause or resume one sound |
static void |
play(int soundSourceHandle)
Play a sound source |
static void |
setGain(int soundSourceHandle,
float gain)
Set the soundsource volume. |
static void |
setGlobalGain(float gain)
Set the volume for all sounds. |
static void |
setListenerOrientation(float lookatx,
float lookaty,
float lookatz,
float upx,
float upy,
float upz)
Set orientation of the listener. |
static void |
setListenerPosition(float x,
float y,
float z)
Set world coordinates of listener. |
static void |
setListenerVelocity(float x,
float y,
float z)
Set world coordinates of listener. |
static void |
setLoop(int soundSourceHandle,
boolean on)
|
static void |
setPitch(int soundSourceHandle,
float pitch)
|
static void |
setReferenceDistance(float d)
Set the reference distance, used by OpenAL to calculate how fast sound drops off. |
static void |
setReferenceDistance(int soundSourceHandle,
float distance)
set the dropoff distance for this sound. |
static void |
setSoundPosition(int soundSourceHandle,
float[] xyz)
|
static void |
setSoundPosition(int soundSourceHandle,
float x,
float y,
float z)
|
static void |
setVelocity(int soundSourceHandle,
float velocity)
Set velocity of sound 0 - 1 |
static void |
stop()
Stop all sounds playing in the SoundScape |
static void |
stop(int soundSourceHandle)
Stop playing one sound. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int SIZE_FLOAT
public static final int SIZE_INT
Constructor Detail |
---|
public SoundScape()
Method Detail |
---|
public static void create()
public static void destroy()
protected static void alExit()
public static void exit(int arg)
public static void demo()
public static void pause(boolean bool)
public static void stop()
public static void setGlobalGain(float gain)
gain
- float: 0 - 1public static void setReferenceDistance(float d)
makeSoundSource().
public static void setListenerPosition(float x, float y, float z)
public static void setListenerVelocity(float x, float y, float z)
public static void setListenerOrientation(float lookatx, float lookaty, float lookatz, float upx, float upy, float upz)
public static void pause(int soundSourceHandle, boolean pause)
public static void play(int soundSourceHandle)
public static void stop(int soundSourceHandle)
public static float getGain(int soundSourceHandle)
public static void setVelocity(int soundSourceHandle, float velocity)
public static void setPitch(int soundSourceHandle, float pitch)
soundSourceHandle
- set pitch of this sound sourcepitch
- public static void setGain(int soundSourceHandle, float gain)
soundSourceHandle
- gain
- public static void setSoundPosition(int soundSourceHandle, float x, float y, float z)
public static void setSoundPosition(int soundSourceHandle, float[] xyz)
public static void setReferenceDistance(int soundSourceHandle, float distance)
soundSourceHandle
- distance
- public static void setLoop(int soundSourceHandle, boolean on)
public static boolean isPlaying(int soundSourceHandle)
soundSourceHandle
-
protected static java.nio.ByteBuffer getData(java.lang.String filename)
filename
- Name of file to load
public static int makeSoundSource(int soundDataHandle)
public static int loadSoundData(java.lang.String soundFilename)
soundFilename
- name of file to load (.wav)
public static int makeSound(java.lang.String soundFilename)
soundFilename
- name of file to load (.wav)
public static java.nio.IntBuffer allocInts(int howmany)
public static java.nio.FloatBuffer allocFloats(float[] floatarray)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |