Aviatrix3D
2.1.0

org.j3d.aviatrix3d
Class Sound

java.lang.Object
  extended by org.j3d.aviatrix3d.SceneGraphObject
      extended by org.j3d.aviatrix3d.Node
          extended by org.j3d.aviatrix3d.Leaf
              extended by org.j3d.aviatrix3d.Sound
All Implemented Interfaces:
java.lang.Comparable, AudioUpdateListener, AudioRenderable, Cullable, LeafCullable, Renderable
Direct Known Subclasses:
BackgroundSound, PointSound

public abstract class Sound
extends Leaf
implements LeafCullable, AudioRenderable, AudioUpdateListener

A Sound class represents all sound emiting nodes in the system.

Version:
$Revision: 1.18 $
Author:
Alan Hudson

Field Summary
protected  int buffer
          The buffer created for this sound
protected  boolean dataChanged
          Has the sound data changed
protected  boolean enabled
          Is the sound currently enabled
protected  int format
          The format of this sound.
protected  int freq
          The frequency of the samples
protected  boolean loop
          Whether to loop this sample
protected  boolean paramsChanged
          Has the sound params
protected  boolean paused
          Is the sound paused
protected  float pitch
          The sounds pitch
protected  boolean playChanged
          Has the play state changed
protected  boolean playing
          Is the sound playing
protected  int seq
          The current seq
protected  AudioComponent soundSource
          The source feeding this sound
protected  java.nio.IntBuffer values
          A temporary value used to fetch values from OpenAL.
 
Fields inherited from class org.j3d.aviatrix3d.Node
bounds, implicitBounds, INVALID_BOUNDS, parent
 
Fields inherited from class org.j3d.aviatrix3d.SceneGraphObject
alive, LISTENER_SET_TIMING_ERR_PROP, updateHandler
 
Fields inherited from interface org.j3d.aviatrix3d.rendering.LeafCullable
AUDIO_CULLABLE, CLIP_CULLABLE, FOG_CULLABLE, GEOMETRY_CULLABLE, LIGHT_CULLABLE, OVERRIDE_CULLABLE
 
Constructor Summary
Sound()
          Creates a sound.
 
Method Summary
 void audioUpdated(int format, int frequency, int seq)
          Notification that the audio has updated a section of the sample.
protected  int compareTo(Sound snd)
          Compares this object with the specified object for order.
protected  boolean equals(Sound snd)
          Compares this object with the specified object to check for equivalence.
 BoundingVolume getBounds()
          Get the currently set bounds for this object.
 int getCullableType()
          Get the type that this cullable represents.
 Renderable getRenderable()
          Get the child renderable of this object.
 boolean isEnabled()
          State check to see whether the sound is enabled.
 boolean isPaused()
          Is this sound currently paused;
 boolean isPlaying()
          Is this sound currently playing.
 boolean isSpatialised()
          Check to see if this renderable is spatialised in any way.
protected  void markBoundsDirty()
          Mark this node as having dirty bounds due to one of it's children having their bounds changed.
 void paramsUpdated(boolean loop, float pitch)
          Notification that the audio's parameters have changed.
 void pauseSound()
          Pause a sound playing.
protected  void recomputeBounds()
          Internal method to recalculate the implicit bounds of this Node.
 void setAudioSource(AudioComponent src)
          Set the source for the sound to use.
 void setEnabled(boolean state)
          Set the enabled state of the light.
 void startSound()
          Start a sound playing.
 void stopSound()
          Stop a sound playing.
 
Methods inherited from class org.j3d.aviatrix3d.Node
boundsChanged, checkForCyclicParent, getParent, removeParent, requestBoundsUpdate, setBounds, setParent, updateBounds, updateParentBounds
 
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject
checkForCyclicChild, dataChanged, getAppUpdateWriteTimingMessage, getBoundsWriteTimingMessage, getDataWriteTimingMessage, getUserData, isLive, setLive, setUpdateHandler, setUserData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.j3d.aviatrix3d.rendering.AudioRenderable
postRender, render
 
Methods inherited from interface org.j3d.aviatrix3d.rendering.Renderable
equals
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

soundSource

protected AudioComponent soundSource
The source feeding this sound


format

protected int format
The format of this sound. Defined in AudioSource


freq

protected int freq
The frequency of the samples


loop

protected boolean loop
Whether to loop this sample


buffer

protected int buffer
The buffer created for this sound


pitch

protected float pitch
The sounds pitch


seq

protected int seq
The current seq


dataChanged

