Skip to content
View in the app

A better way to browse. Learn more.

ResHax

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Help us keep the site running.

.gin and .abk sound formats (Need for Speed mw 2005)(help)

Featured Replies

  • Replies 237
  • Views 25
  • Created
  • Last Reply

Top Posters In This Topic

  • Author
  • Localization

V12-POWER, posted Thu Jul 02, 2015 11:50 pm (6077)


Hi everyone, I got these 2 formats to unpack. .gin format uses a variation of the EA ADPCM codec.

Image

Image

(it's a .gin with a .wav extension and header)

Image

bf3 audio file

I can post all what I know if needed

.abk files

It has just audio compression (no codec), it has a bnk section inside the file (this is similar to hot pursuit 2 .bnk but still has variations because the HP2 extractor throws errors and no data) The file size and offsets are given at the start of the file, it can have many samples but I have yet to find individual sample offsets and sizes.

I can also post what I know if needed.

All I want to do is to crack the formats and then repack to get new engine sounds in game. I have no skills in coding or scripting. But I can do most of what my knowledge lets me do.

All the "progress" I have done is thanks to Frankelstner and thanks to luigi for linking me to this forum

Thanks in advance
  • Author
  • Localization

V12-POWER, posted Tue Jul 07, 2015 2:00 pm (6201)


Here I uploaded a few files with a txt file with all the information I could get from them - For someone willing to take a look

edit: For .abk files they seem to have a different header section but the BNK1 header is "only" a version newer than the one in this script

Code:
Most of sound effects and speech files (and sometimes ASF music files) are
stored in .BNK and .VIV resource files. The .BNK file may contain several
sounds. BNKs of older version have the following header:

struct OldBNKHeader
{
  char   szID[4];
  WORD   wVersion;
  WORD   wNumberOfSounds;
  DWORD dwFirstSoundStart;
  DWORD dwSoundsArray[wNumberOfSounds];
};

For the newer BNK files the header is:

struct NewBNKHeader
{
  char   szID[4];
  WORD   wVersion;
  WORD   wNumberOfSounds;
  DWORD dwFirstSoundStart;
  DWORD dwSoundSize; // = total filesize - dwFirstSoundStart
  DWORD dwUnknown;   // seems to contain small number <20 or -1
  DWORD dwSoundsArray[wNumberOfSounds];
};

szID -- string ID, always "BNKl".

wVersion -- for old version this is 0x0002, for new version -- 0x0004.

wNumberOfSounds -- number of sounds stored in .BNK file.

dwFirstSoundStart -- the starting position of the first sound audio data
relative the BNK file beginning. There's no real use of this...

dwSoundsArray -- the array of (wNumberOfSounds) DWORDs. Each of these is the
shift to the PT header describing the separate sound in .BNK relative to the
starting position of this DWORD. That is, if such DWORD (dwShift) starts at
the position (dwShiftPos) (relative to the start of .BNK), the correspondent
PT header starts at the position: dwPTHeaderPos=dwShiftPos dwShift.
Note that some DWORDs in this array are zeroes that means they correspond to
no sound. Remember that PT header starts with the "PT\0\0" signature.

So, (dwSoundsArray) points to a number of PT headers in .BNK, which follow the
BNK header. Each of these PT headers describe a separate sound in .BNK.
Refer to the .ASF file description for details on dealing with PT headers.
Note that some PT headers do not contain (dwChannels), (dwSampleRate),
(dwCompression) data. I use the default value if it's omitted in the header:
mono, 22050 Hz, unknown compression. In any case, PT header for .BNK sound
should contain values for (dwNumSamples) and (dwDataStart). (dwDataStart) is
the starting position of sound data relative to the start of .BNK file. Sound
data itself has no additional headers and in case of EA ADPCM compression
(dwCompression==0x07) should be decoded just like "SCDl" block data (following
ASFChunkHeader). As to the size of the sound data, just use (dwNumSamples) and
stop playback of the sound when it's exhausted.

As to .VIV files these seem to be multi-data resources. In particular, they
can contain .BNK/.ASF files. So, if you want to play sounds from a .BNK file
contained within .VIV, just search .VIV for "BNKl" string ID and that will
be just the .BNK file described above. Note that all (dwDataShifts) given in
PT headers in .BNK are always positions relative to the start of .BNK file,
that is, if .BNK is in .VIV, they will be relative to the start of "BNKl"
signature you found in .VIV. To play .ASF file from .VIV you may just search
for "SCHl" string ID and that'll mark the beginning of .ASF file, while
the end will be marked by "SCEl" block.


Then this version has small differences between the formats but even then, how to update this script?

EDIT2: It seems like "dwDataStart" is not following the 4 byte/field structure, because my hex editor (hexworkshop) can't display the values however when using the hex calculator it has the proper offset/value. I say this because when we have 00 00 00 01 - 14 15 FF 00, the value is actually starting from last byte of the first field, and the BNK1 section inside the ABK file is big endian, yet the rest of the file is little endian, I never found out this until today...guess it's part of the learning curve
  • Author
  • Localization

V12-POWER, posted Thu Jul 16, 2015 4:36 pm (6418)


So, sorry for impatience but has anybody looked at the samples above?
  • Author
  • Localization

Tropod, posted Sat Sep 05, 2015 2:55 am (7181)


V12-POWER wrote:
So, sorry for impatience but has anybody looked at the samples above?


I have & I'd like to say thank you :D. Though I'm at a bit of a loss, as I don't really grasp sound formats TBH, these posts of yours have been of some help.
I don't have NFS at all but seems SC4 (Sim City 4) AB files (vehicle UDI sounds) may be similar format & have yet to be even remotely deciphered: http://www.wiki.sc4devotion.com/index.php?title=AB

They have similar Header & have an embedded BNKl section. SC4s AB files contain multiple sound effects that can be triggered on demand but only have 1 BNKl section. I'd really like to further decipher these if possible, so if there's anything I can do to help let me know or PM me.
cheers
  • Author
  • Localization

id-daemon, posted Sat Sep 12, 2015 3:34 pm (7424)


There shouldn't be problems decoding it, but as far as I know, there's no tool to ENCODE to this codec back. ffmpeg only supports decoding of EA ADPCM variants
  • Author
  • Localization

Tropod, posted Thu Sep 17, 2015 7:10 am (7522)


So main problem you're having is creating/converting sound back into this format? So does that mean you can already play this format then?
Sorry as I said, don't really understand sound to be honest & I wouldn't mind being able to even play this format.
  • Author
  • Localization

id-daemon, posted Thu Sep 17, 2015 3:35 pm (7528)


I haven't tried playing them yet, but i think this will be easy. But encoding will require a lot more work.
  • Author
  • Localization

V12-POWER, posted Mon Sep 21, 2015 1:44 pm (7597)


The idea was to make a tool to mod the game sounds. The .gin files are encoded by some ADPCM codec and the .abk files are not under codec compression, the problem arises when you need someone willing to waste time on this with scripts n stuff
  • Author
  • Localization

id-daemon, posted Mon Sep 21, 2015 3:18 pm (7602)


ABK files provided here use the same ADPCM codec as GIN files. So the problem is not only in scripting (thats relatively easy), you need to actually WRITE a CODEC.
  • Author
  • Localization

id-daemon, posted Mon Sep 21, 2015 4:04 pm (7603)


So if this can really be interesting for many people, and the codec is the same for many NFS games, I can try this.
  • Author
  • Localization

id-daemon, posted Fri Sep 25, 2015 6:07 pm (7728)


I did some checks and I was able to decode your files with ffmpeg.

You can use SX.exe to encode to this format (raw eaxa blocks)
  • Author
  • Localization

id-daemon, posted Sat Sep 26, 2015 11:11 am (7733)


Ok, I was wrong. EAXA is only used in ABK files.

Here's a GIN decoder I wrote for you, it was some new variant of EA XAS.

gin_decode.rar

  • Author
  • Localization

id-daemon, posted Sun Sep 27, 2015 8:02 am (7748)


And this one for Simcity AB. Something's wrong with stereo files, I will deal with that later.

Update: stereo files fixed. Moved here viewtopic.php?f=6&t=1566
  • Author
  • Localization

Tropod, posted Sat Oct 03, 2015 4:21 am (7909)


Haven't had a look at the files you've attached just yet, but thanks for sharing these :).

