13.13.1 ProblemYou want to be able to modify the panning of both the right and left channels of a stereo sound. 13.13.2 SolutionUse the setTransform( ) method. 13.13.3 DiscussionWhen 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:
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); 13.13.4 See AlsoRecipe 13.12 |