protected boolean dataChanged
Has the sound data changed


playChanged

protected boolean playChanged
Has the play state changed


paramsChanged

protected boolean paramsChanged
Has the sound params


playing

protected boolean playing
Is the sound playing


paused

protected boolean paused
Is the sound paused


enabled

protected boolean enabled
Is the sound currently enabled


values

protected java.nio.IntBuffer values
A temporary value used to fetch values from OpenAL. This is allocated to be the size of a single int in the constructor.

Constructor Detail

Sound

public Sound()
Creates a sound. By default it is not enabled.

Method Detail

markBoundsDirty

protected void markBoundsDirty()
Mark this node as having dirty bounds due to one of it's children having their bounds changed.

Overrides:
markBoundsDirty in class Node

recomputeBounds

protected void recomputeBounds()
Internal method to recalculate the implicit bounds of this Node. By default the bounds are a point sphere, so derived classes should override this method with something better.

Overrides:
recomputeBounds in class Node

getBounds

public BoundingVolume getBounds()
Get the currently set bounds for this object. If no explicit bounds have been set, then an implicit set of bounds is returned based on the current scene graph state.

Specified by:
getBounds in interface LeafCullable
Overrides:
getBounds in class Node
Returns:
The current bounds of this object

audioUpdated

public void audioUpdated(int format,
                         int frequency,
                         int seq)
Notification that the audio has updated a section of the sample. This is generic for all audio sources correctly.

Specified by:
audioUpdated in interface AudioUpdateListener
Parameters:
format - The format of the samples
frequency - The frequency of the samples
seq - The sample seq. Seq 0 means complete file. Streamed sources start at 1

paramsUpdated

public void paramsUpdated(boolean loop,
                          float pitch)
Notification that the audio's parameters have changed.

Specified by:
paramsUpdated in interface AudioUpdateListener
Parameters:
loop - Whether to loop this sample
pitch - The pitch to play at.

getCullableType

public int getCullableType()
Get the type that this cullable represents.

Specified by:
getCullableType in interface LeafCullable
Returns:
One of the _CULLABLE constants

getRenderable

public Renderable getRenderable()
Get the child renderable of this object.

Specified by:
getRenderable in interface LeafCullable
Returns:
an array of nodes

isEnabled

public boolean isEnabled()
State check to see whether the sound is enabled.

Specified by:
isEnabled in interface AudioRenderable
Returns:
true if the sound has something to render

isSpatialised

public boolean isSpatialised()
Check to see if this renderable is spatialised in any way. Spatialised means it would require proper head tracking, where non-spatialised just represents a basic noise such as background sound.

Default implementation returns true. Derived classes should overrride as needed.

Specified by:
isSpatialised in interface AudioRenderable
Returns:
true always unless overrriden

setEnabled

public void setEnabled(boolean state)
                throws InvalidWriteTimingException
Set the enabled state of the light. Can use this to turn it on and off in a general fashion.

Parameters:
state - The new state of the light
Throws:
InvalidWriteTimingException - This was not called during the data changed callback time

startSound

public void startSound()
                throws InvalidWriteTimingException
Start a sound playing. If the sound was previously paused, this will restart it.

Throws:
InvalidWriteTimingException - This was not called during the data changed callback time

stopSound

public void stopSound()
               throws InvalidWriteTimingException
Stop a sound playing.

Throws:
InvalidWriteTimingException - This was not called during the data changed callback time

isPlaying

public boolean isPlaying()
Is this sound currently playing.

Returns:
Whether the sound is playing.

pauseSound

public void pauseSound()
                throws InvalidWriteTimingException
Pause a sound playing. To restart the sound playing from it's current position, use startSound()

Throws:
InvalidWriteTimingException - This was not called during the data changed callback time

isPaused

public boolean isPaused()
Is this sound currently paused;

Returns:
Whether the sound is paused.

setAudioSource

public void setAudioSource(AudioComponent src)
Set the source for the sound to use.

Parameters:
src - The source of the sound
Throws:
InvalidWriteTimingException - This was not called during the data changed callback time

compareTo

protected int compareTo(Sound snd)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Parameters:
snd - The argument instance to be compared
Returns:
-1, 0 or 1 depending on order

equals

protected boolean equals(Sound snd)
Compares this object with the specified object to check for equivalence.

Parameters:
snd - The sound instance to be compared
Returns:
true if the objects represent identical values

Aviatrix3D
2.1.0

Latest Info from http://aviatrix3d.j3d.org/
Copyright © 2003 - 2009 j3d.org