DASound Class


DASound objects can represent a recorded sound, a synthesized sound, or a mixture of these. A characteristic of imported sounds (.WAV and .MIDI files) is that they must have a length.

DASound objects have gain, rate, phase, and pan functions. Gain (volume) defines how loud the sound is played. Rate defines how much 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 adapting monaural sounds for stereo.

Gain, rate, phase, and pan can use animated numbers and can, therefore, change over time. This is useful for modifying the sound based on time or other computed values such as distance.

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

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. This must be an animated number (DANumber).
Return Values

Returns a DASound object representing the newly created sound.


Gain

Same as GainAnim except the parameter is non-animated.

soundObj.Gain


Loop

Creates a DASound object that repeats continuously.

soundObj.Loop( )

Return Values

Returns a DASound object.


PanAnim

Creates a DASound object by repositioning a monophonic sound between the left and right channels. 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

Same as PanAnim except the parameter is non-animated.

soundObj.Pan(
  pan
  )


PhaseAnim

Creates a new DASound object by shifting the sound 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 DASoundobject.


Phase

Same as PhaseAnim except the parameter is non-animated.

soundObj.Phase(
  phase
  )


RateAnim

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.


Rate

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

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