Modifying AMB files

tom2050

Deity
Joined
Oct 12, 2005
Messages
5,516
I have found old threads with some discussions about AMB files, but it appears no one has discovered a way to create new AMB unit sound files. Does anyone know of a thread / or where it is located that may have this info?

Granted, it is just as easy making a new .wav file for a specific sound, but the size of wav files can very quickly amount to a large amount of space, and so in an attempt to try to keep this down to a minimum, I am seeing if there is any info on this.

The AMB files themselves are not too complex, if there is no info elsewhere, I think I may have (somewhat) figured out how to modify them (through use of a hex/ansi/unicode program, etc), but will have to do some additional research first to see if I can get them to work properly in game.

Tom
 
So far, from what I can gather, some of the AMB's usually consist of something of this sort:
this is an example of AlliedCarrierRun.amb (not all is shown)

prgm:
Engine AlliedCarrierRunEngine prgm8
('Engine' must be the variable) (Name of the file without extension) (prgm8 unknown at this point)

Water AlliedCarrierRunwater prgm4
End AlliedCarrierRunEnd kmapV AlliedCarrierRunEngine
(kmapV - a Karnaugh map? Not sure how this is used yet/or what it is exactly, but it may be some type of timing control for both files)

AlliedCarrierRunEngine.wav kmapT AlliedCarrierRunwater AlliedCarrierRunWater.wav kmapP AlliedCarrierRunEnd glbl
(it seems that this line if what 'puts everything together'. Notice the Kmap functions in front of the names that are not .wav files. I'll have to check into this function to find it's purpose later)

MThd MTrk - and a bunch of garbled code after this
(Midi Track Header) (Track Chunks)

The MThd contains this information though: says it is synchronous multiple tracks, says there are 4 tracks (and there are 4 MTrk below the header, obviously :)), and tells the number of delta-time ticks per quarter.

A midi event (the Track Chunks) is preceded by a delta-time. The delta time is the number of ticks after which the midi event is to be executed. The number of ticks per quarter note was defined in the Midi Track Header above.

Each MTrk contains the info (4 bytes) that gives the track length in bytes. (in hex, the first track has length in bytes of 00 00 00 25 (references Seq-1 ??); second 00 00 00 1E (Engine); third 00 00 00 1D (Water); fourth 00 00 00 1B (End)). I'm not too familiar with determining track lengths in bytes though :) I'll have to check on this.

Also there are references made to the variables Engine, Water, and End here; which reference to the info shown above.

Granted, it all seems like a bunch of mumbo jumbo, but it may be possible to create something to auto-create the code for an AMB file. I'll need to understand all of this a bit further first.

Tom
 
This all sounds Greek to me, but I can see that you may be on to something. Good luck!
 
Thanks TG... but to my astonishment, all the AMB file is an... <drum roll>
(appended) MIDI file.
Nothing more and Nothing less.

The majority of the file contains very Basic MIDI information. To see what I'm talking about, this site has info on some basic MIDI specs; and most of what it talks about in there is included in the AMB file.

The only difference (and why I say an Appended MIDI file), is that in the first portions of the AMB, Firaxsis just defines what wav files to use. And nothing more.

The only real MIDI info used here, are the hex codes used for the timing of when the appropriate wav file should start playing (which is obviously what the AMB files do), but there is not much more to it than that.

I'll look around for some free MIDI programs that create hexidecimal code based on the MIDI values selected, then it should be extremely easy to just change the wav filenames in there (and there's probably a few other things that would need to be done).

Tom
 
in the first portions of the AMB, Firaxsis just defines what wav files to use. And nothing more.
IIRC, that's the conclusion come to in the old threads - but no one could figure out what to do with that.
 
Well, from analyzing all the various AMB files, I can see a common structure to most of them. There are a few that are somewhat different. I'll test some of them out, by making slight hex changes to the file, to try to determine what the differences are between them, and to see what happens if certain portions are added / removed. For these unknown sections, they are either a type of variable that the game itself accesses, or is likely some type of sound modifier/timer, or perhaps nothing at all (after all, looking at the unit INI files, there is alot in there that is unused, probably no different here :)).

Tom
 
It's possible to do. The structure of the AMB file is nothing overly complicated, but the more I look at it, it is probably easier for someone to just create a wave by splicing existing sounds together (using a utility such as WavePad Sound Editor), than creating a AMB file (even if there was a utility to use). I am not sure what Firaxsis' intention of the AMB file was, other than to save Hard Drive space. But the size they would have saved would not have been much, maybe several MB's. So the benefit of making something like this, would only help those whom are creating mods that are absolutely huge and wish to keep file size down to absolute minimum, and then it would only help if that modder is creating a vast amount of custom sounds.

So with all things given, I don't see a huge need for it the more I thought about it.

Tom
 
I am not sure what Firaxsis' intention of the AMB file was, other than to save Hard Drive space. But the size they would have saved would not have been much, maybe several MB's.

I still feel like some sort of utility, or even a tutorial, on how to customize AMB files would be worth it. I could easily see a possibility of mods with several custom sounds - I'm thinking unit sounds. Even if you just have the attack and the death sound, that very quickly adds up as you get more and more units created here on this forum and others.
 
I am not sure what Firaxsis' intention of the AMB file was, other than to save Hard Drive space. But the size they would have saved would not have been much, maybe several MB's
Even if you just have the attack and the death sound, that very quickly adds up as you get more and more units
At the time the game was designed MB was a more common measure of memory & drive space than GB. ;)
 
