com.threerings.openal
Class Source

java.lang.Object
  extended by com.threerings.openal.Source

public class Source
extends Object

Represents an OpenAL source object.


Field Summary
protected  float _coneInnerAngle
          The inside angle of the sound cone.
protected  float _coneOuterAngle
          The outside angle of the sound cone.
protected  float _coneOuterGain
          The gain outside the sound cone.
protected  float _dx
          The direction of the source.
protected  float _dy
          The direction of the source.
protected  float _dz
          The direction of the source.
protected  float _gain
          The gain of the source.
protected  int _id
          The OpenAL identifier for this source.
protected  boolean _looping
          Whether or not the source is looping.
protected  float _maxDistance
          The maximum distance for attenuation.
protected  float _maxGain
          The maximum gain.
protected  float _minGain
          The minimum gain.
protected  float _pitch
          The pitch multiplier.
protected  float _px
          The position of the source.
protected  float _py
          The position of the source.
protected  float _pz
          The position of the source.
protected  ArrayList<Buffer> _queue
          The source's queue of buffers (storing them keeps them from being garbage-collected).
protected  float _referenceDistance
          The reference distance for attenuation.
protected  float _rolloffFactor
          The attenuation rolloff factor.
protected  SoundManager _soundmgr
          The sound manager responsible for this source.
protected  boolean _sourceRelative
          Whether or not the source's position, velocity, etc. are relative to the listener.
protected  float _vx
          The velocity of the source.
protected  float _vy
          The velocity of the source.
protected  float _vz
          The velocity of the source.
 
Constructor Summary
Source(SoundManager soundmgr)
          Creates a new source for the specified sound manager.
 
Method Summary
 void delete()
          Deletes this source, rendering it unusable.
protected  void finalize()
           
 int getBuffersProcessed()
          Returns the number of buffers that have been processed.
 int getByteOffset()
          Returns the position offset of the source within the queued buffers, in bytes.
 int getId()
          Returns this source's OpenAL identifier.
 int getSampleOffset()
          Returns the position offset of the source within the queued buffers, in samples.
 float getSecOffset()
          Returns the position offset of the source within the queued buffers, in seconds.
 int getSourceState()
          Returns the state of the source: AL10.AL_INITIAL, AL10.AL_PLAYING, AL10.AL_PAUSED, or AL10.AL_STOPPED.
 boolean isPaused()
          Determines whether the source is paused.
 boolean isPlaying()
          Determines whether the source is playing.
 boolean isStopped()
          Determines whether the source is stopped.
 void pause()
          Pauses the source.
 void play()
          Starts playing the source.
 void queueBuffers(Buffer... buffers)
          Enqueues the specified buffers.
 void rewind()
          Rewinds the source.
 void setBuffer(Buffer buffer)
          Sets the source buffer.
 void setConeInnerAngle(float angle)
          Sets the inside angle of the sound cone.
 void setConeOuterAngle(float angle)
          Sets the outside angle of the sound cone.
 void setConeOuterGain(float gain)
          Sets the gain outside of the sound cone.
 void setDirection(float x, float y, float z)
          Sets the direction of the source.
 void setGain(float gain)
          Sets the gain of the source.
 void setLooping(boolean looping)
          Sets whether or not the source is looping.
 void setMaxDistance(float distance)
          Sets the maximum distance for attenuation.
 void setMaxGain(float gain)
          Sets the maximum gain.
 void setMinGain(float gain)
          Sets the minimum gain.
 void setPitch(float pitch)
          Sets the pitch multiplier.
 void setPosition(float x, float y, float z)
          Sets the position of the source.
 void setReferenceDistance(float distance)
          Sets the reference distance for attenuation.
 void setRolloffFactor(float rolloff)
          Sets the rolloff factor for attenuation.
 void setSourceRelative(boolean relative)
          Sets whether or not the position, velocity, etc., of the source are relative to the listener.
 void setVelocity(float x, float y, float z)
          Sets the velocity of the source.
 void stop()
          Stops the source.
 void unqueueBuffers(Buffer... buffers)
          Removes the specified buffers from the queue.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_soundmgr

protected SoundManager _soundmgr
The sound manager responsible for this source.


_id

protected int _id
The OpenAL identifier for this source.


_px

protected float _px
The position of the source.


_py

protected float _py
The position of the source.


_pz

