Main Content

Add Sound to a Virtual World

To add sound to a virtual world, use a Sound node. You can include an AudioClip node in a Sound node. For an AudioClip node, use a mono or stereo WAV file in uncompressed PCM format.

To listen to the sound, use a computer that supports sound. For details, see Listen to Sound in a Virtual World.


A stereo sound source retains its channel separation during playback. Simulink® 3D Animation™ attenuates the sound based on the distance of the viewer from the sound location. The relative position of the viewer to the sound location and the viewer direction in the virtual world do not affect the stereo channels. There is no impact even if the Sound node has the spatialize field set to true.

The following code adds to a virtual world a sound that switches on and off based on a logical signal.

DEF SoundSwitch Switch {
 choice [
  DEF MySound Sound	{
	  source DEF CraneNoise AudioClip {
		  url "sound/crane_run.wav"
		  loop TRUE

Related Topics