NFS:PS Extracted .dat file containing Sound Files - need help recompiling it

Codecs, formats, encoding/decoding of game audio, video and music
Zyphir
Posts: 1
Joined: Tue May 04, 2021 3:06 pm

NFS:PS Extracted .dat file containing Sound Files - need help recompiling it

Post by Zyphir »

Hello everyone,

I'm currently looking into Sound Modding for NFS ProStreet and had some success extracting sound files I'd like to edit.
I got a set of 3 different .dat files for each Topic the Ingame announcers can talk about. (3 different announcers so a different file for each of them per Topic/Categorie)

I've attached one such .dat file which is assigned to the first announcer you encounter in the game and part of the 'CountDown' Topic/Categorie. (german)
Dragging said .dat file onto ealayer3 spits out 45 individual sound clips/files in .mp3 format which work just fine 'out of the box'.

So far so good. Unfortunatly here is where I encountered my roadblock.
I tried multiple ways of recompiling the .dat file but none allowed for playback ingame as soon as the new file is supposed to be triggered. I tested the following:
-having ealayer3 import multiple files at once results in just a single .mp3 file with multiple streams
-encoding each .mp3 file one by one with ealayer and combinding them by coping the hex contents of each created .dat file at the end of the first .dat file
-tried both additional encoding options ealayer3 offers

Maybe someone can help me figure out what exactly is necessary to be able to recompile the file and still have it work ingame. I tried to look at file differences between the original and my creations with a hex editor but unfortunatly I'm entierly clueless as to what I'm looking at and what should be where.
The_Unpunished
Posts: 1
Joined: Thu Jun 03, 2021 3:13 pm

Re: NFS:PS Extracted .dat file containing Sound Files - need help recompiling it

Post by The_Unpunished »

As me and Zyphir were working together on this, I have found some more files to look at.
Apart from .dat, there are .hdr (header?) and .sth (seek table header?) files.
What I've tried to do is changing the .sth file accordingly to .dat, changing the .dat so it resembles more like the original (still can be decoded with ealayer3 tool). The only thing I have not tried still is reencoding .mp3 files in Audacity but I don't think that's the culprit here.
Here's the information I've found out so far:
.hdr has the structure like this:

Code: Select all

0x00: ID
0x02: parameters (userdata size, etc.)
0x03: number of files
0x04: sub-ID (used for different police voices in NFS games)
0x08: number of files
0x09: block size (seem to be always at 0)
0x0a: number of blocks (doesn't seem to do anything)
0x0c: number of sub-banks (seem to be always at 0)
0x0e: padding
0x10: start of the table
The table is a array of offsets that refer to .sth (2 bytes, big endian) + userdata (size of userdata)

.sth has the structure like this:

Code: Select all

4 bytes: offset for individual stream in .dat (small endian)
8 bytes: additonal info (small endian)
First 4 bits: version (0000, V0 for PS)
Next 4 bits: codec (0101/5/EL31 for PS)
Next 6 bits: channel configuration (000000 or mono for all the files in my case)
Next 18 bits: sample rate (44100 in my case)
Next 2 bits: type (01, streamed in my case)
Next 1 bit: loop flag (0, false, in my case)
Next 29 bits: sample count (varies on the file)
Repeat, until you get all the files.

.dat has this structure:

Code: Select all

First byte: identifier (80 is the last chunk in the file, 00 is not)
Next 3 bytes: chunk size, big endian (including the header)
4 bytes: sample count in the chunk, big endian
1 byte: seems to refer to some sort of raw data or not

original and reencoded files