protected float _pz
The position of the source.


_vx

protected float _vx
The velocity of the source.


_vy

protected float _vy
The velocity of the source.


_vz

protected float _vz
The velocity of the source.


_gain

protected float _gain
The gain of the source.


_sourceRelative

protected boolean _sourceRelative
Whether or not the source's position, velocity, etc. are relative to the listener.


_looping

protected boolean _looping
Whether or not the source is looping.


_minGain

protected float _minGain
The minimum gain.


_maxGain

protected float _maxGain
The maximum gain.


_referenceDistance

protected float _referenceDistance
The reference distance for attenuation.


_rolloffFactor

protected float _rolloffFactor
The attenuation rolloff factor.


_maxDistance

protected float _maxDistance
The maximum distance for attenuation.


_pitch

protected float _pitch
The pitch multiplier.


_dx

protected float _dx
The direction of the source.


_dy

protected float _dy
The direction of the source.


_dz

protected float _dz
The direction of the source.


_coneInnerAngle

protected float _coneInnerAngle
The inside angle of the sound cone.


_coneOuterAngle

protected float _coneOuterAngle
The outside angle of the sound cone.


_coneOuterGain

protected float _coneOuterGain
The gain outside the sound cone.


_queue

protected ArrayList<Buffer> _queue
The source's queue of buffers (storing them keeps them from being garbage-collected).

Constructor Detail

Source

public Source(SoundManager soundmgr)
Creates a new source for the specified sound manager.

Method Detail

getId

public final int getId()
Returns this source's OpenAL identifier.


setPosition

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


setVelocity

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


setGain

public void setGain(float gain)
Sets the gain of the source.


setSourceRelative

public void setSourceRelative(boolean relative)
Sets whether or not the position, velocity, etc., of the source are relative to the listener.


setLooping

public void setLooping(boolean looping)
Sets whether or not the source is looping.


setMinGain

public void setMinGain(float gain)
Sets the minimum gain.


setMaxGain

public void setMaxGain(float gain)
Sets the maximum gain.


setReferenceDistance

public void setReferenceDistance(float distance)
Sets the reference distance for attenuation.


setRolloffFactor

public void setRolloffFactor(float rolloff)
Sets the rolloff factor for attenuation.


setMaxDistance

public void setMaxDistance(float distance)
Sets the maximum distance for attenuation.


setPitch

public void setPitch(float pitch)
Sets the pitch multiplier.


setDirection

public void setDirection(float x,
                         float y,
                         float z)
Sets the direction of the source.


setConeInnerAngle

public void setConeInnerAngle(float angle)
Sets the inside angle of the sound cone.


setConeOuterAngle

public void setConeOuterAngle(float angle)
Sets the outside angle of the sound cone.


setConeOuterGain

public void setConeOuterGain(float gain)
Sets the gain outside of the sound cone.


setBuffer

public void setBuffer(Buffer buffer)
Sets the source buffer. Equivalent to unqueueing all buffers, then queuing the provided buffer. Cannot be called when the source is playing or paused.

Parameters:
buffer - the buffer to set, or null to clear.

queueBuffers

public void queueBuffers(Buffer... buffers)
Enqueues the specified buffers.


unqueueBuffers

public void unqueueBuffers(Buffer... buffers)
Removes the specified buffers from the queue.


isPlaying

public boolean isPlaying()
Determines whether the source is playing.


isPaused

public boolean isPaused()
Determines whether the source is paused.


isStopped

public boolean isStopped()
Determines whether the source is stopped.


getSourceState

public int getSourceState()
Returns the state of the source: AL10.AL_INITIAL, AL10.AL_PLAYING, AL10.AL_PAUSED, or AL10.AL_STOPPED.


getBuffersProcessed

public int getBuffersProcessed()
Returns the number of buffers that have been processed.


getSecOffset

public float getSecOffset()
Returns the position offset of the source within the queued buffers, in seconds.


getSampleOffset

public int getSampleOffset()
Returns the position offset of the source within the queued buffers, in samples.


getByteOffset

public int getByteOffset()
Returns the position offset of the source within the queued buffers, in bytes.


play

public void play()
Starts playing the source.


pause

public void pause()
Pauses the source.


stop

public void stop()
Stops the source.


rewind

public void rewind()
Rewinds the source.


delete

public void delete()
Deletes this source, rendering it unusable.


finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable