Bio 0 "sound" folder discoveries (and a sample extractor) by Nisto at 11:55 PM EDT on April 27, 2014
Hi all. I made some discoveries about the "sound" folder from Bio0 (Resident Evil 0). I don't know if any of this was already known, but I hope it will be helpful to some anyway. The "demo" folder, which seems to have some more samples, is still a big unknown to me, so the script I wrote will not work on any other files from the game. Although, the files in that folder appears to have essentially the same layout of audio data as in the "sound" directory - only they seem to be compressed/encrypted. So I hope we can figure out how to decompress/decrypt those one day.
.arc = these can contain just about anything, but for the "sound" directory, all of them contain only "pool", "proj" and "sdir" files, respectively .sam = samples .son = sequencer data.. I think
If you're curious, you can extract the internal files from the .arc files with MarkGrass' excellent tool, BioFAT (SVN6 anyway).
The sdir files contain DSP header data (such as sample rate and coefficients) and some other data. They contain two tables, which are terminated by 0xFFFFFFFF. As for the pool and proj files, I can't figure those out. If someone knows though, enlighten me/us!
sdir structure:
Table 1 (each entry is 32 bytes) 16 No idea. 16 Reserved? This is always 0x0000. u32 Sample's offset in the .sam file. 32 Reserved? This is always 0x00000000. 16 No idea. This is always 0x3C00. u16 Sample rate. u32 Total number of RAW samples. u32 Loop start offset? u32 Loop end offset? u32 Pointer to entry for this sample in the next table.
Table 2 (each entry is 40 bytes) u16 Size of the first chunk of the entry. This is always 0x0008. 48 Not sure what's stored here. u16[16] Coefficients.
The sample extraction script can be downloaded here.
It's written in PHP (I know, it's a dumb language to use for a task like this, but it's so easy to use), so you'll need PHP. I'm sorry if it's any trouble. Getting the script running is not a lengthy process, even if you're unfamiliar with PHP. Simply get the binary package (windows.php.net for Windows users), unpack it anywhere, then, in a command prompt/terminal use the CD command to change the current working directory to the directory in which you extracted the binaries.
To actually run the script: php [path...]script_name.php [path...]bio0_sound_dir Example: php C:\SamExtract.php C:\bio0\sound
If you come across a bug, please do notify me! I honestly wasn't sure if I should share the script in the first place, due to the harsh criticism it may or may not receive. This is the first time I share the full source code of a project, so please go easy on me.
Finally, some important things to note...
1: The first six samples of voice_1.sam contain only null bytes, and very few of them. As a result, your player (foobar2000 in my case) may crash if you try to open them, so please avoid these samples if possible!
2: The script won't add any loop values to the header [yet] as I'm not sure if those are standard loop start/end offsets in the sdir table (or if they're even loop values at all). Mainly because some of them don't make sense to me, like here for example -- the start offset (assuming that's what it is) is higher than the end offset(?) in a lot of cases. I also don't think they're offset+length pairs. So, if anyone figures it out, certainly do let me know, or post an update of the script even.
I don't know what those files looks like. Although, if they're only .samp files without any complementary files (like .arc in the case of Bio0), then I don't think I can help you. Can you upload one of them?
Easy-peasy. This will extract the Mario samples as well: SampExtract.php
Use it just as described in the OP, only, supply the path to the directory with the Mario sdir/samp files instead, obviously.
The other files seems to contain names for each FX or something.. You'll have to figure that out yourself. But I hope simple numbered filenames will do.
Also, I noticed that some of these files, vgmstream simply will not play. You can likely use DSPADPCM (from the Wii/NGC SDK) to properly convert those to WAV though.. if you don't mind not preserving the format.
Anyway, yeah, those will do until loops are discovered. But with Super Paper Mario already rippable with BrawlBox that MIGHT help, because it ports some sounds from PM:TTYD.
EDIT: I think I found where the loop offsets would be. 2 offsets after the number of samples, I think.
Well, a while ago, I ripped some sound effects from SPM with BrawlBox. I discovered the loop because the sample for the sound where Mario is blasting off (or when an item is being thrown by the audience) has the same loop as a similar sound in SPM, and found the loop there. That loop was 7588, I converted it to hexadecimal, and discovered the loop offset.
EDIT: The offset right after the sample offset, I don't know, but it could be for if the loop points are longer than FF FF in hexadecimal (?), but I don't know of any samples whose loops would last longer than that.