Resident Evil 4 / Biohazard 4 DSP Analysis by unknownfile at 11:57 AM EDT on April 7, 2007
I am doing research into the subject of the DSP format used in Biohazard 4 (or Resident Evil 4). Here is what I have so far. Nontechies may not look as this contains dreaded TECHNICAL INFORMATION.
RE4 DSP extract notes:
The "You Are Dead" stream starts at 0x60 in BIO4BGM.SBB. It apparenly has no header. Checking BIO4STR.HED gives us some numbers, and what appear to be headers:
So to determine the number of stremas, we count the words on the left and multiply them by 4. There are 64 tracks -- there are 62 on the OST, but this doesn't matter and some tracks are probably sequenced or streamed elsewhere.
Let's get to analysing the header:
0x0-0x3 dunno 0x4-0x7 not sure 0x8-0xB ditto 0xC-0xF sample rate (which is set to 32000 Hz in this sample) 0x10-0x13 not sure 0x14-0x17 not sure 0x18-0x1B duplicate of some information the rest of the header looks like some sort of table
Let's compare this to hcs's analysis of the devkit dsp format.
0x00-0x03: number of samples 0x04-0x07: number of ADPCM nibbles (including frame headers) 0x08-0x0b: sample rate (Hz) 0x0c-0x0d: loop flag (1=looped, 0=not looped) 0x0e-0x0f: format (0 for ADPCM) 0x10-0x13: loop start offset 0x14-0x17: loop end offset 0x18-0x1b: ca (always zero) 0x1c-0x3b: decode coefficients 0x3c-0x3d: gain (zero) 0x3e-0x3f: initial predictor/scale 0x40-0x41: initial sample history 1 0x42-0x43: initial sample history 2 0x44-0x45: loop predictor/scale 0x46-0x47: loop sample history 1 0x48-0x49: loop sample history 2 0x4a-0x5f: padding
You can get all of the music from Biohazard 4 in wonderful 48khz ADXs from the PlayStation 2 version of the game unless you just wanted to look into it for having the good feeling of cracking something. :-) Would be interesting to use this for the betas though, since they use the exact same format...
Excellent work, UNKNOWNFILE. I hope you continue with this project; as Farramenta mentioned, it would be great to listen to the DSP variants from Bio4 trials and betas :)
Back in 2005 I did a complete rip with all missing tracks and cutscene audio. This is the Original Soundtrack plus converted tracks from the PlayStation 2 version (ADX to VBR MP3s):
Thanks MarkGrass, I'm a bit bogged down with school work and other crap. Hopefully I'll be able to write an extractor which can convert the archive into dual-file DSPs, as it's a pretty screwy header format.
Possible solutions to finding decode coefs:
- Brute-force using bytes from the headers provided - Add support for RE4 DSP format in in_cube - Get hcs to do it (hardest possible solution)
PS: The ADX archive is in the same order as the GC SBB archive: first track in the SBB is "Game Over" followed by "Ganado I"
No problem. I will keep checking back here until the project is either complete or abandoned.
EDIT: I probably couldn't help with the DSP Headers until I learn more about the format, but after messing areound with bio4str.hed for a little while, I came up with this, I will be looking into bgmtbl.dat soon.
Resident Evil 4 (NTSC/US): 0x00-0x03 Music DSP Offset 0x04-0x07 Misc DSP Offset 0x08-0x1F Pad
Music\Misc DSP: 0x00-0x03 Amount Of Streams In SBB* 0x04-0x07 Header String Offset 0x08-0x0B File String Offset
*Matches correctly with Misc Header, but Music's Header indicates there's 3 more than there should be?
Header String: 0x00-0x03 DSP Header 01 Offset 0x04-0x07 DSP Header 02 Offset 0x08-0x0B DSP Header 03 Offset ... ... ... ... ... ... ...and so on until all Headers are accounted for.
File String: 0x00-0x01 File Number (Music_00.DSP, Music_01.DSP, etc.)* 0x02-0x05 ??? 0x06-0x07 System Reserved 0x08-0x0F ??? ... ... ... ... ... ... ...and so on until all Files are accounted for.
*Some DSPs seem to have been removed from the SBB bank before final production. Ones that have been deleted all have the same 16-btye value in the File String: 0000 0000 0000 0000 0000 0000 8000 7FFF
EDIT2: After studying the Standard DSP format, I believe I may have figured out the DSP Header (Guess Work):
DSP Header: 0x00-0x01 Format 0x02-0x03 Loop Amount 0x04-0x07 Number Of ADPCM Nibbles 0x08-0x0B Number Of Samples 0x0C-0x0F Sample Rate 0x10-0x13 CA 0x14-0x17 Loop Start Offset 0x18-0x1B Loop End Offset 0x1C-0x1F ??? 0x20-0x3F Channel 1 Decode Coefficients 0x40-0x5F Channel 2 Decode Coefficients 0x60-0x6F Padding
I'm positve that the overall file structure of bio4str.hed has been documented properly, but the DSP header is a different story, i'm definitely no expert with the format.