Vizard 8 » Reference » Multimedia » Advanced 3D sound
8.0

Advanced 3D sound

Once you've added localized sound to a node, you can adjust aspects of how the sound travels from its source.

Distance range of the sound's projection

If sound is emanating from an object, the volume is (obviously) going to increase as you get closer to it and decrease as you get further from it. The <multimedia:sound3D>.minmax( <min distance>, <max distance>) command controls this feature by allowing you to set the range over which those changes in volume occur. The minimum distance sets the cap on the volume. So, if your minimum distance is set to 1 meter, then no matter how close you get to the object it's not going to get any louder than it would be at 1 meter away. The maximum distance, on the other hand, sets the floor on the volume. So, if your maximum is set at 10 meters, then no matter how far you get from the object, the volume won't drop below what it would be at 10 meters.

#Add the duck model.
duck = viz.add('duck.cfg', pos = [0,0.5,5], euler = [180,0,0])
#Attach a sound to the model
quack = duck.playsound('quack.wav', viz.LOOP)
#Set the min at 5 meters and the max at 10 meters.
quack.minmax( 5, 10 )

Directional sound

If you add a sound to an object, the default is for the sound to emanate from all sides of the object. You can, however, make sound directional by changing the sound cones. You can think of the sound cones as two megaphones, one inside of the other, pointing down the object's + z axis. (They lie on the z-axis of the object, their tips are at the center of the object, and they grow wider as you travel in the positive direction down the object's z-axis). Within the inner sound cone, volume is at 100% for the given distance from the object. As you move from the boundary of the inner cone to the outer cone, sound fades to the volume set for outside the outer sound cone. That volume is set (in decibels) with the <multimedia:sound3D>.conevolume command. The angles that define the sound cones are set using the <multimedia:sound3D>.coneangle( <inner cone angle>, <outer cone angle> ). NOTE: if you want to use sound cones, make sure you set both the angles of the cones and the cone volume.

#Add a duck and make it quack and spin.
duck = viz.add('duck.cfg', pos = [0,0.5,5], euler = [180,0,0])
duck.state(1)
duck.addAction( vizact.spin( 0,1,0,90 ))
quack = duck.playsound('quack.wav', viz.LOOP)

#Set the volume outside the sound cones.
quack.conevolume(-10000)
#Set the angles of the inner and outer cones.
quack.coneangle(40,180)

Doppler effects

You can also simulate a doppler effect for objects travelling past the view with the <multimedia:sound3D>.velocity( <object velocity> ) command. Drop the velocity of the travelling object into the command as the parameter. The command will use that velocity vector to adjust the sound frequency such that when the vector is pointing toward the viewpoint, the sound frequency will increase and when the velocity vector is pointing away from the view, the sound frequency will decrease.

#Add a duck and its actions.
duck = viz.add('duck.cfg', pos = [-5,0,0])
duck.center([5,0,0])
duck.state(1)
duck.addAction( vizact.spin( 0,1,0,90 ) )
quack = duck.playsound('BUZZER.wav', viz.LOOP)
#Set the velocity of the sound.
quack.velocity( [0,0,100] )

3D Sound Algorithm

To generate 3D sound Vizard uses the Windows DirectSound API. The position and orientation of the sound source and listener are sent to DirectSound and processed by its 3D algorithm.

Sound Cards

Where spatialized sound is concerned, a discreet sound card will most likely not buy you anything in terms of processing over an integrated sound processor. What it will buy you is potentially better sound quality from

Spatialization Quality

Sound drivers can affect the quality of the spatialization. Some drivers provide their own utilities for configuring 3D sound properties. If using speakers, a 5.1 surround system is one of the best options for improving spatialization without making a large investment in hardware.

Static 3D Sound

Vizard supports 5.1 and 7.1 multi-channel WAV files. This can be useful for presenting 3D sounds to a user from a static position. In this case, the file should be played using the non-spatialized audio command (viz.addAudio(<filename>)).

See also

In this section:

Multimedia basics

Video Basics

Sound basics

Ambisonic 3D sound

Recording sound

Multimedia command table

Other sections:

Tutorial: Multimedia

Tutorial: 3D sound

Example scripts:

Adding sounds

3D sound