Editing sound banks
A sound field in an .fcb holds an event id. The game plays it by opening
soundbinary\<id:08x>.spk and running the event of that id, which plays a resource, which ends in
audio. jackall-cli spk turns a bank into an XML document you can edit and build back. With it you
can add variations, make a sound random, change gains and falloff, or author a bank from scratch. The
byte layout behind all of it is on the .spk page.
Banks named after a new event id, their own rolloff curves and multi-events were all built this way
for mods/sound-overhaul and heard. A random container built by the tool has not
been heard yet.
The round trip
jackall-cli spk decode soundbinary\00448bd2.spk -o passby # passby\00448bd2.xml + audio files
jackall-cli spk encode passby\00448bd2.xml -o 00448bd2.spk # checks, then builds
jackall-cli spk verify soundbinary\00448bd2.spk # decode + encode, byte for byte
Every retail bank rebuilds byte for byte (7,513 sound banks and 860 bark banks), so an unedited
decode changes nothing. The built bank goes in your layer at mods/soundbinary/<id>.spk.
In the App
Select an .spk on the Files tab. The panel shows the bank as a tree of what plays what, and edits
the selected record in place:
- Fields: a Play's sound, rolloff and whether it is positioned; a sample's gain and loop; a container's silence and flags. Records a variation adds go where their id falls.
- Random containers: each choice's chance as a percentage, with the others rescaling to keep their proportions. Add variation… imports any audio file as a new choice, transcoded to the format of the samples already there. On a Play over a single sample, it first wraps that sample in a random container.
- Switches and multi-events: add, remove or repoint cases.
- Curves: rolloff and multilayer curves are drawn, and their points are editable.
- Audio: Play a pick draws a fresh random choice on each click. Import… replaces a sample's audio, and the sample's lengths follow the new clip.
- Checks: errors and warnings from the list below show under the panel. An edit is staged in the workspace at once, unless it leaves an error.
New records get ids from 0x10000000 + bank id × 32, a block per bank that no retail id reaches.
What is in a bank
One element per record, in file order:
| Element | Record | What you edit |
|---|---|---|
<Play> | event type 1 | sound (the resource it plays), rolloff (the distance curve), positioned (whether it plays at a position; see below) |
<MultiEvent> | event type 12 | <Child event> per event it starts, all at once |
<SwitchEvent> | event type 11 | group, default, <Case value event> per switch value |
<StopNGo> | event type 4 | stop, play |
<SetReverb> | event type 8 | effect |
<Event type> | any other event type | target |
<Sample> | resource kind 1 | audio, gainDb, loop |
<Random> | resource kind 4 | <Choice resource weight> per variation, silence |
<Switch> | resource kind 3 | group, default, <Case value resource> per switch value |
<Multilayer> | resource kind 7 | <Layer resource>, each with <Curve target parameter> of <Point x y> |
<Resource kind> | kinds 2, 6, 8 | not identified; kept as they are |
<Audio> | the audio stream | file: .ogg stored as is, .wav (16-bit PCM) encoded to IMA-ADPCM, .ima a raw stream that needs rate |
<Rolloff> | a distance curve | <Point m db>, distances increasing |
Every other sub-header word appears as wN="0x…" where it differs from the usual value. Those words
are not identified; copy them from a retail record that behaves like yours. key holds 16
unidentified bytes. Leave it out on a new record and the tool derives one from the id. preamble
lists the bank's own id and the banks that pull it in.
You never write a length, a count or an offset. On encode the tool derives:
- each sample's byte and frame lengths, rate, channels and codec from its audio file;
- every child count;
- every tail offset.
That includes the playback length the game cuts the audio at.
A wN on one of those words overrides the derivation. Decode writes them only where a retail bank
disagrees with it.
Making a sound random
A <Random> picks one <Choice> each time it plays:
<Random id="0x00f80001" silence="1">
<Choice resource="0x00f80002" />
<Choice resource="0x00f80004" weight="2" />
</Random>
- Weights are relative. Here the two choices and
silenceweigh 1, 2 and 1: a quarter of the time the first plays, half the time the second, and a quarter of the time nothing plays. Weights written as probabilities that sum to 1 are read as they stand. Choices without a weight weigh 1. - The choice that played last is skipped on the next play, so two variations already alternate.
A
<Choice repeat="true">may play twice in a row. - Silence never comes twice in a row, unless the container has
repeatSilence="true". sequence="true"plays the choices in order instead, from a random start per emitter, and ignores the weights and silence.
These rules are traced in Dunia.dll; see how a random container picks.
The quickest route is spk new, which scaffolds an event over one clip, or a random container when
given several:
jackall-cli spk new 0x00f80000 shot_a.wav shot_b.wav shot_c.wav --rolloff 0x00442c37 ^
--like soundbinary\00455359.spk
jackall-cli spk encode 00f80000\00f80000.xml
Ids run on from the event's: the container, then a sample and its audio per clip, and the records are
written in that order, as retail sound banks list theirs. Every id must be new across all the banks
that load, not only the bank's own (see Ids of your own). --like copies the unidentified words of a
retail event and sample, which is how a weapon shot should start. The audio is copied in beside the
XML, so the folder is the source you keep.
positioned follows the rolloff, as it does on every retail event. A sound the game plays through a
first-person sound type needs --unpositioned even with a rolloff: a positioned event fails to play
there. The player's shot echo is one (heard); the same event, unpositioned, also serves
NPC shots.
To randomise a retail sound instead, decode its bank. Add a <Sample> and an <Audio> per new
variation. Then put a <Random> between the event and the samples, or add <Choice>s to the one
that is already there. Retail impacts are a material <Switch> over random containers, which is
where a ricochet variant goes (004565a3.spk).
Ids of your own
Every record of every loaded bank registers under its own id in one table the whole game shares. Two
banks holding different records under one id clash: an echo bank whose sample took an id an
explosion bank already held crashed the game when the echo played (seen in game, GOG v1.03).
Retail ids run up to 0x004F2211, so a mod's own sounds go above them, as 0xMMMMCCCC:
MMMMis the mod andCCCCits records, 65,536 per mod. Bit 31 (a group bank) and bit 30 (a localized bank) go on top of the same id.- A mod's ids count up from
CCCC = 0000with no gaps. A new event takes the next free id, andspk newgives its records the ids after it. - The prefixes stay below
0x0100. The mods in this repository hold these, and the next new mod takes0x00FF, then0x00F9and down:
| Prefix | Mod |
|---|---|
0x00FA | Flashlight |
0x00FB | Aiming Overhaul |
0x00FC | Sound Overhaul |
0x00FD | Vehicle Overhaul, which keeps the ids it shipped with, gaps and all: a save keeps the ids written into a car's sound slots |
0x00FE | Inventory Overhaul |
Records the App adds to a bank take 0x10000000 + bank id × 32 instead (see In the App).
They belong to that bank's file, and an install holds one copy of each file, so they never clash.
What spk encode checks
- Errors: a reference to a record of the wrong kind (an event where a resource belongs), an
.imawithout arate, audio that is neither Ogg nor IMA-ADPCM, and a rolloff whose distances go backwards. - Warnings:
- a container with no children;
- an event bank with no record of the id it is named after;
- a
<Play>with a rolloff over a stereo sample. Stereo plays unpositioned, so the curve is ignored (heard).
- Notes:
- ids the bank points at but does not hold. Another loaded bank has to supply them;
- records out of ascending id order in a bank named after its event. Retail sound banks keep that order; the game plays banks out of it too.
How the game finds a bank
- The file is named after the event the
.fcbfield names. Every retail bank that holds events contains a record with its own id (seen in data). A bank of samples or curves is named by a variant id instead. - A new bank named after a new event id loads without a
deploadentry when an.fcbfield names that id. The G3KA4's shots inmods/sound-overhaulare such banks (heard). - Keep everything a new event reaches in its own bank. An id reached only from inside another
bank must already be loaded, and the lookup has no load-on-miss path (see
depload). - Rolloff curves can live in your own bank beside the event that uses them (heard).
The retail curves live in
common/soundbinary/2fffffff.spk.