SoundBvr Class

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.

For relevant methods and fields from the Statics class, see the following topics.

SoundBvr Methods

gain Creates a new sound behavior by multiplying the gain (volume) by the given amount.
loop Creates a sound behavior that repeats itself continuously.
pan Creates a sound behavior by repositioning a monophonic sound between the left and right channels.
phase Creates a sound behavior by shifting the sound in time by the given amount.
rate Creates a sound behavior by multiplying the playback rate by the given amount.
newUninitBvr Enables you to refer to an SoundBvr behavior before that behavior has been defined.

gain

SoundBvr Class

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

Syntax

public SoundBvr gain( NumberBvr gainAmt );

Parameters

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

Returns the SoundBvr object.

Remarks

This attribute composes multiplicatively.

loop

SoundBvr Class

Creates a sound behavior that repeats itself continuously.

Syntax

public SoundBvr loop( );

Return Value

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.

Syntax

public SoundBvr pan( NumberBvr panAmt );

Parameters

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

Returns the SoundBvr object.

Remarks

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

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.

Syntax

public SoundBvr phase( NumberBvr phaseAmt );

Parameters

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

Return Value

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. You can 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.

Syntax

public SoundBvr rate( NumberBvr rateAmt );

Parameters

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

Returns the SoundBvr object.

Remarks

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

newUninitBvr

SoundBvr Class

Enables 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.

Syntax

public static SoundBvr newUninitBvr( );

Return Value

Returns the SoundBvr object.


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