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.
I think the brother of cubed at GFF worked on an extractor before the original soundtrack was released. It was never finished, though, and the old posts of him have been wiped due to the big crash last year... However, you could get in contact with him and ask for the source. Nothing to lose.
Would be pretty cool if the archives are cracked. Beta sound files are not deleted from most games.
With the help a nice little app, I was able to extract every DSP header for the SBB stream bank. There are exactly 63 headers: there are exactly 63 tracks found in the Official BioHazard 4 SoundTrack.
Definitely a bump from the dead, but i'm hoping someone intelligible with the DSP format can look at these files. :)
My apologies for the bump but has anyone figured out the sequences for resident evil 4? Pretty sure the game uses them as I found these in the system, I think the HED is for filenames.
I'm really curious to know how the bio4bgm streams were extracted for the GENH rip on joshw's FTP. Where did the offsets come from? I am quite certain the offsets to the streams are not stored in any of the files in the bgm folder - only Capcom DSP headers and some sort of stream descriptors, but no offsets. So are they in the main executable or something.. ? Would love to know, because I wanted to check out the bio4evt streams too (which were not ripped afai can see).
Well, this was a funny one. Turns out the offsets for the streams within bio4bgm/bio4evt are actually stored within the DSP headers themselves, at 0x1C (presumably some reserved slot which they decided to use.. unless it's used in all Capcom games?)
Whoa! Thanks Nisto!!! :D it really works! This is so awesome man. Do you need all the files from the RE4 ISO?? I can upload them all if you want, it'll take me a while but I am absolutely willing to for Resident Evil 4 music research purposes. :)
Edit: All the streams are in excellent condition too, I don't think this game even uses sequences anymore.
Also the gamecube version of this game always had a better soundtrack at least in terms of quality in my opinion, hell a better everything :) thanks so much for bringing it back to us.
No need to upload anything. I have the game (*RE fan*), I just never bothered to look into its files. bio4bgm and bio4evt are identical between the discs too, so...
Sent you a friend request on ffshrine :) we need more people like you who can look more in depth into formats like these, so consider joining the forums here if you're interested in music related stuff.
Many thanks for this, Nisto :D Your script happens to work on multiple versions of the game, beta and retail alike.
I am providing a complete rip from the E3 2004 demo of Bio Hazard 4, as it contains a few things I've never heard, such as a conversation between Leon and Luis where Luis mentions that he used to be a cop in America but quit because of bureaucratic situations. I think "bio4bgm_002.capdsp" is a new/beta track, though I can't be certain as it's been awhile since I've played. There may be other stuff
I have a few more beta versions that I'll check out for differences later.