PaRappa PSP cmp.img

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
Miles2345
Posts: 76
Joined: Thu Oct 16, 2014 3:05 am

PaRappa PSP cmp.img

Post by Miles2345 »

Everything in this game seems to be in one archive. I'm interested in this game because it has vocal tracks of the songs in the game without any BGM, which is unique to the PSP version. I think they're in .wav, but I can't ever seem to extract them properly.

Sorry about all the rapid requests by the way, I'm sort of on a PaRappa game binge right now. This is the last PaRappa game.

https://drive.google.com/file/d/0B_8j1D ... sp=sharing
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: PaRappa PSP cmp.img

Post by aluigi »

No luck this time.
The directory structure is not clear and the compression algorithm is not guessed by my scanner.
http://aluigi.org/papers/bms/others/parappa_psp.bms
Miles2345
Posts: 76
Joined: Thu Oct 16, 2014 3:05 am

Re: PaRappa PSP cmp.img

Post by Miles2345 »

Hmm, well maybe could you take a look at these .wav files I've extracted using Dragon Unpacker?
I think they use some sort of ATRAC3 codec, but none of them seem to play correctly.

http://puu.sh/cIqYA.zip
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: PaRappa PSP cmp.img

Post by aluigi »

With Mplayer and ffplay/ffmpeg I can play them perfectly (probably the sound will start after some seconds), they show the "atrac3" codec information.
Miles2345
Posts: 76
Joined: Thu Oct 16, 2014 3:05 am

Re: PaRappa PSP cmp.img

Post by Miles2345 »

when I play the sounds using ffplay, they sound alright, but all the verses are broken up. There's equal space between each part of the song that you can actually hear.. I'm expecting a single stream of audio that isn't broken up at all. Is there something I'm doing wrong or is there something wrong with the files themselves?

mplayer repeats the message "Frame decoding error!"

also, about a minute into it, it just starts repeating a short bit of the song.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: PaRappa PSP cmp.img

Post by aluigi »

Unfortunately I can't help more than that with audio stuff.
Maybe try to post in the Audio forum.
oddMLan
Posts: 13
Joined: Mon Jan 19, 2015 12:29 am

Re: PaRappa PSP cmp.img

Post by oddMLan »

I found out how the game stores the audio.

The good/bad/awful/cool songs of each stage are stored in flame/stageX.smg and the acapellas in flame/stageX_to.smg, where X is the stage number.

The SMG files have a 2KB header and 4 WAV ATRAC3 codec Audio files interleaved each 16KB.

Here's an example of a SMG file: https://www.dropbox.com/s/fenem0kcv9vb8 ... o.sng?dl=0


I extracted the audio using this procedure:
-Used a HEX editor to strip out the first 2048 bytes (2KB header)
-Used FFSJ and told it to split the file each 16KB, which brought me 480 parts using Fleaswallow's stage as test
-Separated every 4th part into four different groups (1,5,9,13...; 2,6,10,14...; 3,7,11,15...; 4,8,12,16... etc) and inside each folder used the

Code: Select all

copy /b *.* recording.wav
command to merge the parts into a single file.
-I obtained 4 different WAV files which I could hear in Audacity with perfect audio.

Obviously although this works just fine for extracting the audio files this process isn't the most orthodox.
I would like to have a quickbms script that skips the first 2KB, splits the file every 16KB then join every 4th part to output 4 audio files.
In other words, a script that omits the 2KB header and separates every 16KB in a 64KB block into 4 audio files.

I tried to use @AlphaTwentyThree's deinterleaver script for that task but I couldn't get it to work the way I needed.
EDIT: Damn, user mentions don't seem to work here.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: PaRappa PSP cmp.img

Post by aluigi »

A script like the following:

Code: Select all

idstring "PPST"
math OFFSET = 0x800
math SIZE = 0x4000
get SNG_SIZE asize
math SNG_SIZE - OFFSET
xmath CHUNKS "(SNG_SIZE / SIZE) / 4"

append
for i = 0 <= CHUNKS
    if i == CHUNKS
        xmath SIZE "(SNG_SIZE - (CHUNKS * SIZE * 4)) / 4"
    endif

    log MEMORY_FILE1 OFFSET SIZE
    math OFFSET += SIZE

    log MEMORY_FILE2 OFFSET SIZE
    math OFFSET += SIZE

    log MEMORY_FILE3 OFFSET SIZE
    math OFFSET += SIZE

    log MEMORY_FILE4 OFFSET SIZE
    math OFFSET += SIZE
next i
append

get SIZE asize MEMORY_FILE
get BASE_NAME basename

string NAME p= "%s_%d.wav" BASE_NAME 1
log NAME 0 SIZE MEMORY_FILE1

string NAME p= "%s_%d.wav" BASE_NAME 2
log NAME 0 SIZE MEMORY_FILE2

string NAME p= "%s_%d.wav" BASE_NAME 3
log NAME 0 SIZE MEMORY_FILE3

string NAME p= "%s_%d.wav" BASE_NAME 4
log NAME 0 SIZE MEMORY_FILE4

It can be shorter if you don't use MEMORY_FILEs but then the user is forced to type 'a' to allow quickbms to overwrite the output files to append the data.

*edit*
script updated to handle the last chunks.
oddMLan
Posts: 13
Joined: Mon Jan 19, 2015 12:29 am

Re: PaRappa PSP cmp.img

Post by oddMLan »

Niiice, thanks aluigi! The script works perfectly!

...except for one specific case: https://www.dropbox.com/s/56o4i48hejj9z ... 7.sng?dl=0

I don't see what's wrong... the header is 2KB like the rest of the SNG files, I checked the interleave again and is still 16KB too but the quickbms script fails with the following error.


EDIT: The updated scripts works perfectly. Thanks again!
Last edited by oddMLan on Wed Mar 25, 2015 2:12 am, edited 2 times in total.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: PaRappa PSP cmp.img

Post by aluigi »

Ok I have update the script to handle the last chunk which is not 4kb.