[GUIDE] Basic VGM ripping

Do you know a tool, link or website for working on a specific game files or to help game research? Let's collect them here!
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

[GUIDE] Basic VGM ripping

Post by AlphaTwentyThree »

Hello folks,

somehow I feel the need to talk about VGM ripping. I've been doing it actively for about 12 years now and as you can imagine, I've gathered "some" experience.
I can give you some basic guides for different platforms, audio and video formats, file types and developers/publishers. I can upload samples, screenshots, spectral analysis, character distributions and so on. The platforms I'm experienced in (apart from DOS, gathering experience in brackets):
Sony: PSX, PS2, PS3, PSP
Nintendo: Gamecube, Wii, (WiiU, Switch)
Microsoft: Xbox, Xbox 360
SEGA: Saturn, SEGA CD, (Dreamcast)

IF you're interested that is. Post here if you want to see something like this and I'll start.
gameside
Posts: 66
Joined: Sun Nov 08, 2020 1:07 pm

Re: [GUIDE] Basic VGM ripping

Post by gameside »

Hello, will be happy if you can share your experience. learning new things is always interesting.
I'm especially interested in ps2 stuff...
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: [GUIDE] Basic VGM ripping

Post by AlphaTwentyThree »

Alright, PS2 it is then.
Will compose something during the week for you and others.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: [GUIDE] Basic VGM ripping

Post by AlphaTwentyThree »

Platform: PS2

The PS2 is one of the platforms that is quite easy to rip. Most of the music files are already supported by vgmstream.

music/sounds
Mostly Playstation ADPCM or low frequency PCM - both can normally be played with vgmstream.
The structure of these is easy to identify by its 0x10-byte frames which have a header byte followed by 0x00 or 0x02:
Image

The character distribution looks like other ADPCM codecs and is very smooth:
Image


headers

VAG (mono)

Image

size: 0x30
endianness: big

Values to note:
- 0x0c: stream size
- 0x10: frequency

VAG stop frame:
Image


SS2 (stereo)

Image

size: 0x28
endianness: little

Values to note:
- 0xc: frequency
- 0x10: channels
- 0x14: interleave
- 0x24: stream size

A few words about the interleave
In most cases the interleave is easy to determine, the easiest of which is a leading 0x10 bytes of zeroes that repeats at the interleave. In other cases you have an interleave block at the end that has trailing zeroes if the last block is complete and the stream size isn't a multiple of 2*interleave. Another way to find the interleave without brute-forcing is looking for a repeat of the first 2 bytes down the line. And last but not least, the ending frame sometimes has a 0x03 or 0x06 after the header byte. There are some few cases where the last block ends with a VAG stop marker (see above).
So if you encounter a file with more than one ADPCM stream, be sure to check if:
- stereo files have a leading zero frame
- the last block is complete or incomplete
- the last block ends with an ending frame

Incomplete last blocks
Sadly, vgmstream still doesn't know how to correctly play these. In those cases, use my re-interleave script to create a file with a 0x10 byte interleave where the last block is only one frame and thus complete.


video
In most cases, PSS movies that can be demuxed by VGMToolbox. The problem is that the header is always ss2, no matter if it's ADPCM or PCM (big endian). I suggest you instead use PSSDemux (https://www.zophar.net/utilities/ps2util/pss-demux.html) as it reverses the bytes and writes raw PCM.
PSS is just a slightly changes MPEG so you are able to play it with VLC or other video players, so open pss with VLC by standard. If the suffix is different, rename it to pss and see if it plays or just try to demux it.
In case of *.bik (Bink video), demux with VGMToolbox and rename the audio files to *.bika for vgmstream to play.


In this pack
- vag_header.bms: add standard mono VAG header to raw stream
- ss2_header.bms: add standard SS2 header to a raw stream. Offset can be adjusted, frequency and interleave has to be given
- ss2_re-interleave.bms: as mentioned above. You can use this script on any SS2 that doesn't already have a 0x10 interleave
- vag_join_channels.bms: sometimes sounds or music is saved as [name]L/[name]R. To join these, use this script
- ss2_channel_split.bms: in the rare case that one channel is silent, use this to split a stereo SS2
- PSS demux 1.05