Class dnx.lr.node.SoundNode
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class dnx.lr.node.SoundNode

java.lang.Object
   |
   +----dnx.util.DNXObject
           |
           +----dnx.lr.Node
                   |
                   +----dnx.lr.LeafNode
                           |
                           +----dnx.lr.node.SoundNode

public class SoundNode
extends LeafNode
implements BoundingBoxCachingNode, GlobalPassViewPositionNode, GlobalPassPriorTraversalNode, UniquifyAtAttachNode
 Sound {
    exposedField SFVec3f      direction       0 0 1
    exposedField SFFloat      intensity       1
    exposedField SFVec3f      location        0 0 0
    exposedField SFFloat      maxBack         10
    exposedField SFFloat      maxFront        10
    exposedField SFFloat      minBack         1
    exposedField SFFloat      minFront        1
    exposedField SFFloat      priority        0
    exposedField SFNode       source          NULL
    field        SFBool       spatialize      TRUE
 }

The Sound node describes the positioning and spatial presentation of a sound in a VRML scene. The sound may be located at a point and emit sound in a spherical or ellipsoid pattern, in the local coordinate system. The ellipsoid is pointed in a particular direction and may be shaped to provide more or less directional focus from the location of the sound. The sound node may also be used to describe an ambient sound which tapers off at a specified distance from the sound node.

The Sound node also enables ambient background sound to be created by setting of the maxFront and maxBack to the radius of the area for the ambient noise. If ambient noise is required for the whole scene then these values should be set to at least cover the distance from the location to the farthest point in scene from that point (including effects of transforms).

The source field specifies the sound source for the sound node. If there is no source specified the Sound will emit no audio. The source field shall specify either an AudioClip or a MovieTexture node. Furthermore, the MovieTexture node must refer to a movie format that supports sound (e.g. MPEG1-Systems [MPEG]).

The intensity field adjusts the volume of each sound source; The intensity is an SFFloat that ranges from 0.0 to 1.0. An intensity of 0 is silence, and an intensity of 1 is the full volume of the sound in the sample or the full volume of the MIDI clip.

The priority field gives the author some control over which sounds the browser will choose to play when there are more sounds active than sound channels available. The priority varies between 0.0 and 1.0, with 1.0 being the highest priority. For most applications priority 0.0 should be used for a normal sound and 1.0 should be used only for special event or cue sounds (usually of short duration) that the author wants the user to hear even if they are farther away and perhaps of lower intensity than some other ongoing sounds. Browsers should make as many sound channels available to the scene as is efficiently possible.

If the browser does not have enough sound channels to play all of the currently active sounds, it is recommended that the browser sort the active sounds into an ordered list using the following sort keys:

  1. decreasing priority;
  2. for sounds with priority > 0.5, increasing (now-startTime)
  3. decreasing intensity at viewer location ((intensity/distance)**2);

where now represents the current time, and startTime is the startTime field of the audio source node specified in the source field.

It is important that sort key #2 be used for the high priority (event and cue) sounds so that new cues will be heard even when the channels are "full" of currently active high priority sounds. Sort key #2 should not be used for normal priority sounds so selection among them will be based on sort key #3 - intensity and distance from the viewer.

The browser should play as many sounds from the beginning of this sorted list as it has available channels. On most systems the number of concurrent sound channels is distinct from the number of concurrent MIDI streams. On these systems the browser may maintain separate ordered lists for sampled sounds and MIDI streams.

A sound's location in the scene graph determines its spatial location (the sound's location is transformed by the current transformation) and whether or not it can be heard. A sound can only be heard while it is part of the traversed scene; sound nodes that are descended from LOD, Switch, or any grouping or prototype node that disables traversal (i.e. drawing) of its children will not be audible unless they are traversed. If a sound is silenced for a time under a Switch or LOD node, and later it becomes part of the traversal again, the sound picks up where it would have been had it been playing continuously.

Around the location of the emitter, minFront and minBack determine the extent of the full intensity region in front of and behind the sound. If the location of the sound is taken as a focus of an ellipsoid, the minBack and minFront values, in combination with the direction vector determine the two foci of an ellipsoid bounding the ambient region of the sound. Similarly, maxFront and maxBack determine the limits of audibility in front of and behind the sound; they describe a second, outer ellipsoid. If minFront equals minBack and maxFront equals maxBack, the sound is omni-directional, the direction vector is ignored, and the min and max ellipsoids become spheres centered around the sound node. The fields minFront, maxFront, minBack, and maxBack are scaled by the parent transformations - these values must be >= 0.0.

