You want to be able to modify the panning of both the right and left channels of a stereo sound.
Use the setTransform( ) method.
When working with monaural sounds, the basic getPan( ) and setPan( ) methods suffice. However, when dealing with stereo sounds, you can use the getTransform( ) and setTransform( ) methods to control the panning of each channel.
The setTransform( ) method takes a single parameter: a sound transform object. You can create a sound transform object by creating a generic instance of the Object class with the following properties:
Percentage of the left channel playing through the left speaker
Percentage of the left channel playing through the right speaker
Percentage of the right channel playing through the left speaker
Percentage of the right channel playing through the right speaker
Here is an example in which the right channel is played through the left speaker and the left channel is played through the right speaker:
soundTransform = {ll: 0, lr: 100, rl: 100, rr: 0}; mySound_sound.setTransform(soundTransform);
You can also use getTransform( ) in conjunction with setTransform( ) to perform changes relative to the current settings:
// Get the current transform object. soundTransform = mySound_sound.getTransform( ); // Add 50 to the current ll property. soundTransform.ll += 50; // Set the new transform object. mySound_sound.setTransform(soundTransform);
Recipe 13.12