DirectAnimation Animated Header --SoundBvr Class DirectAnimation Animated Header --SoundBvr Class* Microsoft DirectAnimation SDK
*Contents  *Index  *Topic Contents
*Previous Topic: PropertyDispatcher Class
*Next Topic: Statics Class

SoundBvr Class


public class SoundBvr extends Behavior {

    // Methods
    public SoundBvr gain(NumberBvr gainAmt);
    public SoundBvr loop();
    public SoundBvr pan(NumberBvr panAmt);
    public SoundBvr phase(NumberBvr phaseAmt);
    public SoundBvr rate(NumberBvr rateAmt);

    public static SoundBvr newUninitBvr();
}

Creates an object that represents a sound behavior. Sound behaviors have gain, rate, phase, and pan attributes. Imported sounds (.WAV and .MIDI files) also have a length, returned by the import method.

Gain (volume) defines how loudly 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. It is useful for positioning sounds.

Gain, rate, phase, and pan are number behaviors 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.

For more information about behaviors, see the Behavior class.

SoundBvr Methods

bullet1.gifgain

bullet1.gifloop

bullet1.gifpan

bullet1.gifphase

bullet1.gifrate

bullet1.gifnewUninitBvr


gain

SoundBvr Class

Creates a new sound behavior by multiplying the gain (volume) by the given amount.

public SoundBvr gain(
  NumberBvr gainAmt
  );

Parameters
gainAmt
The NumberBvr object specifying 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 parameter can also be of type double.
Return Values

Returns the SoundBvr object.

Remarks

This attribute composes multiplicatively.


loop

SoundBvr Class

Creates a sound behavior that repeats itself continuously.

public SoundBvr loop( );

Return Values

Returns the SoundBvr object.

Remarks

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 the components of the reactive sound behavior. In the following example, snd1 and snd2 are each looped:


SoundBvr snd3 = SoundBvr(until)(snd1, leftButtonDown, snd2);
SoundBvr snd4 = snd3.loop();

This attribute overrides previous values.


pan

SoundBvr Class

Creates a sound behavior 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.

public SoundBvr pan(
  NumberBvr panAmt
  );

Parameters
panAmt
The NumberBvr object specifying 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 parameter can also be of type double.
Return Values

Returns the SoundBvr object.

Remarks

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

Remarks

This attribute composes additively.


phase

SoundBvr Class

Creates a sound behavior 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.

public SoundBvr phase(
  NumberBvr phaseAmt
  );

Parameters
phaseAmt
The NumberBvr object specifying the amount in seconds (or fractions of seconds) to shift the sound. This parameter can also be of type double.
Return Values

Returns the SoundBvr 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.


rate

SoundBvr Class

Creates a sound behavior by multiplying the playback rate by the given amount.

public SoundBvr rate(
  NumberBvr rateAmt
  );

Parameters
rateAmt
The NumberBvr object specifying the factor by which to multiply the rate. Values greater than one increase the rate and values between zero and 1 decrease it. This parameter can also be of type double.
Return Values

Returns the SoundBvr object.

Remarks

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


newUninitBvr

SoundBvr Class

This method allows you to refer to an SoundBvr behavior before that behavior has been defined. With this method you can create the behavior and use it in the definition of other behaviors, but not actually define its contents until some later point. (This is accomplished with the init method, which is available on all behaviors.) The system generates a run-time error if you initialize a non-uninitialized behavior, initialize an uninitialized behavior that has already been initialized, or run an initialized behavior that has not yet been initialized.

public static SoundBvr newUninitBvr( );

Return Values

Returns the SoundBvr object.

Relevant Methods from the Statics Class

The following methods are defined in the Statics class and are most relevant to objects of type SoundBvr.

public static SoundBvr importSound(URL url, NumberBvr[] soundLength);

public static SoundBvr importSound(URL url, NumberBvr[] soundLength, SoundBvr sndStandIn, DXMEvent[] ev, NumberBvr[] progress, NumberBvr[] size);

public static SoundBvr mix(SoundBvr sound1, SoundBvr sound2);

public static SoundBvr mixArray(SoundBvr[] sounds);

Relevant Fields from the Statics Class

The following fields are defined in the Statics class and are most relevant to objects of type SoundBvr.

public final static SoundBvr silence;

public final static SoundBvr sinSynth;

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

*Top of Page