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. The behavior 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.
Sound behaviors also have gain, rate, phase, and pan attributes. Gain (volume) defines how loud the sound is played. The rate attribute defines how much faster or slower the sound is played relative to its nominal rate. The phase attribute 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. The pan attribute 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 are number behaviors and can, therefore, change over time. This is useful for modifying the sound based on time (See substituteTime) or other computed values such as distance. Sounds can also be embedded in a geometry to achieve spatialized effects. Sounds are omnidirectional.
For more information about behaviors, see the Behavior class.
Creates a new sound behavior by multiplying the gain (volume) by the given amount.
public SoundBvr gain(
NumberBvr gainAmt
);
Returns the SoundBvr object.
This attribute composes multiplicatively.
Creates a sound behavior from imported sounds that repeats itself continuously.
public SoundBvr loop( );
Returns the SoundBvr object.
This attribute overrides previous values.
Creates a sound behavior by repositioning a monophonic sound between the left and right channels. This is similar to adjusting the balance on a stereo.
public SoundBvr pan(
NumberBvr panAmt
);
Returns the SoundBvr object.
With stereophonic sounds, panning away from a channel attenuates it.
This attribute composes additively.
Creates a sound behavior by shifting the sound 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
);
Returns the SoundBvr object.
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 start of the sound, while a negative phase shift controls how far into the sound is the beginning. Phase-shifting only takes effect when the sound begins playing. This attribute composes additively.
Creates a sound behavior by multiplying the playback rate by the given amount.
public SoundBvr rate(
NumberBvr rateAmt
);
Returns the SoundBvr object.
A rate of 0 pauses the sound. This attribute composes additively.
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( );
Returns the SoundBvr object.
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 mix(SoundBvr sound1, SoundBvr sound2);
public static SoundBvr mixArray(SoundBvr[] sounds);
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;
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.