How to add sounds to your mission


Version 1.3


Last Update : February 18th. Written by Bloodmixer.

Version 1.1 - Added a little manual on how to install WaveSurfer
Version 1.2 - Added info on the "name" description (see step 7)
Version 1.3 - Added more info on what Khz to use for voice, radio and music samples.
Version 1.3 - Revised some info on DbPowerAmp
Version 1.3 - Added additional classes "CfgSfx" and "CfgEnvSound" explanation


How to add sounds to your mission

Index
step 0    : A short explanation
step 1    :
The right format
step 2    :
The right programs for converting to OGG
step 2.5 :
Installing/Using wavesurfer
step 3    :
The right editing tools
step 3.5 :
Creating radio chatter
step 4    :
Back to OFP, the setup
step 5    :
The Files
step 6    :
Creating directories
step 7    :
Description.ext
step 8    :
Stringtable.CSV
step 9    :
Radio Chat and Music
step 9.5 :
Additional classes, CfgSFX and CfgEnvSounds
step 10  :
The mission editor 
step 11  :
The LIP file (sound/mouth synchronised speech)
step 12  :
The End

step 0 : A short explanation on sound and music (if you are new to sound-editing)

Windows default sound format is a .wav file. But OFP does not use .wav files, it uses Vorbis OGG. OGG is very similar to MP3, in that it is able to compress sound and still leave the quality intact. To use an image analogy, you can compare a wav-file to a BMP picture (uncompressed picture) and an MP3/OGG file to a JPG picture (highly compressed picture)
What you might want to know is that Vorbis OGG has a better dynamic range than MP3 and is open-source (unlike MP3!) You can use almost any source for recording sound, be it a microphone, your keyboard, etc. etc. Check your sound card manual to learn how to plug in things.
If you need professional sounds, check out your local record-shop, usually they a have a collection of soundfx CD's. If you need more voices and you can't get friends to do it, there are some websites that offer natural speech synthesis. And some come pretty close to a human voice ! I list three of them :

Rhetorical Rvoice:
http://www.rhetorical.com/cgi-bin/demo1.cgi
-The best I found sofar. VERY natural voices. Also has more than one voice, including UK and US voices (and even a scottish one!)

AT&T :
http://www.naturalvoices.com/demos/index.html
-Nice one, but not as much choice (male/female) Voices sound pretty natural.

Bell Labs :
http://www.bell-labs.com/project/tts/voices.html
-Sounds from this site sound a bit robotty, but a bit better than your standard soundblaster textspeech.

step 1 : The right format

Music : Up to 44100 Khz, 16-bit, Stereo. Any length supported.
Speech :
22050-44100 Khz, 16-bit, Mono. Any length supported ?
Radio :
11025-44100 Khz, 16-bit, Mono. Final sound files must not exceed a certain length. I suggest using 11025 Khz since you will notice little difference in quality with 44100 Khz anyway.

Bitrate: Any bitrate seems to work, as long as it is a CONSTANT bitrate.
BIS used 128Kbps on all its sounds. They used 22050 Khz for speech and radio.

Now all you need is the right programs to save an OGG.
 

step 2 : The right programs for converting to OGG

Here are some programs that save to OGG properly. I only use Wavesurfer, so this one is on top. The others I have seen recommended.

Wavesurfer (freeware)
http://www.speech.kth.se/wavesurfer/
Very basic but very good for converting. I had nothing but success in saving to OGG. Do not forget to download the OGG plug-in. and it's FREE !
>>> If you have trouble installing, go to
step 2.5 : Installing Wavesurfer 

DbPowerAmp (freeware)
http://www.dbpoweramp.com
I have tried it a few times and it seems to work, allthough it has no 11Khz conversion option. However, DbpowerAmp is a bit controversial ; Some swear by it and some can't get it to work, so use what works best for you, and at least give this program a spin.

Audio Conversion Wizard (Shareware $29,95)
http://www.litexmedia.com/audio_wizard/
Works good. 14 day-trial. (after trial re-install)

Cool Edit Pro ($399)
http://www.syntrillium.com
King of all sound editing programs. Also available is Cool Edit 2000 which is shareware.

I have heard both good and bad things about GoldWave. It seems to only save Stereo OGG, so that might be a problem if you use speech or radio sounds.