The inner ellipsoid defines a space of full intensity for the sound. Within that space the sound will play at the intensity specified in the sound node. The outer ellipsoid determines the maximum extent of the sound. Outside that space, the sound cannot be heard at all. In between the two ellipsoids, the intensity drops off proportionally with inverse square of the distance. With this model, a Sound usually will have smooth changes in intensity over the entire extent is which it can be heard. However, if at any point the maximum is the same as or inside the minimum, the sound is cut off immediately at the edge of the minimum ellipsoid.

The ideal implementation of the sound attenuation between the inner and outer ellipsoids is an inverse power dropoff. A reasonable approximation to this ideal model is a linear dropoff in decibel value. Since an inverse power dropoff never actually reaches zero, it is necessary to select an appropriate cutoff value for the outer ellipsoid so that the outer ellipsoid contains the space in which the sound is truly audible and excludes space where it would be negligible. Keeping the outer ellipsoid as small as possible will help limit resources used by nearly inaudible sounds. Experimentation suggests that a 20dB dropoff from the maximum intensity is a reasonable cutoff value that makes the bounding volume (the outer ellipsoid) contain the truly audible range of the sound. Since actual physical sound dropoff in an anechoic environment follows the inverse square law, using this algorithm it is possible to mimic real-world sound attenuation by making the maximum ellipsoid ten times larger than the minimum ellipsoid. This will yield inverse square dropoff between them.

Browsers should support spatial localization of sound as well as their underlying sound libraries will allow. The spatialize field is used to indicate to browsers that they should try to locate this sound. If the spatialize field is TRUE, the sound should be treated as a monaural sound coming from a single point. A simple spatialization mechanism just places the sound properly in the pan of the stereo (or multichannel) sound output. Sounds are faded out over distance as described above. Browsers may use more elaborate sound spatialization algorithms if they wish.

Authors can create ambient sounds by setting the spatialize field to FALSE. In that case, stereo and multichannel sounds should be played using their normal separate channels. The distance to the sound and the minimum and maximum ellipsoids (discussed above) should affect the intensity in the normal way. Authors can create ambient sound over the entire scene by setting the minFront and minBack to the maximum extents of the scene.


Variable Index

 o direction
 o intensity
 o location
 o maxBack
 o maxFront
 o minBack
 o minFront
 o priority
 o source
 o spatialize

Constructor Index

 o SoundNode()

Method Index

 o beginGlobalPassPriorTraversal(NodeInstance)
 o boundingBoxHasChanged(Field)
Meant to be overridden by subclasses.
 o createNodeDefinition(NodeDefinition)
Create the node definition.
 o endGlobalPassPriorTraversal(NodeInstance)
 o getCachedBoundingBox()
For BoundingBoxCachingNode.
 o getPart(NodeInstance)
 o handleGlobalPass(NodeInstance, RenderState, Matrix4)
 o initFields()
Initialize field values.
 o recomputeBoundingBox(BoundingBox3)
Meant to be overridden by subclasses; compute the bounding box and store into the argument.

Variables

 o direction
  public SFVec3f direction
 o intensity
  public SFFloat intensity
 o location
  public SFVec3f location
 o maxBack
  public SFFloat maxBack
 o maxFront
  public SFFloat maxFront
 o minBack
  public SFFloat minBack
 o minFront
  public SFFloat minFront
 o priority
  public SFFloat priority
 o source
  public SFNode source
 o spatialize
  public SFBool spatialize

Constructors

 o SoundNode
  public SoundNode()

Methods

 o createNodeDefinition
  protected void createNodeDefinition(NodeDefinition def)
Create the node definition.
Overrides:
createNodeDefinition in class Node
 o initFields
  protected void initFields()
Initialize field values.
Overrides:
initFields in class Node
 o getCachedBoundingBox
  public BoundingBox3 getCachedBoundingBox()
For BoundingBoxCachingNode.
 o recomputeBoundingBox
  public void recomputeBoundingBox(BoundingBox3 box)
Meant to be overridden by subclasses; compute the bounding box and store into the argument.
Overrides:
recomputeBoundingBox in class Node
 o boundingBoxHasChanged
  protected boolean boundingBoxHasChanged(Field f)
Meant to be overridden by subclasses.
Overrides:
boundingBoxHasChanged in class Node
 o getPart
  public SoundPart getPart(NodeInstance inst)
 o handleGlobalPass
  public void handleGlobalPass(NodeInstance inst,
                               RenderState state,
                               Matrix4 objectToViewerMatrix)
 o beginGlobalPassPriorTraversal
  public void beginGlobalPassPriorTraversal(NodeInstance inst)
 o endGlobalPassPriorTraversal
  public void endGlobalPassPriorTraversal(NodeInstance inst)

All Packages  Class Hierarchy  This Package  Previous  Next  Index