DirectX Media for Animation Java Reference Previous
Previous
Classes
Classes
Index
Index
Next
Next

SoundBvr Class

Methods , Fields

public class SoundBvr extends Behavior {
    // Fields
    public static SoundBvr silence;
    public static SoundBvr sinSynth;

    // 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 importSound(String pathname, double[] soundLength) 
        throws IllegalImport;
    public static SoundBvr mix(SoundBvr sound1, SoundBvr sound2);
    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. For more information about using these methods, refer to the DirectX Media for Animation Media Types documentation.

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.


Methods


gain

public SoundBvr gain(NumberBvr gainAmt);

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

Return Value:

Returns the SoundBvr object.

ParameterDescription
gainAmt The NumberBvr object specifying the factor to multiply the volume by. Values greater than one increase the volume and values between zero and 1 decrease the sound's volume.

Remarks:

This attribute composes multiplicatively.


loop

public SoundBvr loop();

Creates a sound behavior from imported sounds that repeats itself continuously.

Return Value:

Returns the SoundBvr object.

Remarks:

This attribute overrides previous values.


pan

public SoundBvr pan(NumberBvr panAmt);

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.

Return Value:

Returns the SoundBvr object.

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

Remarks:

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

Remarks:

This attribute composes additively.


phase

public SoundBvr phase(NumberBvr phaseAmt);

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.

Return Value:

Returns the SoundBvr object.

ParameterDescription
phaseAmt The NumberBvr object specifying the amount in seconds (or fractions of seconds) to shift the sound.

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


rate

public SoundBvr rate(NumberBvr rateAmt);

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

Return Value:

Returns the SoundBvr object.

ParameterDescription
rateAmt The NumberBvr object specifying the factor to multiply the rate by. Values greater than one increase the rate and values between zero and 1 decrease it.

Remarks:

A rate of 0 pauses the sound. This attribute composes additively.


importSound

public static SoundBvr importSound(String pathname, double[] soundLength) 
    throws IllegalImport;

Creates a sound behavior by importing the given .WAV or MIDI file. The soundLength parameter receives the length of the sound.

Return Value:

Returns the SoundBvr object.

ParameterDescription
pathname A character string specifying a URL or name of a file.
soundLength An array of doubles that receives the length of the sound in seconds. An array is used because this is an output parameter, and the system writes into the first element of the array. In Java, this is the simplest way to pass information back to the caller if you are already using the return value, which, in this case, is the sound).

Throws:

IllegalImport The given file does not exist or is not in a valid format.


mix

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

Creates a sound behavior that is equivalent to sound1 + sound2.

Return Value:

Returns the SoundBvr object.

ParameterDescription
sound1 and sound2 The SoundBvr objects.


newUninitBvr

public static SoundBvr newUninitBvr();

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.

Return Value:

Returns the SoundBvr object.


Fields

silence
A sound behavior (SoundBvr object) that is always completely silent (no sound).
sinSynth
A sound behavior (SoundBvr object) that represents a constant tone. This sound is synthesized using a sine wave.


Top© 1997 Microsoft Corporation. All rights reserved. Legal Notices.