I l @ ve RuBoard |
Although setVolume and setBalance seem to provide a lot of control over a sound, you can go even further. By creating sound transform objects, you can precisely control stereo sounds ”which sound channel comes out of which speaker. In a typical sound played in a typical way, the left channel's sound comes out of the left speaker, and the right channel's sound comes out of the right speaker. However, you can change this by creating a sound transform object and applying it to the sound object with a setTransform command. A sound transform object is actually just a plain variable object. But it needs to have four specific properties. Here is an example: mySoundTransform = {ll: 75, rr: 25, rl: 25, lr: 75}; The four properties have two characters in each of their names . The first character represents the speaker. The second character represents the channel. So ll is the property that determines how much of the left channel comes out of the left speaker. rl is how much of the left channel comes out of the right speaker.
Using sound transforms, you can switch which channel comes out of which speaker. All you need to do is put 100 percent of the left channel out of the right speaker and 100 percent of the right channel out of the left speaker. Here is a button that does this: on (release) { var mySound = new Sound(); mySound.attachSound(soundName); var mySoundTransform = new Object(); mySoundTransform = {ll: 0, rr: 0, lr: 100, rl: 100}; mySound.setTransform(mySoundTransform); mySound.start(); } The example movie 22steropan.fla includes several demonstration buttons . It also includes a sound where the left and right channels play completely separate sounds. The left channel features a robin singing away, whereas the right features a cardinal.
You can use one of the top three buttons to play the sound normally, but with the pan set to either the left, middle, or right. The left and right buttons allow you to hear only one channel at a time. Then there are two buttons below that use sound transforms to play only one channel at a time, but in the opposite speakers . |
I l @ ve RuBoard |