Sounds

From Oldunreal-Wiki
Revision as of 19:40, 31 August 2013 by Hellkeeper (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Introduction Sounds are an integral part to any game, from the sounds of gunfire to the tinkling of water in a nearby stream, and eventually you will probably need to play some sort of sound in your modification. Unreal uses its own format for storing sounds (.uax), and in order to get sounds into that format you must use UnrealEd or UCC to import them from the .wav file format. Once you have imported the sounds into a package there are many different ways to get Unreal to actually play the sound, mainly by using the PlaySound() function. Note that this document doesn't cover music, just sound effects. Importing Sounds Using UnrealEd First of all, get the sound you want recorded into .wav format, then start up UnrealEd and select SoundFX in the browser. Click on the Import button and select the file you want imported. Then you can specify the Name of the sound (which can be indepent of the actual filename), the Group the sound should be organized in, and finally the Package which determines the .uax to store the file in. It is generally a good idea to keep your packages seperate from Unreal/UT's and named in such a way as to be able to quickly associate that the package belongs to your mod, ie UnloadedSounds.uax, or RAUTSounds. After you've imported the sound you'll want to click on the Save button to save the package to disk, otherwise you'll have to repeat the above process. Importing Sounds Using UCC Take the sound you want in .wav format and put it in a directory under your package's name, ie MyPackage\Sounds is a good directory. Then in the class where you want the sound to be imported add a line similar to this:


  #exec AUDIO IMPORT FILE="Sounds\MyWeaponFire.wav" NAME="WeaponFire" GROUP="Weapon"

The above line would import the wav file "Sounds\MyWeaponFire.wav", give it the name "WeaponFire", and finally put it in the "Weapon" Group. When you recompile the class UCC will automatically attempt to import the sound and then place it in the current package. This method is useful for when you have only 1 or 2 sounds and don't really need to create a seperate package solely for storing your mods sounds, on the other hand, having a seperate package can save users some time from having to re-download all that data if you just do an update to the code and not the sounds. Playing the Sound with PlaySound() The easiest way to get Unreal to actually play your sound in game is to use the PlaySound() function, which has the following declaration:


  native(264) final function PlaySound
  (
    sound        Sound,
    optional ESoundSlot Slot,
    optional float    Volume,
    optional bool    bNoOverride,
    optional float    Radius,
    optional float    Pitch
  );

Sound would point to the sound you've imported, including the Package name. Optionally you can also specify which Slot the sound is played in (see below for more information on Slots), the Volume, bNoOverride, the Radius at which the sound can be heard, and finally also the Pitch of the sound. Everything except for the Sound is optionally so if you just want to play a sound and nothing else you could try:


  PlaySound(Sound'MyPackage.MySound');

but you could also go with something like:


  PlaySound(Sound'MyPackage.MySound', SLOT_Misc, 4.0, false, 500.0, 64.0);

Sound Slots Each actor in Unreal has several sound slots in which it can play sounds, so that an actor can have "8 simultaneous (overlapping) sound effects". SLOT_None, SLOT_Misc, SLOT_Pain, SLOT_Interact, SLOT_Ambient, SLOT_Talk, SLOT_Interface are the available ones, with SLOT_None being the most common as it allows any sound put there to be played simultaneously with any other songs. Note that Unreal has an internal limit of the number of sounds that can be playing at any one time (determined in Unreal/UT.ini). Playing the Sound with AmbientSound All actors also have a variable called AmbientSound that Unreal will loop, which is useful mainly for level editing to create that nifty waterfall sound in NyLeve, or the chirping of birds, etc etc. You can change the variables SoundVolume, SoundRadius, and SoundPitch to change the way the AmbientSound is played as with PlaySound(). If you're looking for more information on sounds, and more specifically music in Unreal/UT check out the Unreal Audio Document on the Tech Page, Unreal Audio Subsystem.