don't click here

Extracting PS2 files

Discussion in 'Technical Discussion' started by Rosiero, Feb 9, 2012.

  1. Rosiero

    Rosiero

    Mmph! Oldbie
    I'm messing around with the PS2 version of Mega Man Anniversary Collection, but I'm not getting very far. It seems that most of the stuff in the game is packed inside big archives with a .AIF extension. Of course, it's nearly impossible to google that shit, and the only thing I found was a dead link to an app that supposedly extracts the music. Does anyone have any idea how I can extract (and, more importantly, repack) these things?
     
  2. Andlabs

    Andlabs

    「いっきまーす」 Wiki Sysop
    2,175
    1
    0
    Writing my own MD/Genesis sound driver :D
    Can you paste a hex editor dump of the eginning of the file? It might help identify the file type. Thanks.
     
  3. Rosiero

    Rosiero

    Mmph! Oldbie
    I'm not sure if it'll help; none of the files seem to have any kind of header, it all just looks like garbage (and the beginning isn't the same across any of them, I checked.) Nonetheless, here are some screenshots since my hex editor refuses to let me copypaste properly:
    http://3xs.jonnys-place.com/_junk/hex1.png
    http://3xs.jonnys-place.com/_junk/hex2.png
     
  4. kuroshi

    kuroshi

    Member
    32
    0
    0
    Riverside, CA, US
    foobar2000 components, many related to emulation; Cog, an audio player for Mac OS X
    There was a utility from 2008 for ripping these files, but it's gone now. You may come to #console_stream on irc.foreverchat.net to inquire about this soundtrack, but more than likely, you'll have to download the whole set instead of ripping it yourself. The set comes to 1.24GB.

    The resulting AUS files will be playable with VGMStream, which is available for both Winamp and foobar2000, and other platforms or players which I forget off hand.
     
  5. Rosiero

    Rosiero

    Mmph! Oldbie
    Okay... I already have a rip of the music, though—I was more looking into replacing songs in the game, though.
     
  6. kuroshi

    kuroshi

    Member
    32
    0
    0
    Riverside, CA, US
    foobar2000 components, many related to emulation; Cog, an audio player for Mac OS X
    Oh. In that case, maybe someone in that channel has some information on the structure of the game files. At the very least, VGMStream's source code serves as a form of documentation on the format of the individual files. The header is very simple, it only contains a signature ("AUS "), 32 bit little endian channel count at offset 0xC, sample rate at 0x10 in same format, total sample count at 0x08, loop start sample number at 0x14, and a 16 bit flag that may indicate Xbox IMA ADPCM format at 0x06, which is unlikely in this case. In this case, it would be interleaved blocks of Sony PlayStation ADPCM, in blocks of 0x800 bytes per channel, starting at 0x800 bytes into the file.

    The AIF files themselves probably contain a simple directory structure, consisting of number of files, and file sizes and offsets. Matching up offsets with "AUS " (that's a space, not a NULL byte) signatures should make things easier. Also matching up sample counts up to byte sizes of files. There are probably an even number of 0x800 blocks in each file, even up to the number of channels in the file. Each block of 2048 bytes contains 3584 samples. (That's 28 samples to each 16 byte block of data.) And if it's a stereo file, for instance, then each block is paired, so 4096 bytes makes 3584 stereo sample pairs.
     
  7. Rosiero

    Rosiero

    Mmph! Oldbie
    Thanks, that helped a lot! I was able to locate the AUS files and even convert one to .wav with vgmstream after separating it from the rest of the file. I haven't yet been able to find any sort of directory structure (the files don't seem to be in a logical order anyway), but I'm hoping the game will determine the start and stop points of a file by reading the header instead—that'd make things easier. First, however, I have to find a way to convert my custom music to Sony ADPCM, which I'm having a hard time finding any sort of utility for. Most programs only seem to have decoding functions.

    Also, on a side note, DATA1.AIF contains references to files from the original PSX versions of these games, which is kind of odd.
     
  8. kuroshi

    kuroshi

    Member
    32
    0
    0
    Riverside, CA, US
    foobar2000 components, many related to emulation; Cog, an audio player for Mac OS X
    Here are some SNES/PSX/XA ADPCM compression functions I wrote years ago, although the SNES one may not get the clipping/wrapping behavior exactly. Six functions, two for each format. One function does the actual compression of a block of samples, while another will brute force it against the same block of samples to find the least mean square error compared to the input. All three sets also include an extra parameter to factor in the last two samples before a loop start block when encoding the last block of the file.

    Back in foobar2000 0.8 days, they were included in converter output presets in foo_brr. As you may be able to derive from the function names and structure, they were derived from ADPCM encoding functions in SoX.