.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

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

Post by V12-POWER »

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
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 »

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?
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 »

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"
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 »

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
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 »

Tropod wrote: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


it's about encoding now, I tried the decoder and it works for nfs pro street files even, but you need to get the gin files manually by hex editing. There's also guys from GTRCars interested in writing some form of encoder, but daemon has the last word
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 »

V12-POWER wrote:For gin files, the table is a bunch of arrays, which is independent of file size... the big int-array is "not really that important"


I don't know how it may not be important, it depends on file size and it contains the sample numbers from the audio. This example for Ferrari having 149237 samples

Image

first array is always 51 numbers

Image

size of the second depends on file size and forms a curve
Last edited by id-daemon on Sun Oct 04, 2015 12:57 pm, edited 1 time 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 »

Tropod wrote:I can upload some of these for troubleshooting


Yes, some sounds have no sampling rate, so I assume them to be 22050hz like it was stated in EA wiki. If you know how these should sound in game, please send them.
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 »

id-daemon2 wrote:
V12-POWER wrote:For gin files, the table is a bunch of arrays, which is independent of file size... the big int-array is "not really that important"


I don't know how it may not be important, it depends on file size and it contains the sample numbers from the audio. This example for Ferrari having 149237 samples

Image

first array is always 51 numbers

Image

size of the second depends on file size and forms a curve


there are 2 fields at the header that give us how many fields for each array. however if you use or create an array yourself you can still use it and have the sound unchanged, by hexediting. I tested this with almost any car there is, so that's why I said it's not that important but I might be wrong, your decoder works with nfscarbon and pro street gins (manually getting the .gin out of the .tmx audio file) with sampling rate of 44.1khz, common in almost every audio file from NFSC onwards, but .abk has received a update, yet it's very similar to BNK1 section, has relative offsets, sample rate and more info in this section
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 »

V12-POWER wrote:you can still use it and have the sound unchanged


Ok good then, it must be some kind of seektable that is not used in this case. I can just say that

24-27 -> total number of samples
28-31 -> sampling rate

Good to know that decoding works with many games. I don't know where to proceed now. Should I dig into new ABK formats or something?

I saw someone on GTRCars reversed my EXEs, but that was not a secret, I told you about codec types here. There's no reason comparing them with ffmpeg codecs, this will not help at all.

Also I tried replacing CAR_21_ENG_MB_EE.abk (VW GTi) with other files, like CAR_50_ENG_MB_EE.abk and engine sounds wrong (almost silent). It seems they are dependent on some other files. Do you know anything about it?
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 made some tests. Replaced CAR_21_ENG_MB_EE_01.wav with some music loop, encoded it with

sx.exe -raw -eaxa_blk CAR_21_ENG_MB_EE_01.wav -=1.bin

and hex-inserted it into ABK.

As a result you can hear music instead of engine idle on VW GTi. So this prooves we can change sounds with the same number of samples with original EA tool SX.exe and we don't need an encoder for that.
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 »

fuuuaarrrrkkkkkk that was awesome. now I see that you used the same offsets, can we start working towards adding more samples? I understand how this section works, not that hard to understand by looking at the files. there's the version, number of samples, total audio size, the PT offset array, everything
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, today I replaced that idle sound with 7-seconds long music sample. Instead of rebuilding the whole ABK file I just append it to the end and chang offsets and sizes. You know what? It plays.

Still I can't understand why swapping two ABK files doesn't work right.
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 »

It's not that it does not works, it's just that the ABK forms the whole engine sound, so exchanging them can break the structure of the sounds. you don't even need to change the whole .abk, just changing the first part will destroy the sound. If you pay attention to the file you gave me (with the song sample) you can hear that it plays in the wrong tempo when in game. I can dig into this part as I know it's crucial for development.
btw, when I use the same lines (sx.exe -raw -eaxa_blk CAR_21_ENG_MB_EE_01.wav -=1.bin) it gives me a 37,5kb .bin file, not really compressing it at all, so I can't put it in the ABK because the sizes are not identical.
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'm using SX.exe v3.01.01, whats your version?
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 »

V12-POWER wrote:... exchanging them can break the structure of the sounds. you don't even need to change the whole .abk, just changing the first part will destroy the sound


Yes, changing some bytes in ABK can destroy the sound, because it will not be a proper ABK. But if we use one ABK instead of another, it will be proper ABK, how come it doesn't 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 »

id-daemon2 wrote:
V12-POWER wrote:... exchanging them can break the structure of the sounds. you don't even need to change the whole .abk, just changing the first part will destroy the sound


Yes, changing some bytes in ABK can destroy the sound, because it will not be a proper ABK. But if we use one ABK instead of another, it will be proper ABK, how come it doesn't work?


I mean, the data from byte 92 till 9856 (decimal) in car 21 eng, it's that part which makes the sound. Im using the latest version, same as yours
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 »

V12-POWER wrote:Im using the latest version, same as yours


very strange then. it gives me 10k 1.bin
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 »

out of curiosity, have you looked at the text files that I uploaded?
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 »

yes
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 »

I'd say that we start with the hardest first, an encoder for gin files if you're up to it. There are guys from gtrcars that might help if you or I contact them. There's also a mod, called Golden Muscle Era which replaced every music file (not engine sounds sadly) I suppose that the NFSMW music files use the same or similar codec, which we can also see if they are still alive. I also think this is the first logical step because the gin format is the same for all NFS games from NFS UG to NFS Undercover.

I am gonna try to fully understand the abk format once and for all (talking about the first data section before BNKl header and then the last array table) since this does not requires a new encoder, just understanding of how it's made