step 2.5 : Installing/Using Wavesurfer

After receiving a lot of e-mails, I thought I'd better include a guide to installing wavesurfer. It is very easy as long as you stick to it.

1. It is important you use
drive C, not D or E or X
2. It is important that you maintain this directory structure :

C:\.wavesurfer
C:\.wavesurfer\1.0\plugins

----

I've noticed something weird, that is that sometimes my sample got cut off, and it was not completely saved. Make sure wavesurfer completely saves your sound file before you quit the program. This should overcome that problem.

step 3 : The right editing tools

Here are some tools you can use to edit your sounds (add echo, remove noise, band-filtering and so on)

Cool Edit Pro ($399)
http://www.syntrillium.com
Very professional. Also available is Cool Edit 2000 which is shareware.

SoundProbe 2 (£99)
http://www.soundprobe.com
I got this program for free with PCPLUS magazine, and it is an excellent tool.

Goldwave (shareware $40)
http://www.goldwave.com
Very nice program, has been around for a long time.

If you need more options, check out freeware/shareware sites.

step 3.5 : Creating radio chatter

So if you got your editor , check if it is able to filter and distort your sound. This is useful for creating radio chatter. First I distort the sound with the distort filter, to make it sound distorted. After that I remove all the frequencies below 350 Khz and above 5000 Khz with a band filter, to make it seem like a radio/phone transmission.

step 4 : Back to OFP, the setup

So now you got your sounds waiting to be used. If you are unsure if you saved your sounds properly, download this
example mission with samples that work for sure.

step 5 : The files

All sound setup is done outside of the mission editor. OFP needs some configuration files before it "knows" it can use sound
inside the mission editor. Lets take a quick look at them and after that I will explain each one in detail.

First you should go  to your mission directory
(codemasters/operation flashpoint/users/yourusername/missions/yourmission)

What you need :

1. A directory "sound"
2. A directory "music"
3. A file called "description.ext"
4. A file called "stringtable.csv"

step 6 : Creating directories

If you haven't done so already, create a directory "sound" in your mission directory. Create a directory "music " if you have some music ready. Copy all sounds and music to the appropiate directories.

step 7 : description.ext

The description.ext is nothing more than a simple text file, created with a program such as notepad and then saved as description.ext. This file is used by OFP to configure a lot of different options. For instance, you can set Identities for certain characters, or define what weapons the player can choose. This is beside the focus of this tutorial, so check out the editing website if you want to learn more about that. For now we will concentrate on the sound bit.

It might seem difficult if you aren't a programmer, but if you stick to the examples, there shouldn't be any problem. Read the following, and then check out the description.ext in the
example mission.

Including a voice

First you need to declare a new CfgSounds class. It is very simple if you just stick to the format, and keep in mind every class opens with new brackets '{' and closes again '}'   You need to do this carefully, otherwise OFP has difficulty "reading" your work. So place close attention to your syntax. The tabs are there just to make things more readable.

class CfgSounds
     {
     sounds[] = { voicesample, voicesample2 };

     class voicesample
     {
          name = "voicesample";
          sound[] = {"voicesample.ogg", db-40, 1.0};
          titles[] =
          {
               0, $STRM_Voice
          };
     };
     class voicesample2
     {
          name = "voicesample2";
          sound[] = {"voicesample2.ogg", db-20, 1.0};
          titles[] =
          {
               0, $STRM_Voice2
          };
     };
};

With this, you just declared two new sounds for OFP. First, in sounds[] , you told what sounds were going to be declared. Then you created the new sound classes with that name, class "voicesample" and "voicesample2"

Then you will see a line called :

name = "voicesample";

This is used so you can find the name in the "voice" section, after you press the
effects button.

The following line declares what sample is going to be used, such as "voicesample.ogg" by this line :

sound[] = {"voicesample.ogg", db-40, 1.0};

the
db-40 refers to the volume of the sound.
the
1.0 refers to the pitch of the sound.

There is also a line
titles :

  titles[] =
          {
               0, $STRM_Voice
          };


This defines what the subtitle will say when it is used. So if you hear the sound of voicesample.ogg and you want to see on your screen : "war is boring, anyone else bored ?"  The important piece here is :

