Help: extracting & converting PS2 audio files to WAV files

Codecs, formats, encoding/decoding of game audio, video and music
Doomification171
Posts: 3
Joined: Mon Dec 16, 2019 2:42 pm

Help: extracting & converting PS2 audio files to WAV files

Post by Doomification171 »

Hi everyone,

I'm currently trying to rip the music files from one of my fav. PS2 games: Jak X Combat Racing. I unpacked the game's .iso file and found out the music files are contained in a (container) file called VAGWAD.INT. My goal is to basically extract the music files (I think they are VAGp files?) and convert them to individual WAV files.

I tried opening VAGWAD.INT in PSound, and I found out the file contains both mono files (mostly explosion sound effects), and stereo files (the music I want). However, I can only export mono files to WAV with PSound, and stereo files are cut off after 1/2 of a second. The next option I tried was "ADPCM player", but I can't play files with it -- it throws an unpreventable error. Exporting files to WAV with ADPCM player does work, but the music is extremely choppy and distorted because ADPCM player does not let me change sample rate and interleave. The final option I tried was MFAudio, and this was the first program that let me play music files correctly -- I managed to figure out that the sample rate is 48000 and interleave is 1000, (confusingly, the sample rate is different for non-music audio files). However, exporting files with MFaudio results in WAV files that are 6+ hours long and consist only of silence... also it crashes after every file I "successfully converted".

I also tried SoX, VGMtoolbox, and VGSC. All without result. Now, I'm very new to this, and this has been a very frustrating experience so far, but I don't want to give up just yet.

Can anyone help me extract the stereo files from VAGWAD.INT and save them as WAV files?
Allanmaster
Posts: 11
Joined: Thu Mar 22, 2018 7:30 pm

Re: Help: extracting & converting PS2 audio files to WAV files

Post by Allanmaster »

I've found a way, but it's for sure not the best way, somebody who can actually write scripts or has more knowlegde would probably help you best. What I've done is to manually extract the music with an Hex editor. I've used HxD and later MFAudio for this.

Open HxD and open the VAGWAD.INT file.

Every audio file has a header that starts with the ASCII characters "pGAV", followed by 8bytes with value of "00", then 3 bytes of something (dunno what they are), follow by another byte with "00", then 2 bytes indicating the frequency (in this case, 80 BB = 48000 (hz)). Then 14bytes of "00", then at last, ASCII characters representing either "mono" or "stereo".

Every audio file (at least the stereo ones) have two instances of this, and they are 1000bytes apart (that's our interleave). So basicly, it's as easy as to extract the audio file by copying and pasting into a new file in the HexEditor, save it (with just an generic extension, like ".h") and finally, open up with MFAudio, put the data as 48000hz, Stereo, 1000 interleave, 0 OFFSET (the program will automatically put it at 1030bytes, change it) and voila! It converts successfully. Only caviat is that there is a tick at the start of each track, but everything else sounds as it should be, you can probably edit it with Audacity.

For example, the track "Missile" is located between the offsets 99B8000 (where the header starts, in that case in offset 99B9000 its where the "second header" is) and A578FFF (just before the start of the next audio file). There is a search bar to find certain text (ctrl+f, have the search direction enabled as "forward") to search "pGAV", then F3 to search again (do F3 two times, the first leap you do should be 1000bytes, the next should be a huge leap). Also, ctrl+e selects everything between the offsets you input.

There seems to be 22 music tracks in total. Have fun.
Doomification171
Posts: 3
Joined: Mon Dec 16, 2019 2:42 pm

Re: Help: extracting & converting PS2 audio files to WAV files

Post by Doomification171 »

Allanmaster wrote:What I've done is to manually extract the music with an Hex editor. I've used HxD and later MFAudio for this.


This worked perfectly for me! Thank you so much!

Allanmaster wrote:Only caviat is that there is a tick at the start of each track, but everything else sounds as it should be, you can probably edit it with Audacity.


The rest of the tracks sound perfect, so removing these ticks with Audacity was indeed no problem. Although I am interested where the tick is coming from. Maybe MFAudio tries to convert the header data into waveform samples too? Then again, I wasn't able to mitigate this by changing offset. Anyway, I was able to get all of the tracks, thank you again :)
Allanmaster
Posts: 11
Joined: Thu Mar 22, 2018 7:30 pm

Re: Help: extracting & converting PS2 audio files to WAV files

Post by Allanmaster »

As the file is a format type unknown to MFAudio, then it automatically goes to RAW format (files with no header), and so tries to find the audio data, skipping the rest (in this case, our headers), but in doing so in this case, we lose valuable information, making it so that it sounds wrong, as if the left and right channel are out of sync (the interleave is off). Or so I think anyhow, there are websites with information about interleave and what not.

As for the tick, yes, MFAudio tries to read everything that you tell it to read, then plays it out as it can. You can try and open an exe file with MFAudio, and revel in its oh glorious sound (don't, it hurts).

Enjoy your music.