Adding Sounds II

Revision as of 01:46, 4 February 2008 by Nadnerb (Talk | contribs) (Controlling your Sound with Regions)

Fading your Sound

Plasma supports FadeIn and FadeOut properties on sound objects. These can make a sound fade gradually. The properties are set in AlcScript on the Sound Emitter object.

        fadein:
            length: 
            start: <starting volume>
            end: <ending volume>
            type: <fade type>
            stop: <stop when finished fading>

The fadeout params are identical, but defined under fadeout rather than fadein.

Length

Length controls how long it takes for the sound to fade in or out. This is a decimal value in number of seconds.

Start

Starting volume defines the percentage of the volume (as a decimal) to use when fading. For fading in, this value should be 0.0. For fading out, this value should be 1.0.

End

The final volume of the sound at the end of the effect, expressed as a decimal percentage. For fading in, this value should be 1.0. For fading out, this value should be 0.0.

Type

Plasma supports three types of fading, these are mathematical equations used internally to produce the fading effect. The three options are

linear        #Default fade type
logarithmic   #Fade using logarithms, best for fading in
exponential   #Fade using exponents, best for fading out

The fade type is defined as a string of text in AlcScript, using the type names above.

Stop

A boolean value determining whether to stop playing the sound when the effect finishes. This should be set for fadeout effects.

Making your Sound 3D

3D sounds are setup the same way as other sounds, but include two new params in AlcScript and an additional flag.

        flags: 3d|<other flags>
        minfdist: <minimum distance>
        maxfdist: <maximum distance>

Minfdist

This value is the distance before the sound starts to fade out. Keep in mind that this value is in Blender units, and should be quite large.

Maxfdist

This value is the distance at which the sound can no longer be heard. Keep in mind that this value is in Blender units, and should be quite large.

Controlling your Sound with Regions

You can use a sound region to start and stop a sound emitter. Entering and exiting the region will toggle the sound emitter. To add one, use the scripts window menu Scripts > Add > PyPRP > Add a (Generic) Logic Region to add a region. Then you can either set the text properties:

regiontype: soundregion
soundemitter: <Name of sound emitter object>

or use the following AlcScript:

<Name of sound region>:
    region:
        type: soundregion
        soundemitter: <Name of sound emitter object>

Note that when the sound region starts a sound emitter, it sets the volume to 1. This value will be an option in later versions. Also note that entering and exiting a sound region merely toggles the sound emitter, and the sound emitter is started at the first crossing of a region boundary. So if you start inside the region, exiting the region will start the sound emitter, and entering will stop it, whereas if you start outside the region, entering will start it, and exiting will stop it. Again, more flexibility will be added to the sound region quickscript in later versions.