$STRM_Voice

It is called a
string and now it all comes together : you need a file called "stringtable.csv"

So at this stage you have done your work in your
description.ext and you can save it.

Step 8 : Stringtable.CSV

Stringtable.csv is just like description.ext , it is a text document and notepad should open it without problems. Since I am using samples from a real OFP mission, here is the stringtable.csv as BIS uses it :

LANGUAGE,English,French,Italian,Spanish,German,Comment

STRM_voice,War's boring. Anyone else bored?,"La guerre, c'est ennuyeux. Y'en a-t-il d'autres qui s'ennuient ?",Che noia la guerra. C'è nessun altro annoiato?,Vaya aburrimiento de guerra. ¿Alguien más está aburrido?,Krieg ist langweilig. Langweilt sich noch jemand?,Kozlowski

STRM_voice2,"Heads up, guys. Here comes Berghof.",Attention les gars ! Voilà Berghof.,"Attenzione, gente. Arriva, Berghof.",Atención. Aquí viene Berghof.,"Haltung, Jungs. Hier kommt Berghof.",Bormioli 

Here the STRM_voice comes back, but without the '$' sign in front of it. After that all the different languages are there (if you have a language specific version of OFP) Every language is seperated by a comma ( , )
If you only want english, look at the following example by LustyPooh, so you don't have to spend weeks in your foreign dictionaries :)

This is how LustyPooh did it :

LANGUAGE,English,Comment

STRM_message,Welcome\n\nCheck out all the scripts, Comment

The
\n symbol is to define a 'return' (end of line) and to start a new one. It works similar to a BR command in HTML.

Also note I used a
,comment after the line, I noticed that if I didn't, lines sometimes got scrambled.

This concludes all you need to know about the stringtable.csv file. As said, all can be reviewed in
the example mission, so check it out.

Step 9 : Radio Chat and Music 

I will now simply insert the proper format to include radio and a music class, it works the same as CfgSounds, so it shouldn't be a problem to see what is going on.

class CfgRadio
{
     sounds[] =
     { radiosample, radiosample2 };

     class radiosample
     {
          name = "radiosample2";
          sound[] = {"radiosample.ogg", db-40, 1.0};
          title = $STRM_radiosample;
     };

     class radiosample2
     {
          name = "radiosample2";
          sound[] = {"radiosample2.ogg", db-40, 1.0};
          title = $STRM_radiosample;
     };
};

 

class CfgMusic
{
     tracks[]={mymusic,mymusic2};

     class mymusic
     {
     name = "tracknumber1";
     sound[] = {\music\mymusic.ogg, db+10, 1.0};
     };
     class mymusic2
     {
     name = "tracknumber2";
     sound[] = {\music\mymusic2.ogg, db+10, 1.0};
     };
}; 

Step 9.5 : Additional classes, advanced sound.
There are a few more classes, the first I will cover here is the CfgSFX class. Keep in mind that I assume you already know the deal with voices, radio and music classes, because the following is a bit harder.

The CfgSFX is the sound class that is referred to in the trigger effect box under "trigger" The beauty of this class is that it repeats sound, and can repeat a number of sounds. Very usefull if you want to have, for instance, ambient bird or animal sounds. The sound can be random. What it does
not do is mix sounds. You have to do this with a soundeditor , and then use the CfgEnvSounds class.

class CfgSFX
{
   sounds[] = { examplesound };

   class examplesound
      {
      name = "example sound";
      sounds[]={sound1,sound2};
      sound1[]={"soundname.ogg", db-0,1,0.3,5,1,10};
      sound2[]={"soundname2.ogg", db-0,1,0.3,5,1,10};
      empty[]= {, , , , 1 , 5, 20};
      };
};

This line :
sounds[]={sound1,sound2}; defines what sounds are in your loop. In this case sound1 and sound2, which are defined in the lines ahead. Lets take a look at the hard part, this line :

sound1[]={"soundname.ogg", db-0,1,0.3,5,1,10};  
What are these numbers ?

sound1[]={"soundname.ogg", db-0,1,0.3,5,1,10};       
db-0 defines the sound volume

sound1[]={"soundname.ogg", db-0,1,0.3,5,1,10};       
this 1 defines the pitch of the sample.

