(FAQ) Sound editing and you
Posted: Sat May 23, 2009 2:33 am
Custom sounds? No problem. This tutorial will explain the layout you should use for any custom sound and explain why you are doing what you are doing instead of laying out the steps for any specific type of sound editing (although a little bit here or there may be touched on).
This is not a comprehensive tutorial! To refer to specifics of how each type of sound is set up, you should reference the stock sounds. Once you know what each thing means (which is the goal of this tutorial), understanding should flow easily.
Sounds are all set up in a hierarchy. There are two main branches to this hierarchy: streams and effects.
Streams are, for the most part, going to be the "longer" pieces of music/audio that you'd use for ambient environment sounds, voices, or ambient music.
Effects are the shorter sounds used for ordnance and vehicles.
There are four "types" of files loaded in sound .req files:
"str" files (which are all .stm [and maybe .st4; that might be used more for ambient envfx or might be obsolete] files), "bnk" files (which are all .sfx and .asfx files), "config" files (which is most everything else, .snd, .mus) and then "lvl" (other .req files; "children").
Both of these (streams and effects)- if you've correctly set up a sound folder (or looked at stock sound folders for example) - will have corresponding folders of their own in your "data_ABC\Sound\worlds\ABC" folder, as seen here:
In each of those folders you will need to put your .wav files, formatted to:
352 kbps, 16 bit, mono, 22 kHz PCM
Weapon sounds (as seen in this tutorial) need to go in "effects."
Ambient sounds (as seen in this tutorial or this tutorial) need to go in "streams."
The streams hierarchy works like this:
.wav files -> .stm file -> config file(s)
What does this mean? Here is an example "ABC.req" (main .req file)
Next, inside the "ABCgcw.req" file, you'll see something like this:
"ABCgcw_music_config.snd" references "ABC_stream.snd" here:
The same happens with effects. The hierarchy for effects is this:
.wav files -> .asfx (what you will use for custom effects) files -> config files
Our .wav sound will be the explosion sound "combust.wav" for this example. Here is your parent "ABC.req;" note that all this does for us right now is load the child .req:
The last part of setting up sounds (and separate from the hierarchy above) is going to be loading them in the .lua. Effects can always be loaded simply by the basic dc:sound call, e.g.
Streams (since the .stm file is referenced in the main .req and not in the child .req like everything else) need to have an additional reference (they also need the above reference) in the .lua. This is usually further down in the .lua (and is also mentioned in greater detail in other tutorials on the site). It looks something like this:
All of this can be done in the SWBF2 tools, but by default this is not made available to you.
There are three files you need to fix to make your tools work.
Download the following .zip file and place the files inside where directed below:
MediaFire
First: "munge.bat" to "data_ABC\_BUILD\Sound".
Second: "soundmungedir.bat" to "data_ABC".
Third: "soundmunge.bat" to "data_ABC" - edit this first, though:
You will need to edit "soundmunge.bat":
Open it and replace all instances of "ABC" with your three-letter map name.
Once you've done those three, you're good to go.
*This builds on previous tutorials.
This is not a comprehensive tutorial! To refer to specifics of how each type of sound is set up, you should reference the stock sounds. Once you know what each thing means (which is the goal of this tutorial), understanding should flow easily.
Sounds are all set up in a hierarchy. There are two main branches to this hierarchy: streams and effects.
Streams are, for the most part, going to be the "longer" pieces of music/audio that you'd use for ambient environment sounds, voices, or ambient music.
Effects are the shorter sounds used for ordnance and vehicles.
There are four "types" of files loaded in sound .req files:
"str" files (which are all .stm [and maybe .st4; that might be used more for ambient envfx or might be obsolete] files), "bnk" files (which are all .sfx and .asfx files), "config" files (which is most everything else, .snd, .mus) and then "lvl" (other .req files; "children").
Both of these (streams and effects)- if you've correctly set up a sound folder (or looked at stock sound folders for example) - will have corresponding folders of their own in your "data_ABC\Sound\worlds\ABC" folder, as seen here:
Hidden/Spoiler:
352 kbps, 16 bit, mono, 22 kHz PCM
Weapon sounds (as seen in this tutorial) need to go in "effects."
Ambient sounds (as seen in this tutorial or this tutorial) need to go in "streams."
The streams hierarchy works like this:
.wav files -> .stm file -> config file(s)
What does this mean? Here is an example "ABC.req" (main .req file)
In this file, "ABC_stream" (under "str") is the .stm file and "ABCgcw" is the "child" .req (era .req). "ABC_stream.stm" references our .wav file (named "ABC_amb_1.wav") like this:ucft
{
REQN
{
"str"
"align=2048"
"ABC_stream"
}
REQN
{
"lvl"
"ABCgcw"
}
}
You can see that it "renames" it to "ABC_stream_name" which is referenced later.streams\ABC_amb_1.wav ABC_stream_name -resample xbox 22050 pc 22050
Next, inside the "ABCgcw.req" file, you'll see something like this:
In this file, nothing is loaded under "bnk" (no .sfx or .asfx for streams). "ABCgcw_music_config" is a .snd file and "ABCgcw_music" is an .mus file - for ambient music, these must be loaded in this order in the .req (as the .mus file references the .snd file).ucft
{
REQN
{
"bnk"
"align=2048"
}
REQN
{
"config"
"ABCgcw_music_config"
"ABCgcw_music"
}
}
"ABCgcw_music_config.snd" references "ABC_stream.snd" here:
Then, "ABCgcw_music.mus" references "ABCgcw_music_config.snd" here:SoundStream()
{
Name("ABC_stream_name");
Pitch(1.0);
PitchDev(0.0);
Gain(1.0);
GainDev(0.0);
ReverbGain(0.0);
Bus("ingamemusic");
Looping(0);
Pan(0.0);
Mode3D(0);
Stream("ABC_stream");
SegmentList()
{
Segment("ABC_stream_name", 1.0);
}
}
Your name here is going to be the one referenced in the .lua in "SetAmbientMusic". So you can see how each reference trickles down.Music()
{
Name("ABC_stream_name");
Priority(1.0);
FadeInTime(0.0);
FadeOutTime(1.5);
MinPlaybackTime(20.0);
MaxPlaybackTime(300.0);
MinInactiveTime(2.0);
SoundStream("ABC_stream_name");
}
The same happens with effects. The hierarchy for effects is this:
.wav files -> .asfx (what you will use for custom effects) files -> config files
Our .wav sound will be the explosion sound "combust.wav" for this example. Here is your parent "ABC.req;" note that all this does for us right now is load the child .req:
In the child "ABCgcw.req", we have this:ucft
{
REQN
{
"str"
"align=2048"
}
REQN
{
"lvl"
"ABCgcw"
}
}
Note that now we load the next in the hierarchy - "ABC_effects.asfx" - next. It references our "combust.wav" here:ucft
{
REQN
{
"bnk"
"align=2048"
"ABC_effects"
}
REQN
{
"config"
"ABC_wconfig"
}
}
Next loaded is the config file "ABC_wconfig.snd". It references the "ABC_effects.asfx" file here:effects\combust.wav -resample xbox 22050 pc 22050
The name given up top (also "combust") is the name to be referenced in an .odf.SoundProperties()
{
Name("combust");
Group("explosion");
Inherit("explosion_template");
MinDistance(5.0)
MaxDistance(60)
MuteDIstance(60)
RollOff(1.0)
SampleList()
{
Sample("combust", 1.0);
}
}
The last part of setting up sounds (and separate from the hierarchy above) is going to be loading them in the .lua. Effects can always be loaded simply by the basic dc:sound call, e.g.
This is mentioned in greater detail in every other tutorial on the site, make sure you look at them too.ReadDataFile("dc:sound\\ABC.lvl;ABCgcw")
Streams (since the .stm file is referenced in the main .req and not in the child .req like everything else) need to have an additional reference (they also need the above reference) in the .lua. This is usually further down in the .lua (and is also mentioned in greater detail in other tutorials on the site). It looks something like this:
One final word!OpenAudioStream("dc:sound\\ABC.lvl", "ABC_stream")
All of this can be done in the SWBF2 tools, but by default this is not made available to you.
There are three files you need to fix to make your tools work.
Download the following .zip file and place the files inside where directed below:
MediaFire
First: "munge.bat" to "data_ABC\_BUILD\Sound".
Second: "soundmungedir.bat" to "data_ABC".
Third: "soundmunge.bat" to "data_ABC" - edit this first, though:
You will need to edit "soundmunge.bat":
Open it and replace all instances of "ABC" with your three-letter map name.
Once you've done those three, you're good to go.
*This builds on previous tutorials.