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.
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 that repeats itself continuously. 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();
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. 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
);
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 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
);
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 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.
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. Negative rates are not supported. 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.