DirectAnimation Animated Header --DASound Class DirectAnimation Animated Header --DASound Class* Microsoft DirectAnimation SDK
*Contents  *Index  *Topic Contents
*Previous Topic: DAPoint3 Class
*Next Topic: DAStatics Class

DASound Class


DASound Sound behavior objects have gain, rate, phase and pan attributes. Imported sounds (.WAV and .MIDI files) also have a length, returned by the import function. Gain (volume) defines how loud the sound is played. Rate defines how many times faster or slower the sound is played relative to its nominal rate. Phase defines how much to shift the time of the sound, and is useful for creating special sound effects such as echoes. Mixing the same sounds that are out of phase makes the sound richer. Pan defines the strength of the sound relative to the left and right sound channels. This is useful for positioning sounds.

Gain, rate, phase, and pan can use animated numbers and can, therefore, change over time. This is useful for modifying the sound based, not only on time (see SubstituteTime) but also on other computed values such as distance. Sounds can be embedded in a geometry to achieve spatialized effects. Currently, all sounds are omnidirectional.

This class inherits from DABehavior.

DASound Functions

bullet1.gifGainAnim

bullet1.gifGain

bullet1.gifLoop

bullet1.gifPanAnim

bullet1.gifPan

bullet1.gifPhaseAnim

bullet1.gifPhase

bullet1.gifRateAnim

bullet1.gifRate


GainAnim

DASound Class

Multiplies the gain (volume) by the given amount.

soundObj.GainAnim(
  gain
  )

Parameters
gain
The factor by which to multiply the volume. Values greater than one increase the volume and values between zero and 1 decrease the sound's volume. Except for sound geometries, only attenuation values of 0-1 have an effect. For sound geometries, gains greater than 1 affect the distance from which sounds can be heard. The sounds, however, never sound louder than 1. This must be an animated number (DANumber).
Return Values

Returns a DASound object representing the newly created sound.


Gain

DASound Class

Same as GainAnim except the parameter is non-animated.

soundObj.Gain


Loop

DASound Class

Creates a DASound object that repeats continuously. This method applies to the primitive sounds themselves. It does not loop a reactive sound behavior. Instead, it loops each of the primitive sounds that are components of the reactive sound behavior. For example, assume you have a sound that is sound1 until the left mouse button is pressed, and then becomes sound2, and you loop this composite sound, as shown in the following JScript code:


snd =  m.Until(sound1, m.LeftButtonDown, sound2);
loopsnd= snd.Loop();

The resulting sound is a continuous loop of sound1 until the left mouse button is pressed, then becomes a continuous loop of sound2. It does not loop the composite behavior in that it does not loop sound1 until the button is pressed, then cycle through sound2 once, then go back to playing sound1 until the button is pressed again.

soundObj.Loop( )

Return Values

Returns a DASound object.


PanAnim

DASound Class

Creates a DASound object by repositioning a monophonic sound between the left and right channels. To do this, the amplitude of the sound in each channel is changed. This is similar to adjusting the balance on a stereo.

soundObj.PanAnim(
  pan
  )

Parameters
pan
The amount to pan. Can be a value in the range -1.0 to 1.0, with -1.0 as full left, 0 as center, and 1.0 as full right. This must be an animated number (DANumber).
Return Values

Returns a DASound object.

Remarks

With stereophonic sounds, panning away from a channel attenuates it.


Pan

DASound Class

Same as PanAnim except the parameter is non-animated.

soundObj.Pan(
  pan
  )


PhaseAnim

DASound Class

Creates a new DASound object by shifting the sound in time by the given amount. Shifting the sound and mixing with the original sound allows for special effects, such as echoing.

soundObj.PhaseAnim(
  phase
  )

Parameters
phase
The amount in seconds (or fractions of seconds) to shift the sound. This must be an animated number (DANumber).
Return Values

Returns a DASound object.

Remarks

For unlooped sounds, a positive phase shift delays the sound's starting time while a negative phase shift clips off the beginning of the sound. For looped sounds, a positive phase shift adds the end of the sound to the beginning of the sound, while a negative phase shift controls how far into the sound the beginning should be. Phase-shifting only takes effect when the sound begins playing. Currently, you cannot dynamically change the position of a running sound. This attribute composes additively.


Phase

DASound Class

Same as PhaseAnim except the parameter is non-animated.

soundObj.Phase(
  phase
  )


RateAnim

DASound Class

Creates a DASound object by multiplying the playback rate by the given amount.

soundObj.RateAnim(
  rate
  )

Parameters
rate
Specifies the factor by which to multiply the rate. Values greater than one increase the rate and values between zero and 1 decrease it. This must be an animated number (DANumber).
Return Values

Returns a DASound object.

Remarks

A rate of 0 pauses the sound. Negative rates are not supported. This attribute composes additively.


Rate

DASound Class

Same as RateAnim except the parameter is non-animated.

soundObj.Rate(
  rate
  )

Relevant Functions from the DAStatics Class

The following functions are defined in the DAStatics class and are most relevant to objects of type DASound.

lib.ImportSound(url)

lib.ImportSoundAsync(url, soundStandIn)

lib.mix(sound1, sound2)

lib.mixArray(sounds)

Relevant Properties from the DAStatics Class

The following properties are defined in the DAStatics class and are most relevant to objects of type DASound.

lib.Silence

lib.SinSynth

© 1998 Microsoft Corporation. All rights reserved. Terms of Use.

*Top of Page