EvilEngine/Sound Format: Difference between revisions

Battlepedia>Igorseabra4
Battlepedia>Igorseabra4
Line 56:
 
===GameCube (Movie Game/Incredibles/Rise of the Underminer)===
In those games, the SNDI contains not only the sound headers but also the entirety of the sound files themselves. It has a 0x20 byte header:
 
====SNDI Header====
The SNDI itself has a 0x20 byte header:
 
{| class="wikitable"
Line 63 ⟶ 66:
| 0x00 || [[AssetID]] || this || Asset ID of this asset
|-
| 0x04 || uintint || ?footerOffset || Offset relative to end of this header to athe Footer section. whichSubtract has0x20 afrom fewthis unknownto ints thenget the assetabsolute IDoffset of each sound in the SNDIFooter.
|-
| 0x08 || byte[0x10] || ? || Usually all 0s
|-
| 0x18 || short || amount of soundssoundCount || Total amount of sounds in SNDI
|-
| 0x1A || short || firstFSB3soundCount || Amount of sounds in the first FSB3 of the SNDI
|-
| 0x1C || short || otherFSB3soundCount || Amount of sounds combining all FSB3s which are not the first of the SNDI
|-
| 0x1E || short || FSB3count || Amount of FSB3 files
|}
 
All sounds are contained inside FSB3 files. Each FSB3 can contain one or multiple sounds; in all files analyzed so far, most of the sounds are contained in the first FSB3 file, with each subsequent file containing only one. This is the structure of a FSB3 file:
 
====FSB3 Header====
This is the header of a FSB3 file. There is one per FSB3 in the SNDI.
 
{| class="wikitable"
! Offset !! Type !! Variable !! Description
|-
| 0x00 || char[4] || magic || "FSB3" in ASCII
|-
| 0x04 || int || numSamples || Amount of samples in the FSB3. Each sample is a sound. However, unlike most FSB3 files in other games, here only one sample header is used for all sounds, which might be confusing, and a different, custom header is used for individual sounds.
|-
| 0x08 || int || totalHeadersSize || Total size of the single sample header + each individual sound header. This is always equal to (72 + 0x36 * numSamples).
|-
| 0x0C || int || totalDataSize || Total size of all sound data combining all sound entries.
|-
| 0x10 || int || version || Always 196609.
|-
| 0x14 || int || mode || Always 2.
|}
 
After the FSB3 header, there is one sample header.
 
====Sample Header====
This is the header of a FSB3 sample. There is one per FSB3 in the SNDI, immediately after the FSB3 header above.
 
{| class="wikitable"
! Offset !! Type !! Variable !! Description
|-
| 0x00 || short || size || Always 126
|-
| 0x02 || char[30] || soundName || Sample name in ASCII. Since each sample actually refers to multiple sounds and this is usually different from the actual sound names, this is likely leftover data and unused.
|-
| 0x20 || int || lengthSamples || Misleading name; this is actually the amount of samples on the uncompressed data for the first sound only. The first sound in the list will have 0 as its own lengthSamples.
|-
| 0x24 || int || lengthCompressedBytes || Misleading name; this is actually the length of the compressed sound data in bytes for the first sound only. The first sound in the list will have 0 as its own lengthCompressedBytes.
|-
| 0x28 || int || loopStart || Start of loop in sample. Only refers to first sound in list. This is probably unused as each sound would require its own loopStart.
|-
| 0x2C || int || loopEnd || End of loop in sample. Only refers to first sound in list. This is probably unused as each sound would require its own loopEnd.
|-
| 0x30 || int || sampleHeaderMode || Always 33558561
|-
| 0x34 || int || deffreq || Always 32000
|-
| 0x38 || short || defvol || Always 255
|-
| 0x3A || short || defpan || Always 128
|-
| 0x3C || short || defpri || Always 255
|-
| 0x3E || short || numchannels || Always 1
|-
| 0x40 || float || minDistance || Always 1.0
|-
| 0x44 || float || maxDistance || Always 1000000.0
|}
 
====Sound Header====
After the sample header, there are sound headers. This header repeats '''numSamples''' times (one for each sound). This header is 0x36 bytes long, an unusual length since it's not aligned to 4 bytes.
 
{| class="wikitable"
! Offset !! Type !! Variable !! Description
|-
| 0x00 || int || lengthSamples || Length of uncompressed samples in sound. This is 0 for the first sound in the list, as the value is set in the sample header above, but for each subsequent sound it's the actual value.
|-
| 0x04 || int || lengthCompressedBytes || Length of bytes in compressed data. This is 0 for the first sound in the list, as the value is set in the sample header above, but for each subsequent sound it's the actual value.
|-
| 0x08 || uint[8] || unknown || 8 ints with unknown function.
|-
| 0x28 || byte[14] || unknown || 14 bytes with unknown function.
|}
 
Adding the lengthCompressedBytes in each Sound Header entry will result in the totalDataSize value of the FSB3 header.
 
====Sound Data====
After '''numSamples''' occurrences of the Sound Header, we have the compressed sound data. The total length of this is set in the FSB3 Header (totalDataSize), with each sound in order.
 
After the sound data for the entire FSB3 file ends, we usually have the next FSB3 file, or if it's the last one, then we've reached the Footer section.
 
====Footer Section====
This is a section which occurs at the end of the file. The offset to this is set in the SNDI header. This is its structure:
 
{| class="wikitable"
! Offset !! Type !! Variable !! Description
|-
| 0x00 || int[FSB3count] || FSB3offsets || An array of ints. The amount of ints is the same amount of FSB3 files, as set in the SNDI header. Each int is an offset to the start of each FSB3 file, relative to the end of the header. Subtract 0x20 from each value to get the absolute offset of the file.
|}
 
After this, we have '''soundCount''' times the following structure, which refers to each sound in the SNDI:
 
{| class="wikitable"
! Offset !! Type !! Variable !! Description
| 0x00 || [[Asset ID]] || [[SND]]/[[SNDS]] || Asset ID of sound.
|-
| 0x04 || byte || unknown ||
|-
| 0x1A0x05 || shortbyte || amount of sounds in first FSB3index || AmountZero-based index of soundssound ininside the firstits FSB3 of the SNDIfile.
|-
| 0x06 || byte || fileIndex || Zero-based index of the FSB3 file containing this sound (index to the FSB3offsets array).
| 0x1C || short || amount of sounds in the other FSB3s || Amount of sounds in all FSB3s which are not the first of the SNDI
|-
| 0x1E0x07 || shortbyte || amount of FSB3sunknown || amount of FSB3s
|}