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

Codecs, formats, encoding/decoding of game audio, video and music
V12-POWER
Posts: 71
Joined: Thu Jul 02, 2015 10:43 pm

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

Post by V12-POWER »

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
V12-POWER
Posts: 71
Joined: Thu Jul 02, 2015 10:43 pm

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

Post by V12-POWER »

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: Select all

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
V12-POWER
Posts: 71
Joined: Thu Jul 02, 2015 10:43 pm

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

Post by V12-POWER »

So, sorry for impatience but has anybody looked at the samples above?
Tropod
Posts: 6
Joined: Sat Sep 05, 2015 2:36 am

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

Post by Tropod »

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
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

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

Post by id-daemon »

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
Tropod
Posts: 6
Joined: Sat Sep 05, 2015 2:36 am

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

Post by Tropod »

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.
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

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

Post by id-daemon »

I haven't tried playing them yet, but i think this will be easy. But encoding will require a lot more work.
V12-POWER
Posts: 71
Joined: Thu Jul 02, 2015 10:43 pm

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

Post by V12-POWER »

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
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

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

Post by id-daemon »

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.
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

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

Post by id-daemon »

So if this can really be interesting for many people, and the codec is the same for many NFS games, I can try this.
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

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

Post by id-daemon »

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)
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

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

Post by id-daemon »

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.
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

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

Post by id-daemon »

And this is ABK decoder.

UPDATE: moved here

viewtopic.php?f=6&t=1567
Last edited by id-daemon on Sat Oct 17, 2015 5:40 pm, edited 2 times in total.
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

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

Post by id-daemon »

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
Last edited by id-daemon on Sat Oct 17, 2015 3:37 pm, edited 1 time in total.
Tropod
Posts: 6
Joined: Sat Sep 05, 2015 2:36 am

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

Post by Tropod »

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?
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

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

Post by id-daemon »

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


Sure I do, I wrote it.
V12-POWER
Posts: 71
Joined: Thu Jul 02, 2015 10:43 pm

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

Post by V12-POWER »

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
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

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

Post by id-daemon »

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.
V12-POWER
Posts: 71
Joined: Thu Jul 02, 2015 10:43 pm

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

Post by V12-POWER »

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)
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

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

Post by id-daemon »

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.