Simulated Surround Sound
"Surround Sound" places the user in the center of a group of speakers. The positions of these speakers, playing different sounds, allows a person to percieve the direction that a sound originates from. While "Surround Sound" is a nice hardware configuration to have, many users do not have this configuration of speakers.
However, most users have two speakers. Most users also have two ears. Hence, it stands to reason that by correctly calculating the sound that should go to each ear, you should be able to get the same effect as having an actual "Surround Sound" system with only two speakers. This, of course, works best with headphones where interference between the speakers is minimal.
Software is already readily available that can do this, but it's fairly easy to implement a simulated "Surround Sound" using the Unreal Engine without any third party software. The Unreal Engine already modifies stereo sound output based on the 3D position that the sound originates from. As a result, the only thing you need to do is create the appropriate sounds and position the virtual "speakers."
Note that you do not need to do this simply to have positional 3D audio for a single source sound - this is a description of how to simulate surround sound WITHIN the world - for instance, a room in the virtual world that has a surround sound speaker system in it.
Sound Layout
The most common type of "Surround Sound" is "5.1." This setup has 6 different sound channels. This means that you will need 6 different Sounds and 6 Actors to play the sounds. Some surround sound systems have more or less speakers. As all of the speakers we are using are virtual, we can have as many or as few speakers as desired, within the constraints of the user's sound card.
In a 5.1 system, you have 6 channels:
- Forward Left
- Forward Right
- Rear Left
- Rear Right
- Center (Forward Center)
- Subwoofer
The placement of these channels in your virtual room, of course should be fairly obvious. The subwoofer is usually placed very near the Center channel.
Making the Sound Files
As mentioned, you will need a different sound file for each speaker to get the correct effect. Each channel should be a mono sound wave, not stereo. (The stereo effect is being created using multiple mono wavs playing simultaneously, and the Unreal Engine is doing the math to combined them appropriately) You will need to be somewhat familliar with a sound editing program, but generating the different waves is fairly easy.
The left and right channels should be, simply enough, the left and right channels of the sound. If you were converting an existing stereo sound, you could pull out the left and right channels independantly. If you are creating a sound from scratch, then what should be on the left and right channels is up to you.
The left and right channels should be similar for the front and rear sets of speakers, but you may want to tweak the phase and/or amplitude of one relative to the other. Sound waves interfere with each other, creating a "sweet spot" in a Surround Sound environment with "dead spots" sprinkled around, depending on where the speakers are placed. You can tweak the "sweet spot" a little bit by tweaking the phase on the sounds. Note, however, that sound wave propogation and interference is likely to vary between simple, on-board sound (probrably not even calculated) to higher end sound cards.
The center channel should be some mix of the left and right channels. You could do a straight average of the two, or you could try taking an intersection of the two. Which would work better will probrably depend on the source sound.
The sound file for the subwoofer is fairly straightforward. In this instance you want to take your center channel and use a filter to remove high frequency sounds. Settings for the filters on subwoofers vary, but are often between 20 and 200 Hz. The subwoofer will not contribute much to the sound, as in a real surround sound system it produces the "vibration" that you can sometimes feel around a powerful stereo system. However, it is still of value to include it as some are fortunate enough to have fancy force feedback devices that will recreate this vibration based on sound playing through the speakers.
Discussion
EricBlade: Interesting thought, though unless you're using the engine to simulate a real-life environment that includes a surround sound system, I don't see a whole ton of use for it. I wonder how it would actually sound when all placed properly in an environment that includes a nice full surround capable high end audio card. One thing that I did think of, was that some clever programming could use Force Feedback within the engine to do something, although I'm thinking that even ut2004 doesn't have the ability to actually analyze the sound data. However, if you can do native programming for your particular game, you could probably add some functions to deal with that, and do the force feedback on your own. That would be interesting