Aviatrix3D
2.0 Dev

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, java.lang.Comparable, Renderable
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.12 $
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_NOT_LIVE_MESSAGE, 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  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.
 Renderable getRenderable(int bufferId)
          Get the Renderable instance needed to process this object for the given buffer ID.
 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.
protected  void recomputeBounds()
          Internal method to recalculate the implicit bounds of this Node.
 void requestBoundsUpdate()
          Request a recomputation of the bounds of this object.
 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, setBounds, setLive, setParent, updateBounds, updateParentBounds
 
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject
checkForCyclicChild, dataChanged, getUserData, isLive, 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.AudioRenderable
postRender, render
 
Methods inherited from interface org.j3d.aviatrix3d.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

getRenderable

public Renderable getRenderable(int bufferId)
Get the Renderable instance needed to process this object for the given buffer ID.

Overrides:
getRenderable in class Leaf
Parameters:
bufferId - The ID of the buffer for the renderable to encapsulate
Returns:
The renderable object, or null if nothing to render

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

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.

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

isEnabled

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

Returns:
true if the sound has something to render

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.0 Dev

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