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.

For relevant functions and properties from the DAStatics class, see the following topics.

DASound Functions

Gain Multiplies the gain (volume) by the given amount. Same as GainAnim except the parameter is nonanimated.
GainAnim Multiplies the gain (volume) by the given amount.
LoopCreates a DASound object that repeats continuously.
Pan Creates a DASound object by repositioning a monophonic sound between the left and right channels. Same as PanAnim except the parameter is nonanimated.
PanAnim Creates a DASound object by repositioning a monophonic sound between the left and right channels.
Phase Creates a new DASound object by shifting the sound in time by the given amount. Same as PhaseAnim except the parameter is nonanimated.
PhaseAnim Creates a new DASound object by shifting the sound in time by the given amount.
Rate Creates a DASound object by multiplying the playback rate by the given amount. Same as RateAnim except the parameter is nonanimated.
RateAnim Creates a DASound object by multiplying the playback rate by the given amount.

Gain

DASound Class

Multiplies the gain (volume) by the given amount. Same as GainAnim except the parameter is nonanimated.

Syntax

soundObj.Gain( gain )

Parameters

gain
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 from 0 through 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 is a nonanimated number (a double).

Return Value

Returns a DASound object representing the newly created sound.

GainAnim

DASound Class

Multiplies the gain (volume) by the given amount.

Syntax

soundObj.GainAnim( gain )

Parameters

gain
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 Value

Returns a DASound object representing the newly created sound.

Loop

DASound Class

Creates a DASound object that repeats continuously.

Syntax

soundObj.Loop( )

Return Value

Returns a DASound object.

Example

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.

Pan

DASound Class

Creates a DASound object by repositioning a monophonic sound between the left and right channels. Same as PanAnim except the parameter is nonanimated.

Syntax

soundObj.Pan( pan )

Parameters

pan
Amount to pan. Can be a value from –1.0 through 1.0, with –1.0 as full left, 0 as center, and 1.0 as full right. This is a nonanimated number (a double).

Return Value

Returns a DASound object.

Remarks

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

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.

Syntax

soundObj.PanAnim( pan )

Parameters

pan
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 Value

Returns a DASound object.

Remarks

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

Phase

DASound Class

Creates a new DASound object by shifting the sound in time by the given amount. Same as PhaseAnim except the parameter is nonanimated.

Syntax

soundObj.Phase( phase )

Parameters

phase
Amount in seconds (or fractions of seconds) to shift the sound. This is a nonanimated number (a double).

Return Value

Returns a DASound object.

Remarks

For unlooped sounds, a negative phase shift delays the sound's starting time while a positive phase shift clips off the beginning of the sound. For looped sounds, a negative phase shift adds the end of the sound to the beginning of the sound, while a positive phase shift controls how far into the sound the beginning should be.

This attribute composes additively.

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.

Syntax

soundObj.PhaseAnim( phase )

Parameters

phase
Amount in seconds (or fractions of seconds) to shift the sound. This must be an animated number (DANumber).

Return Value

Returns a DASound object.

Remarks

For unlooped sounds, a negative phase shift delays the sound's starting time while a positive phase shift clips off the beginning of the sound. For looped sounds, a negative phase shift adds the end of the sound to the beginning of the sound, while a positive phase shift controls how far into the sound the beginning should be. See the following diagram for an illustration.

Positive and Negative Phase Shifts

You can dynamically change the position of a running sound. Thus, you can alter the phase value to skip and seek in a sound. For an example of how to change phase dynamically, see the Phase Sample in Operations on Sound in the Programmer's Guide.

This attribute composes additively.

Rate

DASound Class

Creates a DASound object by multiplying the playback rate by the given amount. Same as RateAnim except the parameter is nonanimated.

Syntax

soundObj.Rate( rate )

Parameters

rate
Specifies the factor by which to multiply the rate. Values greater than one increase the rate, and values between 0 and 1 decrease it. This is a nonanimated number (a double).

Return Value

Returns a DASound object.

Remarks

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

RateAnim

DASound Class

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

Syntax

soundObj.RateAnim( rate )

Parameters

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

Return Value

Returns a DASound object.

Remarks

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


Top of Page Top of Page
© 2000 Microsoft and/or its suppliers. All rights reserved. Terms of Use.