The Annotated VRML 97 Reference

1 Intro     Concepts     3 Nodes     4 Fields/Events    Conformance
A Grammar     B Java     C JavaScript     D Examples     E Related Info    References
Quick Java         Quick JavaScript         Quick Nodes   

  About the Book
  Copyright © 1997-99
  Purchase the book from

Chapter 3:
Node Reference


+3.42 Sound

Sound { 
  exposedField SFVec3f  direction     0 0 1   # (-INF,INF)
  exposedField SFFloat  intensity     1       # [0,1]
  exposedField SFVec3f  location      0 0 0   # (-INF,INF)
  exposedField SFFloat  maxBack       10      # [0,INF)
  exposedField SFFloat  maxFront      10      # [0,INF)
  exposedField SFFloat  minBack       1       # [0,INF)
  exposedField SFFloat  minFront      1       # [0,INF)
  exposedField SFFloat  priority      0       # [0,1]
  exposedField SFNode   source        NULL
  field        SFBool   spatialize    TRUE

The Sound node specifies the spatial presentation of a sound in a VRML scene. The sound is located at a point in the local coordinate system and emits sound in an elliptical pattern (defined by two ellipsoids). The ellipsoids are oriented in a direction specified by the direction field. The shape of the ellipsoids may be modified to provide more or less directional focus from the location of the sound.

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

The intensity field adjusts the loudness (decibels) of the sound emitted by the Sound node (note: this is different from the traditional definition of intensity with respect to sound; see [SNDA]). The intensity field has a value that ranges from 0.0 to 1.0 and specifies a factor which shall be used to scale the normalized sample data of the sound source during playback. A Sound node with an intensity of 1.0 shall emit audio at its maximum loudness (before attenuation), and a Sound node with an intensity of 0.0 shall emit no audio. Between these values, the loudness should increase linearly from a -20 dB change approaching an intensity of 0.0 to a 0 dB change at an intensity of 1.0.

The priority field provides a hint for the browser to choose which sounds to play when there are more active Sound nodes than can be played at once due to either limited system resources or system load. Section "5.3.4 Sound priority, attenuation, and spatialization" describes a recommended algorithm for determining which sounds to play under such circumstances. The priority field ranges from 0.0 to 1.0, with 1.0 being the highest priority and 0.0 the lowest priority.

The location field determines the location of the sound emitter in the local coordinate system. A Sound node's output is audible only if 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 are not audible unless they are traversed. If a Sound node is disabled by a Switch or LOD node, and later it becomes part of the traversal again, the sound shall resume where it would have been had it been playing continuously.

The Sound node has an inner ellipsoid that defines a volume of space in which the maximum level of the sound is audible. Within this ellipsoid, the normalized sample data is scaled by the intensity field and there is no attenuation. The inner ellipsoid is defined by extending the direction vector through the location. The minBack and minFront fields specify distances behind and in front of the location along the direction vector respectively. The inner ellipsoid has one of its foci at location (the second focus is implicit) and intersects the direction vector at minBack and minFront.

The Sound node has an outer ellipsoid that defines a volume of space that bounds the audibility of the sound. No sound can be heard outside of this outer ellipsoid. The outer ellipsoid is defined by extending the direction vector through the location. The maxBack and maxFront fields specify distances behind and in front of the location along the direction vector respectively. The outer ellipsoid has one of its foci at location (the second focus is implicit) and intersects the direction vector at maxBack and maxFront.

The minFront, maxFront, minBack, and maxBack fields are defined in local coordinates, and shall be >= 0.0. The minBack field shall be <= maxBack, and minFront shall be <= maxFront. The ellipsoid parameters are specified in the local coordinate system but the ellipsoids' geometry is affected by ancestors' transformations.

TIP: To create an ambient background sound track, set the maxFront and maxBack fields as described (to the desired radius of influence) and set the AudioClip node's loop field to TRUE. If stopTime is less than or equal to startTime, the audio will play when the world is loaded. Also, avoid overlapping ambient Sounds, since browsers will have a hard limit (e.g., 3) on how many audio tracks can be played simultaneously.

Between the two ellipsoids, there shall be a linear attenuation ramp in loudness, from 0 dB at the minimum ellipsoid to -20 dB at the maximum ellipsoid:

    attenuation = -20 × (d' / d")

where d'is the distance along the location-to-viewer vector, measured from the transformed minimum ellipsoid boundary to the viewer, and d" is the distance along the location-to-viewer vector from the transformed minimum ellipsoid boundary to the transformed maximum ellipsoid boundary (see Figure 3-47).

Sound node diagram

Figure 3-47: Sound Node

The spatialize field specifies if the sound is perceived as being directionally located relative to the viewer. If the spatialize field is TRUE and the viewer is located between the transformed inner and outer ellipsoids, the viewer's direction and the relative location of the Sound node should be taken into account during playback. Details outlining the minimum required spatialization functionality can be found in "5.3.4 Sound priority, attenuation, and spatialization." If the spatialize field is FALSE, then directional effects are ignored, but the ellipsoid dimensions and intensity will still affect the loudness of the sound. If the sound source is multi-channel (e.g., stereo), then the source should retain its channel separation during playback.

TIP: For better performance, specify minBack, minFront, maxBack, and maxFront values that restrict the Sound to the smallest space possible. This will limit the effects of the Sound node only to the regions where it is needed, and prepare the file for future compatibility and reuse (e.g., if you Inline this file from another file, it will not hurt the performance). A good rule to live by is: "Limit the effects of all Sound nodes in a file to the bounding box that encloses all the Shapes in the file." Also, use the following high-performance settings whenever possible:
  1. Set spatialize to FALSE if the direction of the sound source is not important.
  2. Set minBack = minFront and maxBack = maxFront to produce directionless sounds that fade with distance from the source.
  3. Set minBack = minFront = maxBack = maxFront to produce directionless sounds that emit at constant volume regardless of the distance to the source. This is a good choice for sound effects and ambient sounds.

These tips are especially important for looping Sounds (since they are running continuously!).

TECHNICAL NOTE: The basic design for the Sound node came from a proposal from the RSX (Realistic Sound Experience) group at Intel. Their original proposal can be found at: It contains in-depth explanations of the sound model and justifications for their design.

EXAMPLE (click to run) : The following example illustrates three typical applications of the Sound node (see Figure 3-48). The first Sound is an ambient background track that loops continuously. The min/max fields specify a sphere that encloses the entire world and plays the audio at a constant intensity regardless of the location or orientation of the user. The second Sound node is an example of a directionless sound effect that is triggered by a user event. In this case, the user clicks on the TouchSensor to play one cycle of the audio track, and the user's orientation has no effect on the perceived volume of the sound (minFront = maxFront and minBack = maxBack). The third Sound node is an example of a continuously looping directional sound (i.e., the user's orientation affects perceived volume).

#VRML V2.0 utf8
Group { children [
  DEF S1 Sound {         # Ambient background music
    maxBack 20           # Surround floor area
    minBack 20           # Constant sound within the sphere
    maxFront 20
    minFront 20
    spatialize FALSE     # No spatialization for ambient sound
    intensity 0.2
    source AudioClip {
      description "Ambient background music is playing..."
      url "doodoo.aiff"
      loop TRUE
  Transform {            # Button (triggers the sound effect)
    translation -5 0 0
    children [
      DEF TS TouchSensor {}
      Shape {
        geometry Box {}
        appearance Appearance {
          material Material { diffuseColor 0 0 1 }
      Transform {
        translation -2.2 1.1 0
        children Shape {
          geometry Text {
            string "Click here."
            fontStyle FontStyle {}
      DEF S2 Sound {      # Sound triggered by TouchSensor
        location 0 1 0
        priority 1.0
        minFront 1        # Omni-directional (sphere) sound
        minBack 1
        maxFront 10
        maxBack 10
        source DEF AC AudioClip {
          description "Sound effect is playing once."
          url "forgive.wav"
  Transform {
    translation 8 0 0
    children [
      DEF S3 Sound {          # Spatialized speaker
        location 0 2 0
        priority 0.5
        minBack .5
        minFront 8
        maxBack 5
        maxFront 25
        source AudioClip {
          description "A looping spatialized sound track/"
          url "here.wav"
          loop TRUE
      Transform {            # Speaker geometry
        translation 0 2 0
        rotation 1 0 0 -1.57
        children Shape {
          geometry Cone { bottomRadius 0.2 height .5 }
          appearance Appearance {
            material Material { diffuseColor 1 1 0 }
      Transform {              # Speaker post
        translation 0 1 0
        children Shape {
          geometry Cylinder { radius 0.05 height 2 }
          appearance Appearance {
            material Material { diffuseColor 1 0 0 }
  Transform {                 # Floor
    translation -20 0 -20
    children Shape {
      geometry ElevationGrid {
        height [ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
        xDimension 5
        zDimension 5
        xSpacing 10
        zSpacing 10
      appearance Appearance { material Material {} }
  DirectionalLight { direction -.707 -.707 0 intensity 0.5 }
  NavigationInfo { type "WALK" }
  Viewpoint {
    position 0 1.6 15
    description "Initial view"
ROUTE TS.touchTime TO AC.startTime


Sound node example

Figure 3-48: Sound Node Example