ZenHAX

Free Game Research Forum | Official QuickBMS support | twitter @zenhax | SSL HTTPS://zenhax.com
It is currently Mon Nov 20, 2017 3:30 pm

All times are UTC




Post new topic  Reply to topic  [ 221 posts ]  Go to page 1 2 3 4 512 Next
Author Message
PostPosted: Thu Jul 02, 2015 11:50 pm 

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


Top
   
PostPosted: Tue Jul 07, 2015 2:00 pm 

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


Attachments:
File comment: 4 files and a .txt with info
abk samples.rar [464 KiB]
Downloaded 200 times
File comment: 4 files and a .txt with info
gin samples.rar [390.3 KiB]
Downloaded 153 times
Top
   
PostPosted: Thu Jul 16, 2015 4:36 pm 

Joined: Thu Jul 02, 2015 10:43 pm
Posts: 61
So, sorry for impatience but has anybody looked at the samples above?


Top
   
PostPosted: Sat Sep 05, 2015 2:55 am 

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


Top
   
PostPosted: Sat Sep 12, 2015 3:34 pm 

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


Top
   
PostPosted: Thu Sep 17, 2015 7:10 am 

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


Top
   
PostPosted: Thu Sep 17, 2015 3:35 pm 

Joined: Sun Mar 22, 2015 7:09 pm
Posts: 663
I haven't tried playing them yet, but i think this will be easy. But encoding will require a lot more work.


Top
   
PostPosted: Mon Sep 21, 2015 1:44 pm 

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


Top
   
PostPosted: Mon Sep 21, 2015 3:18 pm 

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


Top
   
PostPosted: Mon Sep 21, 2015 4:04 pm 

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


Top
   
PostPosted: Fri Sep 25, 2015 6:07 pm 

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


Top
   
PostPosted: Sat Sep 26, 2015 11:11 am 

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


Attachments:
gin_decode.rar [3.25 KiB]
Downloaded 173 times
Top
   
PostPosted: Sat Sep 26, 2015 8:08 pm 

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

Top
   
PostPosted: Sun Sep 27, 2015 8:02 am 

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

Top
   
PostPosted: Sat Oct 03, 2015 4:21 am 

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


Top
   
PostPosted: Sat Oct 03, 2015 4:37 am 

Joined: Sun Mar 22, 2015 7:09 pm
Posts: 663
Tropod wrote:
EDIT: do you have any source code, & not just exe?


Sure I do, I wrote it.


Top
   
PostPosted: Sat Oct 03, 2015 6:12 pm 

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


Top
   
PostPosted: Sat Oct 03, 2015 6:30 pm 

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


Top
   
PostPosted: Sat Oct 03, 2015 6:35 pm 

Joined: Thu Jul 02, 2015 10:43 pm
Posts: 61
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)


Top
   
PostPosted: Sat Oct 03, 2015 7:07 pm 

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


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 221 posts ]  Go to page 1 2 3 4 512 Next

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Limited