GTA San Andreas (PS2) - Need help with .VAG audio header

Codecs, formats, encoding/decoding of game audio, video and music
BloodRaynare
Posts: 367
Joined: Fri Mar 10, 2017 7:23 am

GTA San Andreas (PS2) - Need help with .VAG audio header

Post by BloodRaynare »

Guys, I'm trying to mod the audio files of PS2 version of GTA SA (more specifically, I want to mod the radio commercials).

There's a set of tools which does extracting and repacking the audio archives as well encoding and decoding the audio files (You can find it by searching "Pack Extract-Rebuild Radio GTA S-A" on google). But, the encoder only works for radio station songs (not to mention the program sometimes crash when converting files). Basically, the encoder splits your audio into 3 parts (intro, middle, and the outro of the songs) and I wanted the files to be converted into single audio.

Because of that, I figured how about I convert the audio myself with the help from MFAudio + Hex Editor?
So, I start to examine the content of the files. For example, I extracted the ADVERTS.PAK with one of the tools (Stream_PAK.exe) and examine one of the extracted files (FILE0000.VAG) with the hex editor (I use HxD).

At the start of the files there's 4 bytes of "0xFF" dunno what is this, probably some kind of IDString, but what I needed for help is actually on the offset 0x1F40.

Image
As you can see on the image above, there's information about the files (They appeared twice). However, the only thing I could figure out is the frequencies of the audio (at offset 0x1F54 and 0x1F5C, there's hex value of C0 5D 00 00 which when converted to decimal is 24000, so the audio freq is 24000 Hz). I don't know what the rest of the value are (Probably sample lengths or something?).

After that at offset 0x1F64 (or 0x1F74?) is where the audio data starts. The audio data was stored with PS2 Compressed ADPCM format. And, some interesting bits about the audio data. At the start of audio data (or 0x10) and on the next 0x20000 (Like 0x21000, 0x42000 and so on...) offset there's 0x1000 of garbage audio data (sounds like rewind?).

Make the audio data is easier since I just need the convert the audio, split the converted audio to 128kb (131072 bytes), take the garbage audio data, paste to each splitted files, and combine the files again.

Here's the sample files if you guys needed to study the files (It's on the attachment)
Who knows maybe you guys can make it into BMS script or even the standalone tools.
BloodRaynare
Posts: 367
Joined: Fri Mar 10, 2017 7:23 am

Re: GTA San Andreas (PS2) - Need help with .VAG audio header

Post by BloodRaynare »

Bump after more than a year...
Has anyone figured out what those unknown values at 0x1F40 and 0x1F50?
Anexenaumoon
Posts: 119
Joined: Sun Dec 27, 2015 10:22 pm

Re: GTA San Andreas (PS2) - Need help with .VAG audio header

Post by Anexenaumoon »

To be honest, don't know if it's worth it to make a script, as there is no definitive values that explain where these samples end and start. As much as I don't like recommending it, I'd use PSound with this one.