S > Sound.setTransform

Sound.setTransform

Syntax

mySound.setTransform(soundTransformObject); 

Arguments

soundTransformObject An object created with the constructor for the generic Object object.

Description

Method; sets the sound transform information for a Sound object. This method is cumulative with the setVolume and setPan methods, and calling this method deletes and updates any previous setPan or setVolume settings. This call is for expert users who want to add interesting effects to sounds.

Sounds use a considerable amount of disk space and memory. Because stereo sounds use twice as much data as mono sounds, it's generally best to use 22-Khz 6-bit mono sounds. You can use the setTransform method to play mono sounds as stereo, play stereo sounds as mono, and to add interesting effects to sounds.

The soundTransformObject argument is an object that you create using the constructor method of the generic Object object with parameters specifying how the sound is distributed to the left and right channels (speakers).

The parameters for the soundTransformObject are as follows:

11 A percentage value specifying how much of the left input to play in the left speaker (-100 to 100).

1r A percentage value specifying how much of the right input to play in the left speaker (-100 to 100).

rr A percentage value specifying how much of the right input to play in the right speaker (-100 to 100).

rl A percentage value specifying how much of the left input to play in the right speaker (-100 to 100).

The net result of the parameters is represented by the following formula:

leftOutput = left input * ll + right input * lr

rightOutput = right lnput * rr + left input * rl

The values for left input or right input are determined by the type (stereo or mono) of sound in your movie.

Stereo sounds divide the sound input evenly between the left and right speakers and have the following transform settings by default:

ll = 100
lr = 0
rr = 100
rl = 0

Mono sounds play all sound input in the left speaker and have the following transform settings by default:

ll = 100
lr = 100
rr = 0
rl = 0

Player

Flash 5 or later.

Example

The following example creates a sound transform object that plays both the left and right channels in the left channel:

mySoundTransformObject = new Object
mySoundTransformObject.ll = 100
mySoundTransformObject.lr = 100 
mySoundTransformObject.rr = 0
mySoundTransformObject.rl = 0

In order to apply the sound transform object to a Sound object, you need to pass the object to the Sound object using setTransform as follows:

mySound.setTransform(mySoundTransformObject);

The following are examples of settings that can be set using setTransform, but cannot be set using setVolume or setPan, even if combined.

This code plays both the left and right channels through the left channel:

mySound.setTransform(soundTransformObjectLeft);

In the above code, the soundTransformObjectLeft has the following parameters:

11 = 100
1r = 100
rr = 0
rl = 0

This code plays a stereo sound as mono:

setTransform(soundTransformObjectMono);

In the above code, the soundTransformObjectMono has the following parameters:

ll = 50
lr = 50
rr = 50
rl = 50

This code plays the left channel at half capacity and adds the rest of the left channel to the right channel:

setTransform(soundTransformObjectHalf);

In the above code, the soundTransformObjectHalf has the following parameters:

11 = 50
lr = 0
rr = 100
rl = 50

See also

Constructor for the Object object