net.jinx.audio
Class AbstractListener

java.lang.Object
  extended by net.jinx.audio.AbstractListener
All Implemented Interfaces:
Listener
Direct Known Subclasses:
DefaultListener

public abstract class AbstractListener
extends java.lang.Object
implements Listener

Simple Listener implementation that takes care of storing the AL and ALC objects for you. It also has a number of utility methods, too.

API Stability: Alpha; this is subject to change at any time.


Constructor Summary
AbstractListener()
          Constructs an AbstractListener.
 
Method Summary
 void deinit()
          Deinitializes this Listener.
protected  net.java.games.joal.AL getAL()
          Provides the AL object that was used to construct this Listener.
protected  net.java.games.joal.ALC getALC()
          Provides the ALC object that was used to construct this Listener.
 float getGain()
          Provides the gain for the listener.
 float[] getOrientation()
          Provides the orientation of the listener.
 float[] getPosition()
          Provides the position of the listener.
 float[] getVelocity()
          Provides the velocity of the listener.
 void init(net.java.games.joal.AL al, net.java.games.joal.ALC alc)
          Stores the AL and ALC objects for later.
 boolean isInitialized()
          Provides a way to determine if this Listener is in an initialized state.
 void lookAt(float[] pos, float[] at, float[] up)
          Utility method meant to be used alongside OpenGL's gluLookAt command, so the video and audio systems can be configured with the same data.
 void lookAt(float posx, float posy, float posz, float atx, float aty, float atz, float upx, float upy, float upz)
          Utility method meant to be used alongside OpenGL's gluLookAt command, so the video and audio systems can be configured with the same data.
 void setGain(float gain)
          Sets the gain for the listener.
 void setOrientation(float[] o)
          Sets the orientation of the listener.
 void setPosition(float[] pos)
          Sets the position of the listener.
 void setPosition(float x, float y, float z)
          Sets the position of the listener.
 void setVelocity(float[] v)
          Sets the velocity of the listener.
 void setVelocity(float x, float y, float z)
          Sets the velocity of the listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.jinx.audio.Listener
listen
 

Constructor Detail

AbstractListener

public AbstractListener()
Constructs an AbstractListener.

Method Detail

getAL

protected net.java.games.joal.AL getAL()
Provides the AL object that was used to construct this Listener.

Returns:
the AL object.

getALC

protected net.java.games.joal.ALC getALC()
Provides the ALC object that was used to construct this Listener.

Returns:
the ALC object.

isInitialized

public boolean isInitialized()
Provides a way to determine if this Listener is in an initialized state.

Returns:
true if this Audible is in an initialized state.

init

public void init(net.java.games.joal.AL al,
                 net.java.games.joal.ALC alc)
Stores the AL and ALC objects for later.

Specified by:
init in interface Listener
Parameters:
al - the AL object to use for audio rendering.
alc - the ALC object to use for audio rendering.
Throws:
java.lang.NullPointerException - if al or alc are null.

deinit

public void deinit()
Deinitializes this Listener.

Specified by:
deinit in interface Listener

setGain

public void setGain(float gain)
Sets the gain for the listener. This is equivalent to volume.

Parameters:
gain - the gain value to set.

getGain

public float getGain()
Provides the gain for the listener.

Returns:
the gain value.

setPosition

public void setPosition(float x,
                        float y,
                        float z)
Sets the position of the listener.

Parameters:
x - the x value.
y - the y value.
z - the z value.

setPosition

public void setPosition(float[] pos)
Sets the position of the listener.

Parameters:
pos - the position as a float array. This must be at least three elements.

getPosition

public float[] getPosition()
Provides the position of the listener.

Returns:
the position as a length three float array.

setVelocity

public void setVelocity(float x,
                        float y,
                        float z)
Sets the velocity of the listener.

Parameters:
x - the x value.
y - the y value.
z - the z value.

setVelocity

public void setVelocity(float[] v)
Sets the velocity of the listener.

Parameters:
v - the velocity as a float array. This must be at least three elements.

getVelocity

public float[] getVelocity()
Provides the velocity of the listener.

Returns:
the velocity as a length three float array.

setOrientation

public void setOrientation(float[] o)
Sets the orientation of the listener. This is the direction that the listener is facing at, and the direction of up.

Parameters:
o - an array of six floats. The first three are the at vector and the last three are the up vector.

getOrientation

public float[] getOrientation()
Provides the orientation of the listener.

Returns:
the orientation array.

lookAt

public void lookAt(float[] pos,
                   float[] at,
                   float[] up)
Utility method meant to be used alongside OpenGL's gluLookAt command, so the video and audio systems can be configured with the same data.

Parameters:
pos - the position of the listener.
at - the point in space to turn to face.
up - the direction of up.

lookAt

public void lookAt(float posx,
                   float posy,
                   float posz,
                   float atx,
                   float aty,
                   float atz,
                   float upx,
                   float upy,
                   float upz)
Utility method meant to be used alongside OpenGL's gluLookAt command, so the video and audio systems can be configured with the same data.

Parameters:
posx - the position of the listener (X coordinate).
posy - the position of the listener (Y coordinate).
posz - the position of the listener (Z coordinate).
atx - the point in space to turn to face (X coordinate).
aty - the point in space to turn to face (Y coordinate).
atz - the point in space to turn to face (Z coordinate).
upx - the direction of up (X coordinate).
upy - the direction of up (Y coordinate).
upz - the direction of up (Z coordinate).