Line 1: |
Line 1: |
| [[Category:File formats]] | | [[Category:File formats]] |
− | This document is about the format of Banner's CTR Wave files (BCWAV). | + | This document is about the format of Binary CTR Wave files (BCWAV). The structure is very similar to Microsoft's Wave file. |
| | | |
− | The structure is very similar to Microsoft's Wave file.
| + | === Overview === |
| + | |
| + | Microsoft's WAV structure is RIFF Header which defines the data inside which is WAVE, then the media player expects a "fmt " chunk and a "data" chunk. Nintendo's format uses a CWAV header (no need for a general structure for media, only wave), which points to an INFO struct (the equivalent to fmt) and a DATA struct (the equivalent to data). |
| | | |
− | === Overview === | + | === Header === |
| | | |
− | Microsoft's Wave structure is RIFF Header which defines the data inside which is WAVE.
| + | {| class="wikitable" border="1" |
| + | |- |
| + | ! OFFSET !! SIZE !! DESCRIPTION |
| + | |- |
| + | | 0x000 || 4 || Magic (CWAV) |
| + | |- |
| + | | 0x004 || 2 || Endianness (0xFEFF = little, 0xFFFE = big) |
| + | |- |
| + | | 0x006 || 2 || Header Size (0x40 due to [[#Info Block|Info Block]] alignment) |
| + | |- |
| + | | 0x008 || 4 || Version (0x02010000) |
| + | |- |
| + | | 0x00C || 4 || File Size |
| + | |- |
| + | | 0x010 || 2 || Number of Blocks (2) |
| + | |- |
| + | | 0x012 || 2 || Reserved |
| + | |- |
| + | | 0x014 || 12 || [[#Info Block|Info Block]] [[#Sized Reference|Sized Reference]] (Offset relative to start of file) |
| + | |- |
| + | | 0x020 || 12 || [[#Data Block|Data Block]] [[#Sized Reference|Sized Reference]] (Offset relative to start of file) |
| + | |} |
| | | |
− | then the media player expects "fmt " chunk and a "data" chunk.
| + | === Block Header === |
| | | |
− | Nintendo's format uses a CWAV Header (no need for a general structure for media, only wave)
| + | {| class="wikitable" border="1" |
| + | |- |
| + | ! OFFSET !! SIZE !! DESCRIPTION |
| + | |- |
| + | | 0x000 || 4 || Magic |
| + | |- |
| + | | 0x004 || 4 || Size |
| + | |} |
| | | |
− | Which points to an INFO struct (the equivalent to fmt) and a DATA struct (the equivalent to data).
| + | ==== Block Types ==== |
| | | |
− | === Header === | + | {| class="wikitable" border="1" |
| + | |- |
| + | ! MAGIC !! TYPE |
| + | |- |
| + | | INFO || [[#Info Block|Info Block]] |
| + | |- |
| + | | DATA || [[#Data Block|Data Block]] |
| + | |} |
| + | |
| + | === Info Block === |
| | | |
| {| class="wikitable" border="1" | | {| class="wikitable" border="1" |
Line 20: |
Line 59: |
| ! OFFSET !! SIZE !! DESCRIPTION | | ! OFFSET !! SIZE !! DESCRIPTION |
| |- | | |- |
− | | 0x000 || 4 || Magic (CWAV) | + | | 0x000 || 8 || [[#Block Header|Block Header]] |
| + | |- |
| + | | 0x008 || 1 || [[#Encoding|Encoding]] |
| + | |- |
| + | | 0x009 || 1 || Loop (0 = don't loop, 1 = loop) |
| + | |- |
| + | | 0x00A || 2 || Padding |
| + | |- |
| + | | 0x00C || 4 || Sample Rate |
| + | |- |
| + | | 0x010 || 4 || Loop Start Frame |
| + | |- |
| + | | 0x014 || 4 || Loop End Frame |
| + | |- |
| + | | 0x018 || 4 || Reserved |
| + | |- |
| + | | 0x01C || X || [[#Channel Info|Channel Info]] [[#Reference Table|Reference Table]] |
| + | |- |
| + | | X || X || [[#Channel Info|Channel Info]] Entries |
| + | |} |
| + | |
| + | If encoding is DSP ADPCM: |
| + | |
| + | {| class="wikitable" border="1" |
| |- | | |- |
− | | 0x004 || 2 || Endianess (0xFEFF=LE / 0xFFFE=BE)
| + | ! OFFSET !! SIZE !! DESCRIPTION |
| |- | | |- |
− | | 0x006 || 2 || Struct Length | + | | X || X || [[#DSP ADPCM Info|DSP ADPCM Info]] Entries |
| + | |} |
| + | |
| + | If encoding is IMA ADPCM: |
| + | |
| + | {| class="wikitable" border="1" |
| + | |- |
| + | ! OFFSET !! SIZE !! DESCRIPTION |
| |- | | |- |
− | | 0x008 || 4 || Unknown 0 | + | | X || X || [[#IMA ADPCM Info|IMA ADPCM Info]] Entries |
| + | |} |
| + | |
| + | The info block is aligned to 0x20 bytes. |
| + | |
| + | ==== Encoding ==== |
| + | |
| + | {| class="wikitable" border="1" |
| |- | | |- |
− | | 0x00C || 4 || File's size
| + | ! VALUE !! DESCRIPTION |
| |- | | |- |
− | | 0x010 || 4 || Number of chunks (= 2 (INFO & DATA)) | + | | 0 || PCM8 |
| |- | | |- |
− | | 0x014 || 4 || Info Chunk Flags (0x7000) | + | | 1 || PCM16 |
| |- | | |- |
− | | 0x018 || 4 || Info Chunk Offset | + | | 2 || DSP ADPCM |
| |- | | |- |
− | | 0x01C || 4 || Info Chunk Length | + | | 3 || IMA ADPCM |
| + | |} |
| + | |
| + | ==== Channel Info ==== |
| + | |
| + | {| class="wikitable" border="1" |
| |- | | |- |
− | | 0x020 || 4 || Data Chunk Flags (0x7000)
| + | ! OFFSET !! SIZE !! DESCRIPTION |
| |- | | |- |
− | | 0x024 || 4 || Data Chunk Offset | + | | 0x000 || 8 || Samples [[#Reference|Reference]] (Offset relative to [[#Data Block|Data Block]] Data field) |
| |- | | |- |
− | | 0x028 || 4 || Data Chunk Length | + | | 0x008 || 8 || ADPCM Info [[#Reference|Reference]] (Offset relative to Samples [[#Reference|Reference]] field) |
| |- | | |- |
− | | 0x02C || 0x20 || Reserved (for more chunks offsets) | + | | 0x010 || 4 || Reserved |
| |} | | |} |
| | | |
− | === INFO Header === | + | ===== DSP ADPCM Info ===== |
| | | |
| {| class="wikitable" border="1" | | {| class="wikitable" border="1" |
Line 53: |
Line 134: |
| ! OFFSET !! SIZE !! DESCRIPTION | | ! OFFSET !! SIZE !! DESCRIPTION |
| |- | | |- |
− | | 0x000 || 4 || Magic (INFO) | + | | 0x000 || 32 || [[#DSP ADPCM Param|Param]] |
| |- | | |- |
− | | 0x004 || 4 || Length | + | | 0x020 || 6 || [[#DSP ADPCM Context|Context]] |
| |- | | |- |
− | | 0x008 || 4 || Type | + | | 0x026 || 6 || Loop [[#DSP ADPCM Context|Context]] |
| |- | | |- |
− | | 0x00C || 4 || Sample Rate | + | | 0x02C || 2 || Padding |
| + | |} |
| + | |
| + | ====== DSP ADPCM Param ====== |
| + | |
| + | {| class="wikitable" border="1" |
| + | |- |
| + | ! OFFSET !! SIZE !! DESCRIPTION |
| |- | | |- |
− | | 0x010 || 4 || Unknown 1 | + | | 0x000 || 32 || 16-bit Coefficients |
| + | |} |
| + | |
| + | ====== DSP ADPCM Context ====== |
| + | |
| + | {| class="wikitable" border="1" |
| |- | | |- |
− | | 0x014 || 4 || Number or samples
| + | ! OFFSET !! SIZE !! DESCRIPTION |
| |- | | |- |
− | | 0x018 || 4 || Unknown 2 | + | | 0x000 || 1 || 4-bit Predictor + 4-bit Scale |
| |- | | |- |
− | | 0x01C || 4 || Channels | + | | 0x001 || 1 || Reserved |
| |- | | |- |
− | | 0x020 || X || The Channels' Data Pointers | + | | 0x002 || 2 || Previous Sample |
| |- | | |- |
− | | X || X || The Channels' Data | + | | 0x004 || 2 || Second Previous Sample |
| |} | | |} |
| | | |
− | * The channels data pointers are pointers to another struct that points to the actual data (this stucture has flags as well)
| + | ===== IMA ADPCM Info ===== |
| | | |
| {| class="wikitable" border="1" | | {| class="wikitable" border="1" |
Line 80: |
Line 173: |
| ! OFFSET !! SIZE !! DESCRIPTION | | ! OFFSET !! SIZE !! DESCRIPTION |
| |- | | |- |
− | | 0x000 || 4 || Flags | + | | 0x000 || 4 || [[#IMA ADPCM Context|Context]] |
| |- | | |- |
− | | 0x004 || 4 || Offset (from 0x5C, INFO's channels field) | + | | 0x004 || 4 || Loop [[#IMA ADPCM Context|Context]] |
| |} | | |} |
| | | |
− | * The channels data are pointers to the actual data (this stucture has flags as well)
| + | ====== IMA ADPCM Context ====== |
| | | |
| {| class="wikitable" border="1" | | {| class="wikitable" border="1" |
Line 91: |
Line 184: |
| ! OFFSET !! SIZE !! DESCRIPTION | | ! OFFSET !! SIZE !! DESCRIPTION |
| |- | | |- |
− | | 0x000 || 4 || Flags | + | | 0x000 || 2 || Data |
| + | |- |
| + | | 0x002 || 1 || Table Index |
| |- | | |- |
− | | 0x004 || 4 || Offset (inside the DATA block data) | + | | 0x003 || 1 || Padding |
| + | |} |
| + | |
| + | === Data Block === |
| + | |
| + | {| class="wikitable" border="1" |
| |- | | |- |
− | | 0x008 || 4 || FFs (0xFFFFFFFF)
| + | ! OFFSET !! SIZE !! DESCRIPTION |
| |- | | |- |
− | | 0x00C || 4 || Padding (Zero) | + | | 0x000 || 8 || [[#Block Header|Block Header]] |
| + | |- |
| + | | 0x008 || [[#Block Header|Block Header]] Size Value - 8 || Data |
| |} | | |} |
| | | |
| + | The data block is aligned to 0x20 bytes, as well as the data field's actual sample data. |
| | | |
− | === DATA Header === | + | === Reference Table === |
| | | |
| {| class="wikitable" border="1" | | {| class="wikitable" border="1" |
Line 107: |
Line 210: |
| ! OFFSET !! SIZE !! DESCRIPTION | | ! OFFSET !! SIZE !! DESCRIPTION |
| |- | | |- |
− | | 0x000 || 4 || Magic (DATA) | + | | 0x000 || 4 || Count |
| + | |- |
| + | | 0x004 || Count * 8 || [[#Reference|References]] (Offsets relative to Count field) |
| + | |} |
| + | |
| + | === Sized Reference === |
| + | |
| + | {| class="wikitable" border="1" |
| + | |- |
| + | ! OFFSET !! SIZE !! DESCRIPTION |
| + | |- |
| + | | 0x000 || 8 || [[#Reference|Reference]] |
| + | |- |
| + | | 0x008 || 4 || Size |
| + | |} |
| + | |
| + | === Reference === |
| + | |
| + | {| class="wikitable" border="1" |
| + | |- |
| + | ! OFFSET !! SIZE !! DESCRIPTION |
| + | |- |
| + | | 0x000 || 2 || Type ID |
| + | |- |
| + | | 0x002 || 2 || Padding |
| + | |- |
| + | | 0x004 || 4 || Offset ("null" = 0xFFFFFFFF) |
| + | |} |
| + | |
| + | ==== Reference Types ==== |
| + | |
| + | {| class="wikitable" border="1" |
| + | |- |
| + | ! ID !! TYPE |
| + | |- |
| + | | 0x0300 || [[#DSP ADPCM Info|DSP ADPCM Info]] |
| + | |- |
| + | | 0x0301 || [[#IMA ADPCM Info|IMA ADPCM Info]] |
| + | |- |
| + | | 0x1F00 || [[#Data_Block|Sample Data]] |
| + | |- |
| + | | 0x7000 || [[#Info Block|Info Block]] |
| + | |- |
| + | | 0x7001 || [[#Data Block|Data Block]] |
| |- | | |- |
− | | 0x004 || 4 || Length | + | | 0x7100 || [[#Channel Info|Channel Info]] |
| |} | | |} |