EDIT: do you have any source code, & not just exe?
  • Author
  • Localization

id-daemon, posted Sat Oct 03, 2015 4:37 am (7910)


Tropod wrote:
EDIT: do you have any source code, & not just exe?


Sure I do, I wrote it.
  • Author
  • Localization

V12-POWER, posted Sat Oct 03, 2015 6:12 pm (7939)


didn't expect this to be honest. awesome stuff. if you want to try to make a encoder then go for it, the modding guys would be ecstatic and so would I, but I'll like to give a hand as always. btw, any help with ffmpeg and your .exes? don't know if I have to specify input/output etc
  • Author
  • Localization

id-daemon, posted Sat Oct 03, 2015 6:30 pm (7946)


Unfortunately I couldn't make ffmpeg decode the whole files properly, that's why I decided to make these tools. Each takes only 1 parameter for input and outputs all WAVs into the same dir. Or you can just drag the file onto the EXE as usual.

As for encoding, good news we don't have to write an encoder for ABK, because it contains standard EA XA ADPCM. I'm sure you can encode the files if they will have exactly the same sample count, but if you need to change that, this may not work. Audio may be encoded with SX.EXE and then put into the original files with HEX Editor. Or we can try automating this process.

Listen to the samples extracted and tell me how would you like to proceed.
  • Author
  • Localization

