Over the past few months I've been slowly working on decoding the AMB files used by Civ 3. These files have been mysteries since the game was released, a few people have looked into them but no one has gotten very far, at least not that I know of. We want to enable C7 (the open source Civ 3 recreation) to read these files so the time has come to get them figured out once and for all. So far I have the core of the job done. I've posted my work to a GitHub repo here: https://github.com/maxpetul/Civ3AMBAnalysis.
The Python script in that repo can completely parse all AMBs in Civ 3. For example, here's the contents of TrebuchetRun.amb:
You can generate this yourself by following the instructions at the top of the Python script. AMB files are pretty complicated but that's only because they're way over-engineered, they can be boiled down to something very simple. Basically the way AMBs work is that they contain a bunch of component sounds with randomized effects applied. Using the example above, those "NoteOn" events in the Midi tracks indicate when the component sounds are to be triggered (the first number on those lines indicates the time of the event in seconds, computed by the script). Each component sound corresponds to a "prgm" chunk that specifies some randomized effects and a variable name. Finally the variable name is associated with a WAV file name by a "kmap" chunk.
There are still some things I haven't figured out. Specifically, I believe the 2nd and 3rd numbers in the prgm chunks specify bounds for a random pitch/tempo but I don't know what the units are, f.e. from above the pitch/tempo in the first chunk is randomized between +/- 200, but "200" of what? Also I don't know what the fourth and fifth numbers in the prgm chunks are, I suspect at least one of them specifies a randomized volume. I have managed to play an AMB file "manually" by loading the component WAV files into Audacity and arranging them at the set times. I checked that the result sounds similar to the in-game effect, so like I said, the core of the job is done.
Once the AMBs are completely decoded, it would be easy to write a tool to modify them or create new ones. That's not super valuable since you can just stitch together sound files manually, as modders have been doing for 20 years now. The only reason to use AMBs is for the randomized effects and to save a bit of disk space. In any case, if that's something people are interested in, just ask and (maybe) I'll make it happen.
The Python script in that repo can completely parse all AMBs in Civ 3. For example, here's the contents of TrebuchetRun.amb:
Code:
prgm 3 200 -200 127 75 'Foot 1' 'TrebRunFoot1'
prgm 3 200 -200 127 75 'Foot 2' 'TrebRunFoot2'
prgm 0 0 0 0 0 'Wheels' 'TrebRunWheels'
prgm 3 200 -200 127 75 'Vox' 'TrebRunVox'
prgm 0 0 0 0 0 'Wheels End' 'TrebRunWheelsEnd'
kmap 2 0 0 'TrebRunFoot1' 1 12 ["b'\\x7f\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00' 'TrebuchetRunFoot1.wav'"]
kmap 2 0 0 'TrebRunFoot2' 1 12 ["b'\\x7f\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00' 'TrebuchetRunFoot2.wav'"]
kmap 2 0 0 'TrebRunWheels' 1 12 ["b'\\x7f\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00' 'TrebuchetRunWheels.wav'"]
kmap 2 0 0 'TrebRunVox' 1 12 ["b'\\x7f\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00' 'TrebuchetRunVox.wav'"]
kmap 2 0 0 'TrebRunWheelsEnd' 1 12 ["b'\\x7f\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00' 'TrebuchetRunWheelsEnd.wav'"]
glbl 12 b'$\x00\x00\x00\x00\x00\x00\x00\xcd\xcd\xcd\xcd' b''
Midi:
ticks per quarter note: 480
Track:
0.000 TrackName 'Seq-1'
0.000 SMPTEOffset 96 0 0 0 0
0.000 TimeSignature 4 2 24 8
0.000 SetTempo 705882
0.000 EndOfTrack
Track:
0.000 TrackName 'Foot 1'
0.000 ControlChange 0 32 0
0.000 ProgramChange 0 1
0.228 NoteOn 0 60 64
0.625 NoteOff 0 60 64
0.625 EndOfTrack
Track:
0.000 TrackName 'Foot 2'
0.000 ControlChange 1 32 0
0.000 ProgramChange 1 2
0.541 NoteOn 1 62 64
0.625 NoteOff 1 62 64
0.625 EndOfTrack
Track:
0.000 TrackName 'Wheels'
0.000 ControlChange 2 32 0
0.000 ProgramChange 2 3
0.000 NoteOn 2 64 64
0.625 NoteOff 2 64 64
0.625 EndOfTrack
Track:
0.000 TrackName 'Vox'
0.000 ControlChange 3 32 0
0.000 ProgramChange 3 4
0.134 NoteOn 3 65 64
0.625 NoteOff 3 65 64
0.625 EndOfTrack
Track:
0.000 TrackName 'Wheels End'
0.000 ControlChange 4 32 0
0.000 ProgramChange 4 5
0.596 NoteOn 4 67 64
0.625 NoteOff 4 67 64
0.625 EndOfTrack
There are still some things I haven't figured out. Specifically, I believe the 2nd and 3rd numbers in the prgm chunks specify bounds for a random pitch/tempo but I don't know what the units are, f.e. from above the pitch/tempo in the first chunk is randomized between +/- 200, but "200" of what? Also I don't know what the fourth and fifth numbers in the prgm chunks are, I suspect at least one of them specifies a randomized volume. I have managed to play an AMB file "manually" by loading the component WAV files into Audacity and arranging them at the set times. I checked that the result sounds similar to the in-game effect, so like I said, the core of the job is done.
Once the AMBs are completely decoded, it would be easy to write a tool to modify them or create new ones. That's not super valuable since you can just stitch together sound files manually, as modders have been doing for 20 years now. The only reason to use AMBs is for the randomized effects and to save a bit of disk space. In any case, if that's something people are interested in, just ask and (maybe) I'll make it happen.