sound1[]={"soundname.ogg", db-0,1,0.3,5,1,10};       
0.3 is the
chance this sound will play. If chance is 1 than this will be the only sound that plays

sound1[]={"soundname.ogg", db-0,1,0.3,5,1,10};
I really don't know what this setting does.

sound1[]={"soundname.ogg", db-0,1,0.3,5,1,10};
This number defines the minimum time it waits before moving on (randomly)

sound1[]={"soundname.ogg", db-0,1,0.3,5,1,10};
This number defines the maximum time it waits before moving on. (randomly)

And than you got this line :
empty[]= {, , , , 1 , 5, 20};
I have absolutely no idea what this does as of yet. I did notice that taking it away crashes OFP, so tuck it in. Perhaps it is some sort of order of playing ? Or to define the end of this sound class ? I don't know.... 

----
Ok, the next class is CfgEnvSounds.

class CfgEnvSounds
{
sounds[]={mortarambient,rain};
class mortarambient
{
name="mortarambient";
sound[]={"mortarambient.ogg",db-0,0,1};
soundNight[]={"mgunambient2.ogg",db-0,0,1};
};
class rain
{
name="rain";
sound[]={"rainyday.ogg",db-0,0,1};
soundNight[]={"rainynight.ogg",db-0,0,1};
};
};

This class is
very usefull, because you can define the sounds you hear around you. The nice thing is you can create a daytime sound, and a nighttime sound. This class makes sounds that are all around you, like wind or rain sounds (without any fixed positioning) You Can use stereo ogg files, but I only succeeded in playing 22050 Khz stereo sounds succesfully (higher rates cut the sample off) The OGG is looped automaticly.
I don't think I have to explain further how to get it working, because the class pretty much speaks for itself when you are used to the CfgSounds and CfgRadio class.

Step 10 : The mission editor 
In this part we will take a look at the sound commands and how to use them . I will add some comments, but for detailed descriptions download the "command reference", a document with all commands and a detailed description of how they work...get it at the editing site.

EnableRadio TorF - turns the ability to receive radio messages on or off 
FadeMusic - the ability to change the volume of music
FadeSound - the ability to change the volume of sound
PlayMusic - plays a music file
PlaySound - plays a sound
GroupRadio - only members of your group receive what you transmit
VehicleRadio - all units in your vehicle receive what you transmit
SideRadio - all units on your side receive what you transmit
GlobalRadio - all units in the game receive what you transmit
Say - allows a unit to say something
SetMimic - This is usefull for cinematics, it sets the expression on the face of a unit.
SetIdentity - Gives a unit a name like "James Kowzolowski" that shows up in group messages. It is NOT necessary to define CfgIndentities in the description.ext, but it is possible.

Most commands will work straight from the editor. Init fields usually don't work to let a unit speak, but waypoints work great. Also note you can let object use the say command.

I have had one case were a script refused to play my voicesample, but this could be due to the complexity of the script. If you use simple scripts everything works fine.

An example of a simple script :

unitname say "voicesample1"

~4.3

commandunit say "voicesample2"

and so on.

I have taken a good look at how BIS did it and they use either simple scripts similar to the example above or waypoints to talk. There is a waypoint mode called "talk" but I haven't been able to see a link with any of the commands or any advantage to using the talk waypoint. Anyone knows what it does ?

Step 11 : The LIP file (sound/mouth synchronised speech)

Bis released a utility called "wav2lip" which you can use to make a soldier move his lips while the sound plays with the "say" command. This utility is also available at the editing site.

To use it, simply use a wave on the utility, by dragging and dropping your wave file onto wav2lip and the result will be a .lip file, which you can save in your SOUND directory. Now any unit who uses the "say" command will move his lips to the voice-sample. So you need no extra programming, just that file. Make sure that :

-The LIP file is in your SOUND directory
-The LIP file has the exact same name as your sample, only the extension should be different.

Step 12 : The End.

This tutorial should have covered all you need to know about adding sound. If you are still unsure about things, download the example mission.

get the
Example Mission here.

Good luck and have fun !
 

 

Copyright Notice :  Operation Flashpoint is a trademark of Codemasters / Bohemia Interactive.
Disclaimer : This document is NOT created nor supported by Codemasters / Bohemia Interactive.