V12-POWER, posted Sat Oct 03, 2015 6:35 pm (7949)


so encoding back works ONLY with the same number of sample, no more and no less? I realize that adding more samples could result in killing the sound playoff, but why does this happen? (as for not being able to re-do the file with more or less samples)
  • Author
  • Localization

id-daemon, posted Sat Oct 03, 2015 7:07 pm (7953)


I didn't say it will not work. We can try that. But the result is unpredictable, because both ABK & GIN files have some additional infos, tables, and I'm not sure about their meaning.
  • Author
  • Localization

V12-POWER, posted Sat Oct 03, 2015 7:09 pm (7954)


id-daemon2 wrote:
I didn't say it will not work. We can try that. But the result is unpredictable, because both ABK & GIN files have some additional infos, tables, and I'm not sure about their meaning.


what kind of info? is it the big section before the samples or the bnk1 section? if you can elaborate what is important for encoding and requires to look at files, I will def. dig in this
  • Author
  • Localization

id-daemon, posted Sat Oct 03, 2015 7:45 pm (7961)


bnkl section is well documented. I'm talking about the big section before it and the table in the end. GIN files also have similar table. And what is the meaning of BF3/BF4 alpha you mentioned in first post? What sounds would you like to change?
  • Author
  • Localization

V12-POWER, posted Sat Oct 03, 2015 8:16 pm (7964)


id-daemon2 wrote:
bnkl section is well documented. I'm talking about the big section before it and the table in the end. GIN files also have similar table. And what is the meaning of BF3/BF4 alpha you mentioned in first post? What sounds would you like to change?


For gin files, the table is a bunch of arrays, which is independent of file size and it gives the sample the hierarchy, I think I explained this in the text files that I uploaded, I guess there's no problem changing these sounds, as the big int-array is "not really that important" there are also 3 more fields that would need adjusting, which affect the sound event.

For abk files, it is just some sample play off/fade/mixer I guess, though im sure that you can still put as many sounds as you want without exceeding max file size (512kb) the game will load the file properly.

the pic in the OP was not from me, it is Frankelstner pic, he shown me the similarities of the audio codecs (BF4 to NFSMW) that served to tell which codec was being used. The main idea of this "project" is to make sounds moddable, nothing less, nothing more, seeing we have texture and geometry export/import tools, sound tools were "missing"
  • Author
  • Localization

Tropod, posted Sun Oct 04, 2015 2:44 am (8000)


Have just tried this with one of the SC4 AB files, & it spat out 35 WAV files :o :shock:. Some of which appear to be in a different language. Some of them too sound like they're playing at the wrong tempo (ie rate). If need be I can upload some of these for troubleshooting if that helps or help with (c/c ) code if you're not sure of some parts?

cheers
Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.