Design 1, Design 3 (Computer and Video Games) | |
Unit 7 - 19th, 21st November 2002 |
Sound Essentials
Preparing Sounds using SoundForge
First of all, open the sound you recorded or synthesized with SoundForge. (I use version 5, but SoundForge 4.5 does as well and Shareware programs like CoolEdit are fine also.
You can see in the properties panel that the Sound has 44.100 Hz, 16-bit. At present Unreal only works with monophonic sound, the sounds will however be panned stereophonically when output. Don't use .aif files, don't use stereo, don't use 48.000 Hz samplerate! (You may use 22.050 Hz and 44.100 Hz and even mix them in the same Unreal level to save memory.)
Save your file as a .wav format file:
You see, that I changed
the filename from "Imaginary Landscape No. 1(1939)" to "Imaginary_Landscape",
when saving it.
Unreal is a bit intolerant when it comes to filenames. I always avoid blanks
and special characters like "ä,ö,ü" because I encountered
problems with them.Very long filenames are dangerous too. It is probably also
wise to have the folder names of the path the files will be contained in according
to these precautious rule.
Then start up UnrealEd and pop-up the Sounds browser.
In the File menu you select the Import option and will arrive at a dialogue box like the one to the right, which has "Import Sound" in the title bar. There are 4 fields: File: This is the path and file name to the .wav file you just selected. Package: This is a name you have to give to the package you just are about to create. (You can also add your .wav file to an existing package like "Announcer" e.g. but I would strictly advise you not to do so, because with many users working on the same system someone else might mess up your packages then. If you create your own package - preferably with your name in it - you can back it up and feed it into the Unreal "Sounds" folder whenever you need it. In this respect "My_Music" is not a good name either, because someone else might have the same idea. "Mathias_Fuchs_Music" would be better.) Group: As you please. Name: You can, but need not use the filename. |
![]() |
Special care should be taken if soundfiles are supposed to be played as loops in your Unreal level. Click here to see how to do it.
Placing Sounds in UnrealEd
This is an example of how it looks like in the 3D window, if you have placed a trigger and a special event in your level.
Select the Soundfile you want to connect with the special event class ("Finlandia" in our case) and open the "Special Event Properties". You find an entry there which says "SpecialEvent" and another one saying "Sound". Just select the field and click on "Use...". The name and Superclass from the sound browser item is now copied into the special event "Sound" field and held ready for action.
Many problems referring to sound related crashes have either to do with an uncompatible soundcard, non standard audio drivers, or .wav files which contain information, which is not compatible with Unreal. You might try my package out, to see whether it runs on your computer. It contains two 44.100 16bit mono files, with a length fo 1 minute and 2 minutes respectively. Download the package My_Music.uax here. (Attention! Large file of 14 MegaBytes filesize)
Advanced Techniques
If you are not satisfied with the standard method of placing sounds, as has been described above, you can try more adventorous things. 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, e.g. UnloadedSounds.uax. 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, i.e. 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 separate
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, 1.1);
Take care! In many manuals circulating on the Web there is the erronous hint,
that you should set the pitch parameter to something like "64.0".
That's definitely bullshit! The pitch is considered to be specified as a floating
point number which gives the factor the original frequency is multiplied with.
"2" would be an octave up, "0.5" an octave down, "1.0"
would be the original frequency. Integer values as 64 for the original pitch
and 63 for a semitone below only apply when specifying pitch in the property
dialogue boxes, but not in the scripts. In the case of a scripted pawn the script
commands to allow the pawn to make noises when moving, there could be a line
#exec AUDIO IMPORT FILE="Sounds\barking.wav" NAME="noisy_animal" GROUP="animalsounds"
followed by the statements
Auto
State Movement
{
Begin:
LoopAnim('Movement',0.8);
PlaySound(Sound 'animals.noisy_animal');
}
Take care! Unreal Script is case sensitive in regard to filenames!
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().