I initially started dwelling into it, because the size of the sound files was getting quite large in the mod I am working on (Even with using a common SOUNDS directory for all units INI's). I still may go ahead with it, because I wanted to have a large sound base with the mod, but having to make custom wav's for many units unnecessarily adds that much more size. I will likely mess around with it... the only real thing that needs to be done is to test the unknown hex values in the AMB to try to determine what their purpose is (if any). I have already determined the sequences that control the timing, and the values that correlate the wav file with the timing control, so I would just need to come up with the programs and an easy way to create a new AMB file. (I wouldn't write anything, as their are freeware programs out there that could do the fair share of the work). It's just a matter of testing it all out now :)

Tom
 
Success so far!
My initial tests at modifying the AMB were successful. I was able to change the sound files that were played, and was able to modify the timing to get them to play at the correct times. Granted, I did so by modifying the hexidecimal values, but after I mess around with it a bit further, I'll see if I can't throw something together to make it easy and quick to create a new one. It was a bit easier to do than I thought it would be initially, but hopefully I don't run into any snags.

Tom
 
Knowing what lines to edit & what values to change is helpful, even if it's territory for solely the brave / foolhardy / obsessed. Look at embryodead's tutorial on adding types of terrain for an example of effective trail-blazing.

Keep up the good work.
 
Hi tom2050! From what I remember of my studies in Computer-assisted Music and Recording, a MIDI file has codes for many things, not only timing, length, etc. You also have values for pitch, pan, volume, etc. I could find the bits coding for this in my books. Needs some searching though... tell me if you're interested.
The need for AMB files was to give some variations to the units sounds (through the use of pitch-shift), random mixing of different wave sounds, and maybe synchro with the animations, though I'm not sure of it. Pitch-shifting is evident, because if you listen carefully to the Warrior's attack sounds, you'll hear a difference between attack A and B, though they use the same waves. If you replace the AMB with a wave file, then it would be exactly the same at every attack, wich is quite boring to the ear.
Anyway this is very interesting and I wish you good luck and patience with it.
 
Good info themanuneed.. on post #4 above, I listed a site which gave a basic crash course on MIDI files.. although I didn't look too deep into it at the time, I see it also gives a wide range of ways to alter sounds other than timing. This is why my initial thought was to find a freeware MIDI program that could have the user input sound tracks (instead of the common piano key, violin etc); then adjust the sound settings to however the user preferred, and spit out the MID file... but it may not be in the correct format of the AMB. Although from the looks of it, I doubt Firaxsis added anything special in there, so it just may be.

EDIT: Although most sound editors allow to save a file in a different format (OGG, AMR, AAC, etc), these formats are very different from Firaxsis' AMB, and cannot be used.

Tom
 
tom2050... Glad you are seriously looking into the .amb files. IF you do find a method to make new ones and especially if it only requires a few free programs, that would be an Excellent Breakthrough.

In the past, I have seen people try to use existing .amb files and simply add new sounds to them. The problem doing this is that the Game reads this file for the unit it is intended for so any change will also change the sounds for the Original Unit.

I had generally thought that the Game Creators used a single program to create the .amb files. Regardless, if you discover a way to make them using several programs, it will be outstanding and Very Helpful for Unit Sounds.
"Blaze On" and Best of Luck with this endeavor.
 
In the past, I have seen people try to use existing .amb files and simply add new sounds to them. The problem doing this is that the Game reads this file for the unit it is intended for so any change will also change the sounds for the Original Unit.

I'm glad you mention this... because I believe that the 5th byte in the beginning of the AMB file (which was different for every AMB file included in the game) is the key that ties that AMB file to a specific unit. The AMB file starts out like:

prgm(unit key here)

I'll have to see if simply removing the key will allow this not to happen.

Tom
 
tom2050... If there is a way to set a different unit to an existing .amb file, That Too will be a big help as one could simply use an existing .amb file and Modify it. It would then be a New .amb file.

The problem will be to know what the Unit Key should be concerning a change.

Edit... prgm/   È 8ÿÿÿ is the Rifleman .amb key.
How to have the game Read a new.amb file that has a correct Key to a new Unit is what is needed.
 
tom2050... If there is a way to set a different unit to an existing .amb file, That Too will be a big help as one could simply use an existing .amb file and Modify it. It would then be a New .amb file.

The problem will be to know what the Unit Key should be concerning a change.

Edit... prgm/ È 8ÿÿÿ is the Rifleman .amb key.
How to have the game Read a new.amb file that has a correct Key to a new Unit is what is needed.

In this case, the '/' is the unit key (I THINK, haven't tested it yet). Every single key is different for all AMB files in that spot. So although I'm not 100% sure yet, I think by changing that to another unit's key should be fine... or hopefully, deleting that key would be better. You would have to do so in a hex editor, such as FlexHex to make sure you get the correct value.

FlexHex sample Hex/ANSI values shown below:
Hex.jpg
This shows the correct hex value to edit... I am going to test by entering 00 here to get rid of the key... and I can also test entering another unit's hex value here to see if it still grabs that units sounds. This will verify if this byte is indeed a unit key used by the game.

Let me test it to make sure first, before going through all the trouble. Because I have not been able to match up that number (by doing a hex to decimal conversion) with anything in game with a particular unit (such as icon #, etc).

Tom
 
Top Bottom