j3d.org Aviatrix3D

org.j3d.aviatrix3d
Class Sound

java.lang.Object
  extended byorg.j3d.aviatrix3d.SceneGraphObject
      extended byorg.j3d.aviatrix3d.Node
          extended byorg.j3d.aviatrix3d.Leaf
              extended byorg.j3d.aviatrix3d.Sound
All Implemented Interfaces:
AudioRenderable, AudioUpdateListener
Direct Known Subclasses:
BackgroundSound, PointSound

public abstract class Sound
extends Leaf
implements AudioRenderable, AudioUpdateListener

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

Version:
$Revision: 1.3 $
Author:
Alan Hudson

Field Summary
protected  int buffer
          The buffer created for this sound
protected  boolean dataChanged
          Has the sound data changed
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
 
Fields inherited from class org.j3d.aviatrix3d.Node
bounds, implicitBounds, INVALID_BOUNDS, parent
 
Fields inherited from class org.j3d.aviatrix3d.SceneGraphObject
alive, updateHandler, WRITE_TIMING_MSG
 
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  void checkForCyclicChild(SceneGraphObject parent)
          Check to see if this node is the same reference as the passed node that is a parent of this node.
 BoundingVolume getBounds()
          Get the currently set bounds for 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.
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.
 void postRender(net.java.games.joal.AL al)
           
protected  void recomputeBounds()
          Internal method to recalculate the implicit bounds of this Node.
 void render(net.java.games.joal.AL al, javax.vecmath.Matrix4f transform)
          This method is called to render this node.
 void requestBoundsUpdate()
          Request a recomputation of the bounds of this object.
 void setAudioSource(AudioComponent src)
           
protected  void setLive(boolean state)
          Notification that this object is live now.
protected  void setUpdateHandler(NodeUpdateHandler handler)
          Set the scenegraph update handler for this node.
 void startSound()
          Start a sound playing.
 void stopSound()
          Stop a sound playing.
 
Methods inherited from class org.j3d.aviatrix3d.Node
boundsChanged, checkForCyclicParent, getParent, removeParent, setBounds, setParent, updateBounds
 
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject
dataChanged, getUserData, isLive, setUserData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

Constructor Detail

Sound

public Sound()
Creates a sound.

Method Detail

setAudioSource

public void setAudioSource(AudioComponent src)

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.

startSound

public void startSound()
Start a sound playing.


stopSound

public void stopSound()
Stop a sound playing.


pauseSound

public void pauseSound()
Pause a sound playing.


isPlaying

public boolean isPlaying()
Is this sound currently playing.

Returns:
Whether the sound is playing.

isPaused

public boolean isPaused()
Is this sound currently paused;

Returns:
Whether the sound is paused.

render

public void render(net.java.games.joal.AL al,
                   javax.vecmath.Matrix4f transform)
This method is called to render this node. All openGL commands needed to render the node should be executed. Any transformations needed should be added to the transformation stack premultiplied. This method must be re-entrant as it can be called from multiple places at once.

Parameters:
al - The al context to render with
transform - The transformation stack to this node

postRender

public void postRender(net.java.games.joal.AL al)

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

requestBoundsUpdate

public void requestBoundsUpdate()
Request a recomputation of the bounds of this object. If this object is not currently live, you can request a recompute of the bounds to get the most current values. If this node is currently live, then the request is ignored.

This will request the geometry to recompute the bounds. If the geometry is found to be live during this process, it will not update, and thus the value used will be the last updated (ie from the previous frame it was processed).


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.

Overrides:
getBounds in class Node
Returns:
The current bounds of this object

isEnabled

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

Returns:
true if the sound has something to render

setUpdateHandler

protected void setUpdateHandler(NodeUpdateHandler handler)
Set the scenegraph update handler for this node. It will notify all its children of the value. A null value will clear the current handler.

Overrides:
setUpdateHandler in class SceneGraphObject
Parameters:
handler - The instance to use as a handler

setLive

protected void setLive(boolean state)
Notification that this object is live now. Overridden to make sure that the live state of the nodes represents the same state as the parent scene graph.

Overrides:
setLive in class Node
Parameters:
state - true if this should be marked as live now

checkForCyclicChild

protected void checkForCyclicChild(SceneGraphObject parent)
                            throws CyclicSceneGraphStructureException
Check to see if this node is the same reference as the passed node that is a parent of this node. This is the downwards check to ensure that there is no cyclic scene graph structures at the point where someone adds a node to the scenegraph. When the reference and this are the same, an exception is generated. Since each class may have different lists of child node setups, this should be overriden by any class that can take children, and have the call passed along to the children.

Overrides:
checkForCyclicChild in class SceneGraphObject
Parameters:
parent - The reference to check against this class
Throws:
CyclicSceneGraphStructureException - Equal parent and child

j3d.org Aviatrix3D

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